@@ -95,7 +95,7 @@ |
||
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | 97 | * Get the progress of this learnpath. Only the last attempt are taken into account. |
| 98 | - * @param $stud_id student id (default: all students who have results - then the average is returned) |
|
| 98 | + * @param integer $stud_id student id (default: all students who have results - then the average is returned) |
|
| 99 | 99 | * @return array (score, max) if student is given |
| 100 | 100 | * array (sum of scores, number of scores) otherwise |
| 101 | 101 | * or null if no scores available |
@@ -29,8 +29,9 @@ discard block |
||
| 29 | 29 | public function get_not_created_links() |
| 30 | 30 | { |
| 31 | 31 | return false; |
| 32 | - if (empty($this->course_code)) |
|
| 33 | - die('Error in get_not_created_links() : course code not set'); |
|
| 32 | + if (empty($this->course_code)) { |
|
| 33 | + die('Error in get_not_created_links() : course code not set'); |
|
| 34 | + } |
|
| 34 | 35 | |
| 35 | 36 | $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
| 36 | 37 | |
@@ -57,8 +58,9 @@ discard block |
||
| 57 | 58 | */ |
| 58 | 59 | public function get_all_links() |
| 59 | 60 | { |
| 60 | - if (empty($this->course_code)) |
|
| 61 | - die('Error in get_not_created_links() : course code not set'); |
|
| 61 | + if (empty($this->course_code)) { |
|
| 62 | + die('Error in get_not_created_links() : course code not set'); |
|
| 63 | + } |
|
| 62 | 64 | |
| 63 | 65 | $session_id = api_get_session_id(); |
| 64 | 66 | if (empty($session_id)) { |
@@ -111,8 +113,9 @@ discard block |
||
| 111 | 113 | lp_id = ".$this->get_ref_id()." AND |
| 112 | 114 | session_id = $session_id "; |
| 113 | 115 | |
| 114 | - if (isset($stud_id)) |
|
| 115 | - $sql .= ' AND user_id = '.intval($stud_id); |
|
| 116 | + if (isset($stud_id)) { |
|
| 117 | + $sql .= ' AND user_id = '.intval($stud_id); |
|
| 118 | + } |
|
| 116 | 119 | |
| 117 | 120 | // order by id, that way the student's first attempt is accessed first |
| 118 | 121 | $sql .= ' ORDER BY view_count DESC'; |
@@ -122,8 +125,9 @@ discard block |
||
| 122 | 125 | if (isset($stud_id)) { |
| 123 | 126 | if ($data = Database::fetch_array($scores)) { |
| 124 | 127 | return array ($data['progress'], 100); |
| 125 | - } else |
|
| 126 | - return null; |
|
| 128 | + } else { |
|
| 129 | + return null; |
|
| 130 | + } |
|
| 127 | 131 | } else { |
| 128 | 132 | // all students -> get average |
| 129 | 133 | $students = array(); // user list, needed to make sure we only |
@@ -9,261 +9,261 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class LearnpathLink extends AbstractLink |
| 11 | 11 | { |
| 12 | - private $course_info = null; |
|
| 13 | - private $learnpath_table = null; |
|
| 14 | - private $learnpath_data = null; |
|
| 15 | - |
|
| 16 | - /** |
|
| 17 | - * Constructor |
|
| 18 | - */ |
|
| 19 | - public function __construct() |
|
| 20 | - { |
|
| 21 | - parent::__construct(); |
|
| 22 | - $this->set_type(LINK_LEARNPATH); |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Generate an array of learnpaths that a teacher hasn't created a link for. |
|
| 27 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
| 28 | - */ |
|
| 29 | - public function get_not_created_links() |
|
| 30 | - { |
|
| 31 | - return false; |
|
| 32 | - if (empty($this->course_code)) |
|
| 33 | - die('Error in get_not_created_links() : course code not set'); |
|
| 34 | - |
|
| 35 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
| 36 | - |
|
| 37 | - $sql = 'SELECT id, name from '.$this->get_learnpath_table().' lp |
|
| 12 | + private $course_info = null; |
|
| 13 | + private $learnpath_table = null; |
|
| 14 | + private $learnpath_data = null; |
|
| 15 | + |
|
| 16 | + /** |
|
| 17 | + * Constructor |
|
| 18 | + */ |
|
| 19 | + public function __construct() |
|
| 20 | + { |
|
| 21 | + parent::__construct(); |
|
| 22 | + $this->set_type(LINK_LEARNPATH); |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Generate an array of learnpaths that a teacher hasn't created a link for. |
|
| 27 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
| 28 | + */ |
|
| 29 | + public function get_not_created_links() |
|
| 30 | + { |
|
| 31 | + return false; |
|
| 32 | + if (empty($this->course_code)) |
|
| 33 | + die('Error in get_not_created_links() : course code not set'); |
|
| 34 | + |
|
| 35 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
| 36 | + |
|
| 37 | + $sql = 'SELECT id, name from '.$this->get_learnpath_table().' lp |
|
| 38 | 38 | WHERE c_id = '.$this->course_id.' AND id NOT IN ' |
| 39 | - .' (SELECT ref_id FROM '.$tbl_grade_links |
|
| 40 | - .' WHERE type = '.LINK_LEARNPATH |
|
| 41 | - ." AND course_code = '".$this->get_course_code()."'" |
|
| 42 | - .') AND lp.session_id='.api_get_session_id().''; |
|
| 43 | - |
|
| 44 | - $result = Database::query($sql); |
|
| 45 | - |
|
| 46 | - $cats=array(); |
|
| 47 | - while ($data=Database::fetch_array($result)) { |
|
| 48 | - $cats[] = array ($data['id'], $data['name']); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - return $cats; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Generate an array of all learnpaths available. |
|
| 56 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
| 57 | - */ |
|
| 58 | - public function get_all_links() |
|
| 59 | - { |
|
| 60 | - if (empty($this->course_code)) |
|
| 61 | - die('Error in get_not_created_links() : course code not set'); |
|
| 62 | - |
|
| 63 | - $session_id = api_get_session_id(); |
|
| 64 | - if (empty($session_id)) { |
|
| 65 | - $session_condition = api_get_session_condition(0, true); |
|
| 66 | - } else { |
|
| 67 | - $session_condition = api_get_session_condition($session_id, true, true); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - $sql = 'SELECT id, name FROM '.$this->get_learnpath_table().' |
|
| 39 | + .' (SELECT ref_id FROM '.$tbl_grade_links |
|
| 40 | + .' WHERE type = '.LINK_LEARNPATH |
|
| 41 | + ." AND course_code = '".$this->get_course_code()."'" |
|
| 42 | + .') AND lp.session_id='.api_get_session_id().''; |
|
| 43 | + |
|
| 44 | + $result = Database::query($sql); |
|
| 45 | + |
|
| 46 | + $cats=array(); |
|
| 47 | + while ($data=Database::fetch_array($result)) { |
|
| 48 | + $cats[] = array ($data['id'], $data['name']); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + return $cats; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Generate an array of all learnpaths available. |
|
| 56 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
| 57 | + */ |
|
| 58 | + public function get_all_links() |
|
| 59 | + { |
|
| 60 | + if (empty($this->course_code)) |
|
| 61 | + die('Error in get_not_created_links() : course code not set'); |
|
| 62 | + |
|
| 63 | + $session_id = api_get_session_id(); |
|
| 64 | + if (empty($session_id)) { |
|
| 65 | + $session_condition = api_get_session_condition(0, true); |
|
| 66 | + } else { |
|
| 67 | + $session_condition = api_get_session_condition($session_id, true, true); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + $sql = 'SELECT id, name FROM '.$this->get_learnpath_table().' |
|
| 71 | 71 | WHERE c_id = '.$this->course_id.' '.$session_condition.' '; |
| 72 | - $result = Database::query($sql); |
|
| 72 | + $result = Database::query($sql); |
|
| 73 | 73 | |
| 74 | - $cats = array(); |
|
| 75 | - while ($data=Database::fetch_array($result)) { |
|
| 76 | - $cats[] = array ($data['id'], $data['name']); |
|
| 77 | - } |
|
| 74 | + $cats = array(); |
|
| 75 | + while ($data=Database::fetch_array($result)) { |
|
| 76 | + $cats[] = array ($data['id'], $data['name']); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - return $cats; |
|
| 80 | - } |
|
| 79 | + return $cats; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Has anyone used this learnpath yet ? |
|
| 85 | - */ |
|
| 86 | - public function has_results() |
|
| 87 | - { |
|
| 88 | - $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
| 89 | - $sql = "SELECT count(id) AS number FROM $tbl_stats |
|
| 83 | + /** |
|
| 84 | + * Has anyone used this learnpath yet ? |
|
| 85 | + */ |
|
| 86 | + public function has_results() |
|
| 87 | + { |
|
| 88 | + $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
| 89 | + $sql = "SELECT count(id) AS number FROM $tbl_stats |
|
| 90 | 90 | WHERE c_id = ".$this->course_id." AND lp_id = ".$this->get_ref_id(); |
| 91 | - $result = Database::query($sql); |
|
| 92 | - $number = Database::fetch_array($result,'NUM'); |
|
| 93 | - return ($number[0] != 0); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Get the progress of this learnpath. Only the last attempt are taken into account. |
|
| 98 | - * @param $stud_id student id (default: all students who have results - then the average is returned) |
|
| 99 | - * @return array (score, max) if student is given |
|
| 100 | - * array (sum of scores, number of scores) otherwise |
|
| 101 | - * or null if no scores available |
|
| 102 | - */ |
|
| 103 | - public function calc_score($stud_id = null, $type = null) |
|
| 104 | - { |
|
| 105 | - $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
| 106 | - $session_id = api_get_session_id(); |
|
| 107 | - |
|
| 108 | - $sql = "SELECT * FROM $tbl_stats |
|
| 91 | + $result = Database::query($sql); |
|
| 92 | + $number = Database::fetch_array($result,'NUM'); |
|
| 93 | + return ($number[0] != 0); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Get the progress of this learnpath. Only the last attempt are taken into account. |
|
| 98 | + * @param $stud_id student id (default: all students who have results - then the average is returned) |
|
| 99 | + * @return array (score, max) if student is given |
|
| 100 | + * array (sum of scores, number of scores) otherwise |
|
| 101 | + * or null if no scores available |
|
| 102 | + */ |
|
| 103 | + public function calc_score($stud_id = null, $type = null) |
|
| 104 | + { |
|
| 105 | + $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
| 106 | + $session_id = api_get_session_id(); |
|
| 107 | + |
|
| 108 | + $sql = "SELECT * FROM $tbl_stats |
|
| 109 | 109 | WHERE |
| 110 | 110 | c_id = ".$this->course_id." AND |
| 111 | 111 | lp_id = ".$this->get_ref_id()." AND |
| 112 | 112 | session_id = $session_id "; |
| 113 | 113 | |
| 114 | - if (isset($stud_id)) |
|
| 115 | - $sql .= ' AND user_id = '.intval($stud_id); |
|
| 116 | - |
|
| 117 | - // order by id, that way the student's first attempt is accessed first |
|
| 118 | - $sql .= ' ORDER BY view_count DESC'; |
|
| 119 | - |
|
| 120 | - $scores = Database::query($sql); |
|
| 121 | - // for 1 student |
|
| 122 | - if (isset($stud_id)) { |
|
| 123 | - if ($data = Database::fetch_assoc($scores)) { |
|
| 124 | - return array ($data['progress'], 100); |
|
| 125 | - } else |
|
| 126 | - return null; |
|
| 127 | - } else { |
|
| 128 | - // all students -> get average |
|
| 129 | - $students = array(); // user list, needed to make sure we only |
|
| 130 | - // take first attempts into account |
|
| 131 | - $rescount = 0; |
|
| 132 | - $sum = 0; |
|
| 133 | - $bestResult = 0; |
|
| 134 | - $sumResult = 0; |
|
| 135 | - while ($data = Database::fetch_array($scores)) { |
|
| 136 | - if (!(array_key_exists($data['user_id'], $students))) { |
|
| 137 | - $students[$data['user_id']] = $data['progress']; |
|
| 138 | - $rescount++; |
|
| 139 | - $sum += $data['progress'] / 100; |
|
| 140 | - $sumResult += $data['progress']; |
|
| 141 | - |
|
| 142 | - if ($data['progress'] > $bestResult) { |
|
| 143 | - $bestResult = $data['progress']; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - if ($rescount == 0) { |
|
| 149 | - return null; |
|
| 150 | - } else { |
|
| 151 | - |
|
| 152 | - switch ($type) { |
|
| 153 | - case 'best': |
|
| 154 | - return array($bestResult, 100); |
|
| 155 | - break; |
|
| 156 | - case 'average': |
|
| 157 | - return array($sumResult/$rescount, 100); |
|
| 158 | - break; |
|
| 159 | - case 'ranking': |
|
| 160 | - return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
| 161 | - break; |
|
| 162 | - default: |
|
| 163 | - return array($sum, $rescount); |
|
| 164 | - break; |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * Get URL where to go to if the user clicks on the link. |
|
| 172 | - */ |
|
| 173 | - public function get_link() |
|
| 174 | - { |
|
| 175 | - $session_id = api_get_session_id(); |
|
| 176 | - $url = api_get_path(WEB_CODE_PATH) . 'lp/lp_controller.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&gradebook=view'; |
|
| 177 | - |
|
| 178 | - if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) { |
|
| 179 | - $url .= '&action=view&lp_id='.$this->get_ref_id(); |
|
| 180 | - } else { |
|
| 181 | - $url .= '&action=build&lp_id='.$this->get_ref_id(); |
|
| 182 | - } |
|
| 183 | - return $url; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * Get name to display: same as learnpath title |
|
| 188 | - */ |
|
| 189 | - public function get_name() |
|
| 190 | - { |
|
| 191 | - $data = $this->get_learnpath_data(); |
|
| 192 | - return $data['name']; |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * Get description to display: same as learnpath description |
|
| 197 | - */ |
|
| 198 | - public function get_description() |
|
| 199 | - { |
|
| 200 | - $data = $this->get_learnpath_data(); |
|
| 201 | - return $data['description']; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * Check if this still links to a learnpath |
|
| 206 | - */ |
|
| 207 | - public function is_valid_link() { |
|
| 208 | - $sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().' |
|
| 114 | + if (isset($stud_id)) |
|
| 115 | + $sql .= ' AND user_id = '.intval($stud_id); |
|
| 116 | + |
|
| 117 | + // order by id, that way the student's first attempt is accessed first |
|
| 118 | + $sql .= ' ORDER BY view_count DESC'; |
|
| 119 | + |
|
| 120 | + $scores = Database::query($sql); |
|
| 121 | + // for 1 student |
|
| 122 | + if (isset($stud_id)) { |
|
| 123 | + if ($data = Database::fetch_assoc($scores)) { |
|
| 124 | + return array ($data['progress'], 100); |
|
| 125 | + } else |
|
| 126 | + return null; |
|
| 127 | + } else { |
|
| 128 | + // all students -> get average |
|
| 129 | + $students = array(); // user list, needed to make sure we only |
|
| 130 | + // take first attempts into account |
|
| 131 | + $rescount = 0; |
|
| 132 | + $sum = 0; |
|
| 133 | + $bestResult = 0; |
|
| 134 | + $sumResult = 0; |
|
| 135 | + while ($data = Database::fetch_array($scores)) { |
|
| 136 | + if (!(array_key_exists($data['user_id'], $students))) { |
|
| 137 | + $students[$data['user_id']] = $data['progress']; |
|
| 138 | + $rescount++; |
|
| 139 | + $sum += $data['progress'] / 100; |
|
| 140 | + $sumResult += $data['progress']; |
|
| 141 | + |
|
| 142 | + if ($data['progress'] > $bestResult) { |
|
| 143 | + $bestResult = $data['progress']; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + if ($rescount == 0) { |
|
| 149 | + return null; |
|
| 150 | + } else { |
|
| 151 | + |
|
| 152 | + switch ($type) { |
|
| 153 | + case 'best': |
|
| 154 | + return array($bestResult, 100); |
|
| 155 | + break; |
|
| 156 | + case 'average': |
|
| 157 | + return array($sumResult/$rescount, 100); |
|
| 158 | + break; |
|
| 159 | + case 'ranking': |
|
| 160 | + return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
| 161 | + break; |
|
| 162 | + default: |
|
| 163 | + return array($sum, $rescount); |
|
| 164 | + break; |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * Get URL where to go to if the user clicks on the link. |
|
| 172 | + */ |
|
| 173 | + public function get_link() |
|
| 174 | + { |
|
| 175 | + $session_id = api_get_session_id(); |
|
| 176 | + $url = api_get_path(WEB_CODE_PATH) . 'lp/lp_controller.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&gradebook=view'; |
|
| 177 | + |
|
| 178 | + if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) { |
|
| 179 | + $url .= '&action=view&lp_id='.$this->get_ref_id(); |
|
| 180 | + } else { |
|
| 181 | + $url .= '&action=build&lp_id='.$this->get_ref_id(); |
|
| 182 | + } |
|
| 183 | + return $url; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * Get name to display: same as learnpath title |
|
| 188 | + */ |
|
| 189 | + public function get_name() |
|
| 190 | + { |
|
| 191 | + $data = $this->get_learnpath_data(); |
|
| 192 | + return $data['name']; |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * Get description to display: same as learnpath description |
|
| 197 | + */ |
|
| 198 | + public function get_description() |
|
| 199 | + { |
|
| 200 | + $data = $this->get_learnpath_data(); |
|
| 201 | + return $data['description']; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * Check if this still links to a learnpath |
|
| 206 | + */ |
|
| 207 | + public function is_valid_link() { |
|
| 208 | + $sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().' |
|
| 209 | 209 | WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' '; |
| 210 | - $result = Database::query($sql); |
|
| 211 | - $number = Database::fetch_row($result,'NUM'); |
|
| 212 | - return ($number[0] != 0); |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - public function get_type_name() |
|
| 216 | - { |
|
| 217 | - return get_lang('LearningPaths'); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - public function needs_name_and_description() |
|
| 221 | - { |
|
| 222 | - return false; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - public function needs_max() |
|
| 226 | - { |
|
| 227 | - return false; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - public function needs_results() |
|
| 231 | - { |
|
| 232 | - return false; |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - public function is_allowed_to_change_name() |
|
| 236 | - { |
|
| 237 | - return false; |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - // INTERNAL FUNCTIONS |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * Lazy load function to get the database table of the learnpath |
|
| 244 | - */ |
|
| 245 | - private function get_learnpath_table() |
|
| 246 | - { |
|
| 247 | - $this->learnpath_table = Database :: get_course_table(TABLE_LP_MAIN); |
|
| 248 | - return $this->learnpath_table; |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - /** |
|
| 252 | - * Lazy load function to get the database contents of this learnpath |
|
| 253 | - */ |
|
| 254 | - private function get_learnpath_data() |
|
| 255 | - { |
|
| 256 | - if (!isset($this->learnpath_data)) { |
|
| 257 | - $sql = 'SELECT * FROM '.$this->get_learnpath_table().' |
|
| 210 | + $result = Database::query($sql); |
|
| 211 | + $number = Database::fetch_row($result,'NUM'); |
|
| 212 | + return ($number[0] != 0); |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + public function get_type_name() |
|
| 216 | + { |
|
| 217 | + return get_lang('LearningPaths'); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + public function needs_name_and_description() |
|
| 221 | + { |
|
| 222 | + return false; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + public function needs_max() |
|
| 226 | + { |
|
| 227 | + return false; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + public function needs_results() |
|
| 231 | + { |
|
| 232 | + return false; |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + public function is_allowed_to_change_name() |
|
| 236 | + { |
|
| 237 | + return false; |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + // INTERNAL FUNCTIONS |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * Lazy load function to get the database table of the learnpath |
|
| 244 | + */ |
|
| 245 | + private function get_learnpath_table() |
|
| 246 | + { |
|
| 247 | + $this->learnpath_table = Database :: get_course_table(TABLE_LP_MAIN); |
|
| 248 | + return $this->learnpath_table; |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + /** |
|
| 252 | + * Lazy load function to get the database contents of this learnpath |
|
| 253 | + */ |
|
| 254 | + private function get_learnpath_data() |
|
| 255 | + { |
|
| 256 | + if (!isset($this->learnpath_data)) { |
|
| 257 | + $sql = 'SELECT * FROM '.$this->get_learnpath_table().' |
|
| 258 | 258 | WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' '; |
| 259 | - $result = Database::query($sql); |
|
| 260 | - $this->learnpath_data = Database::fetch_array($result); |
|
| 261 | - } |
|
| 262 | - return $this->learnpath_data; |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - public function get_icon_name() |
|
| 266 | - { |
|
| 267 | - return 'learnpath'; |
|
| 268 | - } |
|
| 259 | + $result = Database::query($sql); |
|
| 260 | + $this->learnpath_data = Database::fetch_array($result); |
|
| 261 | + } |
|
| 262 | + return $this->learnpath_data; |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + public function get_icon_name() |
|
| 266 | + { |
|
| 267 | + return 'learnpath'; |
|
| 268 | + } |
|
| 269 | 269 | } |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $result = Database::query($sql); |
| 45 | 45 | |
| 46 | - $cats=array(); |
|
| 47 | - while ($data=Database::fetch_array($result)) { |
|
| 48 | - $cats[] = array ($data['id'], $data['name']); |
|
| 46 | + $cats = array(); |
|
| 47 | + while ($data = Database::fetch_array($result)) { |
|
| 48 | + $cats[] = array($data['id'], $data['name']); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | return $cats; |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | $result = Database::query($sql); |
| 73 | 73 | |
| 74 | 74 | $cats = array(); |
| 75 | - while ($data=Database::fetch_array($result)) { |
|
| 76 | - $cats[] = array ($data['id'], $data['name']); |
|
| 75 | + while ($data = Database::fetch_array($result)) { |
|
| 76 | + $cats[] = array($data['id'], $data['name']); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | return $cats; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $sql = "SELECT count(id) AS number FROM $tbl_stats |
| 90 | 90 | WHERE c_id = ".$this->course_id." AND lp_id = ".$this->get_ref_id(); |
| 91 | 91 | $result = Database::query($sql); |
| 92 | - $number = Database::fetch_array($result,'NUM'); |
|
| 92 | + $number = Database::fetch_array($result, 'NUM'); |
|
| 93 | 93 | return ($number[0] != 0); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -121,12 +121,12 @@ discard block |
||
| 121 | 121 | // for 1 student |
| 122 | 122 | if (isset($stud_id)) { |
| 123 | 123 | if ($data = Database::fetch_assoc($scores)) { |
| 124 | - return array ($data['progress'], 100); |
|
| 124 | + return array($data['progress'], 100); |
|
| 125 | 125 | } else |
| 126 | 126 | return null; |
| 127 | 127 | } else { |
| 128 | 128 | // all students -> get average |
| 129 | - $students = array(); // user list, needed to make sure we only |
|
| 129 | + $students = array(); // user list, needed to make sure we only |
|
| 130 | 130 | // take first attempts into account |
| 131 | 131 | $rescount = 0; |
| 132 | 132 | $sum = 0; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | return array($bestResult, 100); |
| 155 | 155 | break; |
| 156 | 156 | case 'average': |
| 157 | - return array($sumResult/$rescount, 100); |
|
| 157 | + return array($sumResult / $rescount, 100); |
|
| 158 | 158 | break; |
| 159 | 159 | case 'ranking': |
| 160 | 160 | return AbstractLink::getCurrentUserRanking($stud_id, $students); |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | public function get_link() |
| 174 | 174 | { |
| 175 | 175 | $session_id = api_get_session_id(); |
| 176 | - $url = api_get_path(WEB_CODE_PATH) . 'lp/lp_controller.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&gradebook=view'; |
|
| 176 | + $url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&gradebook=view'; |
|
| 177 | 177 | |
| 178 | 178 | if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) { |
| 179 | 179 | $url .= '&action=view&lp_id='.$this->get_ref_id(); |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().' |
| 209 | 209 | WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' '; |
| 210 | 210 | $result = Database::query($sql); |
| 211 | - $number = Database::fetch_row($result,'NUM'); |
|
| 211 | + $number = Database::fetch_row($result, 'NUM'); |
|
| 212 | 212 | return ($number[0] != 0); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -32,6 +32,8 @@ discard block |
||
| 32 | 32 | * @param array $evals |
| 33 | 33 | * @param array $links |
| 34 | 34 | * @param null $addparams |
| 35 | + * @param boolean $showTeacherView |
|
| 36 | + * @param integer $userId |
|
| 35 | 37 | */ |
| 36 | 38 | public function __construct( |
| 37 | 39 | $currentcat, |
@@ -895,7 +897,7 @@ discard block |
||
| 895 | 897 | |
| 896 | 898 | /** |
| 897 | 899 | * @param $item |
| 898 | - * @return mixed |
|
| 900 | + * @return string|null |
|
| 899 | 901 | */ |
| 900 | 902 | private function build_course_code($item) |
| 901 | 903 | { |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $this->set_additional_parameters($addparams); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - $column= 0; |
|
| 74 | + $column = 0; |
|
| 75 | 75 | if ($this->teacherView) { |
| 76 | 76 | if ($this->exportToPdf == false) { |
| 77 | 77 | $this->set_header($column++, '', '', 'width="25px"'); |
@@ -283,13 +283,13 @@ discard block |
||
| 283 | 283 | $main_categories[$item->get_id()]['name'] = $item->get_name(); |
| 284 | 284 | } else { |
| 285 | 285 | $name = $this->build_name_link($item, $type); |
| 286 | - $row[] = $invisibility_span_open.$name. $invisibility_span_close; |
|
| 286 | + $row[] = $invisibility_span_open.$name.$invisibility_span_close; |
|
| 287 | 287 | $main_categories[$item->get_id()]['name'] = $name; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | $this->dataForGraph['categories'][] = $item->get_name(); |
| 291 | 291 | |
| 292 | - $main_categories[$item->get_id()]['weight']= $item->get_weight(); |
|
| 292 | + $main_categories[$item->get_id()]['weight'] = $item->get_weight(); |
|
| 293 | 293 | $total_categories_weight += $item->get_weight(); |
| 294 | 294 | |
| 295 | 295 | // Description. |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | ); |
| 310 | 310 | |
| 311 | 311 | if ($this->teacherView) { |
| 312 | - $row[] = $invisibility_span_open .Display::tag('p', $weight, array('class' => 'score')).$invisibility_span_close; |
|
| 312 | + $row[] = $invisibility_span_open.Display::tag('p', $weight, array('class' => 'score')).$invisibility_span_close; |
|
| 313 | 313 | } else { |
| 314 | - $row[] = $invisibility_span_open .$weight.$invisibility_span_close; |
|
| 314 | + $row[] = $invisibility_span_open.$weight.$invisibility_span_close; |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | $category_weight = $item->get_weight(); |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | |
| 338 | 338 | if (!empty($score[1])) { |
| 339 | 339 | $completeScore = $scoredisplay->display_score($score, SCORE_DIV_PERCENT); |
| 340 | - $score = $score[0]/$score[1]*$item->get_weight(); |
|
| 340 | + $score = $score[0] / $score[1] * $item->get_weight(); |
|
| 341 | 341 | $score = $scoredisplay->display_score(array($score, null), SCORE_SIMPLE); |
| 342 | 342 | $scoreToDisplay = Display::tip($score, $completeScore); |
| 343 | 343 | } else { |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | $totalResultAverageValue = strip_tags($scoredisplay->display_score($totalResult, SCORE_AVERAGE)); |
| 374 | 374 | $this->dataForGraph['my_result'][] = (float) str_replace('%', '', $totalResultAverageValue); |
| 375 | 375 | $totalAverageValue = strip_tags($scoredisplay->display_score($totalAverage, SCORE_AVERAGE)); |
| 376 | - $this->dataForGraph['average'][] = (float) str_replace('%', '', $totalAverageValue); |
|
| 376 | + $this->dataForGraph['average'][] = (float) str_replace('%', '', $totalAverageValue); |
|
| 377 | 377 | // Ranking |
| 378 | 378 | $row[] = $ranking; |
| 379 | 379 | // Best |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | $row[] = $this->build_type_column($item, array('style' => 'padding-left:5px')); |
| 457 | 457 | |
| 458 | 458 | // Name. |
| 459 | - $row[] = $invisibility_span_open." ".$this->build_name_link($item, $type) . $invisibility_span_close; |
|
| 459 | + $row[] = $invisibility_span_open." ".$this->build_name_link($item, $type).$invisibility_span_close; |
|
| 460 | 460 | |
| 461 | 461 | // Description. |
| 462 | 462 | if ($this->exportToPdf == false) { |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | // Students get the results and certificates columns |
| 495 | 495 | $eval_n_links = array_merge($alleval, $alllink); |
| 496 | 496 | |
| 497 | - if (count($eval_n_links)> 0) { |
|
| 497 | + if (count($eval_n_links) > 0) { |
|
| 498 | 498 | $value_data = isset($data[4]) ? $data[4] : null; |
| 499 | 499 | |
| 500 | 500 | if (!is_null($value_data)) { |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | $row = array( |
| 594 | 594 | null, |
| 595 | 595 | null, |
| 596 | - '<strong>' . get_lang('Total') . '</strong>', |
|
| 596 | + '<strong>'.get_lang('Total').'</strong>', |
|
| 597 | 597 | null, |
| 598 | 598 | $total |
| 599 | 599 | ); |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | if ($this->exportToPdf) { |
| 664 | 664 | $row = array( |
| 665 | 665 | null, |
| 666 | - '<h3>' . get_lang('Total') . '</h3>', |
|
| 666 | + '<h3>'.get_lang('Total').'</h3>', |
|
| 667 | 667 | $main_weight, |
| 668 | 668 | $totalResult, |
| 669 | 669 | $totalRanking, |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | } else { |
| 674 | 674 | $row = array( |
| 675 | 675 | null, |
| 676 | - '<h3>' . get_lang('Total') . '</h3>', |
|
| 676 | + '<h3>'.get_lang('Total').'</h3>', |
|
| 677 | 677 | null, |
| 678 | 678 | $main_weight, |
| 679 | 679 | $totalResult, |
@@ -688,7 +688,7 @@ discard block |
||
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | // Warning messages |
| 691 | - $view = isset($_GET['view']) ? $_GET['view']: null; |
|
| 691 | + $view = isset($_GET['view']) ? $_GET['view'] : null; |
|
| 692 | 692 | |
| 693 | 693 | if ($this->teacherView) { |
| 694 | 694 | if (isset($_GET['selectcat']) && |
@@ -701,14 +701,14 @@ discard block |
||
| 701 | 701 | $weight_category = intval($this->build_weight($category[0])); |
| 702 | 702 | |
| 703 | 703 | $course_code = $this->build_course_code($category[0]); |
| 704 | - $weight_total_links = round($weight_total_links); |
|
| 704 | + $weight_total_links = round($weight_total_links); |
|
| 705 | 705 | |
| 706 | 706 | if ($weight_total_links > $weight_category || |
| 707 | 707 | $weight_total_links < $weight_category || |
| 708 | 708 | $weight_total_links > $weight_category |
| 709 | 709 | ) { |
| 710 | 710 | $warning_message = sprintf(get_lang('TotalWeightMustBeX'), $weight_category); |
| 711 | - $modify_icons = '<a href="gradebook_edit_cat.php?editcat='.$id_cat.'&cidReq='.$course_code.'&id_session='.api_get_session_id().'">'. |
|
| 711 | + $modify_icons = '<a href="gradebook_edit_cat.php?editcat='.$id_cat.'&cidReq='.$course_code.'&id_session='.api_get_session_id().'">'. |
|
| 712 | 712 | Display::return_icon('edit.png', $warning_message, array(), ICON_SIZE_SMALL).'</a>'; |
| 713 | 713 | $warning_message .= $modify_icons; |
| 714 | 714 | Display::display_warning_message($warning_message, false); |
@@ -721,7 +721,7 @@ discard block |
||
| 721 | 721 | ); |
| 722 | 722 | |
| 723 | 723 | if (!empty($content_html)) { |
| 724 | - $new_content = explode('</head>',$content_html['content']); |
|
| 724 | + $new_content = explode('</head>', $content_html['content']); |
|
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | if (empty($new_content[0])) { |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | is_array($course_codes) |
| 756 | 756 | ) { |
| 757 | 757 | $warning_message = ''; |
| 758 | - for ($x = 0; $x<count($weight_categories);$x++) { |
|
| 758 | + for ($x = 0; $x < count($weight_categories); $x++) { |
|
| 759 | 759 | $weight_category = intval($weight_categories[$x]); |
| 760 | 760 | $certificate_min_score = intval($certificate_min_scores[$x]); |
| 761 | 761 | $course_code = $course_codes[$x]; |
@@ -763,12 +763,12 @@ discard block |
||
| 763 | 763 | if (empty($certificate_min_score) || |
| 764 | 764 | ($certificate_min_score > $weight_category) |
| 765 | 765 | ) { |
| 766 | - $warning_message .= $course_code .' - '.get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan').' '.$weight_category.'<br />'; |
|
| 766 | + $warning_message .= $course_code.' - '.get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan').' '.$weight_category.'<br />'; |
|
| 767 | 767 | } |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | if (!empty($warning_message)) { |
| 771 | - Display::display_warning_message($warning_message,false); |
|
| 771 | + Display::display_warning_message($warning_message, false); |
|
| 772 | 772 | } |
| 773 | 773 | } |
| 774 | 774 | } |
@@ -812,15 +812,15 @@ discard block |
||
| 812 | 812 | $pChart->Antialias = FALSE; |
| 813 | 813 | |
| 814 | 814 | /* Add a border to the picture */ |
| 815 | - $pChart->drawRectangle(0,0,$xSize-10,$ySize-10,array("R"=>0,"G"=>0,"B"=>0)); |
|
| 815 | + $pChart->drawRectangle(0, 0, $xSize - 10, $ySize - 10, array("R"=>0, "G"=>0, "B"=>0)); |
|
| 816 | 816 | |
| 817 | - $pChart->drawText(10,16,get_lang('Results'),array("FontSize"=>11,"Align"=>TEXT_ALIGN_BOTTOMLEFT)); |
|
| 817 | + $pChart->drawText(10, 16, get_lang('Results'), array("FontSize"=>11, "Align"=>TEXT_ALIGN_BOTTOMLEFT)); |
|
| 818 | 818 | |
| 819 | - $pChart->setGraphArea(50, 30, $xSize-50, $ySize-50); |
|
| 819 | + $pChart->setGraphArea(50, 30, $xSize - 50, $ySize - 50); |
|
| 820 | 820 | |
| 821 | 821 | $pChart->setFontProperties( |
| 822 | 822 | array( |
| 823 | - 'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', |
|
| 823 | + 'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', |
|
| 824 | 824 | 'FontSize' => 10, |
| 825 | 825 | ) |
| 826 | 826 | ); |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | |
| 841 | 841 | /* Draw the line chart */ |
| 842 | 842 | $pChart->drawLineChart(); |
| 843 | - $pChart->drawPlotChart(array("DisplayValues"=>TRUE,"PlotBorder"=>TRUE,"BorderSize"=>2,"Surrounding"=>-60,"BorderAlpha"=>80)); |
|
| 843 | + $pChart->drawPlotChart(array("DisplayValues"=>TRUE, "PlotBorder"=>TRUE, "BorderSize"=>2, "Surrounding"=>-60, "BorderAlpha"=>80)); |
|
| 844 | 844 | |
| 845 | 845 | /* Write the chart legend */ |
| 846 | 846 | $pChart->drawLegend( |
@@ -860,13 +860,13 @@ discard block |
||
| 860 | 860 | $chartHash = $myCache->getHash($dataSet); |
| 861 | 861 | |
| 862 | 862 | $myCache->writeToCache($chartHash, $pChart); |
| 863 | - $imgSysPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash; |
|
| 863 | + $imgSysPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash; |
|
| 864 | 864 | $myCache->saveFromCache($chartHash, $imgSysPath); |
| 865 | - $imgWebPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash; |
|
| 865 | + $imgWebPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash; |
|
| 866 | 866 | |
| 867 | 867 | if (file_exists($imgSysPath)) { |
| 868 | 868 | $result = '<div id="contentArea" style="text-align: center;" >'; |
| 869 | - $result .= '<img src="' . $imgWebPath.'" >'; |
|
| 869 | + $result .= '<img src="'.$imgWebPath.'" >'; |
|
| 870 | 870 | $result .= '</div>'; |
| 871 | 871 | return $result; |
| 872 | 872 | } |
@@ -911,13 +911,13 @@ discard block |
||
| 911 | 911 | switch ($item->get_item_type()) { |
| 912 | 912 | // category |
| 913 | 913 | case 'C' : |
| 914 | - return 'CATE' . $item->get_id(); |
|
| 914 | + return 'CATE'.$item->get_id(); |
|
| 915 | 915 | // evaluation |
| 916 | 916 | case 'E' : |
| 917 | - return 'EVAL' . $item->get_id(); |
|
| 917 | + return 'EVAL'.$item->get_id(); |
|
| 918 | 918 | // link |
| 919 | 919 | case 'L' : |
| 920 | - return 'LINK' . $item->get_id(); |
|
| 920 | + return 'LINK'.$item->get_id(); |
|
| 921 | 921 | } |
| 922 | 922 | } |
| 923 | 923 | |
@@ -945,20 +945,20 @@ discard block |
||
| 945 | 945 | switch ($item->get_item_type()) { |
| 946 | 946 | // category |
| 947 | 947 | case 'C' : |
| 948 | - $prms_uri='?selectcat=' . $item->get_id() . '&view='.$view; |
|
| 948 | + $prms_uri = '?selectcat='.$item->get_id().'&view='.$view; |
|
| 949 | 949 | |
| 950 | 950 | if (isset($_GET['isStudentView'])) { |
| 951 | - if ( isset($is_student) || ( isset($_SESSION['studentview']) && $_SESSION['studentview']=='studentview') ) { |
|
| 952 | - $prms_uri=$prms_uri.'&isStudentView='.Security::remove_XSS($_GET['isStudentView']); |
|
| 951 | + if (isset($is_student) || (isset($_SESSION['studentview']) && $_SESSION['studentview'] == 'studentview')) { |
|
| 952 | + $prms_uri = $prms_uri.'&isStudentView='.Security::remove_XSS($_GET['isStudentView']); |
|
| 953 | 953 | } |
| 954 | 954 | } |
| 955 | 955 | |
| 956 | 956 | $cat = new Category(); |
| 957 | - $show_message=$cat->show_message_resource_delete($item->get_course_code()); |
|
| 957 | + $show_message = $cat->show_message_resource_delete($item->get_course_code()); |
|
| 958 | 958 | return ' <a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).$prms_uri.'">' |
| 959 | 959 | . $item->get_name() |
| 960 | 960 | . '</a>' |
| 961 | - . ($item->is_course() ? ' [' . $item->get_course_code() . ']'.$show_message : ''); |
|
| 961 | + . ($item->is_course() ? ' ['.$item->get_course_code().']'.$show_message : ''); |
|
| 962 | 962 | // evaluation |
| 963 | 963 | case 'E' : |
| 964 | 964 | $cat = new Category(); |
@@ -966,10 +966,10 @@ discard block |
||
| 966 | 966 | $show_message = $cat->show_message_resource_delete($course_id); |
| 967 | 967 | |
| 968 | 968 | // course/platform admin can go to the view_results page |
| 969 | - if (api_is_allowed_to_edit() && $show_message===false) { |
|
| 969 | + if (api_is_allowed_to_edit() && $show_message === false) { |
|
| 970 | 970 | if ($item->get_type() == 'presence') { |
| 971 | 971 | return ' ' |
| 972 | - . '<a href="gradebook_view_result.php?cidReq='.$course_id.'&selecteval=' . $item->get_id() . '">' |
|
| 972 | + . '<a href="gradebook_view_result.php?cidReq='.$course_id.'&selecteval='.$item->get_id().'">' |
|
| 973 | 973 | . $item->get_name() |
| 974 | 974 | . '</a>'; |
| 975 | 975 | } else { |
@@ -978,20 +978,20 @@ discard block |
||
| 978 | 978 | $extra = ''; |
| 979 | 979 | } |
| 980 | 980 | return ' ' |
| 981 | - . '<a href="gradebook_view_result.php?' . api_get_cidreq() . '&selecteval=' . $item->get_id() . '">' |
|
| 981 | + . '<a href="gradebook_view_result.php?'.api_get_cidreq().'&selecteval='.$item->get_id().'">' |
|
| 982 | 982 | . $item->get_name() |
| 983 | 983 | . '</a> '.$extra; |
| 984 | 984 | } |
| 985 | - } elseif (ScoreDisplay :: instance()->is_custom() && $show_message===false) { |
|
| 985 | + } elseif (ScoreDisplay :: instance()->is_custom() && $show_message === false) { |
|
| 986 | 986 | // students can go to the statistics page (if custom display enabled) |
| 987 | 987 | return ' ' |
| 988 | - . '<a href="gradebook_statistics.php?' . api_get_cidreq() . '&selecteval=' . $item->get_id() . '">' |
|
| 988 | + . '<a href="gradebook_statistics.php?'.api_get_cidreq().'&selecteval='.$item->get_id().'">' |
|
| 989 | 989 | . $item->get_name() |
| 990 | 990 | . '</a>'; |
| 991 | 991 | |
| 992 | 992 | } elseif ($show_message === false && !api_is_allowed_to_edit() && !ScoreDisplay :: instance()->is_custom()) { |
| 993 | 993 | return ' ' |
| 994 | - . '<a href="gradebook_statistics.php?' . api_get_cidreq() . '&selecteval=' . $item->get_id() . '">' |
|
| 994 | + . '<a href="gradebook_statistics.php?'.api_get_cidreq().'&selecteval='.$item->get_id().'">' |
|
| 995 | 995 | . $item->get_name() |
| 996 | 996 | . '</a>'; |
| 997 | 997 | } else { |
@@ -1006,7 +1006,7 @@ discard block |
||
| 1006 | 1006 | $url = $item->get_link(); |
| 1007 | 1007 | |
| 1008 | 1008 | if (isset($url) && $show_message === false) { |
| 1009 | - $text = ' <a href="' . $item->get_link() . '">' |
|
| 1009 | + $text = ' <a href="'.$item->get_link().'">' |
|
| 1010 | 1010 | . $item->get_name() |
| 1011 | 1011 | . '</a>'; |
| 1012 | 1012 | } else { |
@@ -256,10 +256,11 @@ |
||
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | // Categories. |
| 259 | - if (!empty($data_array)) |
|
| 260 | - foreach ($data_array as $data) { |
|
| 259 | + if (!empty($data_array)) { |
|
| 260 | + foreach ($data_array as $data) { |
|
| 261 | 261 | // list of items inside the gradebook (exercises, lps, forums, etc) |
| 262 | 262 | $row = array(); |
| 263 | + } |
|
| 263 | 264 | /** @var AbstractLink $item */ |
| 264 | 265 | $item = $mainCategory = $data[0]; |
| 265 | 266 | |
@@ -72,6 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * Get actual array data |
| 75 | + * @param integer $count |
|
| 75 | 76 | * @return array 2-dimensional array - each array contains the elements: |
| 76 | 77 | * 0: eval/link object |
| 77 | 78 | * 1: item name |
@@ -285,7 +286,7 @@ discard block |
||
| 285 | 286 | |
| 286 | 287 | /** |
| 287 | 288 | * @param $item |
| 288 | - * @param $ignore_score_color |
|
| 289 | + * @param boolean $ignore_score_color |
|
| 289 | 290 | * @return string |
| 290 | 291 | */ |
| 291 | 292 | private function build_average_column($item, $ignore_score_color) |
@@ -306,7 +307,7 @@ discard block |
||
| 306 | 307 | |
| 307 | 308 | /** |
| 308 | 309 | * @param $item |
| 309 | - * @param $ignore_score_color |
|
| 310 | + * @param boolean $ignore_score_color |
|
| 310 | 311 | * @return string |
| 311 | 312 | */ |
| 312 | 313 | private function build_result_column($item, $ignore_score_color) |
@@ -323,7 +324,7 @@ discard block |
||
| 323 | 324 | |
| 324 | 325 | /** |
| 325 | 326 | * @param $item |
| 326 | - * @param $ignore_score_color |
|
| 327 | + * @param boolean $ignore_score_color |
|
| 327 | 328 | * @return string |
| 328 | 329 | */ |
| 329 | 330 | private function build_mask_column($item, $ignore_score_color) |
@@ -339,7 +340,7 @@ discard block |
||
| 339 | 340 | |
| 340 | 341 | /** |
| 341 | 342 | * @param $coursecode |
| 342 | - * @return mixed |
|
| 343 | + * @return string |
|
| 343 | 344 | */ |
| 344 | 345 | private function get_course_name_from_code_cached($coursecode) |
| 345 | 346 | { |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | } |
| 52 | 52 | if (count($result) == 0) { |
| 53 | - $evals_filtered=$evals; |
|
| 53 | + $evals_filtered = $evals; |
|
| 54 | 54 | } else { |
| 55 | - $evals_filtered=$evals_filtered_copy; |
|
| 55 | + $evals_filtered = $evals_filtered_copy; |
|
| 56 | 56 | } |
| 57 | 57 | $this->items = array_merge($evals_filtered, $links); |
| 58 | 58 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | // do some checks on count, redefine if invalid value |
| 87 | 87 | if (!isset($count)) { |
| 88 | - $count = count ($this->items) - $start; |
|
| 88 | + $count = count($this->items) - $start; |
|
| 89 | 89 | } |
| 90 | 90 | if ($count < 0) { |
| 91 | 91 | $count = 0; |
@@ -104,20 +104,20 @@ discard block |
||
| 104 | 104 | } elseif ($sorting & self :: UDG_SORT_AVERAGE) { |
| 105 | 105 | // if user sorts on average scores, first calculate them and cache them |
| 106 | 106 | foreach ($allitems as $item) { |
| 107 | - $this->avgcache[$item->get_item_type() . $item->get_id()]= $item->calc_score(); |
|
| 107 | + $this->avgcache[$item->get_item_type().$item->get_id()] = $item->calc_score(); |
|
| 108 | 108 | } |
| 109 | 109 | usort($allitems, array('UserDataGenerator', 'sort_by_average')); |
| 110 | 110 | } elseif ($sorting & self :: UDG_SORT_SCORE) { |
| 111 | 111 | // if user sorts on student's scores, first calculate them and cache them |
| 112 | 112 | foreach ($allitems as $item) { |
| 113 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 113 | + $this->scorecache[$item->get_item_type().$item->get_id()] |
|
| 114 | 114 | = $item->calc_score($this->userid); |
| 115 | 115 | } |
| 116 | 116 | usort($allitems, array('UserDataGenerator', 'sort_by_score')); |
| 117 | 117 | } elseif ($sorting & self :: UDG_SORT_MASK) { |
| 118 | 118 | // if user sorts on student's masks, first calculate scores and cache them |
| 119 | 119 | foreach ($allitems as $item) { |
| 120 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 120 | + $this->scorecache[$item->get_item_type().$item->get_id()] |
|
| 121 | 121 | = $item->calc_score($this->userid); |
| 122 | 122 | } |
| 123 | 123 | usort($allitems, array('UserDataGenerator', 'sort_by_mask')); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | // fill score cache if not done yet |
| 133 | 133 | if (!isset ($this->scorecache)) { |
| 134 | 134 | foreach ($visibleitems as $item) { |
| 135 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 135 | + $this->scorecache[$item->get_item_type().$item->get_id()] |
|
| 136 | 136 | = $item->calc_score($this->userid); |
| 137 | 137 | } |
| 138 | 138 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | $scoredisplay = ScoreDisplay :: instance(); |
| 142 | 142 | $data = array(); |
| 143 | 143 | foreach ($visibleitems as $item) { |
| 144 | - $row = array (); |
|
| 144 | + $row = array(); |
|
| 145 | 145 | $row[] = $item; |
| 146 | 146 | $row[] = $item->get_name(); |
| 147 | 147 | $row[] = $this->build_course_name($item); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | function sort_by_type($item1, $item2) |
| 164 | 164 | { |
| 165 | 165 | if ($item1->get_item_type() == $item2->get_item_type()) { |
| 166 | - return $this->sort_by_name($item1,$item2); |
|
| 166 | + return $this->sort_by_name($item1, $item2); |
|
| 167 | 167 | } else { |
| 168 | 168 | return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1); |
| 169 | 169 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | function sort_by_name($item1, $item2) |
| 205 | 205 | { |
| 206 | - return api_strnatcmp($item1->get_name(),$item2->get_name()); |
|
| 206 | + return api_strnatcmp($item1->get_name(), $item2->get_name()); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | function sort_by_average($item1, $item2) |
| 215 | 215 | { |
| 216 | - $score1 = $this->avgcache[$item1->get_item_type() . $item1->get_id()]; |
|
| 217 | - $score2 = $this->avgcache[$item2->get_item_type() . $item2->get_id()]; |
|
| 216 | + $score1 = $this->avgcache[$item1->get_item_type().$item1->get_id()]; |
|
| 217 | + $score2 = $this->avgcache[$item2->get_item_type().$item2->get_id()]; |
|
| 218 | 218 | |
| 219 | 219 | return $this->compare_scores($score1, $score2); |
| 220 | 220 | } |
@@ -226,8 +226,8 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | function sort_by_score($item1, $item2) |
| 228 | 228 | { |
| 229 | - $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
| 230 | - $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
| 229 | + $score1 = $this->scorecache[$item1->get_item_type().$item1->get_id()]; |
|
| 230 | + $score2 = $this->scorecache[$item2->get_item_type().$item2->get_id()]; |
|
| 231 | 231 | |
| 232 | 232 | return $this->compare_scores($score1, $score2); |
| 233 | 233 | } |
@@ -239,8 +239,8 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | function sort_by_mask($item1, $item2) |
| 241 | 241 | { |
| 242 | - $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
| 243 | - $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
| 242 | + $score1 = $this->scorecache[$item1->get_item_type().$item1->get_id()]; |
|
| 243 | + $score2 = $this->scorecache[$item2->get_item_type().$item2->get_id()]; |
|
| 244 | 244 | |
| 245 | 245 | return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2); |
| 246 | 246 | } |
@@ -256,10 +256,10 @@ discard block |
||
| 256 | 256 | return (isset($score2) ? 1 : 0); |
| 257 | 257 | } elseif (!isset($score2)) { |
| 258 | 258 | return -1; |
| 259 | - } elseif (($score1[0]/$score1[1]) == ($score2[0]/$score2[1])) { |
|
| 259 | + } elseif (($score1[0] / $score1[1]) == ($score2[0] / $score2[1])) { |
|
| 260 | 260 | return 0; |
| 261 | 261 | } else { |
| 262 | - return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1); |
|
| 262 | + return (($score1[0] / $score1[1]) < ($score2[0] / $score2[1]) ? -1 : 1); |
|
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | private function build_average_column($item, $ignore_score_color) |
| 292 | 292 | { |
| 293 | 293 | if (isset($this->avgcache)) { |
| 294 | - $avgscore = $this->avgcache[$item->get_item_type() . $item->get_id()]; |
|
| 294 | + $avgscore = $this->avgcache[$item->get_item_type().$item->get_id()]; |
|
| 295 | 295 | } else { |
| 296 | 296 | $avgscore = $item->calc_score(); |
| 297 | 297 | } |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | */ |
| 312 | 312 | private function build_result_column($item, $ignore_score_color) |
| 313 | 313 | { |
| 314 | - $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
| 314 | + $studscore = $this->scorecache[$item->get_item_type().$item->get_id()]; |
|
| 315 | 315 | $scoredisplay = ScoreDisplay :: instance(); |
| 316 | 316 | $displaytype = SCORE_DIV_PERCENT; |
| 317 | 317 | if ($ignore_score_color) { |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | */ |
| 329 | 329 | private function build_mask_column($item, $ignore_score_color) |
| 330 | 330 | { |
| 331 | - $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
| 331 | + $studscore = $this->scorecache[$item->get_item_type().$item->get_id()]; |
|
| 332 | 332 | $scoredisplay = ScoreDisplay :: instance(); |
| 333 | 333 | $displaytype = SCORE_DIV_PERCENT; |
| 334 | 334 | if ($ignore_score_color) { |
@@ -362,12 +362,12 @@ discard block |
||
| 362 | 362 | if (isset ($this->categorycache) |
| 363 | 363 | && isset ($this->categorycache[$category_id])) { |
| 364 | 364 | return $this->categorycache[$category_id]; |
| 365 | - }else { |
|
| 365 | + } else { |
|
| 366 | 366 | $cat = Category::load($category_id); |
| 367 | - if (isset($cat)){ |
|
| 367 | + if (isset($cat)) { |
|
| 368 | 368 | $this->categorycache[$category_id] = $cat[0]; |
| 369 | 369 | return $cat[0]; |
| 370 | - }else |
|
| 370 | + } else |
|
| 371 | 371 | return null; |
| 372 | 372 | } |
| 373 | 373 | } |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | private function get_category_name_to_display($cat) |
| 380 | 380 | { |
| 381 | 381 | if (isset($cat)) { |
| 382 | - if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null){ |
|
| 382 | + if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null) { |
|
| 383 | 383 | return ''; |
| 384 | 384 | } else { |
| 385 | 385 | return $cat->get_name(); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | // sort users array |
| 96 | 96 | if ($sorting & self :: UDG_SORT_TYPE) { |
| 97 | 97 | usort($allitems, array('UserDataGenerator', 'sort_by_type')); |
| 98 | - }elseif ($sorting & self :: UDG_SORT_NAME) { |
|
| 98 | + } elseif ($sorting & self :: UDG_SORT_NAME) { |
|
| 99 | 99 | usort($allitems, array('UserDataGenerator', 'sort_by_name')); |
| 100 | 100 | } elseif ($sorting & self :: UDG_SORT_COURSE) { |
| 101 | 101 | usort($allitems, array('UserDataGenerator', 'sort_by_course')); |
@@ -148,8 +148,9 @@ discard block |
||
| 148 | 148 | $row[] = $this->build_category_name($item); |
| 149 | 149 | $row[] = $this->build_average_column($item, $ignore_score_color); |
| 150 | 150 | $row[] = $this->build_result_column($item, $ignore_score_color); |
| 151 | - if ($scoredisplay->is_custom()) |
|
| 152 | - $row[] = $this->build_mask_column($item, $ignore_score_color); |
|
| 151 | + if ($scoredisplay->is_custom()) { |
|
| 152 | + $row[] = $this->build_mask_column($item, $ignore_score_color); |
|
| 153 | + } |
|
| 153 | 154 | $data[] = $row; |
| 154 | 155 | } |
| 155 | 156 | return $data; |
@@ -362,13 +363,14 @@ discard block |
||
| 362 | 363 | if (isset ($this->categorycache) |
| 363 | 364 | && isset ($this->categorycache[$category_id])) { |
| 364 | 365 | return $this->categorycache[$category_id]; |
| 365 | - }else { |
|
| 366 | + } else { |
|
| 366 | 367 | $cat = Category::load($category_id); |
| 367 | 368 | if (isset($cat)){ |
| 368 | 369 | $this->categorycache[$category_id] = $cat[0]; |
| 369 | 370 | return $cat[0]; |
| 370 | - }else |
|
| 371 | - return null; |
|
| 371 | + } else { |
|
| 372 | + return null; |
|
| 373 | + } |
|
| 372 | 374 | } |
| 373 | 375 | } |
| 374 | 376 | |
@@ -10,28 +10,28 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | class UserDataGenerator |
| 12 | 12 | { |
| 13 | - // Sorting types constants |
|
| 14 | - const UDG_SORT_TYPE = 1; |
|
| 15 | - const UDG_SORT_NAME = 2; |
|
| 16 | - const UDG_SORT_COURSE = 4; |
|
| 17 | - const UDG_SORT_CATEGORY = 8; |
|
| 18 | - const UDG_SORT_AVERAGE = 16; |
|
| 19 | - const UDG_SORT_SCORE = 32; |
|
| 20 | - const UDG_SORT_MASK = 64; |
|
| 21 | - |
|
| 22 | - const UDG_SORT_ASC = 128; |
|
| 23 | - const UDG_SORT_DESC = 256; |
|
| 24 | - |
|
| 25 | - private $items; |
|
| 26 | - private $userid; |
|
| 27 | - |
|
| 28 | - private $coursecodecache; |
|
| 29 | - private $categorycache; |
|
| 30 | - private $scorecache; |
|
| 31 | - private $avgcache; |
|
| 32 | - |
|
| 33 | - public function __construct($userid, $evals = array(), $links = array()) |
|
| 34 | - { |
|
| 13 | + // Sorting types constants |
|
| 14 | + const UDG_SORT_TYPE = 1; |
|
| 15 | + const UDG_SORT_NAME = 2; |
|
| 16 | + const UDG_SORT_COURSE = 4; |
|
| 17 | + const UDG_SORT_CATEGORY = 8; |
|
| 18 | + const UDG_SORT_AVERAGE = 16; |
|
| 19 | + const UDG_SORT_SCORE = 32; |
|
| 20 | + const UDG_SORT_MASK = 64; |
|
| 21 | + |
|
| 22 | + const UDG_SORT_ASC = 128; |
|
| 23 | + const UDG_SORT_DESC = 256; |
|
| 24 | + |
|
| 25 | + private $items; |
|
| 26 | + private $userid; |
|
| 27 | + |
|
| 28 | + private $coursecodecache; |
|
| 29 | + private $categorycache; |
|
| 30 | + private $scorecache; |
|
| 31 | + private $avgcache; |
|
| 32 | + |
|
| 33 | + public function __construct($userid, $evals = array(), $links = array()) |
|
| 34 | + { |
|
| 35 | 35 | $this->userid = $userid; |
| 36 | 36 | $evals_filtered = array(); |
| 37 | 37 | $result = array(); |
@@ -62,330 +62,330 @@ discard block |
||
| 62 | 62 | $this->avgcache = null; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Get total number of items (rows) |
|
| 67 | - */ |
|
| 68 | - public function get_total_items_count() |
|
| 69 | - { |
|
| 70 | - return count($this->items); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Get actual array data |
|
| 75 | - * @return array 2-dimensional array - each array contains the elements: |
|
| 76 | - * 0: eval/link object |
|
| 77 | - * 1: item name |
|
| 78 | - * 2: course name |
|
| 79 | - * 3: category name |
|
| 80 | - * 4: average score |
|
| 81 | - * 5: student's score |
|
| 82 | - * 6: student's score as custom display (only if custom scoring enabled) |
|
| 83 | - */ |
|
| 84 | - public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false) |
|
| 85 | - { |
|
| 86 | - // do some checks on count, redefine if invalid value |
|
| 87 | - if (!isset($count)) { |
|
| 88 | - $count = count ($this->items) - $start; |
|
| 89 | - } |
|
| 90 | - if ($count < 0) { |
|
| 91 | - $count = 0; |
|
| 92 | - } |
|
| 93 | - $allitems = $this->items; |
|
| 94 | - |
|
| 95 | - // sort users array |
|
| 96 | - if ($sorting & self :: UDG_SORT_TYPE) { |
|
| 97 | - usort($allitems, array('UserDataGenerator', 'sort_by_type')); |
|
| 98 | - }elseif ($sorting & self :: UDG_SORT_NAME) { |
|
| 99 | - usort($allitems, array('UserDataGenerator', 'sort_by_name')); |
|
| 100 | - } elseif ($sorting & self :: UDG_SORT_COURSE) { |
|
| 101 | - usort($allitems, array('UserDataGenerator', 'sort_by_course')); |
|
| 102 | - } elseif ($sorting & self :: UDG_SORT_CATEGORY) { |
|
| 103 | - usort($allitems, array('UserDataGenerator', 'sort_by_category')); |
|
| 104 | - } elseif ($sorting & self :: UDG_SORT_AVERAGE) { |
|
| 105 | - // if user sorts on average scores, first calculate them and cache them |
|
| 106 | - foreach ($allitems as $item) { |
|
| 107 | - $this->avgcache[$item->get_item_type() . $item->get_id()]= $item->calc_score(); |
|
| 108 | - } |
|
| 109 | - usort($allitems, array('UserDataGenerator', 'sort_by_average')); |
|
| 110 | - } elseif ($sorting & self :: UDG_SORT_SCORE) { |
|
| 111 | - // if user sorts on student's scores, first calculate them and cache them |
|
| 112 | - foreach ($allitems as $item) { |
|
| 113 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 114 | - = $item->calc_score($this->userid); |
|
| 115 | - } |
|
| 116 | - usort($allitems, array('UserDataGenerator', 'sort_by_score')); |
|
| 117 | - } elseif ($sorting & self :: UDG_SORT_MASK) { |
|
| 118 | - // if user sorts on student's masks, first calculate scores and cache them |
|
| 119 | - foreach ($allitems as $item) { |
|
| 120 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 121 | - = $item->calc_score($this->userid); |
|
| 122 | - } |
|
| 123 | - usort($allitems, array('UserDataGenerator', 'sort_by_mask')); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - if ($sorting & self :: UDG_SORT_DESC) { |
|
| 127 | - $allitems = array_reverse($allitems); |
|
| 128 | - } |
|
| 129 | - // select the items we have to display |
|
| 130 | - $visibleitems = array_slice($allitems, $start, $count); |
|
| 131 | - |
|
| 132 | - // fill score cache if not done yet |
|
| 133 | - if (!isset ($this->scorecache)) { |
|
| 134 | - foreach ($visibleitems as $item) { |
|
| 135 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 136 | - = $item->calc_score($this->userid); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - } |
|
| 140 | - // generate the data to display |
|
| 141 | - $scoredisplay = ScoreDisplay :: instance(); |
|
| 142 | - $data = array(); |
|
| 143 | - foreach ($visibleitems as $item) { |
|
| 144 | - $row = array (); |
|
| 145 | - $row[] = $item; |
|
| 146 | - $row[] = $item->get_name(); |
|
| 147 | - $row[] = $this->build_course_name($item); |
|
| 148 | - $row[] = $this->build_category_name($item); |
|
| 149 | - $row[] = $this->build_average_column($item, $ignore_score_color); |
|
| 150 | - $row[] = $this->build_result_column($item, $ignore_score_color); |
|
| 151 | - if ($scoredisplay->is_custom()) |
|
| 152 | - $row[] = $this->build_mask_column($item, $ignore_score_color); |
|
| 153 | - $data[] = $row; |
|
| 154 | - } |
|
| 155 | - return $data; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * @param $item1 |
|
| 160 | - * @param $item2 |
|
| 161 | - * @return int |
|
| 162 | - */ |
|
| 163 | - function sort_by_type($item1, $item2) |
|
| 164 | - { |
|
| 165 | - if ($item1->get_item_type() == $item2->get_item_type()) { |
|
| 166 | - return $this->sort_by_name($item1,$item2); |
|
| 167 | - } else { |
|
| 168 | - return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1); |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * @param $item1 |
|
| 174 | - * @param $item2 |
|
| 175 | - * @return int |
|
| 176 | - */ |
|
| 177 | - function sort_by_course($item1, $item2) |
|
| 178 | - { |
|
| 179 | - $name1 = api_strtolower($this->get_course_name_from_code_cached($item1->get_course_code())); |
|
| 180 | - $name2 = api_strtolower($this->get_course_name_from_code_cached($item2->get_course_code())); |
|
| 181 | - return api_strnatcmp($name1, $name2); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * @param $item1 |
|
| 186 | - * @param $item2 |
|
| 187 | - * @return int |
|
| 188 | - */ |
|
| 189 | - function sort_by_category($item1, $item2) |
|
| 190 | - { |
|
| 191 | - $cat1 = $this->get_category_cached($item1->get_category_id()); |
|
| 192 | - $cat2 = $this->get_category_cached($item2->get_category_id()); |
|
| 193 | - $name1 = api_strtolower($this->get_category_name_to_display($cat1)); |
|
| 194 | - $name2 = api_strtolower($this->get_category_name_to_display($cat2)); |
|
| 195 | - |
|
| 196 | - return api_strnatcmp($name1, $name2); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * @param $item1 |
|
| 201 | - * @param $item2 |
|
| 202 | - * @return int |
|
| 203 | - */ |
|
| 204 | - function sort_by_name($item1, $item2) |
|
| 205 | - { |
|
| 206 | - return api_strnatcmp($item1->get_name(),$item2->get_name()); |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * @param $item1 |
|
| 211 | - * @param $item2 |
|
| 212 | - * @return int |
|
| 213 | - */ |
|
| 214 | - function sort_by_average($item1, $item2) |
|
| 215 | - { |
|
| 216 | - $score1 = $this->avgcache[$item1->get_item_type() . $item1->get_id()]; |
|
| 217 | - $score2 = $this->avgcache[$item2->get_item_type() . $item2->get_id()]; |
|
| 218 | - |
|
| 219 | - return $this->compare_scores($score1, $score2); |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * @param $item1 |
|
| 224 | - * @param $item2 |
|
| 225 | - * @return int |
|
| 226 | - */ |
|
| 227 | - function sort_by_score($item1, $item2) |
|
| 228 | - { |
|
| 229 | - $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
| 230 | - $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
| 231 | - |
|
| 232 | - return $this->compare_scores($score1, $score2); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * @param $item1 |
|
| 237 | - * @param $item2 |
|
| 238 | - * @return int |
|
| 239 | - */ |
|
| 240 | - function sort_by_mask($item1, $item2) |
|
| 241 | - { |
|
| 242 | - $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
| 243 | - $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
| 244 | - |
|
| 245 | - return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2); |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * @param $score1 |
|
| 250 | - * @param $score2 |
|
| 251 | - * @return int |
|
| 252 | - */ |
|
| 253 | - function compare_scores($score1, $score2) |
|
| 254 | - { |
|
| 255 | - if (!isset($score1)) { |
|
| 256 | - return (isset($score2) ? 1 : 0); |
|
| 257 | - } elseif (!isset($score2)) { |
|
| 258 | - return -1; |
|
| 259 | - } elseif (($score1[0]/$score1[1]) == ($score2[0]/$score2[1])) { |
|
| 260 | - return 0; |
|
| 261 | - } else { |
|
| 262 | - return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1); |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * @param $item |
|
| 268 | - * @return mixed |
|
| 269 | - */ |
|
| 270 | - private function build_course_name($item) |
|
| 271 | - { |
|
| 272 | - return $this->get_course_name_from_code_cached($item->get_course_code()); |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - /** |
|
| 276 | - * @param $item |
|
| 277 | - * @return string |
|
| 278 | - */ |
|
| 279 | - private function build_category_name($item) |
|
| 280 | - { |
|
| 281 | - $cat = $this->get_category_cached($item->get_category_id()); |
|
| 282 | - |
|
| 283 | - return $this->get_category_name_to_display($cat); |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - /** |
|
| 287 | - * @param $item |
|
| 288 | - * @param $ignore_score_color |
|
| 289 | - * @return string |
|
| 290 | - */ |
|
| 291 | - private function build_average_column($item, $ignore_score_color) |
|
| 292 | - { |
|
| 293 | - if (isset($this->avgcache)) { |
|
| 294 | - $avgscore = $this->avgcache[$item->get_item_type() . $item->get_id()]; |
|
| 295 | - } else { |
|
| 296 | - $avgscore = $item->calc_score(); |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - $scoredisplay = ScoreDisplay :: instance(); |
|
| 300 | - $displaytype = SCORE_AVERAGE; |
|
| 301 | - /*if ($ignore_score_color) |
|
| 65 | + /** |
|
| 66 | + * Get total number of items (rows) |
|
| 67 | + */ |
|
| 68 | + public function get_total_items_count() |
|
| 69 | + { |
|
| 70 | + return count($this->items); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Get actual array data |
|
| 75 | + * @return array 2-dimensional array - each array contains the elements: |
|
| 76 | + * 0: eval/link object |
|
| 77 | + * 1: item name |
|
| 78 | + * 2: course name |
|
| 79 | + * 3: category name |
|
| 80 | + * 4: average score |
|
| 81 | + * 5: student's score |
|
| 82 | + * 6: student's score as custom display (only if custom scoring enabled) |
|
| 83 | + */ |
|
| 84 | + public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false) |
|
| 85 | + { |
|
| 86 | + // do some checks on count, redefine if invalid value |
|
| 87 | + if (!isset($count)) { |
|
| 88 | + $count = count ($this->items) - $start; |
|
| 89 | + } |
|
| 90 | + if ($count < 0) { |
|
| 91 | + $count = 0; |
|
| 92 | + } |
|
| 93 | + $allitems = $this->items; |
|
| 94 | + |
|
| 95 | + // sort users array |
|
| 96 | + if ($sorting & self :: UDG_SORT_TYPE) { |
|
| 97 | + usort($allitems, array('UserDataGenerator', 'sort_by_type')); |
|
| 98 | + }elseif ($sorting & self :: UDG_SORT_NAME) { |
|
| 99 | + usort($allitems, array('UserDataGenerator', 'sort_by_name')); |
|
| 100 | + } elseif ($sorting & self :: UDG_SORT_COURSE) { |
|
| 101 | + usort($allitems, array('UserDataGenerator', 'sort_by_course')); |
|
| 102 | + } elseif ($sorting & self :: UDG_SORT_CATEGORY) { |
|
| 103 | + usort($allitems, array('UserDataGenerator', 'sort_by_category')); |
|
| 104 | + } elseif ($sorting & self :: UDG_SORT_AVERAGE) { |
|
| 105 | + // if user sorts on average scores, first calculate them and cache them |
|
| 106 | + foreach ($allitems as $item) { |
|
| 107 | + $this->avgcache[$item->get_item_type() . $item->get_id()]= $item->calc_score(); |
|
| 108 | + } |
|
| 109 | + usort($allitems, array('UserDataGenerator', 'sort_by_average')); |
|
| 110 | + } elseif ($sorting & self :: UDG_SORT_SCORE) { |
|
| 111 | + // if user sorts on student's scores, first calculate them and cache them |
|
| 112 | + foreach ($allitems as $item) { |
|
| 113 | + $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 114 | + = $item->calc_score($this->userid); |
|
| 115 | + } |
|
| 116 | + usort($allitems, array('UserDataGenerator', 'sort_by_score')); |
|
| 117 | + } elseif ($sorting & self :: UDG_SORT_MASK) { |
|
| 118 | + // if user sorts on student's masks, first calculate scores and cache them |
|
| 119 | + foreach ($allitems as $item) { |
|
| 120 | + $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 121 | + = $item->calc_score($this->userid); |
|
| 122 | + } |
|
| 123 | + usort($allitems, array('UserDataGenerator', 'sort_by_mask')); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + if ($sorting & self :: UDG_SORT_DESC) { |
|
| 127 | + $allitems = array_reverse($allitems); |
|
| 128 | + } |
|
| 129 | + // select the items we have to display |
|
| 130 | + $visibleitems = array_slice($allitems, $start, $count); |
|
| 131 | + |
|
| 132 | + // fill score cache if not done yet |
|
| 133 | + if (!isset ($this->scorecache)) { |
|
| 134 | + foreach ($visibleitems as $item) { |
|
| 135 | + $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 136 | + = $item->calc_score($this->userid); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + } |
|
| 140 | + // generate the data to display |
|
| 141 | + $scoredisplay = ScoreDisplay :: instance(); |
|
| 142 | + $data = array(); |
|
| 143 | + foreach ($visibleitems as $item) { |
|
| 144 | + $row = array (); |
|
| 145 | + $row[] = $item; |
|
| 146 | + $row[] = $item->get_name(); |
|
| 147 | + $row[] = $this->build_course_name($item); |
|
| 148 | + $row[] = $this->build_category_name($item); |
|
| 149 | + $row[] = $this->build_average_column($item, $ignore_score_color); |
|
| 150 | + $row[] = $this->build_result_column($item, $ignore_score_color); |
|
| 151 | + if ($scoredisplay->is_custom()) |
|
| 152 | + $row[] = $this->build_mask_column($item, $ignore_score_color); |
|
| 153 | + $data[] = $row; |
|
| 154 | + } |
|
| 155 | + return $data; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * @param $item1 |
|
| 160 | + * @param $item2 |
|
| 161 | + * @return int |
|
| 162 | + */ |
|
| 163 | + function sort_by_type($item1, $item2) |
|
| 164 | + { |
|
| 165 | + if ($item1->get_item_type() == $item2->get_item_type()) { |
|
| 166 | + return $this->sort_by_name($item1,$item2); |
|
| 167 | + } else { |
|
| 168 | + return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1); |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * @param $item1 |
|
| 174 | + * @param $item2 |
|
| 175 | + * @return int |
|
| 176 | + */ |
|
| 177 | + function sort_by_course($item1, $item2) |
|
| 178 | + { |
|
| 179 | + $name1 = api_strtolower($this->get_course_name_from_code_cached($item1->get_course_code())); |
|
| 180 | + $name2 = api_strtolower($this->get_course_name_from_code_cached($item2->get_course_code())); |
|
| 181 | + return api_strnatcmp($name1, $name2); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * @param $item1 |
|
| 186 | + * @param $item2 |
|
| 187 | + * @return int |
|
| 188 | + */ |
|
| 189 | + function sort_by_category($item1, $item2) |
|
| 190 | + { |
|
| 191 | + $cat1 = $this->get_category_cached($item1->get_category_id()); |
|
| 192 | + $cat2 = $this->get_category_cached($item2->get_category_id()); |
|
| 193 | + $name1 = api_strtolower($this->get_category_name_to_display($cat1)); |
|
| 194 | + $name2 = api_strtolower($this->get_category_name_to_display($cat2)); |
|
| 195 | + |
|
| 196 | + return api_strnatcmp($name1, $name2); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * @param $item1 |
|
| 201 | + * @param $item2 |
|
| 202 | + * @return int |
|
| 203 | + */ |
|
| 204 | + function sort_by_name($item1, $item2) |
|
| 205 | + { |
|
| 206 | + return api_strnatcmp($item1->get_name(),$item2->get_name()); |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * @param $item1 |
|
| 211 | + * @param $item2 |
|
| 212 | + * @return int |
|
| 213 | + */ |
|
| 214 | + function sort_by_average($item1, $item2) |
|
| 215 | + { |
|
| 216 | + $score1 = $this->avgcache[$item1->get_item_type() . $item1->get_id()]; |
|
| 217 | + $score2 = $this->avgcache[$item2->get_item_type() . $item2->get_id()]; |
|
| 218 | + |
|
| 219 | + return $this->compare_scores($score1, $score2); |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * @param $item1 |
|
| 224 | + * @param $item2 |
|
| 225 | + * @return int |
|
| 226 | + */ |
|
| 227 | + function sort_by_score($item1, $item2) |
|
| 228 | + { |
|
| 229 | + $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
| 230 | + $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
| 231 | + |
|
| 232 | + return $this->compare_scores($score1, $score2); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * @param $item1 |
|
| 237 | + * @param $item2 |
|
| 238 | + * @return int |
|
| 239 | + */ |
|
| 240 | + function sort_by_mask($item1, $item2) |
|
| 241 | + { |
|
| 242 | + $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
| 243 | + $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
| 244 | + |
|
| 245 | + return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2); |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * @param $score1 |
|
| 250 | + * @param $score2 |
|
| 251 | + * @return int |
|
| 252 | + */ |
|
| 253 | + function compare_scores($score1, $score2) |
|
| 254 | + { |
|
| 255 | + if (!isset($score1)) { |
|
| 256 | + return (isset($score2) ? 1 : 0); |
|
| 257 | + } elseif (!isset($score2)) { |
|
| 258 | + return -1; |
|
| 259 | + } elseif (($score1[0]/$score1[1]) == ($score2[0]/$score2[1])) { |
|
| 260 | + return 0; |
|
| 261 | + } else { |
|
| 262 | + return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1); |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * @param $item |
|
| 268 | + * @return mixed |
|
| 269 | + */ |
|
| 270 | + private function build_course_name($item) |
|
| 271 | + { |
|
| 272 | + return $this->get_course_name_from_code_cached($item->get_course_code()); |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + /** |
|
| 276 | + * @param $item |
|
| 277 | + * @return string |
|
| 278 | + */ |
|
| 279 | + private function build_category_name($item) |
|
| 280 | + { |
|
| 281 | + $cat = $this->get_category_cached($item->get_category_id()); |
|
| 282 | + |
|
| 283 | + return $this->get_category_name_to_display($cat); |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + /** |
|
| 287 | + * @param $item |
|
| 288 | + * @param $ignore_score_color |
|
| 289 | + * @return string |
|
| 290 | + */ |
|
| 291 | + private function build_average_column($item, $ignore_score_color) |
|
| 292 | + { |
|
| 293 | + if (isset($this->avgcache)) { |
|
| 294 | + $avgscore = $this->avgcache[$item->get_item_type() . $item->get_id()]; |
|
| 295 | + } else { |
|
| 296 | + $avgscore = $item->calc_score(); |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + $scoredisplay = ScoreDisplay :: instance(); |
|
| 300 | + $displaytype = SCORE_AVERAGE; |
|
| 301 | + /*if ($ignore_score_color) |
|
| 302 | 302 | $displaytype |= SCORE_IGNORE_SPLIT; |
| 303 | 303 | */ |
| 304 | - return $scoredisplay->display_score($avgscore, $displaytype); |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - /** |
|
| 308 | - * @param $item |
|
| 309 | - * @param $ignore_score_color |
|
| 310 | - * @return string |
|
| 311 | - */ |
|
| 312 | - private function build_result_column($item, $ignore_score_color) |
|
| 313 | - { |
|
| 314 | - $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
| 315 | - $scoredisplay = ScoreDisplay :: instance(); |
|
| 316 | - $displaytype = SCORE_DIV_PERCENT; |
|
| 317 | - if ($ignore_score_color) { |
|
| 318 | - $displaytype |= SCORE_IGNORE_SPLIT; |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_DEFAULT); |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - /** |
|
| 325 | - * @param $item |
|
| 326 | - * @param $ignore_score_color |
|
| 327 | - * @return string |
|
| 328 | - */ |
|
| 329 | - private function build_mask_column($item, $ignore_score_color) |
|
| 330 | - { |
|
| 331 | - $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
| 332 | - $scoredisplay = ScoreDisplay :: instance(); |
|
| 333 | - $displaytype = SCORE_DIV_PERCENT; |
|
| 334 | - if ($ignore_score_color) { |
|
| 335 | - $displaytype |= SCORE_IGNORE_SPLIT; |
|
| 336 | - } |
|
| 337 | - return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_CUSTOM); |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * @param $coursecode |
|
| 342 | - * @return mixed |
|
| 343 | - */ |
|
| 344 | - private function get_course_name_from_code_cached($coursecode) |
|
| 345 | - { |
|
| 346 | - if (isset ($this->coursecodecache) |
|
| 347 | - && isset ($this->coursecodecache[$coursecode])) { |
|
| 348 | - return $this->coursecodecache[$coursecode]; |
|
| 349 | - } else { |
|
| 350 | - $name = CourseManager::getCourseNameFromCode($coursecode); |
|
| 351 | - $this->coursecodecache[$coursecode] = $name; |
|
| 352 | - return $name; |
|
| 353 | - } |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * @param $category_id |
|
| 358 | - * @return null |
|
| 359 | - */ |
|
| 360 | - private function get_category_cached($category_id) |
|
| 361 | - { |
|
| 362 | - if (isset ($this->categorycache) |
|
| 363 | - && isset ($this->categorycache[$category_id])) { |
|
| 364 | - return $this->categorycache[$category_id]; |
|
| 365 | - }else { |
|
| 366 | - $cat = Category::load($category_id); |
|
| 367 | - if (isset($cat)){ |
|
| 368 | - $this->categorycache[$category_id] = $cat[0]; |
|
| 369 | - return $cat[0]; |
|
| 370 | - }else |
|
| 371 | - return null; |
|
| 372 | - } |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - /** |
|
| 376 | - * @param $cat |
|
| 377 | - * @return string |
|
| 378 | - */ |
|
| 379 | - private function get_category_name_to_display($cat) |
|
| 380 | - { |
|
| 381 | - if (isset($cat)) { |
|
| 382 | - if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null){ |
|
| 383 | - return ''; |
|
| 384 | - } else { |
|
| 385 | - return $cat->get_name(); |
|
| 386 | - } |
|
| 387 | - } else { |
|
| 388 | - return ''; |
|
| 389 | - } |
|
| 390 | - } |
|
| 304 | + return $scoredisplay->display_score($avgscore, $displaytype); |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + /** |
|
| 308 | + * @param $item |
|
| 309 | + * @param $ignore_score_color |
|
| 310 | + * @return string |
|
| 311 | + */ |
|
| 312 | + private function build_result_column($item, $ignore_score_color) |
|
| 313 | + { |
|
| 314 | + $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
| 315 | + $scoredisplay = ScoreDisplay :: instance(); |
|
| 316 | + $displaytype = SCORE_DIV_PERCENT; |
|
| 317 | + if ($ignore_score_color) { |
|
| 318 | + $displaytype |= SCORE_IGNORE_SPLIT; |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_DEFAULT); |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + /** |
|
| 325 | + * @param $item |
|
| 326 | + * @param $ignore_score_color |
|
| 327 | + * @return string |
|
| 328 | + */ |
|
| 329 | + private function build_mask_column($item, $ignore_score_color) |
|
| 330 | + { |
|
| 331 | + $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
| 332 | + $scoredisplay = ScoreDisplay :: instance(); |
|
| 333 | + $displaytype = SCORE_DIV_PERCENT; |
|
| 334 | + if ($ignore_score_color) { |
|
| 335 | + $displaytype |= SCORE_IGNORE_SPLIT; |
|
| 336 | + } |
|
| 337 | + return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_CUSTOM); |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * @param $coursecode |
|
| 342 | + * @return mixed |
|
| 343 | + */ |
|
| 344 | + private function get_course_name_from_code_cached($coursecode) |
|
| 345 | + { |
|
| 346 | + if (isset ($this->coursecodecache) |
|
| 347 | + && isset ($this->coursecodecache[$coursecode])) { |
|
| 348 | + return $this->coursecodecache[$coursecode]; |
|
| 349 | + } else { |
|
| 350 | + $name = CourseManager::getCourseNameFromCode($coursecode); |
|
| 351 | + $this->coursecodecache[$coursecode] = $name; |
|
| 352 | + return $name; |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * @param $category_id |
|
| 358 | + * @return null |
|
| 359 | + */ |
|
| 360 | + private function get_category_cached($category_id) |
|
| 361 | + { |
|
| 362 | + if (isset ($this->categorycache) |
|
| 363 | + && isset ($this->categorycache[$category_id])) { |
|
| 364 | + return $this->categorycache[$category_id]; |
|
| 365 | + }else { |
|
| 366 | + $cat = Category::load($category_id); |
|
| 367 | + if (isset($cat)){ |
|
| 368 | + $this->categorycache[$category_id] = $cat[0]; |
|
| 369 | + return $cat[0]; |
|
| 370 | + }else |
|
| 371 | + return null; |
|
| 372 | + } |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + /** |
|
| 376 | + * @param $cat |
|
| 377 | + * @return string |
|
| 378 | + */ |
|
| 379 | + private function get_category_name_to_display($cat) |
|
| 380 | + { |
|
| 381 | + if (isset($cat)) { |
|
| 382 | + if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null){ |
|
| 383 | + return ''; |
|
| 384 | + } else { |
|
| 385 | + return $cat->get_name(); |
|
| 386 | + } |
|
| 387 | + } else { |
|
| 388 | + return ''; |
|
| 389 | + } |
|
| 390 | + } |
|
| 391 | 391 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | - * @return array |
|
| 21 | + * @return string[] |
|
| 22 | 22 | */ |
| 23 | 23 | public static function get_tags() |
| 24 | 24 | { |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param string $course_code |
| 41 | 41 | * @param int $session_id |
| 42 | 42 | * |
| 43 | - * @return mixed |
|
| 43 | + * @return string |
|
| 44 | 44 | */ |
| 45 | 45 | public static function parse_content($userId, $content, $course_code, $session_id = 0) |
| 46 | 46 | { |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | * @param array uploaded file $_FILES |
| 350 | 350 | * @param string Comment describing the attachment |
| 351 | 351 | * @param bool $sendToUsersInSession |
| 352 | - * @return int false on failure, ID of the announcement on success |
|
| 352 | + * @return false|string false on failure, ID of the announcement on success |
|
| 353 | 353 | */ |
| 354 | 354 | public static function add_announcement( |
| 355 | 355 | $emailTitle, |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | * @param $to_users |
| 461 | 461 | * @param array $file |
| 462 | 462 | * @param string $file_comment |
| 463 | - * @return bool|int |
|
| 463 | + * @return false|string |
|
| 464 | 464 | */ |
| 465 | 465 | public static function add_group_announcement( |
| 466 | 466 | $emailTitle, |
@@ -699,7 +699,7 @@ discard block |
||
| 699 | 699 | |
| 700 | 700 | /** |
| 701 | 701 | * @param int $insert_id |
| 702 | - * @return bool |
|
| 702 | + * @return false|null |
|
| 703 | 703 | */ |
| 704 | 704 | public static function update_mail_sent($insert_id) |
| 705 | 705 | { |
@@ -719,6 +719,7 @@ discard block |
||
| 719 | 719 | * Gets all announcements from a user by course |
| 720 | 720 | * @param string course db |
| 721 | 721 | * @param int user id |
| 722 | + * @param integer $user_id |
|
| 722 | 723 | * @return array html with the content and count of announcements or false otherwise |
| 723 | 724 | */ |
| 724 | 725 | public static function get_all_annoucement_by_user_course($course_code, $user_id) |
@@ -1184,6 +1185,7 @@ discard block |
||
| 1184 | 1185 | * has been sent to |
| 1185 | 1186 | * @param string The tool (announcement, agenda, ...) |
| 1186 | 1187 | * @param int ID of the element of the corresponding type |
| 1188 | + * @param string $tool |
|
| 1187 | 1189 | * @return array Array of users and groups to whom the element has been sent |
| 1188 | 1190 | */ |
| 1189 | 1191 | public static function sent_to($tool, $id) |
@@ -1308,6 +1310,8 @@ discard block |
||
| 1308 | 1310 | * @param int attach id |
| 1309 | 1311 | * @param array uploaded file $_FILES |
| 1310 | 1312 | * @param string file comment |
| 1313 | + * @param integer $id_attach |
|
| 1314 | + * @param string $file_comment |
|
| 1311 | 1315 | * @return int |
| 1312 | 1316 | */ |
| 1313 | 1317 | public static function edit_announcement_attachment_file($id_attach, $file, $file_comment) |
@@ -1510,7 +1510,7 @@ |
||
| 1510 | 1510 | ip.to_user_id=$user_id OR (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) |
| 1511 | 1511 | ) "; |
| 1512 | 1512 | } else { |
| 1513 | - $cond_user_id = " AND ( |
|
| 1513 | + $cond_user_id = " AND ( |
|
| 1514 | 1514 | ip.to_user_id=$user_id OR (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".api_get_group_id().")) |
| 1515 | 1515 | )"; |
| 1516 | 1516 | } |
@@ -216,8 +216,8 @@ discard block |
||
| 216 | 216 | announcement.id = '$announcement_id' AND |
| 217 | 217 | toolitemproperties.tool='announcement' AND |
| 218 | 218 | ( |
| 219 | - toolitemproperties.to_user_id='" . api_get_user_id() . "' OR |
|
| 220 | - toolitemproperties.to_group_id IN ('0', '" . implode("', '", $group_list) . "') OR |
|
| 219 | + toolitemproperties.to_user_id='".api_get_user_id()."' OR |
|
| 220 | + toolitemproperties.to_group_id IN ('0', '" . implode("', '", $group_list)."') OR |
|
| 221 | 221 | toolitemproperties.to_group_id IS NULL |
| 222 | 222 | ) AND |
| 223 | 223 | toolitemproperties.visibility='1' AND |
@@ -246,13 +246,13 @@ discard block |
||
| 246 | 246 | $title = $result['title']; |
| 247 | 247 | $content = $result['content']; |
| 248 | 248 | $html .= "<table height=\"100\" width=\"100%\" cellpadding=\"5\" cellspacing=\"0\" class=\"data_table\">"; |
| 249 | - $html .= "<tr><td><h2>" . $title . "</h2></td></tr>"; |
|
| 249 | + $html .= "<tr><td><h2>".$title."</h2></td></tr>"; |
|
| 250 | 250 | |
| 251 | 251 | if (api_is_allowed_to_edit(false, true) || |
| 252 | 252 | (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) |
| 253 | 253 | ) { |
| 254 | - $modify_icons = "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=modify&id=" . $announcement_id . "\">" . |
|
| 255 | - Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a>"; |
|
| 254 | + $modify_icons = "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=modify&id=".$announcement_id."\">". |
|
| 255 | + Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL)."</a>"; |
|
| 256 | 256 | if ($result['visibility'] == 1) { |
| 257 | 257 | $image_visibility = "visible"; |
| 258 | 258 | $alt_visibility = get_lang('Hide'); |
@@ -262,12 +262,12 @@ discard block |
||
| 262 | 262 | } |
| 263 | 263 | global $stok; |
| 264 | 264 | |
| 265 | - $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&origin=" . (!empty($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '') . "&action=showhide&id=" . $announcement_id . "&sec_token=" . $stok . "\">" . |
|
| 266 | - Display::return_icon($image_visibility . '.png', $alt_visibility, '', ICON_SIZE_SMALL) . "</a>"; |
|
| 265 | + $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&origin=".(!empty($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '')."&action=showhide&id=".$announcement_id."&sec_token=".$stok."\">". |
|
| 266 | + Display::return_icon($image_visibility.'.png', $alt_visibility, '', ICON_SIZE_SMALL)."</a>"; |
|
| 267 | 267 | |
| 268 | 268 | if (api_is_allowed_to_edit(false, true)) { |
| 269 | - $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=delete&id=" . $announcement_id . "&sec_token=" . $stok . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "')) return false;\">" . |
|
| 270 | - Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . |
|
| 269 | + $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete&id=".$announcement_id."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."')) return false;\">". |
|
| 270 | + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL). |
|
| 271 | 271 | "</a>"; |
| 272 | 272 | } |
| 273 | 273 | $html .= "<tr><th style='text-align:right'>$modify_icons</th></tr>"; |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | $content = self::parse_content($result['to_user_id'], $content, api_get_course_id(), api_get_session_id()); |
| 277 | 277 | |
| 278 | 278 | $html .= "<tr><td>$content</td></tr>"; |
| 279 | - $html .= "<tr><td class=\"announcements_datum\">" . get_lang('LastUpdateDate') . " : " . api_convert_and_format_date($result['insert_date'], DATE_TIME_FORMAT_LONG) . "</td></tr>"; |
|
| 279 | + $html .= "<tr><td class=\"announcements_datum\">".get_lang('LastUpdateDate')." : ".api_convert_and_format_date($result['insert_date'], DATE_TIME_FORMAT_LONG)."</td></tr>"; |
|
| 280 | 280 | |
| 281 | 281 | // User or group icon |
| 282 | 282 | $sent_to_icon = ''; |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | $sent_to_form = self::sent_to_form($sent_to); |
| 289 | 289 | $html .= Display::tag( |
| 290 | 290 | 'td', |
| 291 | - get_lang('SentTo') . ' : ' . $sent_to_form, |
|
| 291 | + get_lang('SentTo').' : '.$sent_to_form, |
|
| 292 | 292 | array('class' => 'announcements_datum') |
| 293 | 293 | ); |
| 294 | 294 | } |
@@ -298,15 +298,15 @@ discard block |
||
| 298 | 298 | $html .= "<tr><td>"; |
| 299 | 299 | $realname = $attachment_list['path']; |
| 300 | 300 | $user_filename = $attachment_list['filename']; |
| 301 | - $full_file_name = 'download.php?'.api_get_cidreq().'&file=' . $realname; |
|
| 301 | + $full_file_name = 'download.php?'.api_get_cidreq().'&file='.$realname; |
|
| 302 | 302 | $html .= '<br/>'; |
| 303 | 303 | $html .= Display::return_icon('attachment.gif', get_lang('Attachment')); |
| 304 | - $html .= '<a href="' . $full_file_name . ' "> ' . $user_filename . ' </a>'; |
|
| 305 | - $html .= ' - <span class="forum_attach_comment" >' . $attachment_list['comment'] . '</span>'; |
|
| 304 | + $html .= '<a href="'.$full_file_name.' "> '.$user_filename.' </a>'; |
|
| 305 | + $html .= ' - <span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>'; |
|
| 306 | 306 | if (api_is_allowed_to_edit(false, true)) { |
| 307 | 307 | $html .= Display::url( |
| 308 | 308 | Display::return_icon('delete.png', get_lang('Delete'), '', 16), |
| 309 | - api_get_self() . "?" . api_get_cidreq() . "&action=delete_attachment&id_attach=" . $attachment_list['id'] . "&sec_token=" . $stok |
|
| 309 | + api_get_self()."?".api_get_cidreq()."&action=delete_attachment&id_attach=".$attachment_list['id']."&sec_token=".$stok |
|
| 310 | 310 | ); |
| 311 | 311 | } |
| 312 | 312 | $html .= '</td></tr>'; |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | $order = 0; |
| 335 | 335 | if (Database::num_rows($res_max)) { |
| 336 | 336 | $row_max = Database::fetch_array($res_max); |
| 337 | - $order = intval($row_max[0])+1; |
|
| 337 | + $order = intval($row_max[0]) + 1; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | return $order; |
@@ -754,8 +754,8 @@ discard block |
||
| 754 | 754 | $result = array(); |
| 755 | 755 | if ($num_rows > 0) { |
| 756 | 756 | while ($myrow = Database::fetch_array($rs)) { |
| 757 | - $content.= '<strong>' . $myrow['title'] . '</strong><br /><br />'; |
|
| 758 | - $content.= $myrow['content']; |
|
| 757 | + $content .= '<strong>'.$myrow['title'].'</strong><br /><br />'; |
|
| 758 | + $content .= $myrow['content']; |
|
| 759 | 759 | $i++; |
| 760 | 760 | } |
| 761 | 761 | $result['content'] = $content; |
@@ -786,7 +786,7 @@ discard block |
||
| 786 | 786 | echo "<table id=\"recipient_list\" >"; |
| 787 | 787 | echo '<tr>'; |
| 788 | 788 | echo '<td>'; |
| 789 | - echo '<label><input type="checkbox" id="send_to_all_users">'.get_lang('SendToAllUsers') . "</label>"; |
|
| 789 | + echo '<label><input type="checkbox" id="send_to_all_users">'.get_lang('SendToAllUsers')."</label>"; |
|
| 790 | 790 | echo "</td>"; |
| 791 | 791 | echo '</tr>'; |
| 792 | 792 | echo '<tr>'; |
@@ -794,7 +794,7 @@ discard block |
||
| 794 | 794 | |
| 795 | 795 | // the form containing all the groups and all the users of the course |
| 796 | 796 | echo '<td>'; |
| 797 | - echo "<strong>" . get_lang('Users') . "</strong><br />"; |
|
| 797 | + echo "<strong>".get_lang('Users')."</strong><br />"; |
|
| 798 | 798 | |
| 799 | 799 | self::construct_not_selected_select_form($groupList, $userList, $to_already_selected); |
| 800 | 800 | echo "</td>"; |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | echo "<td>"; |
| 810 | 810 | |
| 811 | 811 | // the form containing the selected groups and users |
| 812 | - echo "<strong>" . get_lang('DestinationUsers') . "</strong><br />"; |
|
| 812 | + echo "<strong>".get_lang('DestinationUsers')."</strong><br />"; |
|
| 813 | 813 | self::construct_selected_select_form($groupList, $userList, $to_already_selected); |
| 814 | 814 | echo "</td>"; |
| 815 | 815 | echo "</tr>"; |
@@ -827,8 +827,8 @@ discard block |
||
| 827 | 827 | echo "<select id=\"not_selected_form\" name=\"not_selected_form[]\" size=5 style=\"width:200px\" multiple>"; |
| 828 | 828 | $group_users = GroupManager::getStudentsAndTutors($group_id); |
| 829 | 829 | foreach ($group_users as $user) { |
| 830 | - echo '<option value="' . $user['user_id'] . '" title="' . sprintf(get_lang('LoginX'), $user['username']) . '" >' . |
|
| 831 | - api_get_person_name($user['firstname'], $user['lastname']) . |
|
| 830 | + echo '<option value="'.$user['user_id'].'" title="'.sprintf(get_lang('LoginX'), $user['username']).'" >'. |
|
| 831 | + api_get_person_name($user['firstname'], $user['lastname']). |
|
| 832 | 832 | '</option>'; |
| 833 | 833 | } |
| 834 | 834 | echo '</select>'; |
@@ -866,12 +866,12 @@ discard block |
||
| 866 | 866 | if (!empty($groupList)) { |
| 867 | 867 | foreach ($groupList as $this_group) { |
| 868 | 868 | if (is_array($to_already_selected)) { |
| 869 | - if (!in_array("GROUP:" . $this_group['id'], $to_already_selected)) { |
|
| 869 | + if (!in_array("GROUP:".$this_group['id'], $to_already_selected)) { |
|
| 870 | 870 | // $to_already_selected is the array containing the groups (and users) that are already selected |
| 871 | - $user_label = ($this_group['userNb'] > 0) ? get_lang('Users') : get_lang('LowerCaseUser') ; |
|
| 872 | - $user_disabled = ($this_group['userNb'] > 0) ? "" : "disabled=disabled" ; |
|
| 873 | - echo "<option $user_disabled value=\"GROUP:" . $this_group['id'] . "\">", |
|
| 874 | - "G: ", $this_group['name'], " - " . $this_group['userNb'] . " " . $user_label . |
|
| 871 | + $user_label = ($this_group['userNb'] > 0) ? get_lang('Users') : get_lang('LowerCaseUser'); |
|
| 872 | + $user_disabled = ($this_group['userNb'] > 0) ? "" : "disabled=disabled"; |
|
| 873 | + echo "<option $user_disabled value=\"GROUP:".$this_group['id']."\">", |
|
| 874 | + "G: ", $this_group['name'], " - ".$this_group['userNb']." ".$user_label. |
|
| 875 | 875 | "</option>"; |
| 876 | 876 | } |
| 877 | 877 | } |
@@ -885,15 +885,15 @@ discard block |
||
| 885 | 885 | if (!empty($userList)) { |
| 886 | 886 | foreach ($userList as $user) { |
| 887 | 887 | if (is_array($to_already_selected)) { |
| 888 | - if (!in_array("USER:" . $user['user_id'], $to_already_selected)) { |
|
| 888 | + if (!in_array("USER:".$user['user_id'], $to_already_selected)) { |
|
| 889 | 889 | // $to_already_selected is the array containing the users (and groups) that are already selected |
| 890 | - echo "<option value=\"USER:" . $user['user_id'] . "\" title='" . sprintf(get_lang('LoginX'), $user['username']) . "'>", |
|
| 890 | + echo "<option value=\"USER:".$user['user_id']."\" title='".sprintf(get_lang('LoginX'), $user['username'])."'>", |
|
| 891 | 891 | "", api_get_person_name($user['firstname'], $user['lastname']), |
| 892 | 892 | "</option>"; |
| 893 | 893 | |
| 894 | 894 | if (isset($user['drh_list']) && !empty($user['drh_list'])) { |
| 895 | 895 | foreach ($user['drh_list'] as $drh) { |
| 896 | - echo "<option value=\"USER:" . $drh['user_id'] . "\" title='" . sprintf(get_lang('LoginX'), $drh['username']) . "'> ", |
|
| 896 | + echo "<option value=\"USER:".$drh['user_id']."\" title='".sprintf(get_lang('LoginX'), $drh['username'])."'> ", |
|
| 897 | 897 | "", api_get_person_name($drh['firstname'], $drh['lastname']), |
| 898 | 898 | "</option>"; |
| 899 | 899 | } |
@@ -925,16 +925,16 @@ discard block |
||
| 925 | 925 | foreach ($to_already_selected as $groupuser) { |
| 926 | 926 | list($type, $id) = explode(":", $groupuser); |
| 927 | 927 | if ($type == "GROUP") { |
| 928 | - echo "<option value=\"" . $groupuser . "\">G: " . $ref_array_groups[$id]['name'] . "</option>"; |
|
| 928 | + echo "<option value=\"".$groupuser."\">G: ".$ref_array_groups[$id]['name']."</option>"; |
|
| 929 | 929 | } else { |
| 930 | 930 | foreach ($ref_array_users as $key => $value) { |
| 931 | 931 | if ($value['user_id'] == $id) { |
| 932 | - echo "<option value=\"" . $groupuser . "\" title='" . sprintf(get_lang('LoginX'), $value['username']) . "'>" . |
|
| 933 | - api_get_person_name($value['firstname'], $value['lastname']) . "</option>"; |
|
| 932 | + echo "<option value=\"".$groupuser."\" title='".sprintf(get_lang('LoginX'), $value['username'])."'>". |
|
| 933 | + api_get_person_name($value['firstname'], $value['lastname'])."</option>"; |
|
| 934 | 934 | |
| 935 | 935 | if (isset($value['drh_list']) && !empty($value['drh_list'])) { |
| 936 | 936 | foreach ($value['drh_list'] as $drh) { |
| 937 | - echo "<option value=\"USER:" . $drh['user_id'] . "\" title='" . sprintf(get_lang('LoginX'), $drh['username']) . "'> ", |
|
| 937 | + echo "<option value=\"USER:".$drh['user_id']."\" title='".sprintf(get_lang('LoginX'), $drh['username'])."'> ", |
|
| 938 | 938 | "", api_get_person_name($drh['firstname'], $drh['lastname']), |
| 939 | 939 | "</option>"; |
| 940 | 940 | } |
@@ -950,17 +950,17 @@ discard block |
||
| 950 | 950 | if (is_array($ref_array_groups)) { |
| 951 | 951 | foreach ($ref_array_groups as $this_group) { |
| 952 | 952 | //api_display_normal_message("group " . $thisGroup[id] . $thisGroup[name]); |
| 953 | - if (!is_array($to_already_selected) || !in_array("GROUP:" . $this_group['id'], $to_already_selected)) { // $to_already_selected is the array containing the groups (and users) that are already selected |
|
| 954 | - echo "<option value=\"GROUP:" . $this_group['id'] . "\">", |
|
| 955 | - "G: ", $this_group['name'], " – " . $this_group['userNb'] . " " . get_lang('Users') . |
|
| 953 | + if (!is_array($to_already_selected) || !in_array("GROUP:".$this_group['id'], $to_already_selected)) { // $to_already_selected is the array containing the groups (and users) that are already selected |
|
| 954 | + echo "<option value=\"GROUP:".$this_group['id']."\">", |
|
| 955 | + "G: ", $this_group['name'], " – ".$this_group['userNb']." ".get_lang('Users'). |
|
| 956 | 956 | "</option>"; |
| 957 | 957 | } |
| 958 | 958 | } |
| 959 | 959 | } |
| 960 | 960 | // adding the individual users to the select form |
| 961 | 961 | foreach ($ref_array_users as $this_user) { |
| 962 | - if (!is_array($to_already_selected) || !in_array("USER:" . $this_user['user_id'], $to_already_selected)) { // $to_already_selected is the array containing the users (and groups) that are already selected |
|
| 963 | - echo "<option value=\"USER:", $this_user['user_id'], "\" title='" . sprintf(get_lang('LoginX'), $this_user['username']) . "'>", |
|
| 962 | + if (!is_array($to_already_selected) || !in_array("USER:".$this_user['user_id'], $to_already_selected)) { // $to_already_selected is the array containing the users (and groups) that are already selected |
|
| 963 | + echo "<option value=\"USER:", $this_user['user_id'], "\" title='".sprintf(get_lang('LoginX'), $this_user['username'])."'>", |
|
| 964 | 964 | "", api_get_person_name($this_user['firstname'], $this_user['lastname']), |
| 965 | 965 | "</option>"; |
| 966 | 966 | } |
@@ -1073,14 +1073,14 @@ discard block |
||
| 1073 | 1073 | switch ($to_group) { |
| 1074 | 1074 | // it was send to one specific user |
| 1075 | 1075 | case null: |
| 1076 | - $to[] = "USER:" . $row['to_user_id']; |
|
| 1076 | + $to[] = "USER:".$row['to_user_id']; |
|
| 1077 | 1077 | break; |
| 1078 | 1078 | // it was sent to everyone |
| 1079 | 1079 | case 0: |
| 1080 | 1080 | return "everyone"; |
| 1081 | 1081 | break; |
| 1082 | 1082 | default: |
| 1083 | - $to[] = "GROUP:" . $row['to_group_id']; |
|
| 1083 | + $to[] = "GROUP:".$row['to_group_id']; |
|
| 1084 | 1084 | } |
| 1085 | 1085 | } |
| 1086 | 1086 | return $to; |
@@ -1161,10 +1161,10 @@ discard block |
||
| 1161 | 1161 | $sent_to_array['groups'][0] !== 0 |
| 1162 | 1162 | ) { |
| 1163 | 1163 | $group_id = $sent_to_array['groups'][0]; |
| 1164 | - $output[] = " " . $group_names[$group_id]['name']; |
|
| 1164 | + $output[] = " ".$group_names[$group_id]['name']; |
|
| 1165 | 1165 | } |
| 1166 | 1166 | if (empty($sent_to_array['groups']) and empty($sent_to_array['users'])) { |
| 1167 | - $output[] = " " . get_lang('Everybody'); |
|
| 1167 | + $output[] = " ".get_lang('Everybody'); |
|
| 1168 | 1168 | } |
| 1169 | 1169 | } |
| 1170 | 1170 | |
@@ -1199,7 +1199,7 @@ discard block |
||
| 1199 | 1199 | |
| 1200 | 1200 | $sql = "SELECT to_group_id, to_user_id |
| 1201 | 1201 | FROM $tbl_item_property |
| 1202 | - WHERE c_id = $course_id AND tool = '$tool' AND ref=" . $id; |
|
| 1202 | + WHERE c_id = $course_id AND tool = '$tool' AND ref=".$id; |
|
| 1203 | 1203 | $result = Database::query($sql); |
| 1204 | 1204 | |
| 1205 | 1205 | while ($row = Database::fetch_array($result)) { |
@@ -1238,8 +1238,8 @@ discard block |
||
| 1238 | 1238 | $announcement_id = intval($announcement_id); |
| 1239 | 1239 | $course_id = api_get_course_int_id(); |
| 1240 | 1240 | $row = array(); |
| 1241 | - $sql = 'SELECT id, path, filename, comment FROM ' . $tbl_announcement_attachment . ' |
|
| 1242 | - WHERE c_id = ' . $course_id . ' AND announcement_id = ' . $announcement_id . ''; |
|
| 1241 | + $sql = 'SELECT id, path, filename, comment FROM '.$tbl_announcement_attachment.' |
|
| 1242 | + WHERE c_id = ' . $course_id.' AND announcement_id = '.$announcement_id.''; |
|
| 1243 | 1243 | $result = Database::query($sql); |
| 1244 | 1244 | if (Database::num_rows($result) != 0) { |
| 1245 | 1245 | $row = Database::fetch_array($result, 'ASSOC'); |
@@ -1264,9 +1264,9 @@ discard block |
||
| 1264 | 1264 | |
| 1265 | 1265 | if (is_array($file) && $file['error'] == 0) { |
| 1266 | 1266 | // TODO: This path is obsolete. The new document repository scheme should be kept in mind here. |
| 1267 | - $courseDir = $_course['path'] . '/upload/announcements'; |
|
| 1267 | + $courseDir = $_course['path'].'/upload/announcements'; |
|
| 1268 | 1268 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
| 1269 | - $updir = $sys_course_path . $courseDir; |
|
| 1269 | + $updir = $sys_course_path.$courseDir; |
|
| 1270 | 1270 | |
| 1271 | 1271 | // Try to add an extension to the file if it hasn't one |
| 1272 | 1272 | $new_file_name = add_ext_on_mime(stripslashes($file['name']), $file['type']); |
@@ -1278,7 +1278,7 @@ discard block |
||
| 1278 | 1278 | Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
| 1279 | 1279 | } else { |
| 1280 | 1280 | $new_file_name = uniqid(''); |
| 1281 | - $new_path = $updir . '/' . $new_file_name; |
|
| 1281 | + $new_path = $updir.'/'.$new_file_name; |
|
| 1282 | 1282 | move_uploaded_file($file['tmp_name'], $new_path); |
| 1283 | 1283 | |
| 1284 | 1284 | $params = [ |
@@ -1319,9 +1319,9 @@ discard block |
||
| 1319 | 1319 | |
| 1320 | 1320 | if (is_array($file) && $file['error'] == 0) { |
| 1321 | 1321 | // TODO: This path is obsolete. The new document repository scheme should be kept in mind here. |
| 1322 | - $courseDir = $_course['path'] . '/upload/announcements'; |
|
| 1322 | + $courseDir = $_course['path'].'/upload/announcements'; |
|
| 1323 | 1323 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
| 1324 | - $updir = $sys_course_path . $courseDir; |
|
| 1324 | + $updir = $sys_course_path.$courseDir; |
|
| 1325 | 1325 | |
| 1326 | 1326 | // Try to add an extension to the file if it hasn't one |
| 1327 | 1327 | $new_file_name = add_ext_on_mime(stripslashes($file['name']), $file['type']); |
@@ -1333,13 +1333,13 @@ discard block |
||
| 1333 | 1333 | Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
| 1334 | 1334 | } else { |
| 1335 | 1335 | $new_file_name = uniqid(''); |
| 1336 | - $new_path = $updir . '/' . $new_file_name; |
|
| 1336 | + $new_path = $updir.'/'.$new_file_name; |
|
| 1337 | 1337 | @move_uploaded_file($file['tmp_name'], $new_path); |
| 1338 | 1338 | $safe_file_comment = Database::escape_string($file_comment); |
| 1339 | 1339 | $safe_file_name = Database::escape_string($file_name); |
| 1340 | 1340 | $safe_new_file_name = Database::escape_string($new_file_name); |
| 1341 | 1341 | $id_attach = intval($id_attach); |
| 1342 | - $sql = "UPDATE $tbl_announcement_attachment SET filename = '$safe_file_name', comment = '$safe_file_comment', path = '$safe_new_file_name', size ='" . intval($file['size']) . "' |
|
| 1342 | + $sql = "UPDATE $tbl_announcement_attachment SET filename = '$safe_file_name', comment = '$safe_file_comment', path = '$safe_new_file_name', size ='".intval($file['size'])."' |
|
| 1343 | 1343 | WHERE c_id = $course_id AND id = '$id_attach'"; |
| 1344 | 1344 | $result = Database::query($sql); |
| 1345 | 1345 | if ($result === false) { |
@@ -1441,7 +1441,7 @@ discard block |
||
| 1441 | 1441 | |
| 1442 | 1442 | //if (!empty($user_id)) { |
| 1443 | 1443 | if (0) { |
| 1444 | - if (is_array($group_memberships) && count($group_memberships) > 0 ) { |
|
| 1444 | + if (is_array($group_memberships) && count($group_memberships) > 0) { |
|
| 1445 | 1445 | $sql = "SELECT $select |
| 1446 | 1446 | FROM $tbl_announcement announcement, $tbl_item_property ip |
| 1447 | 1447 | WHERE |
@@ -1652,8 +1652,8 @@ discard block |
||
| 1652 | 1652 | $attachment_list = AnnouncementManager::get_attachment($myrow['id']); |
| 1653 | 1653 | |
| 1654 | 1654 | $attachment_icon = ''; |
| 1655 | - if (count($attachment_list)>0) { |
|
| 1656 | - $attachment_icon = ' '.Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 1655 | + if (count($attachment_list) > 0) { |
|
| 1656 | + $attachment_icon = ' '.Display::return_icon('attachment.gif', get_lang('Attachment')); |
|
| 1657 | 1657 | } |
| 1658 | 1658 | |
| 1659 | 1659 | /* TITLE */ |
@@ -1672,16 +1672,16 @@ discard block |
||
| 1672 | 1672 | || (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) |
| 1673 | 1673 | ) { |
| 1674 | 1674 | $modify_icons = "<a href=\"".$actionUrl."&action=modify&id=".$myrow['id']."\">". |
| 1675 | - Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL)."</a>"; |
|
| 1676 | - if ($myrow['visibility']==1) { |
|
| 1677 | - $image_visibility="visible"; |
|
| 1678 | - $alt_visibility=get_lang('Hide'); |
|
| 1675 | + Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL)."</a>"; |
|
| 1676 | + if ($myrow['visibility'] == 1) { |
|
| 1677 | + $image_visibility = "visible"; |
|
| 1678 | + $alt_visibility = get_lang('Hide'); |
|
| 1679 | 1679 | } else { |
| 1680 | - $image_visibility="invisible"; |
|
| 1681 | - $alt_visibility=get_lang('Visible'); |
|
| 1680 | + $image_visibility = "invisible"; |
|
| 1681 | + $alt_visibility = get_lang('Visible'); |
|
| 1682 | 1682 | } |
| 1683 | - $modify_icons .= "<a href=\"".$actionUrl."&origin=".$origin."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">". |
|
| 1684 | - Display::return_icon($image_visibility.'.png', $alt_visibility,'',ICON_SIZE_SMALL)."</a>"; |
|
| 1683 | + $modify_icons .= "<a href=\"".$actionUrl."&origin=".$origin."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">". |
|
| 1684 | + Display::return_icon($image_visibility.'.png', $alt_visibility, '', ICON_SIZE_SMALL)."</a>"; |
|
| 1685 | 1685 | |
| 1686 | 1686 | // DISPLAY MOVE UP COMMAND only if it is not the top announcement |
| 1687 | 1687 | if ($iterator != 1) { |
@@ -1696,12 +1696,12 @@ discard block |
||
| 1696 | 1696 | } else { |
| 1697 | 1697 | $modify_icons .= Display::return_icon('down_na.gif', get_lang('Down')); |
| 1698 | 1698 | } |
| 1699 | - if (api_is_allowed_to_edit(false,true)) { |
|
| 1700 | - $modify_icons .= "<a href=\"".$actionUrl."&action=delete&id=".$myrow['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,api_get_system_encoding()))."')) return false;\">". |
|
| 1701 | - Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL). |
|
| 1699 | + if (api_is_allowed_to_edit(false, true)) { |
|
| 1700 | + $modify_icons .= "<a href=\"".$actionUrl."&action=delete&id=".$myrow['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, api_get_system_encoding()))."')) return false;\">". |
|
| 1701 | + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL). |
|
| 1702 | 1702 | "</a>"; |
| 1703 | 1703 | } |
| 1704 | - $iterator ++; |
|
| 1704 | + $iterator++; |
|
| 1705 | 1705 | } else { |
| 1706 | 1706 | $modify_icons = Display::url( |
| 1707 | 1707 | Display::return_icon('default.png'), |
@@ -1731,7 +1731,7 @@ discard block |
||
| 1731 | 1731 | public static function getNumberAnnouncements() |
| 1732 | 1732 | { |
| 1733 | 1733 | // Maximum title messages to display |
| 1734 | - $maximum = '12'; |
|
| 1734 | + $maximum = '12'; |
|
| 1735 | 1735 | // Database Table Definitions |
| 1736 | 1736 | $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
| 1737 | 1737 | $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); |
@@ -1742,7 +1742,7 @@ discard block |
||
| 1742 | 1742 | $userId = api_get_user_id(); |
| 1743 | 1743 | $condition_session = api_get_session_condition($session_id, true, true, 'announcement.session_id'); |
| 1744 | 1744 | |
| 1745 | - if (api_is_allowed_to_edit(false,true)) { |
|
| 1745 | + if (api_is_allowed_to_edit(false, true)) { |
|
| 1746 | 1746 | // check teacher status |
| 1747 | 1747 | if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') { |
| 1748 | 1748 | |
@@ -1805,7 +1805,7 @@ discard block |
||
| 1805 | 1805 | } |
| 1806 | 1806 | |
| 1807 | 1807 | // the user is member of several groups => display personal announcements AND his group announcements AND the general announcements |
| 1808 | - if (is_array($group_memberships) && count($group_memberships)>0) { |
|
| 1808 | + if (is_array($group_memberships) && count($group_memberships) > 0) { |
|
| 1809 | 1809 | $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
| 1810 | 1810 | FROM $tbl_announcement announcement, $tbl_item_property ip |
| 1811 | 1811 | WHERE |
@@ -1855,7 +1855,7 @@ discard block |
||
| 1855 | 1855 | } |
| 1856 | 1856 | |
| 1857 | 1857 | // the user is not identiefied => show only the general announcements |
| 1858 | - $sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
|
| 1858 | + $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
|
| 1859 | 1859 | FROM $tbl_announcement announcement, $tbl_item_property ip |
| 1860 | 1860 | WHERE |
| 1861 | 1861 | announcement.c_id = $course_id AND |
@@ -351,6 +351,12 @@ |
||
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | 353 | * Additional functions needed for fast integration |
| 354 | + * @param integer $status |
|
| 355 | + * @param string $section |
|
| 356 | + * @param string $title |
|
| 357 | + * @param string $url |
|
| 358 | + * @param string|null $formatter |
|
| 359 | + * @param string $comment |
|
| 354 | 360 | */ |
| 355 | 361 | public function build_setting($status, $section, $title, $url, $current_value, $expected_value, $formatter, $comment, $img_path = null) { |
| 356 | 362 | switch ($status) { |
@@ -401,19 +401,19 @@ |
||
| 401 | 401 | |
| 402 | 402 | public function format_yes_no_optional($value) |
| 403 | 403 | { |
| 404 | - $return = ''; |
|
| 405 | - switch($value) { |
|
| 406 | - case 0: |
|
| 407 | - $return = get_lang('No'); |
|
| 408 | - break; |
|
| 409 | - case 1: |
|
| 410 | - $return = get_lang('Yes'); |
|
| 411 | - break; |
|
| 412 | - case 2: |
|
| 413 | - $return = get_lang('Optional'); |
|
| 414 | - break; |
|
| 415 | - } |
|
| 416 | - return $return; |
|
| 404 | + $return = ''; |
|
| 405 | + switch($value) { |
|
| 406 | + case 0: |
|
| 407 | + $return = get_lang('No'); |
|
| 408 | + break; |
|
| 409 | + case 1: |
|
| 410 | + $return = get_lang('Yes'); |
|
| 411 | + break; |
|
| 412 | + case 2: |
|
| 413 | + $return = get_lang('Optional'); |
|
| 414 | + break; |
|
| 415 | + } |
|
| 416 | + return $return; |
|
| 417 | 417 | |
| 418 | 418 | } |
| 419 | 419 | |
@@ -158,8 +158,9 @@ discard block |
||
| 158 | 158 | $array[] = $this->build_setting($status, '[INI]', 'display_errors', 'http://www.php.net/manual/en/ini.core.php#ini.display_errors', $setting, $req_setting, 'on_off', get_lang('DisplayErrorsInfo')); |
| 159 | 159 | |
| 160 | 160 | $setting = ini_get('default_charset'); |
| 161 | - if ($setting == '') |
|
| 162 | - $setting = null; |
|
| 161 | + if ($setting == '') { |
|
| 162 | + $setting = null; |
|
| 163 | + } |
|
| 163 | 164 | $req_setting = null; |
| 164 | 165 | $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_ERROR; |
| 165 | 166 | $array[] = $this->build_setting($status, '[INI]', 'default_charset', 'http://www.php.net/manual/en/ini.core.php#ini.default-charset', $setting, $req_setting, null, get_lang('DefaultCharsetInfo')); |
@@ -177,22 +178,25 @@ discard block |
||
| 177 | 178 | $setting = ini_get('memory_limit'); |
| 178 | 179 | $req_setting = '>= '.REQUIRED_MIN_MEMORY_LIMIT.'M'; |
| 179 | 180 | $status = self :: STATUS_ERROR; |
| 180 | - if ((float)$setting >= REQUIRED_MIN_MEMORY_LIMIT) |
|
| 181 | - $status = self :: STATUS_OK; |
|
| 181 | + if ((float)$setting >= REQUIRED_MIN_MEMORY_LIMIT) { |
|
| 182 | + $status = self :: STATUS_OK; |
|
| 183 | + } |
|
| 182 | 184 | $array[] = $this->build_setting($status, '[INI]', 'memory_limit', 'http://www.php.net/manual/en/ini.core.php#ini.memory-limit', $setting, $req_setting, null, get_lang('MemoryLimitInfo')); |
| 183 | 185 | |
| 184 | 186 | $setting = ini_get('post_max_size'); |
| 185 | 187 | $req_setting = '>= '.REQUIRED_MIN_POST_MAX_SIZE.'M'; |
| 186 | 188 | $status = self :: STATUS_ERROR; |
| 187 | - if ((float)$setting >= REQUIRED_MIN_POST_MAX_SIZE) |
|
| 188 | - $status = self :: STATUS_OK; |
|
| 189 | + if ((float)$setting >= REQUIRED_MIN_POST_MAX_SIZE) { |
|
| 190 | + $status = self :: STATUS_OK; |
|
| 191 | + } |
|
| 189 | 192 | $array[] = $this->build_setting($status, '[INI]', 'post_max_size', 'http://www.php.net/manual/en/ini.core.php#ini.post-max-size', $setting, $req_setting, null, get_lang('PostMaxSizeInfo')); |
| 190 | 193 | |
| 191 | 194 | $setting = ini_get('upload_max_filesize'); |
| 192 | 195 | $req_setting = '>= '.REQUIRED_MIN_UPLOAD_MAX_FILESIZE.'M'; |
| 193 | 196 | $status = self :: STATUS_ERROR; |
| 194 | - if ((float)$setting >= REQUIRED_MIN_UPLOAD_MAX_FILESIZE) |
|
| 195 | - $status = self :: STATUS_OK; |
|
| 197 | + if ((float)$setting >= REQUIRED_MIN_UPLOAD_MAX_FILESIZE) { |
|
| 198 | + $status = self :: STATUS_OK; |
|
| 199 | + } |
|
| 196 | 200 | $array[] = $this->build_setting($status, '[INI]', 'upload_max_filesize', 'http://www.php.net/manual/en/ini.core.php#ini.upload_max_filesize', $setting, $req_setting, null, get_lang('UploadMaxFilesizeInfo')); |
| 197 | 201 | |
| 198 | 202 | $setting = ini_get('variables_order'); |
@@ -205,7 +209,7 @@ discard block |
||
| 205 | 209 | $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_WARNING; |
| 206 | 210 | $array[] = $this->build_setting($status, '[SESSION]', 'session.gc_maxlifetime', 'http://www.php.net/manual/en/ini.core.php#session.gc-maxlifetime', $setting, $req_setting, null, get_lang('SessionGCMaxLifetimeInfo')); |
| 207 | 211 | |
| 208 | - if (api_check_browscap()){$setting = true;}else{$setting=false;} |
|
| 212 | + if (api_check_browscap()){$setting = true;} else{$setting=false;} |
|
| 209 | 213 | $req_setting = true; |
| 210 | 214 | $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_WARNING; |
| 211 | 215 | $array[] = $this->build_setting($status, '[INI]', 'browscap', 'http://www.php.net/manual/en/misc.configuration.php#ini.browscap', $setting, $req_setting, 'on_off', get_lang('BrowscapInfo')); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | const STATUS_OK = 1; |
| 17 | 17 | const STATUS_WARNING = 2; |
| 18 | - const STATUS_ERROR = 3; |
|
| 18 | + const STATUS_ERROR = 3; |
|
| 19 | 19 | const STATUS_INFORMATION = 4; |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -42,12 +42,12 @@ discard block |
||
| 42 | 42 | $html .= '<li>'; |
| 43 | 43 | } |
| 44 | 44 | $params['section'] = $section; |
| 45 | - $html .='<a href="system_status.php?section='.$section.'">'.get_lang($section).'</a></li>'; |
|
| 45 | + $html .= '<a href="system_status.php?section='.$section.'">'.get_lang($section).'</a></li>'; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $html .= '</ul><div class="tab-pane">'; |
| 49 | 49 | |
| 50 | - $data = call_user_func(array($this, 'get_' . $currentSection . '_data')); |
|
| 50 | + $data = call_user_func(array($this, 'get_'.$currentSection.'_data')); |
|
| 51 | 51 | echo $html; |
| 52 | 52 | |
| 53 | 53 | if ($currentSection != 'paths') { |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | { |
| 115 | 115 | $array = array(); |
| 116 | 116 | $writable_folders = array( |
| 117 | - api_get_path(SYS_APP_PATH) .'cache', |
|
| 117 | + api_get_path(SYS_APP_PATH).'cache', |
|
| 118 | 118 | api_get_path(SYS_COURSE_PATH), |
| 119 | - api_get_path(SYS_APP_PATH) .'home', |
|
| 120 | - api_get_path(SYS_APP_PATH) .'upload/users/', |
|
| 121 | - api_get_path(SYS_PATH) .'main/default_course_document/images/', |
|
| 119 | + api_get_path(SYS_APP_PATH).'home', |
|
| 120 | + api_get_path(SYS_APP_PATH).'upload/users/', |
|
| 121 | + api_get_path(SYS_PATH).'main/default_course_document/images/', |
|
| 122 | 122 | ); |
| 123 | 123 | foreach ($writable_folders as $index => $folder) { |
| 124 | 124 | $writable = is_writable($folder); |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | $exists = file_exists(api_get_path(SYS_CODE_PATH).'install'); |
| 139 | 139 | $status = $exists ? self :: STATUS_WARNING : self :: STATUS_OK; |
| 140 | - $array[] = $this->build_setting($status, '[FILES]', get_lang('DirectoryExists') . ': /install', 'http://be2.php.net/file_exists', $exists, 0, 'yes_no', get_lang('DirectoryShouldBeRemoved')); |
|
| 140 | + $array[] = $this->build_setting($status, '[FILES]', get_lang('DirectoryExists').': /install', 'http://be2.php.net/file_exists', $exists, 0, 'yes_no', get_lang('DirectoryShouldBeRemoved')); |
|
| 141 | 141 | |
| 142 | 142 | $app_version = api_get_setting('chamilo_database_version'); |
| 143 | - $array[] = $this->build_setting(self :: STATUS_INFORMATION, '[DB]', 'chamilo_database_version', '#', $app_version, 0, null, 'Chamilo DB version'); |
|
| 143 | + $array[] = $this->build_setting(self :: STATUS_INFORMATION, '[DB]', 'chamilo_database_version', '#', $app_version, 0, null, 'Chamilo DB version'); |
|
| 144 | 144 | |
| 145 | 145 | $access_url_id = api_get_current_access_url_id(); |
| 146 | 146 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | $message2 .= get_lang('SpaceUsedOnSystemCannotBeMeasuredOnWindows'); |
| 153 | 153 | } else { |
| 154 | 154 | $dir = api_get_path(SYS_PATH); |
| 155 | - $du = exec('du -sh ' . $dir, $err); |
|
| 155 | + $du = exec('du -sh '.$dir, $err); |
|
| 156 | 156 | list($size, $none) = explode("\t", $du); |
| 157 | 157 | $limit = $_configuration[$access_url_id]['hosting_limit_disk_space']; |
| 158 | 158 | $message2 .= sprintf(get_lang('TotalSpaceUsedByPortalXLimitIsYMB'), $size, $limit); |
@@ -236,33 +236,33 @@ discard block |
||
| 236 | 236 | $array[] = $this->build_setting($status, '[INI]', 'default_charset', 'http://www.php.net/manual/en/ini.core.php#ini.default-charset', $setting, $req_setting, null, get_lang('DefaultCharsetInfo')); |
| 237 | 237 | |
| 238 | 238 | $setting = ini_get('max_execution_time'); |
| 239 | - $req_setting = '300 (' . get_lang('Minimum') . ')'; |
|
| 239 | + $req_setting = '300 ('.get_lang('Minimum').')'; |
|
| 240 | 240 | $status = $setting >= 300 ? self :: STATUS_OK : self :: STATUS_WARNING; |
| 241 | 241 | $array[] = $this->build_setting($status, '[INI]', 'max_execution_time', 'http://www.php.net/manual/en/ini.core.php#ini.max-execution-time', $setting, $req_setting, null, get_lang('MaxExecutionTimeInfo')); |
| 242 | 242 | |
| 243 | 243 | $setting = ini_get('max_input_time'); |
| 244 | - $req_setting = '300 (' . get_lang('Minimum') . ')'; |
|
| 244 | + $req_setting = '300 ('.get_lang('Minimum').')'; |
|
| 245 | 245 | $status = $setting >= 300 ? self :: STATUS_OK : self :: STATUS_WARNING; |
| 246 | 246 | $array[] = $this->build_setting($status, '[INI]', 'max_input_time', 'http://www.php.net/manual/en/ini.core.php#ini.max-input-time', $setting, $req_setting, null, get_lang('MaxInputTimeInfo')); |
| 247 | 247 | |
| 248 | 248 | $setting = ini_get('memory_limit'); |
| 249 | 249 | $req_setting = '>= '.REQUIRED_MIN_MEMORY_LIMIT.'M'; |
| 250 | 250 | $status = self :: STATUS_ERROR; |
| 251 | - if ((float)$setting >= REQUIRED_MIN_MEMORY_LIMIT) |
|
| 251 | + if ((float) $setting >= REQUIRED_MIN_MEMORY_LIMIT) |
|
| 252 | 252 | $status = self :: STATUS_OK; |
| 253 | 253 | $array[] = $this->build_setting($status, '[INI]', 'memory_limit', 'http://www.php.net/manual/en/ini.core.php#ini.memory-limit', $setting, $req_setting, null, get_lang('MemoryLimitInfo')); |
| 254 | 254 | |
| 255 | 255 | $setting = ini_get('post_max_size'); |
| 256 | 256 | $req_setting = '>= '.REQUIRED_MIN_POST_MAX_SIZE.'M'; |
| 257 | 257 | $status = self :: STATUS_ERROR; |
| 258 | - if ((float)$setting >= REQUIRED_MIN_POST_MAX_SIZE) |
|
| 258 | + if ((float) $setting >= REQUIRED_MIN_POST_MAX_SIZE) |
|
| 259 | 259 | $status = self :: STATUS_OK; |
| 260 | 260 | $array[] = $this->build_setting($status, '[INI]', 'post_max_size', 'http://www.php.net/manual/en/ini.core.php#ini.post-max-size', $setting, $req_setting, null, get_lang('PostMaxSizeInfo')); |
| 261 | 261 | |
| 262 | 262 | $setting = ini_get('upload_max_filesize'); |
| 263 | 263 | $req_setting = '>= '.REQUIRED_MIN_UPLOAD_MAX_FILESIZE.'M'; |
| 264 | 264 | $status = self :: STATUS_ERROR; |
| 265 | - if ((float)$setting >= REQUIRED_MIN_UPLOAD_MAX_FILESIZE) |
|
| 265 | + if ((float) $setting >= REQUIRED_MIN_UPLOAD_MAX_FILESIZE) |
|
| 266 | 266 | $status = self :: STATUS_OK; |
| 267 | 267 | $array[] = $this->build_setting($status, '[INI]', 'upload_max_filesize', 'http://www.php.net/manual/en/ini.core.php#ini.upload_max_filesize', $setting, $req_setting, null, get_lang('UploadMaxFilesizeInfo')); |
| 268 | 268 | |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_WARNING; |
| 277 | 277 | $array[] = $this->build_setting($status, '[SESSION]', 'session.gc_maxlifetime', 'http://www.php.net/manual/en/ini.core.php#session.gc-maxlifetime', $setting, $req_setting, null, get_lang('SessionGCMaxLifetimeInfo')); |
| 278 | 278 | |
| 279 | - if (api_check_browscap()){$setting = true;}else{$setting=false;} |
|
| 279 | + if (api_check_browscap()) {$setting = true; } else {$setting = false; } |
|
| 280 | 280 | $req_setting = true; |
| 281 | 281 | $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_WARNING; |
| 282 | 282 | $array[] = $this->build_setting($status, '[INI]', 'browscap', 'http://www.php.net/manual/en/misc.configuration.php#ini.browscap', $setting, $req_setting, 'on_off', get_lang('BrowscapInfo')); |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | |
| 333 | 333 | $loaded = extension_loaded($extension); |
| 334 | 334 | $status = $loaded ? self :: STATUS_OK : self :: STATUS_ERROR; |
| 335 | - $array[] = $this->build_setting($status, '[EXTENSION]', get_lang('LoadedExtension') . ': ' . $extension, $url, $loaded, $expected_value, 'yes_no_optional', $comment); |
|
| 335 | + $array[] = $this->build_setting($status, '[EXTENSION]', get_lang('LoadedExtension').': '.$extension, $url, $loaded, $expected_value, 'yes_no_optional', $comment); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | return $array; |
@@ -455,9 +455,9 @@ discard block |
||
| 455 | 455 | $formatted_expected_value = $expected_value; |
| 456 | 456 | |
| 457 | 457 | if ($formatter) { |
| 458 | - if (method_exists($this, 'format_' . $formatter)) { |
|
| 459 | - $formatted_current_value = call_user_func(array($this, 'format_' . $formatter), $current_value); |
|
| 460 | - $formatted_expected_value = call_user_func(array($this, 'format_' . $formatter), $expected_value); |
|
| 458 | + if (method_exists($this, 'format_'.$formatter)) { |
|
| 459 | + $formatted_current_value = call_user_func(array($this, 'format_'.$formatter), $current_value); |
|
| 460 | + $formatted_expected_value = call_user_func(array($this, 'format_'.$formatter), $expected_value); |
|
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | 463 | |
@@ -472,13 +472,13 @@ discard block |
||
| 472 | 472 | */ |
| 473 | 473 | public function get_link($title, $url) |
| 474 | 474 | { |
| 475 | - return '<a href="' . $url . '" target="about:bank">' . $title . '</a>'; |
|
| 475 | + return '<a href="'.$url.'" target="about:bank">'.$title.'</a>'; |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | public function format_yes_no_optional($value) |
| 479 | 479 | { |
| 480 | 480 | $return = ''; |
| 481 | - switch($value) { |
|
| 481 | + switch ($value) { |
|
| 482 | 482 | case 0: |
| 483 | 483 | $return = get_lang('No'); |
| 484 | 484 | break; |
@@ -1255,6 +1255,7 @@ discard block |
||
| 1255 | 1255 | |
| 1256 | 1256 | /** |
| 1257 | 1257 | * Validates the time control key |
| 1258 | + * @param integer $exercise_id |
|
| 1258 | 1259 | */ |
| 1259 | 1260 | public static function exercise_time_control_is_valid( |
| 1260 | 1261 | $exercise_id, |
@@ -1388,7 +1389,7 @@ discard block |
||
| 1388 | 1389 | * @param int $in_direction |
| 1389 | 1390 | * @param string $in_hotpot_path |
| 1390 | 1391 | * @param bool $in_get_count |
| 1391 | - * @param null $where_condition |
|
| 1392 | + * @param string $where_condition |
|
| 1392 | 1393 | * @return array|int |
| 1393 | 1394 | */ |
| 1394 | 1395 | public static function get_exam_results_hotpotatoes_data( |
@@ -2179,7 +2180,7 @@ discard block |
||
| 2179 | 2180 | /** |
| 2180 | 2181 | * Return true if pass_pourcentage activated (we use the pass pourcentage feature |
| 2181 | 2182 | * return false if pass_percentage = 0 (we don't use the pass pourcentage feature |
| 2182 | - * @param $in_pass_pourcentage |
|
| 2183 | + * @param string $in_pass_pourcentage |
|
| 2183 | 2184 | * @return boolean |
| 2184 | 2185 | * In this version, pass_percentage and show_success_message are disabled if |
| 2185 | 2186 | * pass_percentage is set to 0 |
@@ -2192,7 +2193,7 @@ discard block |
||
| 2192 | 2193 | /** |
| 2193 | 2194 | * Converts a numeric value in a percentage example 0.66666 to 66.67 % |
| 2194 | 2195 | * @param $value |
| 2195 | - * @return float Converted number |
|
| 2196 | + * @return string Converted number |
|
| 2196 | 2197 | */ |
| 2197 | 2198 | public static function convert_to_percentage($value) |
| 2198 | 2199 | { |
@@ -2208,7 +2209,7 @@ discard block |
||
| 2208 | 2209 | * @param float $score |
| 2209 | 2210 | * @param float $weight |
| 2210 | 2211 | * @deprecated seem not to be used |
| 2211 | - * @return float the score rounded converted to the new range |
|
| 2212 | + * @return string|null the score rounded converted to the new range |
|
| 2212 | 2213 | */ |
| 2213 | 2214 | public static function convert_score($score, $weight) |
| 2214 | 2215 | { |
@@ -2759,6 +2760,7 @@ discard block |
||
| 2759 | 2760 | * @param int exercise id |
| 2760 | 2761 | * @param int $courseId |
| 2761 | 2762 | * @param int session id |
| 2763 | + * @param integer $user_count |
|
| 2762 | 2764 | * @return float Best average score |
| 2763 | 2765 | */ |
| 2764 | 2766 | public static function get_best_average_score_by_exercise( |
@@ -3198,8 +3200,9 @@ discard block |
||
| 3198 | 3200 | } |
| 3199 | 3201 | |
| 3200 | 3202 | /** |
| 3201 | - * @param array $answer |
|
| 3203 | + * @param string|null $answer |
|
| 3202 | 3204 | * @param string $user_answer |
| 3205 | + * @param string|null $current_answer |
|
| 3203 | 3206 | * @return array |
| 3204 | 3207 | */ |
| 3205 | 3208 | public static function check_fill_in_blanks($answer, $user_answer, $current_answer) |
@@ -3805,7 +3808,7 @@ discard block |
||
| 3805 | 3808 | |
| 3806 | 3809 | /** |
| 3807 | 3810 | * @param int $countLetter |
| 3808 | - * @return mixed |
|
| 3811 | + * @return string |
|
| 3809 | 3812 | */ |
| 3810 | 3813 | public static function detectInputAppropriateClass($countLetter) |
| 3811 | 3814 | { |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | if ($show_title) { |
| 68 | 68 | TestCategory::displayCategoryAndTitle($objQuestionTmp->id); |
| 69 | 69 | echo Display::div( |
| 70 | - $current_item . '. ' . $objQuestionTmp->selectTitle(), |
|
| 70 | + $current_item.'. '.$objQuestionTmp->selectTitle(), |
|
| 71 | 71 | array('class' => 'question_title') |
| 72 | 72 | ); |
| 73 | 73 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | <div class="clearfix"> |
| 112 | 112 | <ul class="exercise-draggable-answer ui-helper-reset ui-helper-clearfix list-inline">'; |
| 113 | 113 | } else { |
| 114 | - $s .= '<div id="drag' . $questionId . '_question" class="drag_question"> |
|
| 114 | + $s .= '<div id="drag'.$questionId.'_question" class="drag_question"> |
|
| 115 | 115 | <table class="data_table">'; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -158,12 +158,12 @@ discard block |
||
| 158 | 158 | } elseif ($answerType == FREE_ANSWER) { |
| 159 | 159 | $fck_content = isset($user_choice[0]) && !empty($user_choice[0]['answer']) ? $user_choice[0]['answer'] : null; |
| 160 | 160 | |
| 161 | - $form = new FormValidator('free_choice_' . $questionId); |
|
| 161 | + $form = new FormValidator('free_choice_'.$questionId); |
|
| 162 | 162 | $config = array( |
| 163 | 163 | 'ToolbarSet' => 'TestFreeAnswer' |
| 164 | 164 | ); |
| 165 | - $form->addHtmlEditor("choice[" . $questionId . "]", null, false, false, $config); |
|
| 166 | - $form->setDefaults(array("choice[" . $questionId . "]" => $fck_content)); |
|
| 165 | + $form->addHtmlEditor("choice[".$questionId."]", null, false, false, $config); |
|
| 166 | + $form->setDefaults(array("choice[".$questionId."]" => $fck_content)); |
|
| 167 | 167 | $s .= $form->returnForm(); |
| 168 | 168 | } elseif ($answerType == ORAL_EXPRESSION) { |
| 169 | 169 | // Add nanog |
@@ -190,11 +190,11 @@ discard block |
||
| 190 | 190 | echo $objQuestionTmp->returnRecorder(); |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - $form = new FormValidator('free_choice_' . $questionId); |
|
| 193 | + $form = new FormValidator('free_choice_'.$questionId); |
|
| 194 | 194 | $config = array( |
| 195 | 195 | 'ToolbarSet' => 'TestFreeAnswer' |
| 196 | 196 | ); |
| 197 | - $form->addHtmlEditor("choice[" . $questionId . "]", null, false, false, $config); |
|
| 197 | + $form->addHtmlEditor("choice[".$questionId."]", null, false, false, $config); |
|
| 198 | 198 | //$form->setDefaults(array("choice[" . $questionId . "]" => $fck_content)); |
| 199 | 199 | $s .= $form->returnForm(); |
| 200 | 200 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | case UNIQUE_ANSWER_NO_OPTION: |
| 280 | 280 | //no break |
| 281 | 281 | case UNIQUE_ANSWER_IMAGE: |
| 282 | - $input_id = 'choice-' . $questionId . '-' . $answerId; |
|
| 282 | + $input_id = 'choice-'.$questionId.'-'.$answerId; |
|
| 283 | 283 | |
| 284 | 284 | if (isset($user_choice[0]['answer']) && $user_choice[0]['answer'] == $numAnswer) { |
| 285 | 285 | $attributes = array( |
@@ -305,14 +305,14 @@ discard block |
||
| 305 | 305 | if ($answerType == UNIQUE_ANSWER_IMAGE) { |
| 306 | 306 | if ($show_comment) { |
| 307 | 307 | if (empty($comment)) { |
| 308 | - $s .= '<div id="answer' . $questionId . $numAnswer . '" ' |
|
| 308 | + $s .= '<div id="answer'.$questionId.$numAnswer.'" ' |
|
| 309 | 309 | . 'class="exercise-unique-answer-image" style="text-align: center">'; |
| 310 | 310 | } else { |
| 311 | - $s .= '<div id="answer' . $questionId . $numAnswer . '" ' |
|
| 311 | + $s .= '<div id="answer'.$questionId.$numAnswer.'" ' |
|
| 312 | 312 | . 'class="exercise-unique-answer-image col-xs-6 col-sm-12" style="text-align: center">'; |
| 313 | 313 | } |
| 314 | 314 | } else { |
| 315 | - $s .= '<div id="answer' . $questionId . $numAnswer . '" ' |
|
| 315 | + $s .= '<div id="answer'.$questionId.$numAnswer.'" ' |
|
| 316 | 316 | . 'class="exercise-unique-answer-image col-xs-6 col-md-3" style="text-align: center">'; |
| 317 | 317 | } |
| 318 | 318 | } |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | |
| 322 | 322 | $s .= Display::input( |
| 323 | 323 | 'hidden', |
| 324 | - 'choice2[' . $questionId . ']', |
|
| 324 | + 'choice2['.$questionId.']', |
|
| 325 | 325 | '0' |
| 326 | 326 | ); |
| 327 | 327 | |
@@ -329,13 +329,13 @@ discard block |
||
| 329 | 329 | |
| 330 | 330 | if ($answerType == UNIQUE_ANSWER_IMAGE) { |
| 331 | 331 | $attributes['style'] = 'display: none;'; |
| 332 | - $answer = '<div class="thumbnail">' . $answer . '</div>'; |
|
| 332 | + $answer = '<div class="thumbnail">'.$answer.'</div>'; |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | $answer_input .= '<label class="radio">'; |
| 336 | 336 | $answer_input .= Display::input( |
| 337 | 337 | 'radio', |
| 338 | - 'choice[' . $questionId . ']', |
|
| 338 | + 'choice['.$questionId.']', |
|
| 339 | 339 | $numAnswer, |
| 340 | 340 | $attributes |
| 341 | 341 | ); |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | case MULTIPLE_ANSWER_TRUE_FALSE: |
| 363 | 363 | //no break |
| 364 | 364 | case GLOBAL_MULTIPLE_ANSWER: |
| 365 | - $input_id = 'choice-' . $questionId . '-' . $answerId; |
|
| 365 | + $input_id = 'choice-'.$questionId.'-'.$answerId; |
|
| 366 | 366 | $answer = Security::remove_XSS($answer, STUDENT); |
| 367 | 367 | |
| 368 | 368 | if (in_array($numAnswer, $user_choice_array)) { |
@@ -383,12 +383,12 @@ discard block |
||
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) { |
| 386 | - $s .= '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />'; |
|
| 386 | + $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />'; |
|
| 387 | 387 | |
| 388 | 388 | $answer_input = '<label class="checkbox">'; |
| 389 | 389 | $answer_input .= Display::input( |
| 390 | 390 | 'checkbox', |
| 391 | - 'choice[' . $questionId . '][' . $numAnswer . ']', |
|
| 391 | + 'choice['.$questionId.']['.$numAnswer.']', |
|
| 392 | 392 | $numAnswer, |
| 393 | 393 | $attributes |
| 394 | 394 | ); |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | 'td', |
| 442 | 442 | Display::input( |
| 443 | 443 | 'radio', |
| 444 | - 'choice[' . $questionId . '][' . $numAnswer . ']', |
|
| 444 | + 'choice['.$questionId.']['.$numAnswer.']', |
|
| 445 | 445 | $id, |
| 446 | 446 | $attributes |
| 447 | 447 | ), |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | break; |
| 461 | 461 | case MULTIPLE_ANSWER_COMBINATION: |
| 462 | 462 | // multiple answers |
| 463 | - $input_id = 'choice-' . $questionId . '-' . $answerId; |
|
| 463 | + $input_id = 'choice-'.$questionId.'-'.$answerId; |
|
| 464 | 464 | |
| 465 | 465 | if (in_array($numAnswer, $user_choice_array)) { |
| 466 | 466 | $attributes = array( |
@@ -480,11 +480,11 @@ discard block |
||
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | $answer = Security::remove_XSS($answer, STUDENT); |
| 483 | - $answer_input = '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />'; |
|
| 483 | + $answer_input = '<input type="hidden" name="choice2['.$questionId.']" value="0" />'; |
|
| 484 | 484 | $answer_input .= '<label class="checkbox">'; |
| 485 | 485 | $answer_input .= Display::input( |
| 486 | 486 | 'checkbox', |
| 487 | - 'choice[' . $questionId . '][' . $numAnswer . ']', |
|
| 487 | + 'choice['.$questionId.']['.$numAnswer.']', |
|
| 488 | 488 | 1, |
| 489 | 489 | $attributes |
| 490 | 490 | ); |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | } |
| 506 | 506 | break; |
| 507 | 507 | case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE: |
| 508 | - $s .= '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />'; |
|
| 508 | + $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />'; |
|
| 509 | 509 | |
| 510 | 510 | $my_choice = array(); |
| 511 | 511 | if (!empty($user_choice_array)) { |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | 'td', |
| 541 | 541 | Display::input( |
| 542 | 542 | 'radio', |
| 543 | - 'choice[' . $questionId . '][' . $numAnswer . ']', |
|
| 543 | + 'choice['.$questionId.']['.$numAnswer.']', |
|
| 544 | 544 | $key, |
| 545 | 545 | $attributes |
| 546 | 546 | ) |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | // may be "" if student viewed the question, but did not fill the blanks |
| 598 | 598 | $correctItem = $studentAnswerList[$i]; |
| 599 | 599 | } |
| 600 | - $attributes["style"] = "width:" . $listAnswerInformations["tabinputsize"][$i] . "px"; |
|
| 600 | + $attributes["style"] = "width:".$listAnswerInformations["tabinputsize"][$i]."px"; |
|
| 601 | 601 | $answer .= FillBlanks::getFillTheBlankHtml($separatorStartRegexp, $separatorEndRegexp, $correctItemRegexp, $questionId, $correctItem, $attributes, $answer, $listAnswerInformations, $displayForStudent, $i); |
| 602 | 602 | } |
| 603 | 603 | // display the last common word |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | // display the common words |
| 612 | 612 | $answer .= $listAnswerInformations["commonwords"][$i]; |
| 613 | 613 | // display the blank word |
| 614 | - $attributes["style"] = "width:" . $listAnswerInformations["tabinputsize"][$i] . "px"; |
|
| 614 | + $attributes["style"] = "width:".$listAnswerInformations["tabinputsize"][$i]."px"; |
|
| 615 | 615 | $correctItem = $listAnswerInformations["tabwords"][$i]; |
| 616 | 616 | $correctItemRegexp = $correctItem; |
| 617 | 617 | // replace / with \/ to allow the preg_replace bellow and all the regexp char |
@@ -637,8 +637,8 @@ discard block |
||
| 637 | 637 | $trackAttempts = Database::get_main_table( |
| 638 | 638 | TABLE_STATISTIC_TRACK_E_ATTEMPT |
| 639 | 639 | ); |
| 640 | - $sql = 'SELECT answer FROM ' . $trackAttempts . ' |
|
| 641 | - WHERE exe_id=' . $exe_id . ' AND question_id=' . $questionId; |
|
| 640 | + $sql = 'SELECT answer FROM '.$trackAttempts.' |
|
| 641 | + WHERE exe_id=' . $exe_id.' AND question_id='.$questionId; |
|
| 642 | 642 | $rsLastAttempt = Database::query($sql); |
| 643 | 643 | $rowLastAttempt = Database::fetch_array($rsLastAttempt); |
| 644 | 644 | $answer = $rowLastAttempt['answer']; |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | '', |
| 696 | 696 | $answerCorrected |
| 697 | 697 | ); |
| 698 | - $answerCorrected = '[' . $answerCorrected . ']'; |
|
| 698 | + $answerCorrected = '['.$answerCorrected.']'; |
|
| 699 | 699 | $studentAnswerList[] = $answerCorrected; |
| 700 | 700 | } |
| 701 | 701 | } |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | */ |
| 717 | 717 | $tabComments = api_preg_split( |
| 718 | 718 | '/\[[^]]+\]/', |
| 719 | - ' ' . $answer . ' ' |
|
| 719 | + ' '.$answer.' ' |
|
| 720 | 720 | ); |
| 721 | 721 | if (!empty($correctAnswerList) && !empty($studentAnswerList)) { |
| 722 | 722 | $answer = ""; |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | $size |
| 734 | 734 | ); |
| 735 | 735 | |
| 736 | - $answer .= $tabComments[$i] . |
|
| 736 | + $answer .= $tabComments[$i]. |
|
| 737 | 737 | Display::input( |
| 738 | 738 | 'text', |
| 739 | 739 | "choice[$questionId][]", |
@@ -780,12 +780,12 @@ discard block |
||
| 780 | 780 | $s .= '<tr><td width="45%" valign="top">'; |
| 781 | 781 | $parsed_answer = $answer; |
| 782 | 782 | //left part questions |
| 783 | - $s .= '<p class="indent">' . $lines_count . '. ' . $parsed_answer . '</p></td>'; |
|
| 783 | + $s .= '<p class="indent">'.$lines_count.'. '.$parsed_answer.'</p></td>'; |
|
| 784 | 784 | //middle part (matches selects) |
| 785 | 785 | |
| 786 | 786 | $s .= '<td width="10%" valign="top" align="center" > |
| 787 | 787 | <div class="select-matching"> |
| 788 | - <select name="choice[' . $questionId . '][' . $numAnswer . ']">'; |
|
| 788 | + <select name="choice[' . $questionId.']['.$numAnswer.']">'; |
|
| 789 | 789 | |
| 790 | 790 | // fills the list-box |
| 791 | 791 | foreach ($select_items as $key => $val) { |
@@ -801,14 +801,14 @@ discard block |
||
| 801 | 801 | if (isset($user_choice_array_position[$numAnswer]) && $val['id'] == $user_choice_array_position[$numAnswer]) { |
| 802 | 802 | $selected = 'selected="selected"'; |
| 803 | 803 | } |
| 804 | - $s .= '<option value="' . $val['id'] . '" ' . $selected . '>' . $val['letter'] . '</option>'; |
|
| 804 | + $s .= '<option value="'.$val['id'].'" '.$selected.'>'.$val['letter'].'</option>'; |
|
| 805 | 805 | |
| 806 | 806 | } // end foreach() |
| 807 | 807 | |
| 808 | 808 | $s .= '</select></div></td><td width="5%" class="separate"> </td>'; |
| 809 | 809 | $s .= '<td width="40%" valign="top" >'; |
| 810 | 810 | if (isset($select_items[$lines_count])) { |
| 811 | - $s .= '<div class="text-right"><p class="indent">' . $select_items[$lines_count]['letter'] . '. ' . $select_items[$lines_count]['answer'] . '</p></div>'; |
|
| 811 | + $s .= '<div class="text-right"><p class="indent">'.$select_items[$lines_count]['letter'].'. '.$select_items[$lines_count]['answer'].'</p></div>'; |
|
| 812 | 812 | } else { |
| 813 | 813 | $s .= ' '; |
| 814 | 814 | } |
@@ -823,7 +823,7 @@ discard block |
||
| 823 | 823 | $s .= '<tr> |
| 824 | 824 | <td colspan="2"></td> |
| 825 | 825 | <td valign="top">'; |
| 826 | - $s .= '<b>' . $select_items[$lines_count]['letter'] . '.</b> ' . $select_items[$lines_count]['answer']; |
|
| 826 | + $s .= '<b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer']; |
|
| 827 | 827 | $s .= "</td> |
| 828 | 828 | </tr>"; |
| 829 | 829 | $lines_count++; |
@@ -840,9 +840,9 @@ discard block |
||
| 840 | 840 | $data = $objAnswerTmp->getAnswerByAutoId($data['correct']); |
| 841 | 841 | $lines_count = $data['answer'];*/ |
| 842 | 842 | |
| 843 | - $windowId = $questionId . '_' . $lines_count; |
|
| 843 | + $windowId = $questionId.'_'.$lines_count; |
|
| 844 | 844 | |
| 845 | - $s .= '<li class="touch-items" id="' . $windowId . '">'; |
|
| 845 | + $s .= '<li class="touch-items" id="'.$windowId.'">'; |
|
| 846 | 846 | $s .= Display::div( |
| 847 | 847 | $parsed_answer, |
| 848 | 848 | [ |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | Display::tag( |
| 901 | 901 | 'b', |
| 902 | 902 | $select_items[$lines_count]['letter'] |
| 903 | - ) . $select_items[$lines_count]['answer'], |
|
| 903 | + ).$select_items[$lines_count]['answer'], |
|
| 904 | 904 | [ |
| 905 | 905 | 'id' => "window_{$windowId}_answer", |
| 906 | 906 | 'style' => 'display: none;' |
@@ -1071,7 +1071,7 @@ discard block |
||
| 1071 | 1071 | |
| 1072 | 1072 | for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) { |
| 1073 | 1073 | $answerCorrect = $objAnswerTmp->isCorrect($answerId); |
| 1074 | - $windowId = $questionId . '_' . $counterAnswer; |
|
| 1074 | + $windowId = $questionId.'_'.$counterAnswer; |
|
| 1075 | 1075 | |
| 1076 | 1076 | if ($answerCorrect) { |
| 1077 | 1077 | $s .= Display::div( |
@@ -1120,7 +1120,7 @@ discard block |
||
| 1120 | 1120 | $course = api_get_course_info(); |
| 1121 | 1121 | $doc_id = DocumentManager::get_document_id( |
| 1122 | 1122 | $course, |
| 1123 | - '/images/' . $pictureName |
|
| 1123 | + '/images/'.$pictureName |
|
| 1124 | 1124 | ); |
| 1125 | 1125 | if (is_numeric($doc_id)) { |
| 1126 | 1126 | $images_folder_visibility = api_get_item_visibility( |
@@ -1145,7 +1145,7 @@ discard block |
||
| 1145 | 1145 | echo " |
| 1146 | 1146 | <script> |
| 1147 | 1147 | $(document).on('ready', function () { |
| 1148 | - new " . ($answerType == HOT_SPOT ? "HotspotQuestion" : "DelineationQuestion") . "({ |
|
| 1148 | + new " . ($answerType == HOT_SPOT ? "HotspotQuestion" : "DelineationQuestion")."({ |
|
| 1149 | 1149 | questionId: $questionId, |
| 1150 | 1150 | exerciseId: $exerciseId, |
| 1151 | 1151 | selector: '#hotspot-preview-$questionId', |
@@ -1179,7 +1179,7 @@ discard block |
||
| 1179 | 1179 | if ($answerType != HOT_SPOT_DELINEATION) { |
| 1180 | 1180 | $answerList = ' |
| 1181 | 1181 | <div class="well well-sm"> |
| 1182 | - <h5 class="page-header">' . get_lang('HotspotZones') . '</h5> |
|
| 1182 | + <h5 class="page-header">' . get_lang('HotspotZones').'</h5> |
|
| 1183 | 1183 | <ol> |
| 1184 | 1184 | '; |
| 1185 | 1185 | |
@@ -1204,7 +1204,7 @@ discard block |
||
| 1204 | 1204 | if (!$only_questions) { |
| 1205 | 1205 | if ($show_title) { |
| 1206 | 1206 | TestCategory::displayCategoryAndTitle($objQuestionTmp->id); |
| 1207 | - echo '<div class="question_title">' . $current_item . '. ' . $questionName . '</div>'; |
|
| 1207 | + echo '<div class="question_title">'.$current_item.'. '.$questionName.'</div>'; |
|
| 1208 | 1208 | } |
| 1209 | 1209 | //@todo I need to the get the feedback type |
| 1210 | 1210 | echo <<<HOTSPOT |
@@ -1221,7 +1221,7 @@ discard block |
||
| 1221 | 1221 | <div class=\"hotspot-image\"></div> |
| 1222 | 1222 | <script> |
| 1223 | 1223 | $(document).on('ready', function () { |
| 1224 | - new " . ($answerType == HOT_SPOT_DELINEATION ? 'DelineationQuestion' : 'HotspotQuestion') . "({ |
|
| 1224 | + new " . ($answerType == HOT_SPOT_DELINEATION ? 'DelineationQuestion' : 'HotspotQuestion')."({ |
|
| 1225 | 1225 | questionId: $questionId, |
| 1226 | 1226 | exerciseId: $exe_id, |
| 1227 | 1227 | selector: '#question_div_' + $questionId + ' .hotspot-image', |
@@ -1342,11 +1342,11 @@ discard block |
||
| 1342 | 1342 | $lp_id = intval($lp_id); |
| 1343 | 1343 | $lp_item_id = intval($lp_item_id); |
| 1344 | 1344 | return |
| 1345 | - api_get_course_int_id() . '_' . |
|
| 1346 | - api_get_session_id() . '_' . |
|
| 1347 | - $exercise_id . '_' . |
|
| 1348 | - api_get_user_id() . '_' . |
|
| 1349 | - $lp_id . '_' . |
|
| 1345 | + api_get_course_int_id().'_'. |
|
| 1346 | + api_get_session_id().'_'. |
|
| 1347 | + $exercise_id.'_'. |
|
| 1348 | + api_get_user_id().'_'. |
|
| 1349 | + $lp_id.'_'. |
|
| 1350 | 1350 | $lp_item_id; |
| 1351 | 1351 | } |
| 1352 | 1352 | |
@@ -1460,14 +1460,14 @@ discard block |
||
| 1460 | 1460 | $res = Database::query($sql); |
| 1461 | 1461 | $result = array(); |
| 1462 | 1462 | $apiIsAllowedToEdit = api_is_allowed_to_edit(); |
| 1463 | - $urlBase = api_get_path(WEB_CODE_PATH) . |
|
| 1464 | - 'exercise/hotpotatoes_exercise_report.php?action=delete&' . |
|
| 1465 | - api_get_cidreq() . '&id='; |
|
| 1463 | + $urlBase = api_get_path(WEB_CODE_PATH). |
|
| 1464 | + 'exercise/hotpotatoes_exercise_report.php?action=delete&'. |
|
| 1465 | + api_get_cidreq().'&id='; |
|
| 1466 | 1466 | while ($data = Database::fetch_array($res)) { |
| 1467 | 1467 | $actions = null; |
| 1468 | 1468 | |
| 1469 | 1469 | if ($apiIsAllowedToEdit) { |
| 1470 | - $url = $urlBase . $data['id'] . '&path=' . $data['exe_name']; |
|
| 1470 | + $url = $urlBase.$data['id'].'&path='.$data['exe_name']; |
|
| 1471 | 1471 | $actions = Display::url( |
| 1472 | 1472 | Display::return_icon('delete.png', get_lang('Delete')), |
| 1473 | 1473 | $url |
@@ -1483,7 +1483,7 @@ discard block |
||
| 1483 | 1483 | GroupManager::get_user_group_name($data['user_id']) |
| 1484 | 1484 | ), |
| 1485 | 1485 | 'exe_date' => $data['exe_date'], |
| 1486 | - 'score' => $data['exe_result'] . ' / ' . $data['exe_weighting'], |
|
| 1486 | + 'score' => $data['exe_result'].' / '.$data['exe_weighting'], |
|
| 1487 | 1487 | 'actions' => $actions, |
| 1488 | 1488 | ); |
| 1489 | 1489 | } |
@@ -1568,18 +1568,18 @@ discard block |
||
| 1568 | 1568 | $TBL_TRACK_HOTPOTATOES = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); |
| 1569 | 1569 | $TBL_TRACK_ATTEMPT_RECORDING = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING); |
| 1570 | 1570 | |
| 1571 | - $session_id_and = ' AND te.session_id = ' . $sessionId . ' '; |
|
| 1571 | + $session_id_and = ' AND te.session_id = '.$sessionId.' '; |
|
| 1572 | 1572 | $exercise_id = intval($exercise_id); |
| 1573 | 1573 | |
| 1574 | 1574 | $exercise_where = ''; |
| 1575 | 1575 | if (!empty($exercise_id)) { |
| 1576 | - $exercise_where .= ' AND te.exe_exo_id = ' . $exercise_id . ' '; |
|
| 1576 | + $exercise_where .= ' AND te.exe_exo_id = '.$exercise_id.' '; |
|
| 1577 | 1577 | } |
| 1578 | 1578 | |
| 1579 | 1579 | $hotpotatoe_where = ''; |
| 1580 | 1580 | if (!empty($_GET['path'])) { |
| 1581 | 1581 | $hotpotatoe_path = Database::escape_string($_GET['path']); |
| 1582 | - $hotpotatoe_where .= ' AND exe_name = "' . $hotpotatoe_path . '" '; |
|
| 1582 | + $hotpotatoe_where .= ' AND exe_name = "'.$hotpotatoe_path.'" '; |
|
| 1583 | 1583 | } |
| 1584 | 1584 | |
| 1585 | 1585 | // sql for chamilo-type tests for teacher / tutor view |
@@ -1591,7 +1591,7 @@ discard block |
||
| 1591 | 1591 | WHERE |
| 1592 | 1592 | c_id = $course_id AND |
| 1593 | 1593 | exe_exo_id = $exercise_id AND |
| 1594 | - ttte.session_id = " . $sessionId . " |
|
| 1594 | + ttte.session_id = ".$sessionId." |
|
| 1595 | 1595 | )"; |
| 1596 | 1596 | |
| 1597 | 1597 | if ($is_allowedToEdit) { |
@@ -1614,9 +1614,9 @@ discard block |
||
| 1614 | 1614 | g.id as group_id |
| 1615 | 1615 | FROM $TBL_USER u |
| 1616 | 1616 | INNER JOIN $TBL_GROUP_REL_USER gru |
| 1617 | - ON (gru.user_id = u.user_id AND gru.c_id=" . $course_id . ") |
|
| 1617 | + ON (gru.user_id = u.user_id AND gru.c_id=".$course_id.") |
|
| 1618 | 1618 | INNER JOIN $TBL_GROUP g |
| 1619 | - ON (gru.group_id = g.id AND g.c_id=" . $course_id . ") |
|
| 1619 | + ON (gru.group_id = g.id AND g.c_id=".$course_id.") |
|
| 1620 | 1620 | )"; |
| 1621 | 1621 | } |
| 1622 | 1622 | |
@@ -1678,9 +1678,9 @@ discard block |
||
| 1678 | 1678 | g.id as group_id |
| 1679 | 1679 | FROM $TBL_USER u |
| 1680 | 1680 | LEFT OUTER JOIN $TBL_GROUP_REL_USER gru |
| 1681 | - ON ( gru.user_id = u.user_id AND gru.c_id=" . $course_id . " ) |
|
| 1681 | + ON ( gru.user_id = u.user_id AND gru.c_id=".$course_id." ) |
|
| 1682 | 1682 | LEFT OUTER JOIN $TBL_GROUP g |
| 1683 | - ON (gru.group_id = g.id AND g.c_id = " . $course_id . ") |
|
| 1683 | + ON (gru.group_id = g.id AND g.c_id = ".$course_id.") |
|
| 1684 | 1684 | )"; |
| 1685 | 1685 | } |
| 1686 | 1686 | |
@@ -1693,12 +1693,12 @@ discard block |
||
| 1693 | 1693 | ( |
| 1694 | 1694 | SELECT u.user_id, firstname, lastname, email, username, ' ' as group_name, '' as group_id, official_code |
| 1695 | 1695 | FROM $TBL_USER u |
| 1696 | - WHERE u.status NOT IN(" . api_get_users_status_ignored_in_reports('string') . ") |
|
| 1696 | + WHERE u.status NOT IN(".api_get_users_status_ignored_in_reports('string').") |
|
| 1697 | 1697 | )"; |
| 1698 | 1698 | } |
| 1699 | 1699 | |
| 1700 | 1700 | $sqlFromOption = " , $TBL_GROUP_REL_USER AS gru "; |
| 1701 | - $sqlWhereOption = " AND gru.c_id = " . $course_id . " AND gru.user_id = user.user_id "; |
|
| 1701 | + $sqlWhereOption = " AND gru.c_id = ".$course_id." AND gru.user_id = user.user_id "; |
|
| 1702 | 1702 | $first_and_last_name = api_is_western_name_order() ? "firstname, lastname" : "lastname, firstname"; |
| 1703 | 1703 | |
| 1704 | 1704 | if ($get_count) { |
@@ -1735,8 +1735,8 @@ discard block |
||
| 1735 | 1735 | ON (user.user_id = exe_user_id) |
| 1736 | 1736 | WHERE |
| 1737 | 1737 | te.status != 'incomplete' AND |
| 1738 | - te.c_id = " . $course_id . " $session_id_and AND |
|
| 1739 | - ce.active <>-1 AND ce.c_id = " . $course_id . " |
|
| 1738 | + te.c_id = ".$course_id." $session_id_and AND |
|
| 1739 | + ce.active <>-1 AND ce.c_id = ".$course_id." |
|
| 1740 | 1740 | $exercise_where |
| 1741 | 1741 | $extra_where_conditions |
| 1742 | 1742 | "; |
@@ -1763,12 +1763,12 @@ discard block |
||
| 1763 | 1763 | $sqlFromOption |
| 1764 | 1764 | WHERE |
| 1765 | 1765 | user.user_id=tth.exe_user_id |
| 1766 | - AND tth.c_id = " . $course_id . " |
|
| 1766 | + AND tth.c_id = ".$course_id." |
|
| 1767 | 1767 | $hotpotatoe_where |
| 1768 | 1768 | $sqlWhereOption |
| 1769 | - AND user.status NOT IN(" . api_get_users_status_ignored_in_reports( |
|
| 1769 | + AND user.status NOT IN(".api_get_users_status_ignored_in_reports( |
|
| 1770 | 1770 | 'string' |
| 1771 | - ) . ") |
|
| 1771 | + ).") |
|
| 1772 | 1772 | ORDER BY |
| 1773 | 1773 | tth.c_id ASC, |
| 1774 | 1774 | tth.exe_date DESC"; |
@@ -1841,12 +1841,12 @@ discard block |
||
| 1841 | 1841 | |
| 1842 | 1842 | if ($from_gradebook && ($is_allowedToEdit)) { |
| 1843 | 1843 | if (in_array( |
| 1844 | - $results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname'], |
|
| 1844 | + $results[$i]['username'].$results[$i]['firstname'].$results[$i]['lastname'], |
|
| 1845 | 1845 | $users_array_id |
| 1846 | 1846 | )) { |
| 1847 | 1847 | continue; |
| 1848 | 1848 | } |
| 1849 | - $users_array_id[] = $results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname']; |
|
| 1849 | + $users_array_id[] = $results[$i]['username'].$results[$i]['firstname'].$results[$i]['lastname']; |
|
| 1850 | 1850 | } |
| 1851 | 1851 | |
| 1852 | 1852 | $lp_obj = isset($results[$i]['orig_lp_id']) && isset($lp_list[$results[$i]['orig_lp_id']]) ? $lp_list[$results[$i]['orig_lp_id']] : null; |
@@ -1855,7 +1855,7 @@ discard block |
||
| 1855 | 1855 | if ($lp_obj) { |
| 1856 | 1856 | $url = api_get_path( |
| 1857 | 1857 | WEB_CODE_PATH |
| 1858 | - ) . 'lp/lp_controller.php?' . api_get_cidreq() . '&action=view&lp_id=' . $results[$i]['orig_lp_id']; |
|
| 1858 | + ).'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$results[$i]['orig_lp_id']; |
|
| 1859 | 1859 | $lp_name = Display::url( |
| 1860 | 1860 | $lp_obj['lp_name'], |
| 1861 | 1861 | $url, |
@@ -1873,7 +1873,7 @@ discard block |
||
| 1873 | 1873 | ); |
| 1874 | 1874 | |
| 1875 | 1875 | foreach ($group_list as $id) { |
| 1876 | - $group_name_list .= $clean_group_list[$id] . '<br/>'; |
|
| 1876 | + $group_name_list .= $clean_group_list[$id].'<br/>'; |
|
| 1877 | 1877 | } |
| 1878 | 1878 | $results[$i]['group_name'] = $group_name_list; |
| 1879 | 1879 | } |
@@ -1929,7 +1929,7 @@ discard block |
||
| 1929 | 1929 | } |
| 1930 | 1930 | } |
| 1931 | 1931 | if ($revised) { |
| 1932 | - $actions .= "<a href='exercise_show.php?" . api_get_cidreq() . "&action=edit&id=$id'>" . |
|
| 1932 | + $actions .= "<a href='exercise_show.php?".api_get_cidreq()."&action=edit&id=$id'>". |
|
| 1933 | 1933 | Display:: return_icon( |
| 1934 | 1934 | 'edit.png', |
| 1935 | 1935 | get_lang('Edit'), |
@@ -1938,7 +1938,7 @@ discard block |
||
| 1938 | 1938 | ); |
| 1939 | 1939 | $actions .= ' '; |
| 1940 | 1940 | } else { |
| 1941 | - $actions .= "<a href='exercise_show.php?" . api_get_cidreq() . "&action=qualify&id=$id'>" . |
|
| 1941 | + $actions .= "<a href='exercise_show.php?".api_get_cidreq()."&action=qualify&id=$id'>". |
|
| 1942 | 1942 | Display:: return_icon( |
| 1943 | 1943 | 'quiz.gif', |
| 1944 | 1944 | get_lang('Qualify') |
@@ -1948,11 +1948,11 @@ discard block |
||
| 1948 | 1948 | $actions .= "</a>"; |
| 1949 | 1949 | |
| 1950 | 1950 | if ($filter == 2) { |
| 1951 | - $actions .= ' <a href="exercise_history.php?' . api_get_cidreq() . '&exe_id=' . $id . '">' . |
|
| 1951 | + $actions .= ' <a href="exercise_history.php?'.api_get_cidreq().'&exe_id='.$id.'">'. |
|
| 1952 | 1952 | Display:: return_icon( |
| 1953 | 1953 | 'history.gif', |
| 1954 | 1954 | get_lang('ViewHistoryChange') |
| 1955 | - ) . '</a>'; |
|
| 1955 | + ).'</a>'; |
|
| 1956 | 1956 | } |
| 1957 | 1957 | |
| 1958 | 1958 | //Admin can always delete the attempt |
@@ -1962,13 +1962,13 @@ discard block |
||
| 1962 | 1962 | date('Y-m-d h:i:s'), |
| 1963 | 1963 | false |
| 1964 | 1964 | ); |
| 1965 | - $actions .= '<a href="http://www.whatsmyip.org/ip-geo-location/?ip=' . $ip . '" target="_blank"> |
|
| 1966 | - ' . Display::return_icon('info.png', $ip) . ' |
|
| 1965 | + $actions .= '<a href="http://www.whatsmyip.org/ip-geo-location/?ip='.$ip.'" target="_blank"> |
|
| 1966 | + ' . Display::return_icon('info.png', $ip).' |
|
| 1967 | 1967 | </a>'; |
| 1968 | 1968 | |
| 1969 | 1969 | |
| 1970 | - $recalculateUrl = api_get_path(WEB_CODE_PATH) . 'exercise/recalculate.php?' . |
|
| 1971 | - api_get_cidreq() . '&' . |
|
| 1970 | + $recalculateUrl = api_get_path(WEB_CODE_PATH).'exercise/recalculate.php?'. |
|
| 1971 | + api_get_cidreq().'&'. |
|
| 1972 | 1972 | http_build_query([ |
| 1973 | 1973 | 'id' => $id, |
| 1974 | 1974 | 'exercise' => $exercise_id, |
@@ -1985,27 +1985,27 @@ discard block |
||
| 1985 | 1985 | ] |
| 1986 | 1986 | ); |
| 1987 | 1987 | |
| 1988 | - $delete_link = '<a href="exercise_report.php?' . api_get_cidreq() . '&filter_by_user=' . intval($_GET['filter_by_user']) . '&filter=' . $filter . '&exerciseId=' . $exercise_id . '&delete=delete&did=' . $id . '" |
|
| 1988 | + $delete_link = '<a href="exercise_report.php?'.api_get_cidreq().'&filter_by_user='.intval($_GET['filter_by_user']).'&filter='.$filter.'&exerciseId='.$exercise_id.'&delete=delete&did='.$id.'" |
|
| 1989 | 1989 | onclick="javascript:if(!confirm(\'' . sprintf( |
| 1990 | 1990 | get_lang('DeleteAttempt'), |
| 1991 | 1991 | $results[$i]['username'], |
| 1992 | 1992 | $dt |
| 1993 | - ) . '\')) return false;">' . Display:: return_icon( |
|
| 1993 | + ).'\')) return false;">'.Display:: return_icon( |
|
| 1994 | 1994 | 'delete.png', |
| 1995 | 1995 | get_lang('Delete') |
| 1996 | - ) . '</a>'; |
|
| 1996 | + ).'</a>'; |
|
| 1997 | 1997 | $delete_link = utf8_encode($delete_link); |
| 1998 | 1998 | |
| 1999 | 1999 | if (api_is_drh() && !api_is_platform_admin()) { |
| 2000 | 2000 | $delete_link = null; |
| 2001 | 2001 | } |
| 2002 | - $actions .= $delete_link . ' '; |
|
| 2002 | + $actions .= $delete_link.' '; |
|
| 2003 | 2003 | } |
| 2004 | 2004 | |
| 2005 | 2005 | } else { |
| 2006 | 2006 | $attempt_url = api_get_path( |
| 2007 | 2007 | WEB_CODE_PATH |
| 2008 | - ) . 'exercise/result.php?' . api_get_cidreq() . '&id=' . $results[$i]['exe_id'] . '&id_session=' . $sessionId; |
|
| 2008 | + ).'exercise/result.php?'.api_get_cidreq().'&id='.$results[$i]['exe_id'].'&id_session='.$sessionId; |
|
| 2009 | 2009 | $attempt_link = Display::url( |
| 2010 | 2010 | get_lang('Show'), |
| 2011 | 2011 | $attempt_url, |
@@ -2064,7 +2064,7 @@ discard block |
||
| 2064 | 2064 | $hp_result = round( |
| 2065 | 2065 | ($hpresults[$i][4] / ($hpresults[$i][5] != 0 ? $hpresults[$i][5] : 1)) * 100, |
| 2066 | 2066 | 2 |
| 2067 | - ) . '% (' . $hpresults[$i][4] . ' / ' . $hpresults[$i][5] . ')'; |
|
| 2067 | + ).'% ('.$hpresults[$i][4].' / '.$hpresults[$i][5].')'; |
|
| 2068 | 2068 | if ($is_allowedToEdit) { |
| 2069 | 2069 | $list_info[] = array( |
| 2070 | 2070 | $hpresults[$i][0], |
@@ -2138,13 +2138,13 @@ discard block |
||
| 2138 | 2138 | |
| 2139 | 2139 | $html = null; |
| 2140 | 2140 | if ($show_percentage) { |
| 2141 | - $parent = '(' . $score . ' / ' . $weight . ')'; |
|
| 2142 | - $html = $percentage . "% $parent"; |
|
| 2141 | + $parent = '('.$score.' / '.$weight.')'; |
|
| 2142 | + $html = $percentage."% $parent"; |
|
| 2143 | 2143 | if ($show_only_percentage) { |
| 2144 | - $html = $percentage . "% "; |
|
| 2144 | + $html = $percentage."% "; |
|
| 2145 | 2145 | } |
| 2146 | 2146 | } else { |
| 2147 | - $html = $score . ' / ' . $weight; |
|
| 2147 | + $html = $score.' / '.$weight; |
|
| 2148 | 2148 | } |
| 2149 | 2149 | $html = Display::span($html, array('class' => 'score_exercise')); |
| 2150 | 2150 | |
@@ -2238,7 +2238,7 @@ discard block |
||
| 2238 | 2238 | { |
| 2239 | 2239 | $return = '-'; |
| 2240 | 2240 | if ($value != '') { |
| 2241 | - $return = float_format($value * 100, 1) . ' %'; |
|
| 2241 | + $return = float_format($value * 100, 1).' %'; |
|
| 2242 | 2242 | } |
| 2243 | 2243 | return $return; |
| 2244 | 2244 | } |
@@ -2317,7 +2317,7 @@ discard block |
||
| 2317 | 2317 | } |
| 2318 | 2318 | |
| 2319 | 2319 | $needle_where = !empty($search) ? " AND title LIKE '?' " : ''; |
| 2320 | - $needle = !empty($search) ? "%" . $search . "%" : ''; |
|
| 2320 | + $needle = !empty($search) ? "%".$search."%" : ''; |
|
| 2321 | 2321 | |
| 2322 | 2322 | // Show courses by active status |
| 2323 | 2323 | $active_sql = ''; |
@@ -2332,7 +2332,7 @@ discard block |
||
| 2332 | 2332 | if ($search_all_sessions == true) { |
| 2333 | 2333 | $conditions = array( |
| 2334 | 2334 | 'where' => array( |
| 2335 | - $active_sql . ' c_id = ? ' . $needle_where . $time_conditions => array( |
|
| 2335 | + $active_sql.' c_id = ? '.$needle_where.$time_conditions => array( |
|
| 2336 | 2336 | $course_id, |
| 2337 | 2337 | $needle |
| 2338 | 2338 | ) |
@@ -2343,7 +2343,7 @@ discard block |
||
| 2343 | 2343 | if ($session_id == 0) { |
| 2344 | 2344 | $conditions = array( |
| 2345 | 2345 | 'where' => array( |
| 2346 | - $active_sql . ' session_id = ? AND c_id = ? ' . $needle_where . $time_conditions => array( |
|
| 2346 | + $active_sql.' session_id = ? AND c_id = ? '.$needle_where.$time_conditions => array( |
|
| 2347 | 2347 | $session_id, |
| 2348 | 2348 | $course_id, |
| 2349 | 2349 | $needle |
@@ -2354,7 +2354,7 @@ discard block |
||
| 2354 | 2354 | } else { |
| 2355 | 2355 | $conditions = array( |
| 2356 | 2356 | 'where' => array( |
| 2357 | - $active_sql . ' (session_id = 0 OR session_id = ? ) AND c_id = ? ' . $needle_where . $time_conditions => array( |
|
| 2357 | + $active_sql.' (session_id = 0 OR session_id = ? ) AND c_id = ? '.$needle_where.$time_conditions => array( |
|
| 2358 | 2358 | $session_id, |
| 2359 | 2359 | $course_id, |
| 2360 | 2360 | $needle |
@@ -2535,7 +2535,7 @@ discard block |
||
| 2535 | 2535 | |
| 2536 | 2536 | if ($return_string) { |
| 2537 | 2537 | if (!empty($position) && !empty($my_ranking)) { |
| 2538 | - $return_value = $position . '/' . count($my_ranking); |
|
| 2538 | + $return_value = $position.'/'.count($my_ranking); |
|
| 2539 | 2539 | } else { |
| 2540 | 2540 | $return_value = '-'; |
| 2541 | 2541 | } |
@@ -2616,7 +2616,7 @@ discard block |
||
| 2616 | 2616 | |
| 2617 | 2617 | if ($return_string) { |
| 2618 | 2618 | if (!empty($position) && !empty($my_ranking)) { |
| 2619 | - return $position . '/' . count($my_ranking); |
|
| 2619 | + return $position.'/'.count($my_ranking); |
|
| 2620 | 2620 | } |
| 2621 | 2621 | } |
| 2622 | 2622 | return $return_value; |
@@ -3021,7 +3021,7 @@ discard block |
||
| 3021 | 3021 | $courseCondition = " |
| 3022 | 3022 | INNER JOIN $courseUser cu |
| 3023 | 3023 | ON cu.c_id = c.id AND cu.user_id = exe_user_id"; |
| 3024 | - $courseConditionWhere = " AND relation_type <> 2 AND cu.status = " . STUDENT; |
|
| 3024 | + $courseConditionWhere = " AND relation_type <> 2 AND cu.status = ".STUDENT; |
|
| 3025 | 3025 | } else { |
| 3026 | 3026 | $courseCondition = " |
| 3027 | 3027 | INNER JOIN $courseUserSession cu |
@@ -3097,7 +3097,7 @@ discard block |
||
| 3097 | 3097 | $courseCondition = " |
| 3098 | 3098 | INNER JOIN $courseUser cu |
| 3099 | 3099 | ON cu.c_id = c.id AND cu.user_id = exe_user_id"; |
| 3100 | - $courseConditionWhere = " AND relation_type <> 2 AND cu.status = " . STUDENT; |
|
| 3100 | + $courseConditionWhere = " AND relation_type <> 2 AND cu.status = ".STUDENT; |
|
| 3101 | 3101 | } else { |
| 3102 | 3102 | $courseCondition = " |
| 3103 | 3103 | INNER JOIN $courseUserSession cu |
@@ -3190,7 +3190,7 @@ discard block |
||
| 3190 | 3190 | $courseCondition = " |
| 3191 | 3191 | INNER JOIN $courseUser cu |
| 3192 | 3192 | ON cu.c_id = c.id AND cu.user_id = exe_user_id"; |
| 3193 | - $courseConditionWhere = " AND relation_type <> 2 AND cu.status = " . STUDENT; |
|
| 3193 | + $courseConditionWhere = " AND relation_type <> 2 AND cu.status = ".STUDENT; |
|
| 3194 | 3194 | } else { |
| 3195 | 3195 | $courseCondition = " |
| 3196 | 3196 | INNER JOIN $courseUserSession cu |
@@ -3372,7 +3372,7 @@ discard block |
||
| 3372 | 3372 | } |
| 3373 | 3373 | } |
| 3374 | 3374 | // adds the correct word, followed by ] to close the blank |
| 3375 | - $answer .= ' / <font color="green"><b>' . $real_correct_tags[$i] . '</b></font>]'; |
|
| 3375 | + $answer .= ' / <font color="green"><b>'.$real_correct_tags[$i].'</b></font>]'; |
|
| 3376 | 3376 | if (isset ($real_text[$i + 1])) { |
| 3377 | 3377 | $answer .= $real_text[$i + 1]; |
| 3378 | 3378 | } |
@@ -3432,13 +3432,13 @@ discard block |
||
| 3432 | 3432 | // check the default value of option |
| 3433 | 3433 | $tabSelected = array($in_default => " selected='selected' "); |
| 3434 | 3434 | $res = ""; |
| 3435 | - $res .= "<select name='$in_name' id='$in_name' onchange='" . $in_onchange . "' >"; |
|
| 3436 | - $res .= "<option value='-1'" . $tabSelected["-1"] . ">-- " . get_lang( |
|
| 3435 | + $res .= "<select name='$in_name' id='$in_name' onchange='".$in_onchange."' >"; |
|
| 3436 | + $res .= "<option value='-1'".$tabSelected["-1"].">-- ".get_lang( |
|
| 3437 | 3437 | 'AllGroups' |
| 3438 | - ) . " --</option>"; |
|
| 3439 | - $res .= "<option value='0'" . $tabSelected["0"] . ">- " . get_lang( |
|
| 3438 | + )." --</option>"; |
|
| 3439 | + $res .= "<option value='0'".$tabSelected["0"].">- ".get_lang( |
|
| 3440 | 3440 | 'NotInAGroup' |
| 3441 | - ) . " -</option>"; |
|
| 3441 | + )." -</option>"; |
|
| 3442 | 3442 | $tabGroups = GroupManager::get_group_list(); |
| 3443 | 3443 | $currentCatId = 0; |
| 3444 | 3444 | for ($i = 0; $i < count($tabGroups); $i++) { |
@@ -3446,10 +3446,10 @@ discard block |
||
| 3446 | 3446 | $tabGroups[$i]["id"] |
| 3447 | 3447 | ); |
| 3448 | 3448 | if ($tabCategory["id"] != $currentCatId) { |
| 3449 | - $res .= "<option value='-1' disabled='disabled'>" . $tabCategory["title"] . "</option>"; |
|
| 3449 | + $res .= "<option value='-1' disabled='disabled'>".$tabCategory["title"]."</option>"; |
|
| 3450 | 3450 | $currentCatId = $tabCategory["id"]; |
| 3451 | 3451 | } |
| 3452 | - $res .= "<option " . $tabSelected[$tabGroups[$i]["id"]] . "style='margin-left:40px' value='" . $tabGroups[$i]["id"] . "'>" . $tabGroups[$i]["name"] . "</option>"; |
|
| 3452 | + $res .= "<option ".$tabSelected[$tabGroups[$i]["id"]]."style='margin-left:40px' value='".$tabGroups[$i]["id"]."'>".$tabGroups[$i]["name"]."</option>"; |
|
| 3453 | 3453 | } |
| 3454 | 3454 | $res .= "</select>"; |
| 3455 | 3455 | return $res; |
@@ -3684,14 +3684,14 @@ discard block |
||
| 3684 | 3684 | if ($show_results) { |
| 3685 | 3685 | $comnt = Event::get_comments($exe_id, $questionId); |
| 3686 | 3686 | if (!empty($comnt)) { |
| 3687 | - echo '<b>' . get_lang('Feedback') . '</b>'; |
|
| 3688 | - echo '<div id="question_feedback">' . $comnt . '</div>'; |
|
| 3687 | + echo '<b>'.get_lang('Feedback').'</b>'; |
|
| 3688 | + echo '<div id="question_feedback">'.$comnt.'</div>'; |
|
| 3689 | 3689 | } |
| 3690 | 3690 | } |
| 3691 | 3691 | |
| 3692 | 3692 | if ($show_results) { |
| 3693 | 3693 | $score = array( |
| 3694 | - 'result' => get_lang('Score') . " : " . self::show_score( |
|
| 3694 | + 'result' => get_lang('Score')." : ".self::show_score( |
|
| 3695 | 3695 | $my_total_score, |
| 3696 | 3696 | $my_total_weight, |
| 3697 | 3697 | false, |
@@ -3759,9 +3759,9 @@ discard block |
||
| 3759 | 3759 | } |
| 3760 | 3760 | |
| 3761 | 3761 | if ($show_all_but_expected_answer) { |
| 3762 | - $exercise_content .= "<div class='normal-message'>" . get_lang( |
|
| 3762 | + $exercise_content .= "<div class='normal-message'>".get_lang( |
|
| 3763 | 3763 | "ExerciseWithFeedbackWithoutCorrectionComment" |
| 3764 | - ) . "</div>"; |
|
| 3764 | + )."</div>"; |
|
| 3765 | 3765 | } |
| 3766 | 3766 | // Remove audio auto play from questions on results page - refs BT#7939 |
| 3767 | 3767 | $exercise_content = preg_replace( |
@@ -3861,11 +3861,11 @@ discard block |
||
| 3861 | 3861 | $ribbon_total_success_or_error = ' ribbon-total-error'; |
| 3862 | 3862 | } |
| 3863 | 3863 | } |
| 3864 | - $ribbon .= '<div class="total ' . $ribbon_total_success_or_error . '">'; |
|
| 3864 | + $ribbon .= '<div class="total '.$ribbon_total_success_or_error.'">'; |
|
| 3865 | 3865 | } else { |
| 3866 | 3866 | $ribbon .= '<div class="total">'; |
| 3867 | 3867 | } |
| 3868 | - $ribbon .= '<h3>' . get_lang('YourTotalScore') . ": "; |
|
| 3868 | + $ribbon .= '<h3>'.get_lang('YourTotalScore').": "; |
|
| 3869 | 3869 | $ribbon .= self::show_score($score, $weight, false, true); |
| 3870 | 3870 | $ribbon .= '</h3>'; |
| 3871 | 3871 | $ribbon .= '</div>'; |
@@ -9,7 +9,6 @@ |
||
| 9 | 9 | { |
| 10 | 10 | /** |
| 11 | 11 | * @param $value array Uploaded file info (from $_FILES) |
| 12 | - * @param null $options |
|
| 13 | 12 | * @return bool |
| 14 | 13 | */ |
| 15 | 14 | public function validate($elementValue, $maxSize) |
@@ -7,22 +7,22 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class HTML_QuickForm_Rule_MaxFileSize extends HTML_QuickForm_Rule |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * @param $value array Uploaded file info (from $_FILES) |
|
| 12 | - * @param null $options |
|
| 13 | - * @return bool |
|
| 14 | - */ |
|
| 15 | - public function validate($elementValue, $maxSize) |
|
| 16 | - { |
|
| 17 | - if (!empty($elementValue['error']) && |
|
| 18 | - (UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error']) |
|
| 19 | - ) { |
|
| 20 | - return false; |
|
| 21 | - } |
|
| 22 | - if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { |
|
| 23 | - return true; |
|
| 24 | - } |
|
| 10 | + /** |
|
| 11 | + * @param $value array Uploaded file info (from $_FILES) |
|
| 12 | + * @param null $options |
|
| 13 | + * @return bool |
|
| 14 | + */ |
|
| 15 | + public function validate($elementValue, $maxSize) |
|
| 16 | + { |
|
| 17 | + if (!empty($elementValue['error']) && |
|
| 18 | + (UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error']) |
|
| 19 | + ) { |
|
| 20 | + return false; |
|
| 21 | + } |
|
| 22 | + if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { |
|
| 23 | + return true; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - return ($maxSize >= @filesize($elementValue['tmp_name'])); |
|
| 27 | - } |
|
| 26 | + return ($maxSize >= @filesize($elementValue['tmp_name'])); |
|
| 27 | + } |
|
| 28 | 28 | } |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | * |
| 17 | 17 | * @param string Mobile phone number to be validated |
| 18 | 18 | * @param string Not using it. Just to respect the declaration |
| 19 | - * @return boolean Returns true if valid, false otherwise. |
|
| 19 | + * @return integer Returns true if valid, false otherwise. |
|
| 20 | 20 | */ |
| 21 | 21 | function validate($mobilePhoneNumber, $options = null) |
| 22 | 22 | { |
@@ -456,6 +456,10 @@ discard block |
||
| 456 | 456 | |
| 457 | 457 | |
| 458 | 458 | // Add warning(s) to $this->warnings[] |
| 459 | + |
|
| 460 | + /** |
|
| 461 | + * @param string $message |
|
| 462 | + */ |
|
| 459 | 463 | public function warning($message) { |
| 460 | 464 | |
| 461 | 465 | if (is_array($message)) { |
@@ -482,6 +486,11 @@ discard block |
||
| 482 | 486 | |
| 483 | 487 | |
| 484 | 488 | // Convert string between charsets -- iconv() wrapper |
| 489 | + |
|
| 490 | + /** |
|
| 491 | + * @param string $out_charset |
|
| 492 | + * @param string $string |
|
| 493 | + */ |
|
| 485 | 494 | public function iconv($in_charset, $out_charset, $string, $drop01 = false) { |
| 486 | 495 | |
| 487 | 496 | if ($drop01 && ($string === "\x00" || $string === "\x01")) { |
@@ -509,6 +518,9 @@ discard block |
||
| 509 | 518 | |
| 510 | 519 | |
| 511 | 520 | |
| 521 | + /** |
|
| 522 | + * @param string $name |
|
| 523 | + */ |
|
| 512 | 524 | public function include_module($name) { |
| 513 | 525 | |
| 514 | 526 | if (!file_exists($this->include_path.'module.'.$name.'.php')) { |
@@ -1342,6 +1354,10 @@ discard block |
||
| 1342 | 1354 | |
| 1343 | 1355 | |
| 1344 | 1356 | // Convert Big Endian byte string to int - max 32 bits |
| 1357 | + |
|
| 1358 | + /** |
|
| 1359 | + * @param string $byte_word |
|
| 1360 | + */ |
|
| 1345 | 1361 | public static function BigEndian2Int($byte_word, $signed = false) { |
| 1346 | 1362 | |
| 1347 | 1363 | $int_value = 0; |
@@ -1391,6 +1407,9 @@ discard block |
||
| 1391 | 1407 | |
| 1392 | 1408 | |
| 1393 | 1409 | |
| 1410 | + /** |
|
| 1411 | + * @param string $byte_word |
|
| 1412 | + */ |
|
| 1394 | 1413 | public static function BigEndian2Float($byte_word) { |
| 1395 | 1414 | |
| 1396 | 1415 | // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic |
@@ -1478,6 +1497,9 @@ discard block |
||
| 1478 | 1497 | |
| 1479 | 1498 | |
| 1480 | 1499 | |
| 1500 | + /** |
|
| 1501 | + * @param string $binary_numerator |
|
| 1502 | + */ |
|
| 1481 | 1503 | public static function DecimalBinary2Float($binary_numerator) { |
| 1482 | 1504 | $numerator = bindec($binary_numerator); |
| 1483 | 1505 | $denominator = bindec('1'.str_repeat('0', strlen($binary_numerator))); |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | $class = new $class_name($this); |
| 301 | 301 | |
| 302 | 302 | try { |
| 303 | - $this->option_analyze and $class->Analyze(); |
|
| 303 | + $this->option_analyze and $class->Analyze(); |
|
| 304 | 304 | } |
| 305 | 305 | catch (getid3_exception $e) { |
| 306 | 306 | throw $e; |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | // CalculateReplayGain() { |
| 384 | 384 | if (@$this->info['replay_gain']) { |
| 385 | 385 | if (!@$this->info['replay_gain']['reference_volume']) { |
| 386 | - $this->info['replay_gain']['reference_volume'] = 89; |
|
| 386 | + $this->info['replay_gain']['reference_volume'] = 89; |
|
| 387 | 387 | } |
| 388 | 388 | if (isset($this->info['replay_gain']['track']['adjustment'])) { |
| 389 | 389 | $this->info['replay_gain']['track']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['track']['adjustment']; |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | |
| 404 | 404 | // ProcessAudioStreams() { |
| 405 | 405 | if (@!$this->info['audio']['streams'] && (@$this->info['audio']['bitrate'] || @$this->info['audio']['channels'] || @$this->info['audio']['sample_rate'])) { |
| 406 | - foreach ($this->info['audio'] as $key => $value) { |
|
| 406 | + foreach ($this->info['audio'] as $key => $value) { |
|
| 407 | 407 | if ($key != 'streams') { |
| 408 | 408 | $this->info['audio']['streams'][0][$key] = $value; |
| 409 | 409 | } |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | 'group' => 'audio', |
| 545 | 545 | 'module' => 'ac3', |
| 546 | 546 | 'mime_type' => 'audio/ac3', |
| 547 | - ), |
|
| 547 | + ), |
|
| 548 | 548 | |
| 549 | 549 | // AAC - audio - Advanced Audio Coding (AAC) - ADIF format |
| 550 | 550 | 'adif' => array ( |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | 'module' => 'aac_adif', |
| 554 | 554 | 'mime_type' => 'application/octet-stream', |
| 555 | 555 | 'fail_ape' => 'WARNING', |
| 556 | - ), |
|
| 556 | + ), |
|
| 557 | 557 | |
| 558 | 558 | |
| 559 | 559 | // AAC - audio - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3) |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | 'module' => 'aac_adts', |
| 564 | 564 | 'mime_type' => 'application/octet-stream', |
| 565 | 565 | 'fail_ape' => 'WARNING', |
| 566 | - ), |
|
| 566 | + ), |
|
| 567 | 567 | |
| 568 | 568 | |
| 569 | 569 | // AU - audio - NeXT/Sun AUdio (AU) |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | 'group' => 'audio', |
| 573 | 573 | 'module' => 'au', |
| 574 | 574 | 'mime_type' => 'audio/basic', |
| 575 | - ), |
|
| 575 | + ), |
|
| 576 | 576 | |
| 577 | 577 | // AVR - audio - Audio Visual Research |
| 578 | 578 | 'avr' => array ( |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | 'group' => 'audio', |
| 581 | 581 | 'module' => 'avr', |
| 582 | 582 | 'mime_type' => 'application/octet-stream', |
| 583 | - ), |
|
| 583 | + ), |
|
| 584 | 584 | |
| 585 | 585 | // BONK - audio - Bonk v0.9+ |
| 586 | 586 | 'bonk' => array ( |
@@ -588,15 +588,15 @@ discard block |
||
| 588 | 588 | 'group' => 'audio', |
| 589 | 589 | 'module' => 'bonk', |
| 590 | 590 | 'mime_type' => 'audio/xmms-bonk', |
| 591 | - ), |
|
| 591 | + ), |
|
| 592 | 592 | |
| 593 | 593 | // DTS - audio - Dolby Theatre System |
| 594 | - 'dts' => array( |
|
| 595 | - 'pattern' => '^\x7F\xFE\x80\x01', |
|
| 596 | - 'group' => 'audio', |
|
| 597 | - 'module' => 'dts', |
|
| 598 | - 'mime_type' => 'audio/dts', |
|
| 599 | - ), |
|
| 594 | + 'dts' => array( |
|
| 595 | + 'pattern' => '^\x7F\xFE\x80\x01', |
|
| 596 | + 'group' => 'audio', |
|
| 597 | + 'module' => 'dts', |
|
| 598 | + 'mime_type' => 'audio/dts', |
|
| 599 | + ), |
|
| 600 | 600 | |
| 601 | 601 | // FLAC - audio - Free Lossless Audio Codec |
| 602 | 602 | 'flac' => array ( |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | 'group' => 'audio', |
| 605 | 605 | 'module' => 'xiph', |
| 606 | 606 | 'mime_type' => 'audio/x-flac', |
| 607 | - ), |
|
| 607 | + ), |
|
| 608 | 608 | |
| 609 | 609 | // LA - audio - Lossless Audio (LA) |
| 610 | 610 | 'la' => array ( |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | 'group' => 'audio', |
| 613 | 613 | 'module' => 'la', |
| 614 | 614 | 'mime_type' => 'application/octet-stream', |
| 615 | - ), |
|
| 615 | + ), |
|
| 616 | 616 | |
| 617 | 617 | // LPAC - audio - Lossless Predictive Audio Compression (LPAC) |
| 618 | 618 | 'lpac' => array ( |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | 'group' => 'audio', |
| 621 | 621 | 'module' => 'lpac', |
| 622 | 622 | 'mime_type' => 'application/octet-stream', |
| 623 | - ), |
|
| 623 | + ), |
|
| 624 | 624 | |
| 625 | 625 | // MIDI - audio - MIDI (Musical Instrument Digital Interface) |
| 626 | 626 | 'midi' => array ( |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | 'group' => 'audio', |
| 629 | 629 | 'module' => 'midi', |
| 630 | 630 | 'mime_type' => 'audio/midi', |
| 631 | - ), |
|
| 631 | + ), |
|
| 632 | 632 | |
| 633 | 633 | // MAC - audio - Monkey's Audio Compressor |
| 634 | 634 | 'mac' => array ( |
@@ -636,31 +636,31 @@ discard block |
||
| 636 | 636 | 'group' => 'audio', |
| 637 | 637 | 'module' => 'monkey', |
| 638 | 638 | 'mime_type' => 'application/octet-stream', |
| 639 | - ), |
|
| 639 | + ), |
|
| 640 | 640 | |
| 641 | 641 | // MOD - audio - MODule (assorted sub-formats) |
| 642 | 642 | 'mod' => array ( |
| 643 | 643 | 'pattern' => '^.{1080}(M.K.|[5-9]CHN|[1-3][0-9]CH)', |
| 644 | 644 | 'mime_type' => 'audio/mod', |
| 645 | - ), |
|
| 645 | + ), |
|
| 646 | 646 | |
| 647 | 647 | // MOD - audio - MODule (Impulse Tracker) |
| 648 | 648 | 'it' => array ( |
| 649 | 649 | 'pattern' => '^IMPM', |
| 650 | 650 | 'mime_type' => 'audio/it', |
| 651 | - ), |
|
| 651 | + ), |
|
| 652 | 652 | |
| 653 | 653 | // MOD - audio - MODule (eXtended Module, various sub-formats) |
| 654 | 654 | 'xm' => array ( |
| 655 | 655 | 'pattern' => '^Extended Module', |
| 656 | 656 | 'mime_type' => 'audio/xm', |
| 657 | - ), |
|
| 657 | + ), |
|
| 658 | 658 | |
| 659 | 659 | // MOD - audio - MODule (ScreamTracker) |
| 660 | 660 | 's3m' => array ( |
| 661 | 661 | 'pattern' => '^.{44}SCRM', |
| 662 | 662 | 'mime_type' => 'audio/s3m', |
| 663 | - ), |
|
| 663 | + ), |
|
| 664 | 664 | |
| 665 | 665 | // MPC - audio - Musepack / MPEGplus SV7+ |
| 666 | 666 | 'mpc' => array ( |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | 'group' => 'audio', |
| 669 | 669 | 'module' => 'mpc', |
| 670 | 670 | 'mime_type' => 'audio/x-musepack', |
| 671 | - ), |
|
| 671 | + ), |
|
| 672 | 672 | |
| 673 | 673 | // MPC - audio - Musepack / MPEGplus SV4-6 |
| 674 | 674 | 'mpc_old' => array ( |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | 'group' => 'audio', |
| 677 | 677 | 'module' => 'mpc_old', |
| 678 | 678 | 'mime_type' => 'application/octet-stream', |
| 679 | - ), |
|
| 679 | + ), |
|
| 680 | 680 | |
| 681 | 681 | |
| 682 | 682 | // MP3 - audio - MPEG-audio Layer 3 (very similar to AAC-ADTS) |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | 'group' => 'audio', |
| 686 | 686 | 'module' => 'mp3', |
| 687 | 687 | 'mime_type' => 'audio/mpeg', |
| 688 | - ), |
|
| 688 | + ), |
|
| 689 | 689 | |
| 690 | 690 | // OFR - audio - OptimFROG |
| 691 | 691 | 'ofr' => array ( |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | 'group' => 'audio', |
| 694 | 694 | 'module' => 'optimfrog', |
| 695 | 695 | 'mime_type' => 'application/octet-stream', |
| 696 | - ), |
|
| 696 | + ), |
|
| 697 | 697 | |
| 698 | 698 | // RKAU - audio - RKive AUdio compressor |
| 699 | 699 | 'rkau' => array ( |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | 'group' => 'audio', |
| 702 | 702 | 'module' => 'rkau', |
| 703 | 703 | 'mime_type' => 'application/octet-stream', |
| 704 | - ), |
|
| 704 | + ), |
|
| 705 | 705 | |
| 706 | 706 | // SHN - audio - Shorten |
| 707 | 707 | 'shn' => array ( |
@@ -711,7 +711,7 @@ discard block |
||
| 711 | 711 | 'mime_type' => 'audio/xmms-shn', |
| 712 | 712 | 'fail_id3' => 'ERROR', |
| 713 | 713 | 'fail_ape' => 'ERROR', |
| 714 | - ), |
|
| 714 | + ), |
|
| 715 | 715 | |
| 716 | 716 | // TTA - audio - TTA Lossless Audio Compressor (http://tta.corecodec.org) |
| 717 | 717 | 'tta' => array ( |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | 'group' => 'audio', |
| 720 | 720 | 'module' => 'tta', |
| 721 | 721 | 'mime_type' => 'application/octet-stream', |
| 722 | - ), |
|
| 722 | + ), |
|
| 723 | 723 | |
| 724 | 724 | // VOC - audio - Creative Voice (VOC) |
| 725 | 725 | 'voc' => array ( |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | 'group' => 'audio', |
| 728 | 728 | 'module' => 'voc', |
| 729 | 729 | 'mime_type' => 'audio/voc', |
| 730 | - ), |
|
| 730 | + ), |
|
| 731 | 731 | |
| 732 | 732 | // VQF - audio - transform-domain weighted interleave Vector Quantization Format (VQF) |
| 733 | 733 | 'vqf' => array ( |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | 'group' => 'audio', |
| 736 | 736 | 'module' => 'vqf', |
| 737 | 737 | 'mime_type' => 'application/octet-stream', |
| 738 | - ), |
|
| 738 | + ), |
|
| 739 | 739 | |
| 740 | 740 | // WV - audio - WavPack (v4.0+) |
| 741 | 741 | 'vw' => array( |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | 'group' => 'audio', |
| 744 | 744 | 'module' => 'wavpack', |
| 745 | 745 | 'mime_type' => 'application/octet-stream', |
| 746 | - ), |
|
| 746 | + ), |
|
| 747 | 747 | |
| 748 | 748 | |
| 749 | 749 | // Audio-Video formats |
@@ -754,13 +754,13 @@ discard block |
||
| 754 | 754 | 'group' => 'audio-video', |
| 755 | 755 | 'module' => 'asf', |
| 756 | 756 | 'mime_type' => 'video/x-ms-asf', |
| 757 | - ), |
|
| 757 | + ), |
|
| 758 | 758 | |
| 759 | 759 | // BINK - audio/video - Bink / Smacker |
| 760 | 760 | 'bink' => array( |
| 761 | 761 | 'pattern' => '^(BIK|SMK)', |
| 762 | 762 | 'mime_type' => 'application/octet-stream', |
| 763 | - ), |
|
| 763 | + ), |
|
| 764 | 764 | |
| 765 | 765 | // FLV - audio/video - FLash Video |
| 766 | 766 | 'flv' => array( |
@@ -768,13 +768,13 @@ discard block |
||
| 768 | 768 | 'group' => 'audio-video', |
| 769 | 769 | 'module' => 'flv', |
| 770 | 770 | 'mime_type' => 'video/x-flv', |
| 771 | - ), |
|
| 771 | + ), |
|
| 772 | 772 | |
| 773 | 773 | // MKAV - audio/video - Mastroka |
| 774 | 774 | 'matroska' => array ( |
| 775 | 775 | 'pattern' => '^\x1A\x45\xDF\xA3', |
| 776 | 776 | 'mime_type' => 'application/octet-stream', |
| 777 | - ), |
|
| 777 | + ), |
|
| 778 | 778 | |
| 779 | 779 | // MPEG - audio/video - MPEG (Moving Pictures Experts Group) |
| 780 | 780 | 'mpeg' => array ( |
@@ -782,7 +782,7 @@ discard block |
||
| 782 | 782 | 'group' => 'audio-video', |
| 783 | 783 | 'module' => 'mpeg', |
| 784 | 784 | 'mime_type' => 'video/mpeg', |
| 785 | - ), |
|
| 785 | + ), |
|
| 786 | 786 | |
| 787 | 787 | // NSV - audio/video - Nullsoft Streaming Video (NSV) |
| 788 | 788 | 'nsv' => array ( |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | 'group' => 'audio-video', |
| 791 | 791 | 'module' => 'nsv', |
| 792 | 792 | 'mime_type' => 'application/octet-stream', |
| 793 | - ), |
|
| 793 | + ), |
|
| 794 | 794 | |
| 795 | 795 | // Ogg - audio/video - Ogg (Ogg Vorbis, OggFLAC, Speex, Ogg Theora(*), Ogg Tarkin(*)) |
| 796 | 796 | 'ogg' => array ( |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | 'mime_type' => 'application/ogg', |
| 801 | 801 | 'fail_id3' => 'WARNING', |
| 802 | 802 | 'fail_ape' => 'WARNING', |
| 803 | - ), |
|
| 803 | + ), |
|
| 804 | 804 | |
| 805 | 805 | // QT - audio/video - Quicktime |
| 806 | 806 | 'quicktime' => array ( |
@@ -808,7 +808,7 @@ discard block |
||
| 808 | 808 | 'group' => 'audio-video', |
| 809 | 809 | 'module' => 'quicktime', |
| 810 | 810 | 'mime_type' => 'video/quicktime', |
| 811 | - ), |
|
| 811 | + ), |
|
| 812 | 812 | |
| 813 | 813 | // RIFF - audio/video - Resource Interchange File Format (RIFF) / WAV / AVI / CD-audio / SDSS = renamed variant used by SmartSound QuickTracks (www.smartsound.com) / FORM = Audio Interchange File Format (AIFF) |
| 814 | 814 | 'riff' => array ( |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | 'module' => 'riff', |
| 818 | 818 | 'mime_type' => 'audio/x-wave', |
| 819 | 819 | 'fail_ape' => 'WARNING', |
| 820 | - ), |
|
| 820 | + ), |
|
| 821 | 821 | |
| 822 | 822 | // Real - audio/video - RealAudio, RealVideo |
| 823 | 823 | 'real' => array ( |
@@ -825,7 +825,7 @@ discard block |
||
| 825 | 825 | 'group' => 'audio-video', |
| 826 | 826 | 'module' => 'real', |
| 827 | 827 | 'mime_type' => 'audio/x-realaudio', |
| 828 | - ), |
|
| 828 | + ), |
|
| 829 | 829 | |
| 830 | 830 | // SWF - audio/video - ShockWave Flash |
| 831 | 831 | 'swf' => array ( |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | 'group' => 'audio-video', |
| 834 | 834 | 'module' => 'swf', |
| 835 | 835 | 'mime_type' => 'application/x-shockwave-flash', |
| 836 | - ), |
|
| 836 | + ), |
|
| 837 | 837 | |
| 838 | 838 | |
| 839 | 839 | // Still-Image formats |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | 'mime_type' => 'image/bmp', |
| 847 | 847 | 'fail_id3' => 'ERROR', |
| 848 | 848 | 'fail_ape' => 'ERROR', |
| 849 | - ), |
|
| 849 | + ), |
|
| 850 | 850 | |
| 851 | 851 | // GIF - still image - Graphics Interchange Format |
| 852 | 852 | 'gif' => array ( |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | 'mime_type' => 'image/gif', |
| 857 | 857 | 'fail_id3' => 'ERROR', |
| 858 | 858 | 'fail_ape' => 'ERROR', |
| 859 | - ), |
|
| 859 | + ), |
|
| 860 | 860 | |
| 861 | 861 | // JPEG - still image - Joint Photographic Experts Group (JPEG) |
| 862 | 862 | 'jpeg' => array ( |
@@ -866,7 +866,7 @@ discard block |
||
| 866 | 866 | 'mime_type' => 'image/jpeg', |
| 867 | 867 | 'fail_id3' => 'ERROR', |
| 868 | 868 | 'fail_ape' => 'ERROR', |
| 869 | - ), |
|
| 869 | + ), |
|
| 870 | 870 | |
| 871 | 871 | // PCD - still image - Kodak Photo CD |
| 872 | 872 | 'pcd' => array ( |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | 'mime_type' => 'image/x-photo-cd', |
| 877 | 877 | 'fail_id3' => 'ERROR', |
| 878 | 878 | 'fail_ape' => 'ERROR', |
| 879 | - ), |
|
| 879 | + ), |
|
| 880 | 880 | |
| 881 | 881 | |
| 882 | 882 | // PNG - still image - Portable Network Graphics (PNG) |
@@ -887,16 +887,16 @@ discard block |
||
| 887 | 887 | 'mime_type' => 'image/png', |
| 888 | 888 | 'fail_id3' => 'ERROR', |
| 889 | 889 | 'fail_ape' => 'ERROR', |
| 890 | - ), |
|
| 890 | + ), |
|
| 891 | 891 | |
| 892 | 892 | |
| 893 | 893 | // SVG - still image - Scalable Vector Graphics (SVG) |
| 894 | - 'svg' => array( |
|
| 895 | - 'pattern' => '<!DOCTYPE svg PUBLIC ', |
|
| 896 | - 'mime_type' => 'image/svg+xml', |
|
| 897 | - 'fail_id3' => 'ERROR', |
|
| 898 | - 'fail_ape' => 'ERROR', |
|
| 899 | - ), |
|
| 894 | + 'svg' => array( |
|
| 895 | + 'pattern' => '<!DOCTYPE svg PUBLIC ', |
|
| 896 | + 'mime_type' => 'image/svg+xml', |
|
| 897 | + 'fail_id3' => 'ERROR', |
|
| 898 | + 'fail_ape' => 'ERROR', |
|
| 899 | + ), |
|
| 900 | 900 | |
| 901 | 901 | |
| 902 | 902 | // TIFF - still image - Tagged Information File Format (TIFF) |
@@ -907,7 +907,7 @@ discard block |
||
| 907 | 907 | 'mime_type' => 'image/tiff', |
| 908 | 908 | 'fail_id3' => 'ERROR', |
| 909 | 909 | 'fail_ape' => 'ERROR', |
| 910 | - ), |
|
| 910 | + ), |
|
| 911 | 911 | |
| 912 | 912 | |
| 913 | 913 | // Data formats |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | 'mime_type' => 'application/octet-stream', |
| 918 | 918 | 'fail_id3' => 'ERROR', |
| 919 | 919 | 'fail_ape' => 'ERROR', |
| 920 | - ), |
|
| 920 | + ), |
|
| 921 | 921 | |
| 922 | 922 | // ISO - data - International Standards Organization (ISO) CD-ROM Image |
| 923 | 923 | 'iso' => array ( |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | 'mime_type' => 'application/octet-stream', |
| 928 | 928 | 'fail_id3' => 'ERROR', |
| 929 | 929 | 'fail_ape' => 'ERROR', |
| 930 | - ), |
|
| 930 | + ), |
|
| 931 | 931 | |
| 932 | 932 | // RAR - data - RAR compressed data |
| 933 | 933 | 'rar' => array( |
@@ -935,7 +935,7 @@ discard block |
||
| 935 | 935 | 'mime_type' => 'application/octet-stream', |
| 936 | 936 | 'fail_id3' => 'ERROR', |
| 937 | 937 | 'fail_ape' => 'ERROR', |
| 938 | - ), |
|
| 938 | + ), |
|
| 939 | 939 | |
| 940 | 940 | // SZIP - audio - SZIP compressed data |
| 941 | 941 | 'szip' => array ( |
@@ -945,7 +945,7 @@ discard block |
||
| 945 | 945 | 'mime_type' => 'application/octet-stream', |
| 946 | 946 | 'fail_id3' => 'ERROR', |
| 947 | 947 | 'fail_ape' => 'ERROR', |
| 948 | - ), |
|
| 948 | + ), |
|
| 949 | 949 | |
| 950 | 950 | // TAR - data - TAR compressed data |
| 951 | 951 | 'tar' => array( |
@@ -955,7 +955,7 @@ discard block |
||
| 955 | 955 | 'mime_type' => 'application/x-tar', |
| 956 | 956 | 'fail_id3' => 'ERROR', |
| 957 | 957 | 'fail_ape' => 'ERROR', |
| 958 | - ), |
|
| 958 | + ), |
|
| 959 | 959 | |
| 960 | 960 | // GZIP - data - GZIP compressed data |
| 961 | 961 | 'gz' => array( |
@@ -965,7 +965,7 @@ discard block |
||
| 965 | 965 | 'mime_type' => 'application/x-gzip', |
| 966 | 966 | 'fail_id3' => 'ERROR', |
| 967 | 967 | 'fail_ape' => 'ERROR', |
| 968 | - ), |
|
| 968 | + ), |
|
| 969 | 969 | |
| 970 | 970 | |
| 971 | 971 | // ZIP - data - ZIP compressed data |
@@ -976,33 +976,33 @@ discard block |
||
| 976 | 976 | 'mime_type' => 'application/zip', |
| 977 | 977 | 'fail_id3' => 'ERROR', |
| 978 | 978 | 'fail_ape' => 'ERROR', |
| 979 | - ), |
|
| 979 | + ), |
|
| 980 | 980 | |
| 981 | 981 | |
| 982 | 982 | // PAR2 - data - Parity Volume Set Specification 2.0 |
| 983 | 983 | 'par2' => array ( |
| 984 | - 'pattern' => '^PAR2\x00PKT', |
|
| 985 | - 'mime_type' => 'application/octet-stream', |
|
| 986 | - 'fail_id3' => 'ERROR', |
|
| 987 | - 'fail_ape' => 'ERROR', |
|
| 988 | - ), |
|
| 984 | + 'pattern' => '^PAR2\x00PKT', |
|
| 985 | + 'mime_type' => 'application/octet-stream', |
|
| 986 | + 'fail_id3' => 'ERROR', |
|
| 987 | + 'fail_ape' => 'ERROR', |
|
| 988 | + ), |
|
| 989 | 989 | |
| 990 | 990 | |
| 991 | - // PDF - data - Portable Document Format |
|
| 992 | - 'pdf' => array( |
|
| 991 | + // PDF - data - Portable Document Format |
|
| 992 | + 'pdf' => array( |
|
| 993 | 993 | 'pattern' => '^\x25PDF', |
| 994 | 994 | 'mime_type' => 'application/pdf', |
| 995 | 995 | 'fail_id3' => 'ERROR', |
| 996 | 996 | 'fail_ape' => 'ERROR', |
| 997 | - ), |
|
| 997 | + ), |
|
| 998 | 998 | |
| 999 | - // DOC - data - Microsoft Word |
|
| 1000 | - 'msoffice' => array( |
|
| 999 | + // DOC - data - Microsoft Word |
|
| 1000 | + 'msoffice' => array( |
|
| 1001 | 1001 | 'pattern' => '^\xD0\xCF\x11\xE0', // D0CF11E == DOCFILE == Microsoft Office Document |
| 1002 | 1002 | 'mime_type' => 'application/octet-stream', |
| 1003 | 1003 | 'fail_id3' => 'ERROR', |
| 1004 | 1004 | 'fail_ape' => 'ERROR', |
| 1005 | - ), |
|
| 1005 | + ), |
|
| 1006 | 1006 | ); |
| 1007 | 1007 | |
| 1008 | 1008 | return $format_info; |
@@ -1393,99 +1393,99 @@ discard block |
||
| 1393 | 1393 | |
| 1394 | 1394 | public static function BigEndian2Float($byte_word) { |
| 1395 | 1395 | |
| 1396 | - // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic |
|
| 1397 | - // http://www.psc.edu/general/software/packages/ieee/ieee.html |
|
| 1398 | - // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html |
|
| 1396 | + // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic |
|
| 1397 | + // http://www.psc.edu/general/software/packages/ieee/ieee.html |
|
| 1398 | + // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html |
|
| 1399 | 1399 | |
| 1400 | - $bit_word = getid3_lib::BigEndian2Bin($byte_word); |
|
| 1401 | - if (!$bit_word) { |
|
| 1400 | + $bit_word = getid3_lib::BigEndian2Bin($byte_word); |
|
| 1401 | + if (!$bit_word) { |
|
| 1402 | 1402 | return 0; |
| 1403 | 1403 | } |
| 1404 | - $sign_bit = $bit_word{0}; |
|
| 1405 | - |
|
| 1406 | - switch (strlen($byte_word) * 8) { |
|
| 1407 | - case 32: |
|
| 1408 | - $exponent_bits = 8; |
|
| 1409 | - $fraction_bits = 23; |
|
| 1410 | - break; |
|
| 1411 | - |
|
| 1412 | - case 64: |
|
| 1413 | - $exponent_bits = 11; |
|
| 1414 | - $fraction_bits = 52; |
|
| 1415 | - break; |
|
| 1416 | - |
|
| 1417 | - case 80: |
|
| 1418 | - // 80-bit Apple SANE format |
|
| 1419 | - // http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/ |
|
| 1420 | - $exponent_string = substr($bit_word, 1, 15); |
|
| 1421 | - $is_normalized = intval($bit_word{16}); |
|
| 1422 | - $fraction_string = substr($bit_word, 17, 63); |
|
| 1423 | - $exponent = pow(2, getid3_lib::Bin2Dec($exponent_string) - 16383); |
|
| 1424 | - $fraction = $is_normalized + getid3_lib::DecimalBinary2Float($fraction_string); |
|
| 1425 | - $float_value = $exponent * $fraction; |
|
| 1426 | - if ($sign_bit == '1') { |
|
| 1427 | - $float_value *= -1; |
|
| 1428 | - } |
|
| 1429 | - return $float_value; |
|
| 1430 | - break; |
|
| 1431 | - |
|
| 1432 | - default: |
|
| 1433 | - return false; |
|
| 1434 | - break; |
|
| 1435 | - } |
|
| 1436 | - $exponent_string = substr($bit_word, 1, $exponent_bits); |
|
| 1437 | - $fraction_string = substr($bit_word, $exponent_bits + 1, $fraction_bits); |
|
| 1438 | - $exponent = bindec($exponent_string); |
|
| 1439 | - $fraction = bindec($fraction_string); |
|
| 1440 | - |
|
| 1441 | - if (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction != 0)) { |
|
| 1442 | - // Not a Number |
|
| 1443 | - $float_value = false; |
|
| 1444 | - } elseif (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction == 0)) { |
|
| 1445 | - if ($sign_bit == '1') { |
|
| 1446 | - $float_value = '-infinity'; |
|
| 1447 | - } else { |
|
| 1448 | - $float_value = '+infinity'; |
|
| 1449 | - } |
|
| 1450 | - } elseif (($exponent == 0) && ($fraction == 0)) { |
|
| 1451 | - if ($sign_bit == '1') { |
|
| 1452 | - $float_value = -0; |
|
| 1453 | - } else { |
|
| 1454 | - $float_value = 0; |
|
| 1455 | - } |
|
| 1456 | - $float_value = ($sign_bit ? 0 : -0); |
|
| 1457 | - } elseif (($exponent == 0) && ($fraction != 0)) { |
|
| 1458 | - // These are 'unnormalized' values |
|
| 1459 | - $float_value = pow(2, (-1 * (pow(2, $exponent_bits - 1) - 2))) * getid3_lib::DecimalBinary2Float($fraction_string); |
|
| 1460 | - if ($sign_bit == '1') { |
|
| 1461 | - $float_value *= -1; |
|
| 1462 | - } |
|
| 1463 | - } elseif ($exponent != 0) { |
|
| 1464 | - $float_value = pow(2, ($exponent - (pow(2, $exponent_bits - 1) - 1))) * (1 + getid3_lib::DecimalBinary2Float($fraction_string)); |
|
| 1465 | - if ($sign_bit == '1') { |
|
| 1466 | - $float_value *= -1; |
|
| 1467 | - } |
|
| 1468 | - } |
|
| 1469 | - return (float) $float_value; |
|
| 1470 | - } |
|
| 1471 | - |
|
| 1472 | - |
|
| 1473 | - |
|
| 1474 | - public static function LittleEndian2Float($byte_word) { |
|
| 1475 | - |
|
| 1476 | - return getid3_lib::BigEndian2Float(strrev($byte_word)); |
|
| 1477 | - } |
|
| 1478 | - |
|
| 1479 | - |
|
| 1480 | - |
|
| 1481 | - public static function DecimalBinary2Float($binary_numerator) { |
|
| 1482 | - $numerator = bindec($binary_numerator); |
|
| 1483 | - $denominator = bindec('1'.str_repeat('0', strlen($binary_numerator))); |
|
| 1484 | - return ($numerator / $denominator); |
|
| 1485 | - } |
|
| 1486 | - |
|
| 1487 | - |
|
| 1488 | - public static function PrintHexBytes($string, $hex=true, $spaces=true, $html_safe=true) { |
|
| 1404 | + $sign_bit = $bit_word{0}; |
|
| 1405 | + |
|
| 1406 | + switch (strlen($byte_word) * 8) { |
|
| 1407 | + case 32: |
|
| 1408 | + $exponent_bits = 8; |
|
| 1409 | + $fraction_bits = 23; |
|
| 1410 | + break; |
|
| 1411 | + |
|
| 1412 | + case 64: |
|
| 1413 | + $exponent_bits = 11; |
|
| 1414 | + $fraction_bits = 52; |
|
| 1415 | + break; |
|
| 1416 | + |
|
| 1417 | + case 80: |
|
| 1418 | + // 80-bit Apple SANE format |
|
| 1419 | + // http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/ |
|
| 1420 | + $exponent_string = substr($bit_word, 1, 15); |
|
| 1421 | + $is_normalized = intval($bit_word{16}); |
|
| 1422 | + $fraction_string = substr($bit_word, 17, 63); |
|
| 1423 | + $exponent = pow(2, getid3_lib::Bin2Dec($exponent_string) - 16383); |
|
| 1424 | + $fraction = $is_normalized + getid3_lib::DecimalBinary2Float($fraction_string); |
|
| 1425 | + $float_value = $exponent * $fraction; |
|
| 1426 | + if ($sign_bit == '1') { |
|
| 1427 | + $float_value *= -1; |
|
| 1428 | + } |
|
| 1429 | + return $float_value; |
|
| 1430 | + break; |
|
| 1431 | + |
|
| 1432 | + default: |
|
| 1433 | + return false; |
|
| 1434 | + break; |
|
| 1435 | + } |
|
| 1436 | + $exponent_string = substr($bit_word, 1, $exponent_bits); |
|
| 1437 | + $fraction_string = substr($bit_word, $exponent_bits + 1, $fraction_bits); |
|
| 1438 | + $exponent = bindec($exponent_string); |
|
| 1439 | + $fraction = bindec($fraction_string); |
|
| 1440 | + |
|
| 1441 | + if (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction != 0)) { |
|
| 1442 | + // Not a Number |
|
| 1443 | + $float_value = false; |
|
| 1444 | + } elseif (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction == 0)) { |
|
| 1445 | + if ($sign_bit == '1') { |
|
| 1446 | + $float_value = '-infinity'; |
|
| 1447 | + } else { |
|
| 1448 | + $float_value = '+infinity'; |
|
| 1449 | + } |
|
| 1450 | + } elseif (($exponent == 0) && ($fraction == 0)) { |
|
| 1451 | + if ($sign_bit == '1') { |
|
| 1452 | + $float_value = -0; |
|
| 1453 | + } else { |
|
| 1454 | + $float_value = 0; |
|
| 1455 | + } |
|
| 1456 | + $float_value = ($sign_bit ? 0 : -0); |
|
| 1457 | + } elseif (($exponent == 0) && ($fraction != 0)) { |
|
| 1458 | + // These are 'unnormalized' values |
|
| 1459 | + $float_value = pow(2, (-1 * (pow(2, $exponent_bits - 1) - 2))) * getid3_lib::DecimalBinary2Float($fraction_string); |
|
| 1460 | + if ($sign_bit == '1') { |
|
| 1461 | + $float_value *= -1; |
|
| 1462 | + } |
|
| 1463 | + } elseif ($exponent != 0) { |
|
| 1464 | + $float_value = pow(2, ($exponent - (pow(2, $exponent_bits - 1) - 1))) * (1 + getid3_lib::DecimalBinary2Float($fraction_string)); |
|
| 1465 | + if ($sign_bit == '1') { |
|
| 1466 | + $float_value *= -1; |
|
| 1467 | + } |
|
| 1468 | + } |
|
| 1469 | + return (float) $float_value; |
|
| 1470 | + } |
|
| 1471 | + |
|
| 1472 | + |
|
| 1473 | + |
|
| 1474 | + public static function LittleEndian2Float($byte_word) { |
|
| 1475 | + |
|
| 1476 | + return getid3_lib::BigEndian2Float(strrev($byte_word)); |
|
| 1477 | + } |
|
| 1478 | + |
|
| 1479 | + |
|
| 1480 | + |
|
| 1481 | + public static function DecimalBinary2Float($binary_numerator) { |
|
| 1482 | + $numerator = bindec($binary_numerator); |
|
| 1483 | + $denominator = bindec('1'.str_repeat('0', strlen($binary_numerator))); |
|
| 1484 | + return ($numerator / $denominator); |
|
| 1485 | + } |
|
| 1486 | + |
|
| 1487 | + |
|
| 1488 | + public static function PrintHexBytes($string, $hex=true, $spaces=true, $html_safe=true) { |
|
| 1489 | 1489 | |
| 1490 | 1490 | $return_string = ''; |
| 1491 | 1491 | for ($i = 0; $i < strlen($string); $i++) { |
@@ -27,42 +27,42 @@ discard block |
||
| 27 | 27 | //// Settings Section - do NOT modify this file - change setting after newing getid3! |
| 28 | 28 | |
| 29 | 29 | // Encoding |
| 30 | - public $encoding = 'ISO-8859-1'; // CASE SENSITIVE! - i.e. (must be supported by iconv() - see http://www.gnu.org/software/libiconv/). Examples: ISO-8859-1 UTF-8 UTF-16 UTF-16BE. |
|
| 31 | - public $encoding_id3v1 = 'ISO-8859-1'; // Override SPECIFICATION encoding for broken ID3v1 tags caused by bad tag programs. Examples: 'EUC-CN' for "Chinese MP3s" and 'CP1251' for "Cyrillic". |
|
| 32 | - public $encoding_id3v2 = 'ISO-8859-1'; // Override ISO-8859-1 encoding for broken ID3v2 tags caused by BRAINDEAD tag programs that writes system codepage as 'ISO-8859-1' instead of UTF-8. |
|
| 30 | + public $encoding = 'ISO-8859-1'; // CASE SENSITIVE! - i.e. (must be supported by iconv() - see http://www.gnu.org/software/libiconv/). Examples: ISO-8859-1 UTF-8 UTF-16 UTF-16BE. |
|
| 31 | + public $encoding_id3v1 = 'ISO-8859-1'; // Override SPECIFICATION encoding for broken ID3v1 tags caused by bad tag programs. Examples: 'EUC-CN' for "Chinese MP3s" and 'CP1251' for "Cyrillic". |
|
| 32 | + public $encoding_id3v2 = 'ISO-8859-1'; // Override ISO-8859-1 encoding for broken ID3v2 tags caused by BRAINDEAD tag programs that writes system codepage as 'ISO-8859-1' instead of UTF-8. |
|
| 33 | 33 | |
| 34 | 34 | // Tags - disable for speed |
| 35 | - public $option_tag_id3v1 = false; // Read and process ID3v1 tags. |
|
| 36 | - public $option_tag_id3v2 = false; // Read and process ID3v2 tags. |
|
| 37 | - public $option_tag_lyrics3 = false; // Read and process Lyrics3 tags. |
|
| 38 | - public $option_tag_apetag = false; // Read and process APE tags. |
|
| 35 | + public $option_tag_id3v1 = false; // Read and process ID3v1 tags. |
|
| 36 | + public $option_tag_id3v2 = false; // Read and process ID3v2 tags. |
|
| 37 | + public $option_tag_lyrics3 = false; // Read and process Lyrics3 tags. |
|
| 38 | + public $option_tag_apetag = false; // Read and process APE tags. |
|
| 39 | 39 | |
| 40 | 40 | // Misc calucations - disable for speed |
| 41 | - public $option_analyze = true; // Analyze file - disable if you only need to detect file format. |
|
| 42 | - public $option_accurate_results = true; // Disable to greatly speed up parsing of some file formats at the cost of accuracy. |
|
| 43 | - public $option_tags_process = true; // Copy tags to root key 'tags' and 'comments' and encode to $this->encoding. |
|
| 44 | - public $option_tags_images = false; // Scan tags for binary image data - ID3v2 and vorbiscomments only. |
|
| 45 | - public $option_extra_info = true; // Calculate/return additional info such as bitrate, channelmode etc. |
|
| 46 | - public $option_max_2gb_check = false; // Check whether file is larger than 2 Gb and thus not supported by PHP. |
|
| 41 | + public $option_analyze = true; // Analyze file - disable if you only need to detect file format. |
|
| 42 | + public $option_accurate_results = true; // Disable to greatly speed up parsing of some file formats at the cost of accuracy. |
|
| 43 | + public $option_tags_process = true; // Copy tags to root key 'tags' and 'comments' and encode to $this->encoding. |
|
| 44 | + public $option_tags_images = false; // Scan tags for binary image data - ID3v2 and vorbiscomments only. |
|
| 45 | + public $option_extra_info = true; // Calculate/return additional info such as bitrate, channelmode etc. |
|
| 46 | + public $option_max_2gb_check = false; // Check whether file is larger than 2 Gb and thus not supported by PHP. |
|
| 47 | 47 | |
| 48 | 48 | // Misc data hashes - slow - require hash module |
| 49 | - public $option_md5_data = false; // Get MD5 sum of data part - slow. |
|
| 50 | - public $option_md5_data_source = false; // Use MD5 of source file if available - only FLAC, MAC, OptimFROG and Wavpack4. |
|
| 51 | - public $option_sha1_data = false; // Get SHA1 sum of data part - slow. |
|
| 49 | + public $option_md5_data = false; // Get MD5 sum of data part - slow. |
|
| 50 | + public $option_md5_data_source = false; // Use MD5 of source file if available - only FLAC, MAC, OptimFROG and Wavpack4. |
|
| 51 | + public $option_sha1_data = false; // Get SHA1 sum of data part - slow. |
|
| 52 | 52 | |
| 53 | 53 | // Public variables |
| 54 | - public $filename; // Filename of file being analysed. |
|
| 55 | - public $fp; // Filepointer to file being analysed. |
|
| 56 | - public $info; // Result array. |
|
| 54 | + public $filename; // Filename of file being analysed. |
|
| 55 | + public $fp; // Filepointer to file being analysed. |
|
| 56 | + public $info; // Result array. |
|
| 57 | 57 | |
| 58 | 58 | // Protected variables |
| 59 | - protected $include_path; // getid3 include path. |
|
| 60 | - protected $warnings = array (); |
|
| 59 | + protected $include_path; // getid3 include path. |
|
| 60 | + protected $warnings = array(); |
|
| 61 | 61 | protected $iconv_present; |
| 62 | 62 | |
| 63 | 63 | // Class constants |
| 64 | 64 | const VERSION = '2.0.0b4'; |
| 65 | - const FREAD_BUFFER_SIZE = 16384; // Read buffer size in bytes. |
|
| 65 | + const FREAD_BUFFER_SIZE = 16384; // Read buffer size in bytes. |
|
| 66 | 66 | const ICONV_TEST_STRING = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~�������������������������������� �����������������������������������������������������������������������������������������������'; |
| 67 | 67 | |
| 68 | 68 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // Get include_path |
| 90 | - $this->include_path = $include_path = dirname(__FILE__) . '/'; |
|
| 90 | + $this->include_path = $include_path = dirname(__FILE__).'/'; |
|
| 91 | 91 | |
| 92 | 92 | // Check for presence of iconv() and make sure it works (simpel test only). |
| 93 | 93 | if (function_exists('iconv') && @iconv('UTF-16LE', 'ISO-8859-1', @iconv('ISO-8859-1', 'UTF-16LE', getid3::ICONV_TEST_STRING)) == getid3::ICONV_TEST_STRING) { |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | |
| 125 | 125 | // Check safe_mode off |
| 126 | - if ((bool)ini_get('safe_mode')) { |
|
| 126 | + if ((bool) ini_get('safe_mode')) { |
|
| 127 | 127 | $this->warning('Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbis/flac tag writing disabled.'); |
| 128 | 128 | } |
| 129 | 129 | |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | // Init and save values |
| 139 | 139 | $this->filename = $filename; |
| 140 | - $this->warnings = array (); |
|
| 140 | + $this->warnings = array(); |
|
| 141 | 141 | |
| 142 | 142 | // Init result array and set parameters |
| 143 | - $this->info = array (); |
|
| 143 | + $this->info = array(); |
|
| 144 | 144 | $this->info['GETID3_VERSION'] = getid3::VERSION; |
| 145 | 145 | |
| 146 | 146 | // Remote files not supported |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | fseek($this->fp, 0, SEEK_SET); |
| 181 | 181 | $header = fread($this->fp, 10); |
| 182 | - if (substr($header, 0, 3) == 'ID3' && strlen($header) == 10) { |
|
| 182 | + if (substr($header, 0, 3) == 'ID3' && strlen($header) == 10) { |
|
| 183 | 183 | $this->info['id3v2']['header'] = true; |
| 184 | 184 | $this->info['id3v2']['majorversion'] = ord($header{3}); |
| 185 | 185 | $this->info['id3v2']['minorversion'] = ord($header{4}); |
@@ -189,13 +189,13 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | |
| 191 | 191 | // Handle tags |
| 192 | - foreach (array ("id3v2", "id3v1", "apetag", "lyrics3") as $tag_name) { |
|
| 192 | + foreach (array("id3v2", "id3v1", "apetag", "lyrics3") as $tag_name) { |
|
| 193 | 193 | |
| 194 | - $option_tag = 'option_tag_' . $tag_name; |
|
| 194 | + $option_tag = 'option_tag_'.$tag_name; |
|
| 195 | 195 | if ($this->$option_tag) { |
| 196 | 196 | $this->include_module('tag.'.$tag_name); |
| 197 | 197 | try { |
| 198 | - $tag_class = 'getid3_' . $tag_name; |
|
| 198 | + $tag_class = 'getid3_'.$tag_name; |
|
| 199 | 199 | $tag = new $tag_class($this); |
| 200 | 200 | $tag->Analyze(); |
| 201 | 201 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | return $this->info; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - $determined_format = $info; // copy $info deleted by foreach() |
|
| 234 | + $determined_format = $info; // copy $info deleted by foreach() |
|
| 235 | 235 | continue; |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | |
| 342 | 342 | // Set playtime string |
| 343 | 343 | if (!empty($this->info['playtime_seconds']) && empty($this->info['playtime_string'])) { |
| 344 | - $this->info['playtime_string'] = floor(round($this->info['playtime_seconds']) / 60) . ':' . str_pad(floor(round($this->info['playtime_seconds']) % 60), 2, 0, STR_PAD_LEFT);; |
|
| 344 | + $this->info['playtime_string'] = floor(round($this->info['playtime_seconds']) / 60).':'.str_pad(floor(round($this->info['playtime_seconds']) % 60), 2, 0, STR_PAD_LEFT); ; |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | if (@$this->info['video'] && @$this->info['video']['resolution_x'] && @$this->info['video']['resolution_y'] && @$this->info['video']['bits_per_sample']) { |
| 350 | 350 | |
| 351 | 351 | // From static image formats |
| 352 | - if (in_array($this->info['video']['dataformat'], array ('bmp', 'gif', 'jpeg', 'jpg', 'png', 'tiff'))) { |
|
| 352 | + if (in_array($this->info['video']['dataformat'], array('bmp', 'gif', 'jpeg', 'jpg', 'png', 'tiff'))) { |
|
| 353 | 353 | $frame_rate = 1; |
| 354 | 354 | $bitrate_compressed = $this->info['filesize'] * 8; |
| 355 | 355 | } |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | // Clear all warnings when cloning |
| 472 | 472 | public function __clone() { |
| 473 | 473 | |
| 474 | - $this->warnings = array (); |
|
| 474 | + $this->warnings = array(); |
|
| 475 | 475 | |
| 476 | 476 | // Copy info array, otherwise it will be a reference. |
| 477 | 477 | $temp = $this->info; |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | return $result; |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | - $this->warning('iconv() was unable to convert the string: "' . $string . '" from ' . $in_charset . ' to ' . $out_charset); |
|
| 506 | + $this->warning('iconv() was unable to convert the string: "'.$string.'" from '.$in_charset.' to '.$out_charset); |
|
| 507 | 507 | return $string; |
| 508 | 508 | } |
| 509 | 509 | |
@@ -534,12 +534,12 @@ discard block |
||
| 534 | 534 | // Return array containing information about all supported formats |
| 535 | 535 | public static function GetFileFormatArray() { |
| 536 | 536 | |
| 537 | - static $format_info = array ( |
|
| 537 | + static $format_info = array( |
|
| 538 | 538 | |
| 539 | 539 | // Audio formats |
| 540 | 540 | |
| 541 | 541 | // AC-3 - audio - Dolby AC-3 / Dolby Digital |
| 542 | - 'ac3' => array ( |
|
| 542 | + 'ac3' => array( |
|
| 543 | 543 | 'pattern' => '^\x0B\x77', |
| 544 | 544 | 'group' => 'audio', |
| 545 | 545 | 'module' => 'ac3', |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | ), |
| 548 | 548 | |
| 549 | 549 | // AAC - audio - Advanced Audio Coding (AAC) - ADIF format |
| 550 | - 'adif' => array ( |
|
| 550 | + 'adif' => array( |
|
| 551 | 551 | 'pattern' => '^ADIF', |
| 552 | 552 | 'group' => 'audio', |
| 553 | 553 | 'module' => 'aac_adif', |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | |
| 558 | 558 | |
| 559 | 559 | // AAC - audio - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3) |
| 560 | - 'adts' => array ( |
|
| 560 | + 'adts' => array( |
|
| 561 | 561 | 'pattern' => '^\xFF[\xF0-\xF1\xF8-\xF9]', |
| 562 | 562 | 'group' => 'audio', |
| 563 | 563 | 'module' => 'aac_adts', |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | |
| 568 | 568 | |
| 569 | 569 | // AU - audio - NeXT/Sun AUdio (AU) |
| 570 | - 'au' => array ( |
|
| 570 | + 'au' => array( |
|
| 571 | 571 | 'pattern' => '^\.snd', |
| 572 | 572 | 'group' => 'audio', |
| 573 | 573 | 'module' => 'au', |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | ), |
| 576 | 576 | |
| 577 | 577 | // AVR - audio - Audio Visual Research |
| 578 | - 'avr' => array ( |
|
| 578 | + 'avr' => array( |
|
| 579 | 579 | 'pattern' => '^2BIT', |
| 580 | 580 | 'group' => 'audio', |
| 581 | 581 | 'module' => 'avr', |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | ), |
| 584 | 584 | |
| 585 | 585 | // BONK - audio - Bonk v0.9+ |
| 586 | - 'bonk' => array ( |
|
| 586 | + 'bonk' => array( |
|
| 587 | 587 | 'pattern' => '^\x00(BONK|INFO|META| ID3)', |
| 588 | 588 | 'group' => 'audio', |
| 589 | 589 | 'module' => 'bonk', |
@@ -599,7 +599,7 @@ discard block |
||
| 599 | 599 | ), |
| 600 | 600 | |
| 601 | 601 | // FLAC - audio - Free Lossless Audio Codec |
| 602 | - 'flac' => array ( |
|
| 602 | + 'flac' => array( |
|
| 603 | 603 | 'pattern' => '^fLaC', |
| 604 | 604 | 'group' => 'audio', |
| 605 | 605 | 'module' => 'xiph', |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | ), |
| 608 | 608 | |
| 609 | 609 | // LA - audio - Lossless Audio (LA) |
| 610 | - 'la' => array ( |
|
| 610 | + 'la' => array( |
|
| 611 | 611 | 'pattern' => '^LA0[2-4]', |
| 612 | 612 | 'group' => 'audio', |
| 613 | 613 | 'module' => 'la', |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | ), |
| 616 | 616 | |
| 617 | 617 | // LPAC - audio - Lossless Predictive Audio Compression (LPAC) |
| 618 | - 'lpac' => array ( |
|
| 618 | + 'lpac' => array( |
|
| 619 | 619 | 'pattern' => '^LPAC', |
| 620 | 620 | 'group' => 'audio', |
| 621 | 621 | 'module' => 'lpac', |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | ), |
| 624 | 624 | |
| 625 | 625 | // MIDI - audio - MIDI (Musical Instrument Digital Interface) |
| 626 | - 'midi' => array ( |
|
| 626 | + 'midi' => array( |
|
| 627 | 627 | 'pattern' => '^MThd', |
| 628 | 628 | 'group' => 'audio', |
| 629 | 629 | 'module' => 'midi', |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | ), |
| 632 | 632 | |
| 633 | 633 | // MAC - audio - Monkey's Audio Compressor |
| 634 | - 'mac' => array ( |
|
| 634 | + 'mac' => array( |
|
| 635 | 635 | 'pattern' => '^MAC ', |
| 636 | 636 | 'group' => 'audio', |
| 637 | 637 | 'module' => 'monkey', |
@@ -639,31 +639,31 @@ discard block |
||
| 639 | 639 | ), |
| 640 | 640 | |
| 641 | 641 | // MOD - audio - MODule (assorted sub-formats) |
| 642 | - 'mod' => array ( |
|
| 642 | + 'mod' => array( |
|
| 643 | 643 | 'pattern' => '^.{1080}(M.K.|[5-9]CHN|[1-3][0-9]CH)', |
| 644 | 644 | 'mime_type' => 'audio/mod', |
| 645 | 645 | ), |
| 646 | 646 | |
| 647 | 647 | // MOD - audio - MODule (Impulse Tracker) |
| 648 | - 'it' => array ( |
|
| 648 | + 'it' => array( |
|
| 649 | 649 | 'pattern' => '^IMPM', |
| 650 | 650 | 'mime_type' => 'audio/it', |
| 651 | 651 | ), |
| 652 | 652 | |
| 653 | 653 | // MOD - audio - MODule (eXtended Module, various sub-formats) |
| 654 | - 'xm' => array ( |
|
| 654 | + 'xm' => array( |
|
| 655 | 655 | 'pattern' => '^Extended Module', |
| 656 | 656 | 'mime_type' => 'audio/xm', |
| 657 | 657 | ), |
| 658 | 658 | |
| 659 | 659 | // MOD - audio - MODule (ScreamTracker) |
| 660 | - 's3m' => array ( |
|
| 660 | + 's3m' => array( |
|
| 661 | 661 | 'pattern' => '^.{44}SCRM', |
| 662 | 662 | 'mime_type' => 'audio/s3m', |
| 663 | 663 | ), |
| 664 | 664 | |
| 665 | 665 | // MPC - audio - Musepack / MPEGplus SV7+ |
| 666 | - 'mpc' => array ( |
|
| 666 | + 'mpc' => array( |
|
| 667 | 667 | 'pattern' => '^(MP\+)', |
| 668 | 668 | 'group' => 'audio', |
| 669 | 669 | 'module' => 'mpc', |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | ), |
| 672 | 672 | |
| 673 | 673 | // MPC - audio - Musepack / MPEGplus SV4-6 |
| 674 | - 'mpc_old' => array ( |
|
| 674 | + 'mpc_old' => array( |
|
| 675 | 675 | 'pattern' => '^([\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0])', |
| 676 | 676 | 'group' => 'audio', |
| 677 | 677 | 'module' => 'mpc_old', |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | |
| 681 | 681 | |
| 682 | 682 | // MP3 - audio - MPEG-audio Layer 3 (very similar to AAC-ADTS) |
| 683 | - 'mp3' => array ( |
|
| 683 | + 'mp3' => array( |
|
| 684 | 684 | 'pattern' => '^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]', |
| 685 | 685 | 'group' => 'audio', |
| 686 | 686 | 'module' => 'mp3', |
@@ -688,7 +688,7 @@ discard block |
||
| 688 | 688 | ), |
| 689 | 689 | |
| 690 | 690 | // OFR - audio - OptimFROG |
| 691 | - 'ofr' => array ( |
|
| 691 | + 'ofr' => array( |
|
| 692 | 692 | 'pattern' => '^(\*RIFF|OFR)', |
| 693 | 693 | 'group' => 'audio', |
| 694 | 694 | 'module' => 'optimfrog', |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | ), |
| 697 | 697 | |
| 698 | 698 | // RKAU - audio - RKive AUdio compressor |
| 699 | - 'rkau' => array ( |
|
| 699 | + 'rkau' => array( |
|
| 700 | 700 | 'pattern' => '^RKA', |
| 701 | 701 | 'group' => 'audio', |
| 702 | 702 | 'module' => 'rkau', |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | ), |
| 705 | 705 | |
| 706 | 706 | // SHN - audio - Shorten |
| 707 | - 'shn' => array ( |
|
| 707 | + 'shn' => array( |
|
| 708 | 708 | 'pattern' => '^ajkg', |
| 709 | 709 | 'group' => 'audio', |
| 710 | 710 | 'module' => 'shorten', |
@@ -714,15 +714,15 @@ discard block |
||
| 714 | 714 | ), |
| 715 | 715 | |
| 716 | 716 | // TTA - audio - TTA Lossless Audio Compressor (http://tta.corecodec.org) |
| 717 | - 'tta' => array ( |
|
| 718 | - 'pattern' => '^TTA', // could also be '^TTA(\x01|\x02|\x03|2|1)' |
|
| 717 | + 'tta' => array( |
|
| 718 | + 'pattern' => '^TTA', // could also be '^TTA(\x01|\x02|\x03|2|1)' |
|
| 719 | 719 | 'group' => 'audio', |
| 720 | 720 | 'module' => 'tta', |
| 721 | 721 | 'mime_type' => 'application/octet-stream', |
| 722 | 722 | ), |
| 723 | 723 | |
| 724 | 724 | // VOC - audio - Creative Voice (VOC) |
| 725 | - 'voc' => array ( |
|
| 725 | + 'voc' => array( |
|
| 726 | 726 | 'pattern' => '^Creative Voice File', |
| 727 | 727 | 'group' => 'audio', |
| 728 | 728 | 'module' => 'voc', |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | ), |
| 731 | 731 | |
| 732 | 732 | // VQF - audio - transform-domain weighted interleave Vector Quantization Format (VQF) |
| 733 | - 'vqf' => array ( |
|
| 733 | + 'vqf' => array( |
|
| 734 | 734 | 'pattern' => '^TWIN', |
| 735 | 735 | 'group' => 'audio', |
| 736 | 736 | 'module' => 'vqf', |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | // Audio-Video formats |
| 750 | 750 | |
| 751 | 751 | // ASF - audio/video - Advanced Streaming Format, Windows Media Video, Windows Media Audio |
| 752 | - 'asf' => array ( |
|
| 752 | + 'asf' => array( |
|
| 753 | 753 | 'pattern' => '^\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C', |
| 754 | 754 | 'group' => 'audio-video', |
| 755 | 755 | 'module' => 'asf', |
@@ -771,13 +771,13 @@ discard block |
||
| 771 | 771 | ), |
| 772 | 772 | |
| 773 | 773 | // MKAV - audio/video - Mastroka |
| 774 | - 'matroska' => array ( |
|
| 774 | + 'matroska' => array( |
|
| 775 | 775 | 'pattern' => '^\x1A\x45\xDF\xA3', |
| 776 | 776 | 'mime_type' => 'application/octet-stream', |
| 777 | 777 | ), |
| 778 | 778 | |
| 779 | 779 | // MPEG - audio/video - MPEG (Moving Pictures Experts Group) |
| 780 | - 'mpeg' => array ( |
|
| 780 | + 'mpeg' => array( |
|
| 781 | 781 | 'pattern' => '^\x00\x00\x01(\xBA|\xB3)', |
| 782 | 782 | 'group' => 'audio-video', |
| 783 | 783 | 'module' => 'mpeg', |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | ), |
| 786 | 786 | |
| 787 | 787 | // NSV - audio/video - Nullsoft Streaming Video (NSV) |
| 788 | - 'nsv' => array ( |
|
| 788 | + 'nsv' => array( |
|
| 789 | 789 | 'pattern' => '^NSV[sf]', |
| 790 | 790 | 'group' => 'audio-video', |
| 791 | 791 | 'module' => 'nsv', |
@@ -793,7 +793,7 @@ discard block |
||
| 793 | 793 | ), |
| 794 | 794 | |
| 795 | 795 | // Ogg - audio/video - Ogg (Ogg Vorbis, OggFLAC, Speex, Ogg Theora(*), Ogg Tarkin(*)) |
| 796 | - 'ogg' => array ( |
|
| 796 | + 'ogg' => array( |
|
| 797 | 797 | 'pattern' => '^OggS', |
| 798 | 798 | 'group' => 'audio', |
| 799 | 799 | 'module' => 'xiph', |
@@ -803,7 +803,7 @@ discard block |
||
| 803 | 803 | ), |
| 804 | 804 | |
| 805 | 805 | // QT - audio/video - Quicktime |
| 806 | - 'quicktime' => array ( |
|
| 806 | + 'quicktime' => array( |
|
| 807 | 807 | 'pattern' => '^.{4}(cmov|free|ftyp|mdat|moov|pnot|skip|wide)', |
| 808 | 808 | 'group' => 'audio-video', |
| 809 | 809 | 'module' => 'quicktime', |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | ), |
| 812 | 812 | |
| 813 | 813 | // RIFF - audio/video - Resource Interchange File Format (RIFF) / WAV / AVI / CD-audio / SDSS = renamed variant used by SmartSound QuickTracks (www.smartsound.com) / FORM = Audio Interchange File Format (AIFF) |
| 814 | - 'riff' => array ( |
|
| 814 | + 'riff' => array( |
|
| 815 | 815 | 'pattern' => '^(RIFF|SDSS|FORM)', |
| 816 | 816 | 'group' => 'audio-video', |
| 817 | 817 | 'module' => 'riff', |
@@ -820,7 +820,7 @@ discard block |
||
| 820 | 820 | ), |
| 821 | 821 | |
| 822 | 822 | // Real - audio/video - RealAudio, RealVideo |
| 823 | - 'real' => array ( |
|
| 823 | + 'real' => array( |
|
| 824 | 824 | 'pattern' => '^(\.RMF|.ra)', |
| 825 | 825 | 'group' => 'audio-video', |
| 826 | 826 | 'module' => 'real', |
@@ -828,7 +828,7 @@ discard block |
||
| 828 | 828 | ), |
| 829 | 829 | |
| 830 | 830 | // SWF - audio/video - ShockWave Flash |
| 831 | - 'swf' => array ( |
|
| 831 | + 'swf' => array( |
|
| 832 | 832 | 'pattern' => '^(F|C)WS', |
| 833 | 833 | 'group' => 'audio-video', |
| 834 | 834 | 'module' => 'swf', |
@@ -839,7 +839,7 @@ discard block |
||
| 839 | 839 | // Still-Image formats |
| 840 | 840 | |
| 841 | 841 | // BMP - still image - Bitmap (Windows, OS/2; uncompressed, RLE8, RLE4) |
| 842 | - 'bmp' => array ( |
|
| 842 | + 'bmp' => array( |
|
| 843 | 843 | 'pattern' => '^BM', |
| 844 | 844 | 'group' => 'graphic', |
| 845 | 845 | 'module' => 'bmp', |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | ), |
| 850 | 850 | |
| 851 | 851 | // GIF - still image - Graphics Interchange Format |
| 852 | - 'gif' => array ( |
|
| 852 | + 'gif' => array( |
|
| 853 | 853 | 'pattern' => '^GIF', |
| 854 | 854 | 'group' => 'graphic', |
| 855 | 855 | 'module' => 'gif', |
@@ -859,7 +859,7 @@ discard block |
||
| 859 | 859 | ), |
| 860 | 860 | |
| 861 | 861 | // JPEG - still image - Joint Photographic Experts Group (JPEG) |
| 862 | - 'jpeg' => array ( |
|
| 862 | + 'jpeg' => array( |
|
| 863 | 863 | 'pattern' => '^\xFF\xD8\xFF', |
| 864 | 864 | 'group' => 'graphic', |
| 865 | 865 | 'module' => 'jpeg', |
@@ -869,7 +869,7 @@ discard block |
||
| 869 | 869 | ), |
| 870 | 870 | |
| 871 | 871 | // PCD - still image - Kodak Photo CD |
| 872 | - 'pcd' => array ( |
|
| 872 | + 'pcd' => array( |
|
| 873 | 873 | 'pattern' => '^.{2048}PCD_IPI\x00', |
| 874 | 874 | 'group' => 'graphic', |
| 875 | 875 | 'module' => 'pcd', |
@@ -880,7 +880,7 @@ discard block |
||
| 880 | 880 | |
| 881 | 881 | |
| 882 | 882 | // PNG - still image - Portable Network Graphics (PNG) |
| 883 | - 'png' => array ( |
|
| 883 | + 'png' => array( |
|
| 884 | 884 | 'pattern' => '^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A', |
| 885 | 885 | 'group' => 'graphic', |
| 886 | 886 | 'module' => 'png', |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | |
| 901 | 901 | |
| 902 | 902 | // TIFF - still image - Tagged Information File Format (TIFF) |
| 903 | - 'tiff' => array ( |
|
| 903 | + 'tiff' => array( |
|
| 904 | 904 | 'pattern' => '^(II\x2A\x00|MM\x00\x2A)', |
| 905 | 905 | 'group' => 'graphic', |
| 906 | 906 | 'module' => 'tiff', |
@@ -920,7 +920,7 @@ discard block |
||
| 920 | 920 | ), |
| 921 | 921 | |
| 922 | 922 | // ISO - data - International Standards Organization (ISO) CD-ROM Image |
| 923 | - 'iso' => array ( |
|
| 923 | + 'iso' => array( |
|
| 924 | 924 | 'pattern' => '^.{32769}CD001', |
| 925 | 925 | 'group' => 'misc', |
| 926 | 926 | 'module' => 'iso', |
@@ -938,7 +938,7 @@ discard block |
||
| 938 | 938 | ), |
| 939 | 939 | |
| 940 | 940 | // SZIP - audio - SZIP compressed data |
| 941 | - 'szip' => array ( |
|
| 941 | + 'szip' => array( |
|
| 942 | 942 | 'pattern' => '^SZ\x0A\x04', |
| 943 | 943 | 'group' => 'archive', |
| 944 | 944 | 'module' => 'szip', |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | |
| 970 | 970 | |
| 971 | 971 | // ZIP - data - ZIP compressed data |
| 972 | - 'zip' => array ( |
|
| 972 | + 'zip' => array( |
|
| 973 | 973 | 'pattern' => '^PK\x03\x04', |
| 974 | 974 | 'group' => 'archive', |
| 975 | 975 | 'module' => 'zip', |
@@ -980,7 +980,7 @@ discard block |
||
| 980 | 980 | |
| 981 | 981 | |
| 982 | 982 | // PAR2 - data - Parity Volume Set Specification 2.0 |
| 983 | - 'par2' => array ( |
|
| 983 | + 'par2' => array( |
|
| 984 | 984 | 'pattern' => '^PAR2\x00PKT', |
| 985 | 985 | 'mime_type' => 'application/octet-stream', |
| 986 | 986 | 'fail_id3' => 'ERROR', |
@@ -1039,22 +1039,22 @@ discard block |
||
| 1039 | 1039 | protected function HandleAllTags() { |
| 1040 | 1040 | |
| 1041 | 1041 | // Key name => array (tag name, character encoding) |
| 1042 | - static $tags = array ( |
|
| 1043 | - 'asf' => array ('asf', 'UTF-16LE'), |
|
| 1044 | - 'midi' => array ('midi', 'ISO-8859-1'), |
|
| 1045 | - 'nsv' => array ('nsv', 'ISO-8859-1'), |
|
| 1046 | - 'ogg' => array ('vorbiscomment', 'UTF-8'), |
|
| 1047 | - 'png' => array ('png', 'UTF-8'), |
|
| 1048 | - 'tiff' => array ('tiff', 'ISO-8859-1'), |
|
| 1049 | - 'quicktime' => array ('quicktime', 'ISO-8859-1'), |
|
| 1050 | - 'real' => array ('real', 'ISO-8859-1'), |
|
| 1051 | - 'vqf' => array ('vqf', 'ISO-8859-1'), |
|
| 1052 | - 'zip' => array ('zip', 'ISO-8859-1'), |
|
| 1053 | - 'riff' => array ('riff', 'ISO-8859-1'), |
|
| 1054 | - 'lyrics3' => array ('lyrics3', 'ISO-8859-1'), |
|
| 1055 | - 'id3v1' => array ('id3v1', ''), // change below - cannot assign variable to static array |
|
| 1056 | - 'id3v2' => array ('id3v2', 'UTF-8'), // module converts all frames to UTF-8 |
|
| 1057 | - 'ape' => array ('ape', 'UTF-8') |
|
| 1042 | + static $tags = array( |
|
| 1043 | + 'asf' => array('asf', 'UTF-16LE'), |
|
| 1044 | + 'midi' => array('midi', 'ISO-8859-1'), |
|
| 1045 | + 'nsv' => array('nsv', 'ISO-8859-1'), |
|
| 1046 | + 'ogg' => array('vorbiscomment', 'UTF-8'), |
|
| 1047 | + 'png' => array('png', 'UTF-8'), |
|
| 1048 | + 'tiff' => array('tiff', 'ISO-8859-1'), |
|
| 1049 | + 'quicktime' => array('quicktime', 'ISO-8859-1'), |
|
| 1050 | + 'real' => array('real', 'ISO-8859-1'), |
|
| 1051 | + 'vqf' => array('vqf', 'ISO-8859-1'), |
|
| 1052 | + 'zip' => array('zip', 'ISO-8859-1'), |
|
| 1053 | + 'riff' => array('riff', 'ISO-8859-1'), |
|
| 1054 | + 'lyrics3' => array('lyrics3', 'ISO-8859-1'), |
|
| 1055 | + 'id3v1' => array('id3v1', ''), // change below - cannot assign variable to static array |
|
| 1056 | + 'id3v2' => array('id3v2', 'UTF-8'), // module converts all frames to UTF-8 |
|
| 1057 | + 'ape' => array('ape', 'UTF-8') |
|
| 1058 | 1058 | ); |
| 1059 | 1059 | $tags['id3v1'][1] = $this->encoding_id3v1; |
| 1060 | 1060 | |
@@ -1063,7 +1063,7 @@ discard block |
||
| 1063 | 1063 | list($tag_name, $encoding) = $tag_name_encoding_array; |
| 1064 | 1064 | |
| 1065 | 1065 | // Fill in default encoding type if not already present |
| 1066 | - @$this->info[$comment_name] and $this->info[$comment_name]['encoding'] = $encoding; |
|
| 1066 | + @$this->info[$comment_name] and $this->info[$comment_name]['encoding'] = $encoding; |
|
| 1067 | 1067 | |
| 1068 | 1068 | // Copy comments if key name set |
| 1069 | 1069 | if (@$this->info[$comment_name]['comments']) { |
@@ -1142,11 +1142,11 @@ discard block |
||
| 1142 | 1142 | abstract class getid3_handler |
| 1143 | 1143 | { |
| 1144 | 1144 | |
| 1145 | - protected $getid3; // pointer |
|
| 1145 | + protected $getid3; // pointer |
|
| 1146 | 1146 | |
| 1147 | - protected $data_string_flag = false; // analyzing filepointer or string |
|
| 1148 | - protected $data_string; // string to analyze |
|
| 1149 | - protected $data_string_position = 0; // seek position in string |
|
| 1147 | + protected $data_string_flag = false; // analyzing filepointer or string |
|
| 1148 | + protected $data_string; // string to analyze |
|
| 1149 | + protected $data_string_position = 0; // seek position in string |
|
| 1150 | 1150 | |
| 1151 | 1151 | |
| 1152 | 1152 | public function __construct(getID3 $getid3) { |
@@ -1247,20 +1247,20 @@ discard block |
||
| 1247 | 1247 | public function __construct($filename) { |
| 1248 | 1248 | |
| 1249 | 1249 | if (!file_exists($filename)) { |
| 1250 | - throw new getid3_exception('File does not exist: "' . $filename . '"'); |
|
| 1250 | + throw new getid3_exception('File does not exist: "'.$filename.'"'); |
|
| 1251 | 1251 | } |
| 1252 | 1252 | |
| 1253 | 1253 | if (!is_writeable($filename)) { |
| 1254 | - throw new getid3_exception('File is not writeable: "' . $filename . '"'); |
|
| 1254 | + throw new getid3_exception('File is not writeable: "'.$filename.'"'); |
|
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | 1257 | if (!is_writeable(dirname($filename))) { |
| 1258 | - throw new getid3_exception('Directory is not writeable: ' . dirname($filename) . ' (need to write lock file).'); |
|
| 1258 | + throw new getid3_exception('Directory is not writeable: '.dirname($filename).' (need to write lock file).'); |
|
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | 1261 | $this->user_abort = ignore_user_abort(true); |
| 1262 | 1262 | |
| 1263 | - $this->fp_lock = fopen($filename . '.getid3.lock', 'w'); |
|
| 1263 | + $this->fp_lock = fopen($filename.'.getid3.lock', 'w'); |
|
| 1264 | 1264 | flock($this->fp_lock, LOCK_EX); |
| 1265 | 1265 | |
| 1266 | 1266 | $this->filename = $filename; |
@@ -1271,7 +1271,7 @@ discard block |
||
| 1271 | 1271 | |
| 1272 | 1272 | flock($this->fp_lock, LOCK_UN); |
| 1273 | 1273 | fclose($this->fp_lock); |
| 1274 | - unlink($this->filename . '.getid3.lock'); |
|
| 1274 | + unlink($this->filename.'.getid3.lock'); |
|
| 1275 | 1275 | |
| 1276 | 1276 | ignore_user_abort($this->user_abort); |
| 1277 | 1277 | } |
@@ -1325,7 +1325,7 @@ discard block |
||
| 1325 | 1325 | |
| 1326 | 1326 | |
| 1327 | 1327 | // Convert number to Little Endian byte string |
| 1328 | - public static function LittleEndian2String($number, $minbytes=1, $synchsafe=false) { |
|
| 1328 | + public static function LittleEndian2String($number, $minbytes = 1, $synchsafe = false) { |
|
| 1329 | 1329 | $intstring = ''; |
| 1330 | 1330 | while ($number > 0) { |
| 1331 | 1331 | if ($synchsafe) { |
@@ -1485,7 +1485,7 @@ discard block |
||
| 1485 | 1485 | } |
| 1486 | 1486 | |
| 1487 | 1487 | |
| 1488 | - public static function PrintHexBytes($string, $hex=true, $spaces=true, $html_safe=true) { |
|
| 1488 | + public static function PrintHexBytes($string, $hex = true, $spaces = true, $html_safe = true) { |
|
| 1489 | 1489 | |
| 1490 | 1490 | $return_string = ''; |
| 1491 | 1491 | for ($i = 0; $i < strlen($string); $i++) { |
@@ -1545,7 +1545,7 @@ discard block |
||
| 1545 | 1545 | |
| 1546 | 1546 | public static function NameLookup($name_code) { |
| 1547 | 1547 | |
| 1548 | - static $lookup = array ( |
|
| 1548 | + static $lookup = array( |
|
| 1549 | 1549 | 0 => 'not set', |
| 1550 | 1550 | 1 => 'Track Gain Adjustment', |
| 1551 | 1551 | 2 => 'Album Gain Adjustment' |
@@ -1558,7 +1558,7 @@ discard block |
||
| 1558 | 1558 | |
| 1559 | 1559 | public static function OriginatorLookup($originator_code) { |
| 1560 | 1560 | |
| 1561 | - static $lookup = array ( |
|
| 1561 | + static $lookup = array( |
|
| 1562 | 1562 | 0 => 'unspecified', |
| 1563 | 1563 | 1 => 'pre-set by artist/producer/mastering engineer', |
| 1564 | 1564 | 2 => 'set by user', |
@@ -1572,7 +1572,7 @@ discard block |
||
| 1572 | 1572 | |
| 1573 | 1573 | public static function AdjustmentLookup($raw_adjustment, $sign_bit) { |
| 1574 | 1574 | |
| 1575 | - return (float)$raw_adjustment / 10 * ($sign_bit == 1 ? -1 : 1); |
|
| 1575 | + return (float) $raw_adjustment / 10 * ($sign_bit == 1 ? -1 : 1); |
|
| 1576 | 1576 | } |
| 1577 | 1577 | |
| 1578 | 1578 | |
@@ -198,8 +198,7 @@ discard block |
||
| 198 | 198 | $tag_class = 'getid3_' . $tag_name; |
| 199 | 199 | $tag = new $tag_class($this); |
| 200 | 200 | $tag->Analyze(); |
| 201 | - } |
|
| 202 | - catch (getid3_exception $e) { |
|
| 201 | + } catch (getid3_exception $e) { |
|
| 203 | 202 | throw $e; |
| 204 | 203 | } |
| 205 | 204 | } |
@@ -243,9 +242,7 @@ discard block |
||
| 243 | 242 | // use assume format on these if format detection failed |
| 244 | 243 | if (preg_match('/\.mp[123a]$/i', $filename)) { |
| 245 | 244 | $determined_format = $file_format_array['mp3']; |
| 246 | - } |
|
| 247 | - |
|
| 248 | - else { |
|
| 245 | + } else { |
|
| 249 | 246 | fclose($this->fp); |
| 250 | 247 | throw new getid3_exception('Unable to determine file format'); |
| 251 | 248 | } |
@@ -259,8 +256,7 @@ discard block |
||
| 259 | 256 | if ($determined_format['fail_id3'] === 'ERROR') { |
| 260 | 257 | fclose($this->fp); |
| 261 | 258 | throw new getid3_exception('ID3 tags not allowed on this file type.'); |
| 262 | - } |
|
| 263 | - elseif ($determined_format['fail_id3'] === 'WARNING') { |
|
| 259 | + } elseif ($determined_format['fail_id3'] === 'WARNING') { |
|
| 264 | 260 | @$this->info['id3v1'] and $this->warning('ID3v1 tags not allowed on this file type.'); |
| 265 | 261 | @$this->info['id3v2'] and $this->warning('ID3v2 tags not allowed on this file type.'); |
| 266 | 262 | } |
@@ -301,11 +297,9 @@ discard block |
||
| 301 | 297 | |
| 302 | 298 | try { |
| 303 | 299 | $this->option_analyze and $class->Analyze(); |
| 304 | - } |
|
| 305 | - catch (getid3_exception $e) { |
|
| 300 | + } catch (getid3_exception $e) { |
|
| 306 | 301 | throw $e; |
| 307 | - } |
|
| 308 | - catch (Exception $e) { |
|
| 302 | + } catch (Exception $e) { |
|
| 309 | 303 | throw new getid3_exception('Corrupt file.'); |
| 310 | 304 | } |
| 311 | 305 | |
@@ -460,8 +454,7 @@ discard block |
||
| 460 | 454 | |
| 461 | 455 | if (is_array($message)) { |
| 462 | 456 | $this->warnings = array_merge($this->warnings, $message); |
| 463 | - } |
|
| 464 | - else { |
|
| 457 | + } else { |
|
| 465 | 458 | $this->warnings[] = $message; |
| 466 | 459 | } |
| 467 | 460 | } |
@@ -1101,8 +1094,7 @@ discard block |
||
| 1101 | 1094 | if (empty($this->info['comments'][$tag_name])) { |
| 1102 | 1095 | |
| 1103 | 1096 | // fall through and append value |
| 1104 | - } |
|
| 1105 | - elseif ($tag_type == 'id3v1') { |
|
| 1097 | + } elseif ($tag_type == 'id3v1') { |
|
| 1106 | 1098 | |
| 1107 | 1099 | $new_value_length = strlen(trim($value)); |
| 1108 | 1100 | foreach ($this->info['comments'][$tag_name] as $existing_key => $existing_value) { |
@@ -1112,8 +1104,7 @@ discard block |
||
| 1112 | 1104 | break 2; |
| 1113 | 1105 | } |
| 1114 | 1106 | } |
| 1115 | - } |
|
| 1116 | - else { |
|
| 1107 | + } else { |
|
| 1117 | 1108 | |
| 1118 | 1109 | $new_value_length = strlen(trim($value)); |
| 1119 | 1110 | foreach ($this->info['comments'][$tag_name] as $existing_key => $existing_value) { |