From 5b8fd7cf15eba5916dbd995990220eee1d2ff923 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Mon, 25 Apr 2016 10:18:48 +0200 Subject: [PATCH] Fix constructors --- main/dropbox/dropbox_class.inc.php | 12 +-- main/gradebook/lib/scoredisplay.class.php | 74 ++++++++++--------- .../formvalidator/Element/DateTimePicker.php | 2 +- .../lib/formvalidator/Element/SelectAjax.php | 4 +- .../formvalidator/Element/SelectLanguage.php | 2 +- main/inc/lib/formvalidator/Element/Url.php | 2 +- main/inc/lib/pear/HTML/Table/Storage.php | 14 ++-- 7 files changed, 56 insertions(+), 54 deletions(-) diff --git a/main/dropbox/dropbox_class.inc.php b/main/dropbox/dropbox_class.inc.php index 7c795e798d..65e6ab446f 100755 --- a/main/dropbox/dropbox_class.inc.php +++ b/main/dropbox/dropbox_class.inc.php @@ -68,7 +68,7 @@ class Dropbox_Work * @param unknown_type $arg6 * @return Dropbox_Work */ - public function Dropbox_Work($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null) + public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null) { if (func_num_args() > 1) { $this->_createNewWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6); @@ -248,7 +248,7 @@ class Dropbox_SentWork extends Dropbox_Work * @param unknown_type $arg7 * @return Dropbox_SentWork */ - function Dropbox_SentWork($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null) + public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null) { if (func_num_args() > 1) { $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7); @@ -274,7 +274,7 @@ class Dropbox_SentWork extends Dropbox_Work $_course = api_get_course_info(); // Call constructor of Dropbox_Work object - $this->Dropbox_Work( + parent::__construct( $uploader_id, $title, $description, @@ -361,7 +361,7 @@ class Dropbox_SentWork extends Dropbox_Work * * @param unknown_type $id */ - function _createExistingSentWork($id) + public function _createExistingSentWork($id) { $dropbox_cnf = getDropboxConf(); $id = intval($id); @@ -369,7 +369,7 @@ class Dropbox_SentWork extends Dropbox_Work $course_id = api_get_course_int_id(); // Call constructor of Dropbox_Work object - $this->Dropbox_Work($id); + parent::__construct($id); // Fill in recipients array $this->recipients = array(); @@ -417,7 +417,7 @@ class Dropbox_Person * @param bool $isCourseTutor * @return Dropbox_Person */ - function Dropbox_Person($userId, $isCourseAdmin, $isCourseTutor) + public function __construct($userId, $isCourseAdmin, $isCourseTutor) { $course_id = api_get_course_int_id(); diff --git a/main/gradebook/lib/scoredisplay.class.php b/main/gradebook/lib/scoredisplay.class.php index 3490f113e9..749a7a77d9 100755 --- a/main/gradebook/lib/scoredisplay.class.php +++ b/main/gradebook/lib/scoredisplay.class.php @@ -17,45 +17,10 @@ class ScoreDisplay private $custom_display; private $custom_display_conv; - /** - * Get the instance of this class - * @param int $category_id - */ - public static function instance($category_id = 0) - { - static $instance; - if (!isset ($instance)) { - $instance = new ScoreDisplay($category_id); - } - - return $instance; - } - - /** - * Compare the custom display of 2 scores, can be useful in sorting - */ - public static function compare_scores_by_custom_display ($score1, $score2) - { - if (!isset($score1)) { - return (isset($score2) ? 1 : 0); - } elseif (!isset($score2)) { - return -1; - } else { - $scoredisplay = ScoreDisplay :: instance(); - $custom1 = $scoredisplay->display_custom($score1); - $custom2 = $scoredisplay->display_custom($score2); - if ($custom1 == $custom2) { - return 0; - } else { - return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1); - } - } - } - /** * Protected constructor - call instance() to instantiate */ - protected function ScoreDisplay($category_id = 0) + protected function __constructor($category_id = 0) { if (!empty($category_id)) { $this->category_id = $category_id; @@ -121,6 +86,43 @@ class ScoreDisplay } } + /** + * Get the instance of this class + * @param int $category_id + */ + public static function instance($category_id = 0) + { + static $instance; + if (!isset ($instance)) { + $instance = new ScoreDisplay($category_id); + } + + return $instance; + } + + /** + * Compare the custom display of 2 scores, can be useful in sorting + */ + public static function compare_scores_by_custom_display ($score1, $score2) + { + if (!isset($score1)) { + return (isset($score2) ? 1 : 0); + } elseif (!isset($score2)) { + return -1; + } else { + $scoredisplay = ScoreDisplay :: instance(); + $custom1 = $scoredisplay->display_custom($score1); + $custom2 = $scoredisplay->display_custom($score2); + if ($custom1 == $custom2) { + return 0; + } else { + return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1); + } + } + } + + + /** * Is coloring enabled ? */ diff --git a/main/inc/lib/formvalidator/Element/DateTimePicker.php b/main/inc/lib/formvalidator/Element/DateTimePicker.php index c6657279b5..18b8c86311 100755 --- a/main/inc/lib/formvalidator/Element/DateTimePicker.php +++ b/main/inc/lib/formvalidator/Element/DateTimePicker.php @@ -9,7 +9,7 @@ class DateTimePicker extends HTML_QuickForm_text /** * Constructor */ - public function DateTimePicker($elementName = null, $elementLabel = null, $attributes = null) + public function __construct($elementName = null, $elementLabel = null, $attributes = null) { if (!isset($attributes['id'])) { $attributes['id'] = $elementName; diff --git a/main/inc/lib/formvalidator/Element/SelectAjax.php b/main/inc/lib/formvalidator/Element/SelectAjax.php index 41d63a7f98..bc954190fd 100644 --- a/main/inc/lib/formvalidator/Element/SelectAjax.php +++ b/main/inc/lib/formvalidator/Element/SelectAjax.php @@ -9,7 +9,7 @@ class SelectAjax extends HTML_QuickForm_select /** * Class constructor */ - function SelectAjax($elementName = null, $elementLabel = null, $options = null, $attributes = null) + public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null) { parent::__construct($elementName, $elementLabel, $options, $attributes); } @@ -18,7 +18,7 @@ class SelectAjax extends HTML_QuickForm_select * The ajax call must contain an array of id and text * @return string */ - function toHtml() + public function toHtml() { $html = api_get_asset('select2/dist/js/select2.min.js'); diff --git a/main/inc/lib/formvalidator/Element/SelectLanguage.php b/main/inc/lib/formvalidator/Element/SelectLanguage.php index 1c7eda8f80..02aaf9f6df 100644 --- a/main/inc/lib/formvalidator/Element/SelectLanguage.php +++ b/main/inc/lib/formvalidator/Element/SelectLanguage.php @@ -9,7 +9,7 @@ class SelectLanguage extends HTML_QuickForm_select /** * Class constructor */ - function SelectLanguage($elementName=null, $elementLabel=null, $options=null, $attributes=null) + public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null) { parent::__construct($elementName, $elementLabel, $options, $attributes); // Get all languages diff --git a/main/inc/lib/formvalidator/Element/Url.php b/main/inc/lib/formvalidator/Element/Url.php index e40efc5f97..b54c5ebecc 100644 --- a/main/inc/lib/formvalidator/Element/Url.php +++ b/main/inc/lib/formvalidator/Element/Url.php @@ -14,7 +14,7 @@ class Url extends HTML_QuickForm_text * @param type $elementLabel * @param type $attributes */ - public function Url($elementName = null, $elementLabel = null, $attributes = null) + public function __construct($elementName = null, $elementLabel = null, $attributes = null) { if (!isset($attributes['id'])) { $attributes['id'] = $elementName; diff --git a/main/inc/lib/pear/HTML/Table/Storage.php b/main/inc/lib/pear/HTML/Table/Storage.php index d83f354b89..dbdefeb895 100755 --- a/main/inc/lib/pear/HTML/Table/Storage.php +++ b/main/inc/lib/pear/HTML/Table/Storage.php @@ -126,7 +126,7 @@ class HTML_Table_Storage extends HTML_Common { * or not * @access public */ - function HTML_Table_Storage($tabOffset = 0, $useTGroups = false) + public function __construct($tabOffset = 0, $useTGroups = false) { parent::__construct(null, (int)$tabOffset); $this->_useTGroups = (boolean)$useTGroups; @@ -137,7 +137,7 @@ class HTML_Table_Storage extends HTML_Common { * @param boolean $useTGroups * @access public */ - function setUseTGroups($useTGroups) + public function setUseTGroups($useTGroups) { $this->_useTGroups = $useTGroups; } @@ -147,7 +147,7 @@ class HTML_Table_Storage extends HTML_Common { * @access public * @return boolean */ - function getUseTGroups() + public function getUseTGroups() { return $this->_useTGroups; } @@ -157,7 +157,7 @@ class HTML_Table_Storage extends HTML_Common { * @param mixed $fill * @access public */ - function setAutoFill($fill) + public function setAutoFill($fill) { $this->_autoFill = $fill; } @@ -167,7 +167,7 @@ class HTML_Table_Storage extends HTML_Common { * @access public * @return mixed */ - function getAutoFill() + public function getAutoFill() { return $this->_autoFill; } @@ -177,7 +177,7 @@ class HTML_Table_Storage extends HTML_Common { * @param bool $fill * @access public */ - function setAutoGrow($grow) + public function setAutoGrow($grow) { $this->_autoGrow = $grow; } @@ -187,7 +187,7 @@ class HTML_Table_Storage extends HTML_Common { * @access public * @return mixed */ - function getAutoGrow() + public function getAutoGrow() { return $this->_autoGrow; }