@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
35 | - * @return array |
|
35 | + * @return string[] |
|
36 | 36 | */ |
37 | 37 | public static function toolList() |
38 | 38 | { |
@@ -290,7 +290,6 @@ discard block |
||
290 | 290 | * 'page_nr' = The page to display |
291 | 291 | * 'hide_navigation' = true to hide the navigation |
292 | 292 | * @param array $query_vars Additional variables to add in the query-string |
293 | - * @param array $form actions Additional variables to add in the query-string |
|
294 | 293 | * @param mixed An array with bool values to know which columns show. |
295 | 294 | * i.e: $visibility_options= array(true, false) we will only show the first column |
296 | 295 | * Can be also only a bool value. TRUE: show all columns, FALSE: show nothing |
@@ -331,7 +330,6 @@ discard block |
||
331 | 330 | * 'page_nr' = The page to display |
332 | 331 | * 'hide_navigation' = true to hide the navigation |
333 | 332 | * @param array $query_vars Additional variables to add in the query-string |
334 | - * @param array $form actions Additional variables to add in the query-string |
|
335 | 333 | * @param mixed An array with bool values to know which columns show. i.e: |
336 | 334 | * $visibility_options= array(true, false) we will only show the first column |
337 | 335 | * Can be also only a bool value. TRUE: show all columns, FALSE: show nothing |
@@ -388,10 +386,11 @@ discard block |
||
388 | 386 | * 'per_page' = number of items to show per page |
389 | 387 | * 'page_nr' = The page to display |
390 | 388 | * @param array $query_vars Additional variables to add in the query-string |
391 | - * @param array $column_show Array of binaries 1= show columns 0. hide a column |
|
389 | + * @param integer[] $column_show Array of binaries 1= show columns 0. hide a column |
|
392 | 390 | * @param array $column_order An array of integers that let us decide how the columns are going to be sort. |
393 | 391 | * i.e: $column_order=array('1''4','3','4'); The 2nd column will be order like the 4th column |
394 | 392 | * @param array $form_actions Set optional forms actions |
393 | + * @param string $table_name |
|
395 | 394 | * |
396 | 395 | * @author Julio Montoya |
397 | 396 | */ |
@@ -444,7 +443,7 @@ discard block |
||
444 | 443 | * @param bool $filter (true) or not (false) |
445 | 444 | * @param bool $returnValue |
446 | 445 | * |
447 | - * @return void |
|
446 | + * @return string|null |
|
448 | 447 | */ |
449 | 448 | public static function display_normal_message($message, $filter = true, $returnValue = false) |
450 | 449 | { |
@@ -474,7 +473,7 @@ discard block |
||
474 | 473 | /** |
475 | 474 | * Displays an confirmation message. Use this if something has been done successfully |
476 | 475 | * @param bool Filter (true) or not (false) |
477 | - * @return void |
|
476 | + * @return string|null |
|
478 | 477 | */ |
479 | 478 | public static function display_confirmation_message ($message, $filter = true, $returnValue = false) |
480 | 479 | { |
@@ -491,7 +490,7 @@ discard block |
||
491 | 490 | * @param string $message - include any additional html |
492 | 491 | * tags if you need them |
493 | 492 | * @param bool Filter (true) or not (false) |
494 | - * @return void |
|
493 | + * @return string|null |
|
495 | 494 | */ |
496 | 495 | public static function display_error_message ($message, $filter = true, $returnValue = false) |
497 | 496 | { |
@@ -681,6 +680,7 @@ discard block |
||
681 | 680 | * @param string The alt text (probably a language variable) |
682 | 681 | * @param array additional attributes (for instance height, width, onclick, ...) |
683 | 682 | * @param integer The wanted width of the icon (to be looked for in the corresponding img/icons/ folder) |
683 | + * @param string $image |
|
684 | 684 | * @return void |
685 | 685 | */ |
686 | 686 | public static function display_icon( |
@@ -881,6 +881,7 @@ discard block |
||
881 | 881 | /** |
882 | 882 | * Displays an HTML input tag |
883 | 883 | * |
884 | + * @param string $type |
|
884 | 885 | */ |
885 | 886 | public static function input($type, $name, $value, $attributes = array()) |
886 | 887 | { |
@@ -897,8 +898,8 @@ discard block |
||
897 | 898 | } |
898 | 899 | |
899 | 900 | /** |
900 | - * @param $name |
|
901 | - * @param $value |
|
901 | + * @param string $name |
|
902 | + * @param string $value |
|
902 | 903 | * @param array $attributes |
903 | 904 | * @return string |
904 | 905 | */ |
@@ -913,6 +914,7 @@ discard block |
||
913 | 914 | /** |
914 | 915 | * Displays an HTML select tag |
915 | 916 | * |
917 | + * @param string $blank_item_text |
|
916 | 918 | */ |
917 | 919 | public static function select( |
918 | 920 | $name, |
@@ -983,6 +985,8 @@ discard block |
||
983 | 985 | * @param array content that will be showed |
984 | 986 | * @param string the id of the container of the tab in the example "tabs" |
985 | 987 | * @param array attributes for the ul |
988 | + * @param string[] $header_list |
|
989 | + * @param string[] $content_list |
|
986 | 990 | * |
987 | 991 | */ |
988 | 992 | public static function tabs($header_list, $content_list, $id = 'tabs', $attributes = array(), $ul_attributes = array()) |
@@ -1029,7 +1033,7 @@ discard block |
||
1029 | 1033 | |
1030 | 1034 | /** |
1031 | 1035 | * @param $headers |
1032 | - * @param null $selected |
|
1036 | + * @param integer $selected |
|
1033 | 1037 | * |
1034 | 1038 | * @return string |
1035 | 1039 | */ |
@@ -1067,6 +1071,7 @@ discard block |
||
1067 | 1071 | * As you can see both function use the same "my_grid_name" this is very important otherwise nothing will work |
1068 | 1072 | * |
1069 | 1073 | * @param string the div id, this value must be the same with the first parameter of Display::grid_js() |
1074 | + * @param string $div_id |
|
1070 | 1075 | * @return string html |
1071 | 1076 | * |
1072 | 1077 | */ |
@@ -1622,6 +1627,8 @@ discard block |
||
1622 | 1627 | * @param string url that will be added (for jquery see hot_courses.tpl) |
1623 | 1628 | * @param string point info array see function CourseManager::get_course_ranking() |
1624 | 1629 | * @param bool add a div wrapper |
1630 | + * @param string $id |
|
1631 | + * @param string $url |
|
1625 | 1632 | * @todo use templates |
1626 | 1633 | **/ |
1627 | 1634 | public static function return_rating_system($id, $url, $point_info = array(), $add_div_wrapper = true) |
@@ -1717,6 +1724,9 @@ discard block |
||
1717 | 1724 | return '<'.$size.'>'.Security::remove_XSS($title).'</'.$size.'>'; |
1718 | 1725 | } |
1719 | 1726 | |
1727 | + /** |
|
1728 | + * @param string $title |
|
1729 | + */ |
|
1720 | 1730 | public static function page_subheader2($title, $second_title = null) |
1721 | 1731 | { |
1722 | 1732 | return self::page_header($title, $second_title, 'h4'); |
@@ -1947,6 +1957,7 @@ discard block |
||
1947 | 1957 | |
1948 | 1958 | /** |
1949 | 1959 | * @todo use twig |
1960 | + * @param string $title |
|
1950 | 1961 | */ |
1951 | 1962 | public static function group_button($title, $elements) |
1952 | 1963 | { |
@@ -2164,9 +2175,9 @@ discard block |
||
2164 | 2175 | |
2165 | 2176 | /** |
2166 | 2177 | * @param int $id |
2167 | - * @param array $content |
|
2178 | + * @param string[] $content |
|
2168 | 2179 | * @param int $col |
2169 | - * @param bool|true $right |
|
2180 | + * @param boolean $right |
|
2170 | 2181 | * @return string |
2171 | 2182 | */ |
2172 | 2183 | public static function toolbarAction($id, $content = array(), $col = 2, $right = true) |
@@ -2248,10 +2259,10 @@ discard block |
||
2248 | 2259 | /** |
2249 | 2260 | * @param string $title |
2250 | 2261 | * @param string $content |
2251 | - * @param null $id |
|
2262 | + * @param string $id |
|
2252 | 2263 | * @param array $params |
2253 | - * @param null $idAccordion |
|
2254 | - * @param null $idCollapse |
|
2264 | + * @param string $idAccordion |
|
2265 | + * @param string $idCollapse |
|
2255 | 2266 | * @param bool|true $open |
2256 | 2267 | * @param bool|false $fullClickable |
2257 | 2268 | * @return null|string |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | ); |
50 | 50 | } |
51 | 51 | |
52 | - /** |
|
53 | - * Displays the page header |
|
54 | - * @param string The name of the page (will be showed in the page title) |
|
55 | - * @param string Optional help file name |
|
56 | - * @param string $page_header |
|
57 | - */ |
|
52 | + /** |
|
53 | + * Displays the page header |
|
54 | + * @param string The name of the page (will be showed in the page title) |
|
55 | + * @param string Optional help file name |
|
56 | + * @param string $page_header |
|
57 | + */ |
|
58 | 58 | public static function display_header($tool_name ='', $help = null, $page_header = null) |
59 | 59 | { |
60 | 60 | $origin = api_get_origin(); |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | */ |
449 | 449 | public static function display_normal_message($message, $filter = true, $returnValue = false) |
450 | 450 | { |
451 | - $message = self::return_message($message, 'normal', $filter); |
|
451 | + $message = self::return_message($message, 'normal', $filter); |
|
452 | 452 | if ($returnValue) { |
453 | 453 | return $message; |
454 | 454 | } else { |
@@ -524,22 +524,22 @@ discard block |
||
524 | 524 | public static function return_message($message, $type = 'normal', $filter = true) |
525 | 525 | { |
526 | 526 | if ($filter) { |
527 | - $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding()); |
|
527 | + $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding()); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | $class = ""; |
531 | 531 | switch($type) { |
532 | 532 | case 'warning': |
533 | 533 | $class .= 'alert alert-warning'; |
534 | - break; |
|
534 | + break; |
|
535 | 535 | case 'error': |
536 | 536 | $class .= 'alert alert-danger'; |
537 | - break; |
|
537 | + break; |
|
538 | 538 | case 'confirmation': |
539 | 539 | case 'confirm': |
540 | 540 | case 'success': |
541 | 541 | $class .= 'alert alert-success'; |
542 | - break; |
|
542 | + break; |
|
543 | 543 | case 'normal': |
544 | 544 | default: |
545 | 545 | $class .= 'alert alert-info'; |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | * @param array additional attributes (for instance height, width, onclick, ...) |
683 | 683 | * @param integer The wanted width of the icon (to be looked for in the corresponding img/icons/ folder) |
684 | 684 | * @return void |
685 | - */ |
|
685 | + */ |
|
686 | 686 | public static function display_icon( |
687 | 687 | $image, |
688 | 688 | $alt_text = '', |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | * @author Julio Montoya 2010 Function improved, adding image constants |
706 | 706 | * @author Yannick Warnier 2011 Added size handler |
707 | 707 | * @version Feb 2011 |
708 | - */ |
|
708 | + */ |
|
709 | 709 | public static function return_icon( |
710 | 710 | $image, |
711 | 711 | $alt_text = '', |
@@ -884,14 +884,14 @@ discard block |
||
884 | 884 | */ |
885 | 885 | public static function input($type, $name, $value, $attributes = array()) |
886 | 886 | { |
887 | - if (isset($type)) { |
|
888 | - $attributes['type']= $type; |
|
889 | - } |
|
890 | - if (isset($name)) { |
|
891 | - $attributes['name']= $name; |
|
892 | - } |
|
893 | - if (isset($value)) { |
|
894 | - $attributes['value']= $value; |
|
887 | + if (isset($type)) { |
|
888 | + $attributes['type']= $type; |
|
889 | + } |
|
890 | + if (isset($name)) { |
|
891 | + $attributes['name']= $name; |
|
892 | + } |
|
893 | + if (isset($value)) { |
|
894 | + $attributes['value']= $value; |
|
895 | 895 | } |
896 | 896 | return self::tag('input', '', $attributes); |
897 | 897 | } |
@@ -904,10 +904,10 @@ discard block |
||
904 | 904 | */ |
905 | 905 | public static function button($name, $value, $attributes = array()) |
906 | 906 | { |
907 | - if (!empty($name)) { |
|
907 | + if (!empty($name)) { |
|
908 | 908 | $attributes['name'] = $name; |
909 | - } |
|
910 | - return self::tag('button', $value, $attributes); |
|
909 | + } |
|
910 | + return self::tag('button', $value, $attributes); |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | /** |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | * in the $htmlHeadXtra variable before the display_header |
975 | 975 | * Add this script |
976 | 976 | * @example |
977 | - * <script> |
|
977 | + * <script> |
|
978 | 978 | $(function() { |
979 | 979 | $( "#tabs" ).tabs(); |
980 | 980 | }); |
@@ -1035,20 +1035,20 @@ discard block |
||
1035 | 1035 | */ |
1036 | 1036 | public static function tabsOnlyLink($headers, $selected = null) |
1037 | 1037 | { |
1038 | - $id = uniqid(); |
|
1039 | - $i = 1; |
|
1040 | - $lis = null; |
|
1041 | - foreach ($headers as $item) { |
|
1038 | + $id = uniqid(); |
|
1039 | + $i = 1; |
|
1040 | + $lis = null; |
|
1041 | + foreach ($headers as $item) { |
|
1042 | 1042 | $class = null; |
1043 | 1043 | if ($i == $selected) { |
1044 | 1044 | $class = 'active'; |
1045 | 1045 | } |
1046 | - $item = self::tag( |
|
1047 | - 'a', |
|
1048 | - $item['content'], |
|
1049 | - array('id' => $id.'-'.$i, 'href' => $item['url']) |
|
1050 | - ); |
|
1051 | - $lis .= self::tag('li', $item, array('class' => $class)); |
|
1046 | + $item = self::tag( |
|
1047 | + 'a', |
|
1048 | + $item['content'], |
|
1049 | + array('id' => $id.'-'.$i, 'href' => $item['url']) |
|
1050 | + ); |
|
1051 | + $lis .= self::tag('li', $item, array('class' => $class)); |
|
1052 | 1052 | $i++; |
1053 | 1053 | } |
1054 | 1054 | return self::tag('ul', $lis, array('class' => 'nav nav-tabs tabs-margin')); |
@@ -1260,8 +1260,8 @@ discard block |
||
1260 | 1260 | */ |
1261 | 1261 | public static function table($headers, $rows, $attributes = array()) |
1262 | 1262 | { |
1263 | - if (empty($attributes)) { |
|
1264 | - $attributes['class'] = 'data_table'; |
|
1263 | + if (empty($attributes)) { |
|
1264 | + $attributes['class'] = 'data_table'; |
|
1265 | 1265 | } |
1266 | 1266 | $table = new HTML_Table($attributes); |
1267 | 1267 | $row = 0; |
@@ -1269,17 +1269,17 @@ discard block |
||
1269 | 1269 | |
1270 | 1270 | // Course headers |
1271 | 1271 | if (!empty($headers)) { |
1272 | - foreach ($headers as $item) { |
|
1273 | - $table->setHeaderContents($row, $column, $item); |
|
1274 | - $column++; |
|
1275 | - } |
|
1276 | - $row = 1; |
|
1277 | - $column = 0; |
|
1272 | + foreach ($headers as $item) { |
|
1273 | + $table->setHeaderContents($row, $column, $item); |
|
1274 | + $column++; |
|
1275 | + } |
|
1276 | + $row = 1; |
|
1277 | + $column = 0; |
|
1278 | 1278 | } |
1279 | 1279 | |
1280 | 1280 | if (!empty($rows)) { |
1281 | - foreach($rows as $content) { |
|
1282 | - $table->setCellContents($row, $column, $content); |
|
1281 | + foreach($rows as $content) { |
|
1282 | + $table->setCellContents($row, $column, $content); |
|
1283 | 1283 | $row++; |
1284 | 1284 | } |
1285 | 1285 | } |
@@ -1385,7 +1385,7 @@ discard block |
||
1385 | 1385 | //$item_property['tool'] != TOOL_DROPBOX && |
1386 | 1386 | $item_property['tool'] != TOOL_NOTEBOOK && |
1387 | 1387 | $item_property['tool'] != TOOL_CHAT) |
1388 | - ) |
|
1388 | + ) |
|
1389 | 1389 | ) |
1390 | 1390 | // Take only what's visible or "invisible but where the user is a teacher" or where the visibility is unset. |
1391 | 1391 | && ($item_property['visibility'] == '1' |
@@ -1401,7 +1401,7 @@ discard block |
||
1401 | 1401 | ($item_property['to_user_id'] != $user_id) && |
1402 | 1402 | (!isset($item_property['to_group_id']) || !in_array($item_property['to_group_id'], $group_ids))) |
1403 | 1403 | ) { |
1404 | - continue; |
|
1404 | + continue; |
|
1405 | 1405 | } |
1406 | 1406 | |
1407 | 1407 | // If it's a survey, make sure the user's invited. Otherwise drop it. |
@@ -1620,21 +1620,21 @@ discard block |
||
1620 | 1620 | * |
1621 | 1621 | * @param string id of the rating ul element |
1622 | 1622 | * @param string url that will be added (for jquery see hot_courses.tpl) |
1623 | - * @param string point info array see function CourseManager::get_course_ranking() |
|
1624 | - * @param bool add a div wrapper |
|
1625 | - * @todo use templates |
|
1623 | + * @param string point info array see function CourseManager::get_course_ranking() |
|
1624 | + * @param bool add a div wrapper |
|
1625 | + * @todo use templates |
|
1626 | 1626 | **/ |
1627 | 1627 | public static function return_rating_system($id, $url, $point_info = array(), $add_div_wrapper = true) |
1628 | 1628 | { |
1629 | - $number_of_users_who_voted = isset($point_info['users_who_voted']) ? $point_info['users_who_voted'] : null; |
|
1630 | - $percentage = isset($point_info['point_average']) ? $point_info['point_average'] : 0; |
|
1629 | + $number_of_users_who_voted = isset($point_info['users_who_voted']) ? $point_info['users_who_voted'] : null; |
|
1630 | + $percentage = isset($point_info['point_average']) ? $point_info['point_average'] : 0; |
|
1631 | 1631 | |
1632 | - if (!empty($percentage)) { |
|
1632 | + if (!empty($percentage)) { |
|
1633 | 1633 | $percentage = $percentage*125/100; |
1634 | 1634 | } |
1635 | - $accesses = isset($point_info['accesses']) ? $point_info['accesses'] : 0; |
|
1635 | + $accesses = isset($point_info['accesses']) ? $point_info['accesses'] : 0; |
|
1636 | 1636 | |
1637 | - $star_label = sprintf(get_lang('XStarsOutOf5'), $point_info['point_average_star']); |
|
1637 | + $star_label = sprintf(get_lang('XStarsOutOf5'), $point_info['point_average_star']); |
|
1638 | 1638 | |
1639 | 1639 | $html = '<ul id="'.$id.'" class="star-rating"> |
1640 | 1640 | <li class="current-rating" style="width:'.$percentage.'px;"></li> |
@@ -1645,26 +1645,26 @@ discard block |
||
1645 | 1645 | <li><a href="javascript:void(0);" data-link="'.$url.'&star=5" title="'.$star_label.'" class="five-stars">5</a></li> |
1646 | 1646 | </ul>'; |
1647 | 1647 | |
1648 | - $labels = array(); |
|
1648 | + $labels = array(); |
|
1649 | 1649 | |
1650 | - $labels[]= $number_of_users_who_voted == 1 ? $number_of_users_who_voted.' '.get_lang('Vote') : $number_of_users_who_voted.' '.get_lang('Votes'); |
|
1651 | - $labels[]= $accesses == 1 ? $accesses.' '.get_lang('Visit') : $accesses.' '.get_lang('Visits'); |
|
1652 | - if (!empty($number_of_users_who_voted)) { |
|
1653 | - $labels[]= get_lang('Average').' '.$point_info['point_average_star'].'/5'; |
|
1654 | - } |
|
1650 | + $labels[]= $number_of_users_who_voted == 1 ? $number_of_users_who_voted.' '.get_lang('Vote') : $number_of_users_who_voted.' '.get_lang('Votes'); |
|
1651 | + $labels[]= $accesses == 1 ? $accesses.' '.get_lang('Visit') : $accesses.' '.get_lang('Visits'); |
|
1652 | + if (!empty($number_of_users_who_voted)) { |
|
1653 | + $labels[]= get_lang('Average').' '.$point_info['point_average_star'].'/5'; |
|
1654 | + } |
|
1655 | 1655 | |
1656 | - $labels[]= $point_info['user_vote'] ? get_lang('YourVote').' ['.$point_info['user_vote'].']' : get_lang('YourVote'). ' [?] '; |
|
1656 | + $labels[]= $point_info['user_vote'] ? get_lang('YourVote').' ['.$point_info['user_vote'].']' : get_lang('YourVote'). ' [?] '; |
|
1657 | 1657 | |
1658 | - if (!$add_div_wrapper && api_is_anonymous()) { |
|
1659 | - $labels[]= Display::tag('span', get_lang('LoginToVote'), array('class' => 'error')); |
|
1660 | - } |
|
1658 | + if (!$add_div_wrapper && api_is_anonymous()) { |
|
1659 | + $labels[]= Display::tag('span', get_lang('LoginToVote'), array('class' => 'error')); |
|
1660 | + } |
|
1661 | 1661 | |
1662 | 1662 | $html .= Display::div(implode(' | ', $labels) , array('id' => 'vote_label_'.$id, 'class' => 'vote_label_info')); |
1663 | 1663 | $html .= ' '.Display::span(' ', array('id' => 'vote_label2_'.$id)); |
1664 | 1664 | |
1665 | 1665 | if ($add_div_wrapper) { |
1666 | - $html = Display::div($html, array('id' => 'rating_wrapper_'.$id)); |
|
1667 | - } |
|
1666 | + $html = Display::div($html, array('id' => 'rating_wrapper_'.$id)); |
|
1667 | + } |
|
1668 | 1668 | |
1669 | 1669 | return $html; |
1670 | 1670 | } |
@@ -1702,8 +1702,8 @@ discard block |
||
1702 | 1702 | return self::page_header($title, $second_title); |
1703 | 1703 | } |
1704 | 1704 | |
1705 | - public static function page_subheader_and_translate($title, $second_title = null) |
|
1706 | - { |
|
1705 | + public static function page_subheader_and_translate($title, $second_title = null) |
|
1706 | + { |
|
1707 | 1707 | $title = get_lang($title); |
1708 | 1708 | return self::page_subheader($title, $second_title); |
1709 | 1709 | } |
@@ -666,9 +666,10 @@ |
||
666 | 666 | $result = ''; |
667 | 667 | for ($i = $min; $i <= $max; $i ++) { |
668 | 668 | $result .= '<option value="'.$i.'"'; |
669 | - if (is_int($selected_num)) |
|
670 | - if ($selected_num == $i) { |
|
669 | + if (is_int($selected_num)) { |
|
670 | + if ($selected_num == $i) { |
|
671 | 671 | $result .= ' selected="selected"'; |
672 | + } |
|
672 | 673 | } |
673 | 674 | $result .= '>'.$i.'</option>'; |
674 | 675 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @param string Optional help file name |
56 | 56 | * @param string $page_header |
57 | 57 | */ |
58 | - public static function display_header($tool_name ='', $help = null, $page_header = null) |
|
58 | + public static function display_header($tool_name = '', $help = null, $page_header = null) |
|
59 | 59 | { |
60 | 60 | $origin = api_get_origin(); |
61 | 61 | $showHeader = true; |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | $grid_class = array(), |
352 | 352 | $elementCount = 0 |
353 | 353 | ) { |
354 | - $column = 0; |
|
354 | + $column = 0; |
|
355 | 355 | $default_items_per_page = isset($paging_options['per_page']) ? $paging_options['per_page'] : 20; |
356 | 356 | |
357 | 357 | $table = new SortableTableFromArray($content, $column, $default_items_per_page, $name); |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | * @param bool Filter (true) or not (false) |
477 | 477 | * @return void |
478 | 478 | */ |
479 | - public static function display_confirmation_message ($message, $filter = true, $returnValue = false) |
|
479 | + public static function display_confirmation_message($message, $filter = true, $returnValue = false) |
|
480 | 480 | { |
481 | 481 | $message = self::return_message($message, 'confirm', $filter); |
482 | 482 | if ($returnValue) { |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | * @param bool Filter (true) or not (false) |
494 | 494 | * @return void |
495 | 495 | */ |
496 | - public static function display_error_message ($message, $filter = true, $returnValue = false) |
|
496 | + public static function display_error_message($message, $filter = true, $returnValue = false) |
|
497 | 497 | { |
498 | 498 | $message = self::return_message($message, 'error', $filter); |
499 | 499 | if ($returnValue) { |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @param string $type |
509 | 509 | * @param bool $filter |
510 | 510 | */ |
511 | - public static function return_message_and_translate($message, $type='normal', $filter = true) |
|
511 | + public static function return_message_and_translate($message, $type = 'normal', $filter = true) |
|
512 | 512 | { |
513 | 513 | $message = get_lang($message); |
514 | 514 | echo self::return_message($message, $type, $filter); |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | } |
533 | 533 | |
534 | 534 | $class = ""; |
535 | - switch($type) { |
|
535 | + switch ($type) { |
|
536 | 536 | case 'warning': |
537 | 537 | $class .= 'alert alert-warning'; |
538 | 538 | break; |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * @param string optional, class from stylesheet |
561 | 561 | * @return string encrypted mailto hyperlink |
562 | 562 | */ |
563 | - public static function encrypted_mailto_link ($email, $clickable_text = null, $style_class = '') |
|
563 | + public static function encrypted_mailto_link($email, $clickable_text = null, $style_class = '') |
|
564 | 564 | { |
565 | 565 | if (is_null($clickable_text)) { |
566 | 566 | $clickable_text = $email; |
@@ -575,14 +575,14 @@ discard block |
||
575 | 575 | } |
576 | 576 | // Encrypt email |
577 | 577 | $hmail = ''; |
578 | - for ($i = 0; $i < strlen($email); $i ++) { |
|
578 | + for ($i = 0; $i < strlen($email); $i++) { |
|
579 | 579 | $hmail .= '&#'.ord($email { |
580 | 580 | $i }).';'; |
581 | 581 | } |
582 | 582 | $hclickable_text = null; |
583 | 583 | // Encrypt clickable text if @ is present |
584 | 584 | if (strpos($clickable_text, '@')) { |
585 | - for ($i = 0; $i < strlen($clickable_text); $i ++) { |
|
585 | + for ($i = 0; $i < strlen($clickable_text); $i++) { |
|
586 | 586 | $hclickable_text .= '&#'.ord($clickable_text { |
587 | 587 | $i }).';'; |
588 | 588 | } |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | } |
615 | 615 | // Encrypt email |
616 | 616 | $hmail = ''; |
617 | - for ($i = 0; $i < strlen($email); $i ++) { |
|
617 | + for ($i = 0; $i < strlen($email); $i++) { |
|
618 | 618 | $hmail .= '&#'.ord($email { |
619 | 619 | $i }).';'; |
620 | 620 | } |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | public static function get_alphabet_options($selected_letter = '') |
648 | 648 | { |
649 | 649 | $result = ''; |
650 | - for ($i = 65; $i <= 90; $i ++) { |
|
650 | + for ($i = 65; $i <= 90; $i++) { |
|
651 | 651 | $letter = chr($i); |
652 | 652 | $result .= '<option value="'.$letter.'"'; |
653 | 653 | if ($selected_letter == $letter) { |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | public static function get_numeric_options($min, $max, $selected_num = 0) |
669 | 669 | { |
670 | 670 | $result = ''; |
671 | - for ($i = $min; $i <= $max; $i ++) { |
|
671 | + for ($i = $min; $i <= $max; $i++) { |
|
672 | 672 | $result .= '<option value="'.$i.'"'; |
673 | 673 | if (is_int($selected_num)) |
674 | 674 | if ($selected_num == $i) { |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | $size = ICON_SIZE_SMALL; |
746 | 746 | } |
747 | 747 | |
748 | - $size_extra = $size . '/'; |
|
748 | + $size_extra = $size.'/'; |
|
749 | 749 | |
750 | 750 | // Checking the img/ folder |
751 | 751 | $icon = $w_code_path.'img/'.$image; |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | $theme = 'themes/chamilo/icons/'; |
754 | 754 | |
755 | 755 | if ($loadThemeIcon) { |
756 | - $theme = 'themes/' . api_get_visual_theme() . '/icons/'; |
|
756 | + $theme = 'themes/'.api_get_visual_theme().'/icons/'; |
|
757 | 757 | // Checking the theme icons folder example: app/Resources/public/css/themes/chamilo/icons/XXX |
758 | 758 | if (is_file($alternateCssPath.$theme.$size_extra.$image)) { |
759 | 759 | $icon = $alternateWebCssPath.$theme.$size_extra.$image; |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | } |
860 | 860 | } |
861 | 861 | //some tags don't have this </XXX> |
862 | - if (in_array($tag, array('img','input','br'))) { |
|
862 | + if (in_array($tag, array('img', 'input', 'br'))) { |
|
863 | 863 | $return_value = '<'.$tag.' '.$attribute_list.' />'; |
864 | 864 | } else { |
865 | 865 | $return_value = '<'.$tag.' '.$attribute_list.' > '.$content.'</'.$tag.'>'; |
@@ -912,13 +912,13 @@ discard block |
||
912 | 912 | public static function input($type, $name, $value, $attributes = array()) |
913 | 913 | { |
914 | 914 | if (isset($type)) { |
915 | - $attributes['type']= $type; |
|
915 | + $attributes['type'] = $type; |
|
916 | 916 | } |
917 | 917 | if (isset($name)) { |
918 | - $attributes['name']= $name; |
|
918 | + $attributes['name'] = $name; |
|
919 | 919 | } |
920 | 920 | if (isset($value)) { |
921 | - $attributes['value']= $value; |
|
921 | + $attributes['value'] = $value; |
|
922 | 922 | } |
923 | 923 | return self::tag('input', '', $attributes); |
924 | 924 | } |
@@ -951,14 +951,14 @@ discard block |
||
951 | 951 | ) { |
952 | 952 | $html = ''; |
953 | 953 | $extra = ''; |
954 | - $default_id = 'id="' . $name . '" '; |
|
954 | + $default_id = 'id="'.$name.'" '; |
|
955 | 955 | foreach ($extra_attributes as $key => $parameter) { |
956 | 956 | if ($key == 'id') { |
957 | 957 | $default_id = ''; |
958 | 958 | } |
959 | - $extra .= $key . '="' . $parameter . '" '; |
|
959 | + $extra .= $key.'="'.$parameter.'" '; |
|
960 | 960 | } |
961 | - $html .= '<select name="' . $name . '" ' . $default_id . ' ' . $extra . '>'; |
|
961 | + $html .= '<select name="'.$name.'" '.$default_id.' '.$extra.'>'; |
|
962 | 962 | |
963 | 963 | if ($show_blank_item) { |
964 | 964 | if (empty($blank_item_text)) { |
@@ -966,14 +966,14 @@ discard block |
||
966 | 966 | } else { |
967 | 967 | $blank_item_text = Security::remove_XSS($blank_item_text); |
968 | 968 | } |
969 | - $html .= self::tag('option', '-- ' . $blank_item_text . ' --', array('value' => '-1')); |
|
969 | + $html .= self::tag('option', '-- '.$blank_item_text.' --', array('value' => '-1')); |
|
970 | 970 | } |
971 | 971 | if ($values) { |
972 | 972 | foreach ($values as $key => $value) { |
973 | 973 | if (is_array($value) && isset($value['name'])) { |
974 | 974 | $value = $value['name']; |
975 | 975 | } |
976 | - $html .= '<option value="' . $key . '"'; |
|
976 | + $html .= '<option value="'.$key.'"'; |
|
977 | 977 | |
978 | 978 | if (is_array($default)) { |
979 | 979 | foreach ($default as $item) { |
@@ -988,7 +988,7 @@ discard block |
||
988 | 988 | } |
989 | 989 | } |
990 | 990 | |
991 | - $html .= '>' . $value . '</option>'; |
|
991 | + $html .= '>'.$value.'</option>'; |
|
992 | 992 | } |
993 | 993 | } |
994 | 994 | $html .= '</select>'; |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | */ |
1015 | 1015 | public static function tabs($header_list, $content_list, $id = 'tabs', $attributes = array(), $ul_attributes = array()) |
1016 | 1016 | { |
1017 | - if (empty($header_list) || count($header_list) == 0 ) { |
|
1017 | + if (empty($header_list) || count($header_list) == 0) { |
|
1018 | 1018 | return ''; |
1019 | 1019 | } |
1020 | 1020 | |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | |
1052 | 1052 | $main_div = self::tag('div', $ul.self::tag('div', $divs, ['class' => 'tab-content']), $attributes); |
1053 | 1053 | |
1054 | - return $main_div ; |
|
1054 | + return $main_div; |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | /** |
@@ -1099,8 +1099,8 @@ discard block |
||
1099 | 1099 | */ |
1100 | 1100 | public static function grid_html($div_id) |
1101 | 1101 | { |
1102 | - $table = self::tag('table','', array('id' => $div_id)); |
|
1103 | - $table .= self::tag('div','', array('id' => $div_id.'_pager')); |
|
1102 | + $table = self::tag('table', '', array('id' => $div_id)); |
|
1103 | + $table .= self::tag('div', '', array('id' => $div_id.'_pager')); |
|
1104 | 1104 | return $table; |
1105 | 1105 | } |
1106 | 1106 | |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | $obj->colNames = $column_names; |
1162 | 1162 | $obj->colModel = $column_model; |
1163 | 1163 | $obj->pager = '#'.$div_id.'_pager'; |
1164 | - $obj->datatype = 'json'; |
|
1164 | + $obj->datatype = 'json'; |
|
1165 | 1165 | $obj->viewrecords = 'true'; |
1166 | 1166 | |
1167 | 1167 | $all_value = 10000000; |
@@ -1222,10 +1222,10 @@ discard block |
||
1222 | 1222 | // Adding static data. |
1223 | 1223 | if (!empty($data)) { |
1224 | 1224 | $data_var = $div_id.'_data'; |
1225 | - $json.=' var '.$data_var.' = '.json_encode($data).';'; |
|
1225 | + $json .= ' var '.$data_var.' = '.json_encode($data).';'; |
|
1226 | 1226 | $obj->data = $data_var; |
1227 | 1227 | $obj->datatype = 'local'; |
1228 | - $json.="\n"; |
|
1228 | + $json .= "\n"; |
|
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | $obj->end = 'end'; |
@@ -1239,12 +1239,12 @@ discard block |
||
1239 | 1239 | } |
1240 | 1240 | |
1241 | 1241 | // Fixing true/false js values that doesn't need the "" |
1242 | - $json_encode = str_replace(':"true"',':true',$json_encode); |
|
1242 | + $json_encode = str_replace(':"true"', ':true', $json_encode); |
|
1243 | 1243 | // wrap_cell is not a valid jqgrid attributes is a hack to wrap a text |
1244 | 1244 | $json_encode = str_replace('"wrap_cell":true', 'cellattr : function(rowId, value, rowObject, colModel, arrData) { return \'class = "jqgrid_whitespace"\'; }', $json_encode); |
1245 | - $json_encode = str_replace(':"false"',':false',$json_encode); |
|
1245 | + $json_encode = str_replace(':"false"', ':false', $json_encode); |
|
1246 | 1246 | $json_encode = str_replace('"formatter":"action_formatter"', 'formatter:action_formatter', $json_encode); |
1247 | - $json_encode = str_replace(array('{"first":"first",','"end":"end"}'), '', $json_encode); |
|
1247 | + $json_encode = str_replace(array('{"first":"first",', '"end":"end"}'), '', $json_encode); |
|
1248 | 1248 | |
1249 | 1249 | // Creating the jqgrid element. |
1250 | 1250 | $json .= '$("#'.$div_id.'").jqGrid({'; |
@@ -1259,22 +1259,22 @@ discard block |
||
1259 | 1259 | $groups = ''; |
1260 | 1260 | foreach ($extra_params['groupHeaders'] as $group) { |
1261 | 1261 | //{ "startColumnName" : "courses", "numberOfColumns" : 1, "titleText" : "Order Info" }, |
1262 | - $groups .= '{ "startColumnName" : "' . $group['startColumnName'] . '", "numberOfColumns" : ' . $group['numberOfColumns'] . ', "titleText" : "' . $group['titleText'] . '" },'; |
|
1262 | + $groups .= '{ "startColumnName" : "'.$group['startColumnName'].'", "numberOfColumns" : '.$group['numberOfColumns'].', "titleText" : "'.$group['titleText'].'" },'; |
|
1263 | 1263 | |
1264 | 1264 | } |
1265 | 1265 | $json .= '$("#'.$div_id.'").jqGrid("setGroupHeaders", { |
1266 | 1266 | "useColSpanStyle" : false, |
1267 | 1267 | "groupHeaders" : [ |
1268 | - ' . $groups . ' |
|
1268 | + ' . $groups.' |
|
1269 | 1269 | ] |
1270 | 1270 | });'; |
1271 | 1271 | } |
1272 | 1272 | |
1273 | 1273 | $all_text = addslashes(get_lang('All')); |
1274 | 1274 | $json .= '$("'.$obj->pager.' option[value='.$all_value.']").text("'.$all_text.'");'; |
1275 | - $json.= "\n"; |
|
1275 | + $json .= "\n"; |
|
1276 | 1276 | // Adding edit/delete icons. |
1277 | - $json.= $formatter; |
|
1277 | + $json .= $formatter; |
|
1278 | 1278 | |
1279 | 1279 | return $json; |
1280 | 1280 | } |
@@ -1305,7 +1305,7 @@ discard block |
||
1305 | 1305 | } |
1306 | 1306 | |
1307 | 1307 | if (!empty($rows)) { |
1308 | - foreach($rows as $content) { |
|
1308 | + foreach ($rows as $content) { |
|
1309 | 1309 | $table->setCellContents($row, $column, $content); |
1310 | 1310 | $row++; |
1311 | 1311 | } |
@@ -1467,7 +1467,7 @@ discard block |
||
1467 | 1467 | |
1468 | 1468 | // Show all tool icons where there is something new. |
1469 | 1469 | $return = ' '; |
1470 | - foreach($notifications as $notification) { |
|
1470 | + foreach ($notifications as $notification) { |
|
1471 | 1471 | $lastDate = date('d/m/Y H:i', convert_sql_date($notification['lastedit_date'])); |
1472 | 1472 | $type = $notification['lastedit_type']; |
1473 | 1473 | $label = get_lang('TitleNotification').": ".get_lang($type)." ($lastDate)"; |
@@ -1510,9 +1510,9 @@ discard block |
||
1510 | 1510 | $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
1511 | 1511 | $active = false; |
1512 | 1512 | // Request for the name of the general coach |
1513 | - $sql ='SELECT tu.lastname, tu.firstname, ts.* |
|
1513 | + $sql = 'SELECT tu.lastname, tu.firstname, ts.* |
|
1514 | 1514 | FROM '.$tbl_session.' ts |
1515 | - LEFT JOIN '.$main_user_table .' tu |
|
1515 | + LEFT JOIN '.$main_user_table.' tu |
|
1516 | 1516 | ON ts.id_coach = tu.user_id |
1517 | 1517 | WHERE ts.id = '.intval($session_id); |
1518 | 1518 | $rs = Database::query($sql); |
@@ -1522,7 +1522,7 @@ discard block |
||
1522 | 1522 | $session = array(); |
1523 | 1523 | $session['title'] = $session_info['name']; |
1524 | 1524 | $session['coach'] = ''; |
1525 | - $session['dates'] = ''; |
|
1525 | + $session['dates'] = ''; |
|
1526 | 1526 | |
1527 | 1527 | if ( |
1528 | 1528 | ( |
@@ -1604,8 +1604,8 @@ discard block |
||
1604 | 1604 | ); |
1605 | 1605 | } |
1606 | 1606 | |
1607 | - if ( api_get_setting('show_session_coach') === 'true' ) { |
|
1608 | - $session['coach'] = get_lang('GeneralCoach') . ': ' . api_get_person_name( |
|
1607 | + if (api_get_setting('show_session_coach') === 'true') { |
|
1608 | + $session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name( |
|
1609 | 1609 | $session_info['firstname'], |
1610 | 1610 | $session_info['lastname'] |
1611 | 1611 | ); |
@@ -1657,9 +1657,9 @@ discard block |
||
1657 | 1657 | $percentage = isset($point_info['point_average']) ? $point_info['point_average'] : 0; |
1658 | 1658 | |
1659 | 1659 | if (!empty($percentage)) { |
1660 | - $percentage = $percentage*125/100; |
|
1660 | + $percentage = $percentage * 125 / 100; |
|
1661 | 1661 | } |
1662 | - $accesses = isset($point_info['accesses']) ? $point_info['accesses'] : 0; |
|
1662 | + $accesses = isset($point_info['accesses']) ? $point_info['accesses'] : 0; |
|
1663 | 1663 | |
1664 | 1664 | $star_label = sprintf(get_lang('XStarsOutOf5'), $point_info['point_average_star']); |
1665 | 1665 | |
@@ -1674,19 +1674,19 @@ discard block |
||
1674 | 1674 | |
1675 | 1675 | $labels = array(); |
1676 | 1676 | |
1677 | - $labels[]= $number_of_users_who_voted == 1 ? $number_of_users_who_voted.' '.get_lang('Vote') : $number_of_users_who_voted.' '.get_lang('Votes'); |
|
1678 | - $labels[]= $accesses == 1 ? $accesses.' '.get_lang('Visit') : $accesses.' '.get_lang('Visits'); |
|
1677 | + $labels[] = $number_of_users_who_voted == 1 ? $number_of_users_who_voted.' '.get_lang('Vote') : $number_of_users_who_voted.' '.get_lang('Votes'); |
|
1678 | + $labels[] = $accesses == 1 ? $accesses.' '.get_lang('Visit') : $accesses.' '.get_lang('Visits'); |
|
1679 | 1679 | if (!empty($number_of_users_who_voted)) { |
1680 | - $labels[]= get_lang('Average').' '.$point_info['point_average_star'].'/5'; |
|
1680 | + $labels[] = get_lang('Average').' '.$point_info['point_average_star'].'/5'; |
|
1681 | 1681 | } |
1682 | 1682 | |
1683 | - $labels[]= $point_info['user_vote'] ? get_lang('YourVote').' ['.$point_info['user_vote'].']' : get_lang('YourVote'). ' [?] '; |
|
1683 | + $labels[] = $point_info['user_vote'] ? get_lang('YourVote').' ['.$point_info['user_vote'].']' : get_lang('YourVote').' [?] '; |
|
1684 | 1684 | |
1685 | 1685 | if (!$add_div_wrapper && api_is_anonymous()) { |
1686 | - $labels[]= Display::tag('span', get_lang('LoginToVote'), array('class' => 'error')); |
|
1686 | + $labels[] = Display::tag('span', get_lang('LoginToVote'), array('class' => 'error')); |
|
1687 | 1687 | } |
1688 | 1688 | |
1689 | - $html .= Display::div(implode(' | ', $labels) , array('id' => 'vote_label_'.$id, 'class' => 'vote_label_info')); |
|
1689 | + $html .= Display::div(implode(' | ', $labels), array('id' => 'vote_label_'.$id, 'class' => 'vote_label_info')); |
|
1690 | 1690 | $html .= ' '.Display::span(' ', array('id' => 'vote_label2_'.$id)); |
1691 | 1691 | |
1692 | 1692 | if ($add_div_wrapper) { |
@@ -1764,8 +1764,8 @@ discard block |
||
1764 | 1764 | if (!empty($list)) { |
1765 | 1765 | $html = '<dl class="dl-horizontal">'; |
1766 | 1766 | foreach ($list as $item) { |
1767 | - $html .= '<dt>' . $item['title'] . '</dt>'; |
|
1768 | - $html .= '<dd>' . $item['content'] . '</dd>'; |
|
1767 | + $html .= '<dt>'.$item['title'].'</dt>'; |
|
1768 | + $html .= '<dd>'.$item['content'].'</dd>'; |
|
1769 | 1769 | } |
1770 | 1770 | $html .= '</dl>'; |
1771 | 1771 | } |
@@ -1807,7 +1807,7 @@ discard block |
||
1807 | 1807 | * @param string $type |
1808 | 1808 | * @return null|string |
1809 | 1809 | */ |
1810 | - public static function badge($count, $type ="warning") |
|
1810 | + public static function badge($count, $type = "warning") |
|
1811 | 1811 | { |
1812 | 1812 | $class = ''; |
1813 | 1813 | |
@@ -1883,7 +1883,7 @@ discard block |
||
1883 | 1883 | if (!empty($content)) { |
1884 | 1884 | $html = '<span class="label '.$class.'">'; |
1885 | 1885 | $html .= $content; |
1886 | - $html .='</span>'; |
|
1886 | + $html .= '</span>'; |
|
1887 | 1887 | } |
1888 | 1888 | |
1889 | 1889 | return $html; |
@@ -1904,7 +1904,7 @@ discard block |
||
1904 | 1904 | $class = 'class ="active"'; |
1905 | 1905 | } |
1906 | 1906 | |
1907 | - if (basename($_SERVER['REQUEST_URI']) == basename($value['url']) ) { |
|
1907 | + if (basename($_SERVER['REQUEST_URI']) == basename($value['url'])) { |
|
1908 | 1908 | $class = 'class ="active"'; |
1909 | 1909 | } |
1910 | 1910 | $html .= "<li $class >"; |
@@ -2155,7 +2155,7 @@ discard block |
||
2155 | 2155 | } |
2156 | 2156 | $label = $nextValue + $localCounter + 1; |
2157 | 2157 | if ($isMedia) { |
2158 | - $label = ($fixedValue + 1) .' '.chr(97 + $localCounter); |
|
2158 | + $label = ($fixedValue + 1).' '.chr(97 + $localCounter); |
|
2159 | 2159 | $link_to_show = $link.$fixedValue.'#questionanchor'.$itemId; |
2160 | 2160 | } |
2161 | 2161 | $link = Display::url($label.' ', $link_to_show, $linkAttributes); |
@@ -2267,7 +2267,7 @@ discard block |
||
2267 | 2267 | */ |
2268 | 2268 | public static function getVCardUserLink($userId) |
2269 | 2269 | { |
2270 | - $vCardUrl = api_get_path(WEB_PATH).'main/social/vcard_export.php?userId='.intval($userId);; |
|
2270 | + $vCardUrl = api_get_path(WEB_PATH).'main/social/vcard_export.php?userId='.intval($userId); ; |
|
2271 | 2271 | |
2272 | 2272 | return $vCardUrl; |
2273 | 2273 | } |
@@ -2285,7 +2285,7 @@ discard block |
||
2285 | 2285 | { |
2286 | 2286 | $title = !empty($title) ? '<div class="panel-heading"><h3 class="panel-title">'.$title.'</h3>'.$extra.'</div>' : ''; |
2287 | 2287 | $footer = !empty($footer) ? '<div class="panel-footer ">'.$footer.'</div>' : ''; |
2288 | - $styles = ['primary','success','info','warning','danger']; |
|
2288 | + $styles = ['primary', 'success', 'info', 'warning', 'danger']; |
|
2289 | 2289 | $style = !in_array($style, $styles) ? 'default' : $style; |
2290 | 2290 | |
2291 | 2291 | return ' |
@@ -2330,7 +2330,7 @@ discard block |
||
2330 | 2330 | $attributes['class'] = isset($attributes['class']) ? "$buttonClass {$attributes['class']}" : $buttonClass; |
2331 | 2331 | |
2332 | 2332 | if (!$includeText) { |
2333 | - $text = '<span class="sr-only">' . $text . '</span>'; |
|
2333 | + $text = '<span class="sr-only">'.$text.'</span>'; |
|
2334 | 2334 | } |
2335 | 2335 | |
2336 | 2336 | return self::url("$icon $text", $url, $attributes); |
@@ -2345,16 +2345,16 @@ discard block |
||
2345 | 2345 | */ |
2346 | 2346 | public static function toolbarAction($id, $content = array(), $col = 2, $right = true) |
2347 | 2347 | { |
2348 | - $columns = 12/$col; |
|
2348 | + $columns = 12 / $col; |
|
2349 | 2349 | $html = ''; |
2350 | - $html .= '<div id="' . $id . '" class="actions">'; |
|
2350 | + $html .= '<div id="'.$id.'" class="actions">'; |
|
2351 | 2351 | $html .= '<div class="row">'; |
2352 | 2352 | if ($col > 4) { |
2353 | 2353 | $html = '<div class="alert alert-warning" role="alert">Action toolbar design does not work when exceeding four columns - check Display::toolbarAction()</div>'; |
2354 | 2354 | } else { |
2355 | - for ( $i = 0; $i < $col; $i++ ) { |
|
2356 | - $html .= '<div class="col-md-' . $columns . '">'; |
|
2357 | - if ( $col == 2 && $i == 1 ) { |
|
2355 | + for ($i = 0; $i < $col; $i++) { |
|
2356 | + $html .= '<div class="col-md-'.$columns.'">'; |
|
2357 | + if ($col == 2 && $i == 1) { |
|
2358 | 2358 | if ($right === true) { |
2359 | 2359 | $html .= '<div class="pull-right">'; |
2360 | 2360 | $html .= (isset($content[$i]) ? $content[$i] : ''); |
@@ -2469,9 +2469,9 @@ discard block |
||
2469 | 2469 | $params['class'] = 'panel panel-default'; |
2470 | 2470 | $html = null; |
2471 | 2471 | if (!empty($title)) { |
2472 | - $html .= '<div class="panel-heading">'.$title.'</div>' . PHP_EOL; |
|
2472 | + $html .= '<div class="panel-heading">'.$title.'</div>'.PHP_EOL; |
|
2473 | 2473 | } |
2474 | - $html.= '<div class="panel-body">'.$content.'</div>' . PHP_EOL; |
|
2474 | + $html .= '<div class="panel-body">'.$content.'</div>'.PHP_EOL; |
|
2475 | 2475 | $html = Display::div($html, $params); |
2476 | 2476 | } |
2477 | 2477 | return $html; |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
242 | - * @param doc_id id of document (id in mainDb.document table) |
|
242 | + * @param doc_id string of document (id in mainDb.document table) |
|
243 | 243 | * @author Sebastien Piraux <[email protected]> |
244 | 244 | * @desc Record information for upload event |
245 | 245 | * used in the works tool to record informations when |
@@ -311,6 +311,8 @@ discard block |
||
311 | 311 | * @param int session_id |
312 | 312 | * @param int learnpath_id (id of the learnpath) |
313 | 313 | * @param int learnpath_item_id (id of the learnpath_item) |
314 | + * @param integer $weighting |
|
315 | + * @param integer $session_id |
|
314 | 316 | * |
315 | 317 | * @author Sebastien Piraux <[email protected]> |
316 | 318 | * @author Julio Montoya Armas <[email protected]> Reworked 2010 |
@@ -412,7 +414,9 @@ discard block |
||
412 | 414 | * @param integer Session ID (from the session table). Default value of null means "get from context". |
413 | 415 | * @param integer Learnpath ID (from c_lp table). Default value of null means "get from context". |
414 | 416 | * @param integer Learnpath item ID (from the c_lp_item table). Default value of null means "get from context". |
415 | - * @return boolean Result of the insert query |
|
417 | + * @param integer $exe_id |
|
418 | + * @param integer $position |
|
419 | + * @return false|string Result of the insert query |
|
416 | 420 | */ |
417 | 421 | public static function saveQuestionAttempt( |
418 | 422 | $score, |
@@ -582,6 +586,7 @@ discard block |
||
582 | 586 | * @param int Whether this answer is correct (1) or not (0) |
583 | 587 | * @param string Coordinates of this point (e.g. 123;324) |
584 | 588 | * @param bool update results? |
589 | + * @param integer $exe_id |
|
585 | 590 | * @return boolean Result of the insert query |
586 | 591 | * @uses Course code and user_id from global scope $_cid and $_user |
587 | 592 | */ |
@@ -714,7 +719,6 @@ discard block |
||
714 | 719 | /** |
715 | 720 | * Get every email stored in the database |
716 | 721 | * |
717 | - * @param int $etId |
|
718 | 722 | * @return type |
719 | 723 | * @assert () !== false |
720 | 724 | */ |
@@ -782,11 +786,11 @@ discard block |
||
782 | 786 | /** |
783 | 787 | * Save the new message for one event and for one language |
784 | 788 | * |
785 | - * @param string $eventName |
|
789 | + * @param string $event_name |
|
786 | 790 | * @param array $users |
787 | 791 | * @param string $message |
788 | 792 | * @param string $subject |
789 | - * @param string $eventMessageLanguage |
|
793 | + * @param string $event_message_language |
|
790 | 794 | * @param int $activated |
791 | 795 | */ |
792 | 796 | public static function save_event_type_message($event_name, $users, $message, $subject, $event_message_language, $activated) |
@@ -920,10 +924,10 @@ discard block |
||
920 | 924 | } |
921 | 925 | |
922 | 926 | /** |
923 | - * @param $user_id |
|
927 | + * @param integer $user_id |
|
924 | 928 | * @param $exerciseId |
925 | - * @param $lp_id |
|
926 | - * @param $lp_item_id |
|
929 | + * @param integer $lp_id |
|
930 | + * @param integer $lp_item_id |
|
927 | 931 | * @return int |
928 | 932 | */ |
929 | 933 | public static function get_attempt_count_not_finished($user_id, $exerciseId, $lp_id, $lp_item_id) |
@@ -1100,6 +1104,7 @@ discard block |
||
1100 | 1104 | * @param int exercise id |
1101 | 1105 | * @param int $courseId |
1102 | 1106 | * @param int session id |
1107 | + * @param integer $user_id |
|
1103 | 1108 | * @return array with the results |
1104 | 1109 | * |
1105 | 1110 | */ |
@@ -1195,6 +1200,7 @@ discard block |
||
1195 | 1200 | * @param int exercise id |
1196 | 1201 | * @param int $courseId |
1197 | 1202 | * @param int session id |
1203 | + * @param integer $user_id |
|
1198 | 1204 | * @return array with the results |
1199 | 1205 | * |
1200 | 1206 | */ |
@@ -1235,6 +1241,7 @@ discard block |
||
1235 | 1241 | * @param int exercise id |
1236 | 1242 | * @param string course code |
1237 | 1243 | * @param int session id |
1244 | + * @param integer $exe_id |
|
1238 | 1245 | * @return array with the results |
1239 | 1246 | * |
1240 | 1247 | */ |
@@ -1284,6 +1291,7 @@ discard block |
||
1284 | 1291 | * @param int lp id |
1285 | 1292 | * @param int lp item id |
1286 | 1293 | * @param string order asc or desc |
1294 | + * @param integer $courseId |
|
1287 | 1295 | * @return array with the results |
1288 | 1296 | * |
1289 | 1297 | */ |
@@ -1343,7 +1351,7 @@ discard block |
||
1343 | 1351 | * @param int exercise id |
1344 | 1352 | * @param int $courseId |
1345 | 1353 | * @param int session id |
1346 | - * @return array with the results |
|
1354 | + * @return string with the results |
|
1347 | 1355 | * |
1348 | 1356 | */ |
1349 | 1357 | public static function count_exercise_attempts_by_user($user_id, $exercise_id, $courseId, $session_id = 0) |
@@ -1519,7 +1527,7 @@ discard block |
||
1519 | 1527 | * @param int exercise id |
1520 | 1528 | * @param int course id |
1521 | 1529 | * @param int session id |
1522 | - * @return array with the results |
|
1530 | + * @return integer with the results |
|
1523 | 1531 | * |
1524 | 1532 | */ |
1525 | 1533 | public static function get_count_exercises_attempted_by_course($courseId, $session_id = 0) |
@@ -78,9 +78,7 @@ discard block |
||
78 | 78 | Database::query($sql); |
79 | 79 | |
80 | 80 | // Auto subscribe |
81 | - $user_status = $userInfo['status'] == SESSIONADMIN ? 'sessionadmin' : |
|
82 | - $userInfo['status'] == COURSEMANAGER ? 'teacher' : |
|
83 | - $userInfo['status'] == DRH ? 'DRH' : 'student'; |
|
81 | + $user_status = $userInfo['status'] == SESSIONADMIN ? 'sessionadmin' : $userInfo['status'] == COURSEMANAGER ? 'teacher' : $userInfo['status'] == DRH ? 'DRH' : 'student'; |
|
84 | 82 | $autoSubscribe = api_get_setting($user_status.'_autosubscribe'); |
85 | 83 | if ($autoSubscribe) { |
86 | 84 | $autoSubscribe = explode('|', $autoSubscribe); |
@@ -334,7 +332,7 @@ discard block |
||
334 | 332 | global $debug; |
335 | 333 | |
336 | 334 | if ($debug) error_log('Called to update_event_exercice'); |
337 | - if ($debug) error_log('duration:' . $duration); |
|
335 | + if ($debug) error_log('duration:'.$duration); |
|
338 | 336 | |
339 | 337 | if ($exeid != '') { |
340 | 338 | /* |
@@ -382,7 +380,7 @@ discard block |
||
382 | 380 | status = '".$status."', |
383 | 381 | questions_to_check = '".$remind_list."', |
384 | 382 | data_tracking = '".implode(',', $question_list)."', |
385 | - user_ip = '" . Database::escape_string(api_get_real_ip()) . "' |
|
383 | + user_ip = '" . Database::escape_string(api_get_real_ip())."' |
|
386 | 384 | WHERE exe_id = '".Database::escape_string($exeid)."'"; |
387 | 385 | $res = Database::query($sql); |
388 | 386 | |
@@ -1036,15 +1034,15 @@ discard block |
||
1036 | 1034 | |
1037 | 1035 | if (!empty($exe_list) && is_array($exe_list) && count($exe_list) > 0) { |
1038 | 1036 | $sql = "DELETE FROM $track_e_exercises |
1039 | - WHERE exe_id IN (" . implode(',', $exe_list) . ")"; |
|
1037 | + WHERE exe_id IN (".implode(',', $exe_list).")"; |
|
1040 | 1038 | Database::query($sql); |
1041 | 1039 | |
1042 | 1040 | $sql = "DELETE FROM $track_attempts |
1043 | - WHERE exe_id IN (" . implode(',', $exe_list) . ")"; |
|
1041 | + WHERE exe_id IN (".implode(',', $exe_list).")"; |
|
1044 | 1042 | Database::query($sql); |
1045 | 1043 | |
1046 | 1044 | $sql = "DELETE FROM $recording_table |
1047 | - WHERE exe_id IN (" . implode(',', $exe_list) . ")"; |
|
1045 | + WHERE exe_id IN (".implode(',', $exe_list).")"; |
|
1048 | 1046 | Database::query($sql); |
1049 | 1047 | } |
1050 | 1048 | |
@@ -1086,7 +1084,7 @@ discard block |
||
1086 | 1084 | Event::addEvent( |
1087 | 1085 | LOG_EXERCISE_RESULT_DELETE, |
1088 | 1086 | LOG_EXERCISE_AND_USER_ID, |
1089 | - $exercise_id . '-' . $user_id, |
|
1087 | + $exercise_id.'-'.$user_id, |
|
1090 | 1088 | null, |
1091 | 1089 | null, |
1092 | 1090 | $course_id, |
@@ -1458,7 +1456,7 @@ discard block |
||
1458 | 1456 | $res = Database::query($sql); |
1459 | 1457 | $list = array(); |
1460 | 1458 | while ($row = Database::fetch_array($res, 'ASSOC')) { |
1461 | - $list[$row['exe_id']] = $row; /* |
|
1459 | + $list[$row['exe_id']] = $row; /* |
|
1462 | 1460 | $sql = "SELECT * FROM $table_track_attempt WHERE exe_id = {$row['exe_id']}"; |
1463 | 1461 | $res_question = Database::query($sql); |
1464 | 1462 | while($row_q = Database::fetch_array($res_question,'ASSOC')) { |
@@ -1684,7 +1682,7 @@ discard block |
||
1684 | 1682 | Event::addEvent( |
1685 | 1683 | LOG_QUESTION_RESULT_DELETE, |
1686 | 1684 | LOG_EXERCISE_ATTEMPT_QUESTION_ID, |
1687 | - $exe_id . '-' . $question_id, |
|
1685 | + $exe_id.'-'.$question_id, |
|
1688 | 1686 | null, |
1689 | 1687 | null, |
1690 | 1688 | $courseId, |
@@ -1720,7 +1718,7 @@ discard block |
||
1720 | 1718 | Event::addEvent( |
1721 | 1719 | LOG_QUESTION_RESULT_DELETE, |
1722 | 1720 | LOG_EXERCISE_ATTEMPT_QUESTION_ID, |
1723 | - $exe_id . '-' . $question_id, |
|
1721 | + $exe_id.'-'.$question_id, |
|
1724 | 1722 | null, |
1725 | 1723 | null, |
1726 | 1724 | $courseId, |
@@ -333,8 +333,12 @@ discard block |
||
333 | 333 | ) { |
334 | 334 | global $debug; |
335 | 335 | |
336 | - if ($debug) error_log('Called to update_event_exercice'); |
|
337 | - if ($debug) error_log('duration:' . $duration); |
|
336 | + if ($debug) { |
|
337 | + error_log('Called to update_event_exercice'); |
|
338 | + } |
|
339 | + if ($debug) { |
|
340 | + error_log('duration:' . $duration); |
|
341 | + } |
|
338 | 342 | |
339 | 343 | if ($exeid != '') { |
340 | 344 | /* |
@@ -386,8 +390,12 @@ discard block |
||
386 | 390 | WHERE exe_id = '".Database::escape_string($exeid)."'"; |
387 | 391 | $res = Database::query($sql); |
388 | 392 | |
389 | - if ($debug) error_log('update_event_exercice called'); |
|
390 | - if ($debug) error_log("$sql"); |
|
393 | + if ($debug) { |
|
394 | + error_log('update_event_exercice called'); |
|
395 | + } |
|
396 | + if ($debug) { |
|
397 | + error_log("$sql"); |
|
398 | + } |
|
391 | 399 | |
392 | 400 | //Deleting control time session track |
393 | 401 | //ExerciseLib::exercise_time_control_delete($exo_id); |
@@ -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 | { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | if ($show_title) { |
66 | 66 | TestCategory::displayCategoryAndTitle($objQuestionTmp->id); |
67 | 67 | echo Display::div( |
68 | - $current_item . '. ' . $objQuestionTmp->selectTitle(), |
|
68 | + $current_item.'. '.$objQuestionTmp->selectTitle(), |
|
69 | 69 | array('class' => 'question_title') |
70 | 70 | ); |
71 | 71 | } |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | $config = array( |
162 | 162 | 'ToolbarSet' => 'TestFreeAnswer' |
163 | 163 | ); |
164 | - $form->addHtmlEditor("choice[" . $questionId . "]", null, false, false, $config); |
|
165 | - $form->setDefaults(array("choice[" . $questionId . "]" => $fck_content)); |
|
164 | + $form->addHtmlEditor("choice[".$questionId."]", null, false, false, $config); |
|
165 | + $form->setDefaults(array("choice[".$questionId."]" => $fck_content)); |
|
166 | 166 | $s .= $form->returnForm(); |
167 | 167 | } elseif ($answerType == ORAL_EXPRESSION) { |
168 | 168 | // Add nanog |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $config = array( |
192 | 192 | 'ToolbarSet' => 'TestFreeAnswer' |
193 | 193 | ); |
194 | - $form->addHtmlEditor("choice[" . $questionId . "]", null, false, false, $config); |
|
194 | + $form->addHtmlEditor("choice[".$questionId."]", null, false, false, $config); |
|
195 | 195 | //$form->setDefaults(array("choice[" . $questionId . "]" => $fck_content)); |
196 | 196 | $s .= $form->returnForm(); |
197 | 197 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | |
273 | 273 | // Unique answer |
274 | 274 | if (in_array($answerType, [UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION, UNIQUE_ANSWER_IMAGE])) { |
275 | - $input_id = 'choice-' . $questionId . '-' . $answerId; |
|
275 | + $input_id = 'choice-'.$questionId.'-'.$answerId; |
|
276 | 276 | if (isset($user_choice[0]['answer']) && $user_choice[0]['answer'] == $numAnswer) { |
277 | 277 | $attributes = array( |
278 | 278 | 'id' => $input_id, |
@@ -297,14 +297,14 @@ discard block |
||
297 | 297 | if ($answerType == UNIQUE_ANSWER_IMAGE) { |
298 | 298 | if ($show_comment) { |
299 | 299 | if (empty($comment)) { |
300 | - $s .= '<div id="answer' . $questionId . $numAnswer . '" ' |
|
300 | + $s .= '<div id="answer'.$questionId.$numAnswer.'" ' |
|
301 | 301 | . 'class="exercise-unique-answer-image" style="text-align: center">'; |
302 | 302 | } else { |
303 | - $s .= '<div id="answer' . $questionId . $numAnswer . '" ' |
|
303 | + $s .= '<div id="answer'.$questionId.$numAnswer.'" ' |
|
304 | 304 | . 'class="exercise-unique-answer-image col-xs-6 col-sm-12" style="text-align: center">'; |
305 | 305 | } |
306 | 306 | } else { |
307 | - $s .= '<div id="answer' . $questionId . $numAnswer . '" ' |
|
307 | + $s .= '<div id="answer'.$questionId.$numAnswer.'" ' |
|
308 | 308 | . 'class="exercise-unique-answer-image col-xs-6 col-md-3" style="text-align: center">'; |
309 | 309 | } |
310 | 310 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $answer = Security::remove_XSS($answer, STUDENT); |
313 | 313 | $s .= Display::input( |
314 | 314 | 'hidden', |
315 | - 'choice2[' . $questionId . ']', |
|
315 | + 'choice2['.$questionId.']', |
|
316 | 316 | '0' |
317 | 317 | ); |
318 | 318 | |
@@ -320,13 +320,13 @@ discard block |
||
320 | 320 | |
321 | 321 | if ($answerType == UNIQUE_ANSWER_IMAGE) { |
322 | 322 | $attributes['style'] = 'display: none;'; |
323 | - $answer = '<div class="thumbnail">' . $answer . '</div>'; |
|
323 | + $answer = '<div class="thumbnail">'.$answer.'</div>'; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | $answer_input .= '<label class="radio">'; |
327 | 327 | $answer_input .= Display::input( |
328 | 328 | 'radio', |
329 | - 'choice[' . $questionId . ']', |
|
329 | + 'choice['.$questionId.']', |
|
330 | 330 | $numAnswer, |
331 | 331 | $attributes |
332 | 332 | ); |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $answerType == MULTIPLE_ANSWER_TRUE_FALSE || |
354 | 354 | $answerType == GLOBAL_MULTIPLE_ANSWER |
355 | 355 | ) { |
356 | - $input_id = 'choice-' . $questionId . '-' . $answerId; |
|
356 | + $input_id = 'choice-'.$questionId.'-'.$answerId; |
|
357 | 357 | $answer = Security::remove_XSS($answer, STUDENT); |
358 | 358 | |
359 | 359 | if (in_array($numAnswer, $user_choice_array)) { |
@@ -374,12 +374,12 @@ discard block |
||
374 | 374 | } |
375 | 375 | |
376 | 376 | if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) { |
377 | - $s .= '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />'; |
|
377 | + $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />'; |
|
378 | 378 | |
379 | 379 | $answer_input = '<label class="checkbox">'; |
380 | 380 | $answer_input .= Display::input( |
381 | 381 | 'checkbox', |
382 | - 'choice[' . $questionId . '][' . $numAnswer . ']', |
|
382 | + 'choice['.$questionId.']['.$numAnswer.']', |
|
383 | 383 | $numAnswer, |
384 | 384 | $attributes |
385 | 385 | ); |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | 'td', |
433 | 433 | Display::input( |
434 | 434 | 'radio', |
435 | - 'choice[' . $questionId . '][' . $numAnswer . ']', |
|
435 | + 'choice['.$questionId.']['.$numAnswer.']', |
|
436 | 436 | $id, |
437 | 437 | $attributes |
438 | 438 | ), |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | } |
451 | 451 | } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) { |
452 | 452 | // multiple answers |
453 | - $input_id = 'choice-' . $questionId . '-' . $answerId; |
|
453 | + $input_id = 'choice-'.$questionId.'-'.$answerId; |
|
454 | 454 | |
455 | 455 | if (in_array($numAnswer, $user_choice_array)) { |
456 | 456 | $attributes = array( |
@@ -470,11 +470,11 @@ discard block |
||
470 | 470 | } |
471 | 471 | |
472 | 472 | $answer = Security::remove_XSS($answer, STUDENT); |
473 | - $answer_input = '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />'; |
|
473 | + $answer_input = '<input type="hidden" name="choice2['.$questionId.']" value="0" />'; |
|
474 | 474 | $answer_input .= '<label class="checkbox">'; |
475 | 475 | $answer_input .= Display::input( |
476 | 476 | 'checkbox', |
477 | - 'choice[' . $questionId . '][' . $numAnswer . ']', |
|
477 | + 'choice['.$questionId.']['.$numAnswer.']', |
|
478 | 478 | 1, |
479 | 479 | $attributes |
480 | 480 | ); |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | } |
496 | 496 | |
497 | 497 | } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { |
498 | - $s .= '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />'; |
|
498 | + $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />'; |
|
499 | 499 | |
500 | 500 | $my_choice = array(); |
501 | 501 | if (!empty($user_choice_array)) { |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | 'td', |
531 | 531 | Display::input( |
532 | 532 | 'radio', |
533 | - 'choice[' . $questionId . '][' . $numAnswer . ']', |
|
533 | + 'choice['.$questionId.']['.$numAnswer.']', |
|
534 | 534 | $key, |
535 | 535 | $attributes |
536 | 536 | ) |
@@ -626,8 +626,8 @@ discard block |
||
626 | 626 | $trackAttempts = Database::get_main_table( |
627 | 627 | TABLE_STATISTIC_TRACK_E_ATTEMPT |
628 | 628 | ); |
629 | - $sql = 'SELECT answer FROM ' . $trackAttempts . ' |
|
630 | - WHERE exe_id=' . $exe_id . ' AND question_id=' . $questionId; |
|
629 | + $sql = 'SELECT answer FROM '.$trackAttempts.' |
|
630 | + WHERE exe_id=' . $exe_id.' AND question_id='.$questionId; |
|
631 | 631 | $rsLastAttempt = Database::query($sql); |
632 | 632 | $rowLastAttempt = Database::fetch_array($rsLastAttempt); |
633 | 633 | $answer = $rowLastAttempt['answer']; |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | '', |
683 | 683 | $answerCorrected |
684 | 684 | ); |
685 | - $answerCorrected = '[' . $answerCorrected . ']'; |
|
685 | + $answerCorrected = '['.$answerCorrected.']'; |
|
686 | 686 | $studentAnswerList[] = $answerCorrected; |
687 | 687 | } |
688 | 688 | } |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | */ |
702 | 702 | $tabComments = api_preg_split( |
703 | 703 | '/\[[^]]+\]/', |
704 | - ' ' . $answer . ' ' |
|
704 | + ' '.$answer.' ' |
|
705 | 705 | ); |
706 | 706 | if (!empty($correctAnswerList) && !empty($studentAnswerList)) { |
707 | 707 | $answer = ""; |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | $size |
719 | 719 | ); |
720 | 720 | |
721 | - $answer .= $tabComments[$i] . |
|
721 | + $answer .= $tabComments[$i]. |
|
722 | 722 | Display::input( |
723 | 723 | 'text', |
724 | 724 | "choice[$questionId][]", |
@@ -764,12 +764,12 @@ discard block |
||
764 | 764 | $s .= '<tr><td width="45%" valign="top">'; |
765 | 765 | $parsed_answer = $answer; |
766 | 766 | //left part questions |
767 | - $s .= '<p class="indent">' . $lines_count . '. ' . $parsed_answer . '</p></td>'; |
|
767 | + $s .= '<p class="indent">'.$lines_count.'. '.$parsed_answer.'</p></td>'; |
|
768 | 768 | //middle part (matches selects) |
769 | 769 | |
770 | 770 | $s .= '<td width="10%" valign="top" align="center" > |
771 | 771 | <div class="select-matching"> |
772 | - <select name="choice[' . $questionId . '][' . $numAnswer . ']">'; |
|
772 | + <select name="choice[' . $questionId.']['.$numAnswer.']">'; |
|
773 | 773 | |
774 | 774 | // fills the list-box |
775 | 775 | foreach ($select_items as $key => $val) { |
@@ -785,14 +785,14 @@ discard block |
||
785 | 785 | if (isset($user_choice_array_position[$numAnswer]) && $val['id'] == $user_choice_array_position[$numAnswer]) { |
786 | 786 | $selected = 'selected="selected"'; |
787 | 787 | } |
788 | - $s .= '<option value="' . $val['id'] . '" ' . $selected . '>' . $val['letter'] . '</option>'; |
|
788 | + $s .= '<option value="'.$val['id'].'" '.$selected.'>'.$val['letter'].'</option>'; |
|
789 | 789 | |
790 | 790 | } // end foreach() |
791 | 791 | |
792 | 792 | $s .= '</select></div></td><td width="5%" class="separate"> </td>'; |
793 | 793 | $s .= '<td width="40%" valign="top" >'; |
794 | 794 | if (isset($select_items[$lines_count])) { |
795 | - $s .= '<div class="text-right"><p class="indent">' . $select_items[$lines_count]['letter'].'. '. $select_items[$lines_count]['answer'].'</p></div>'; |
|
795 | + $s .= '<div class="text-right"><p class="indent">'.$select_items[$lines_count]['letter'].'. '.$select_items[$lines_count]['answer'].'</p></div>'; |
|
796 | 796 | } else { |
797 | 797 | $s .= ' '; |
798 | 798 | } |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | $s .= '<tr> |
808 | 808 | <td colspan="2"></td> |
809 | 809 | <td valign="top">'; |
810 | - $s .= '<b>' . $select_items[$lines_count]['letter'] . '.</b> ' . $select_items[$lines_count]['answer']; |
|
810 | + $s .= '<b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer']; |
|
811 | 811 | $s .= "</td> |
812 | 812 | </tr>"; |
813 | 813 | $lines_count++; |
@@ -823,9 +823,9 @@ discard block |
||
823 | 823 | $data = $objAnswerTmp->getAnswerByAutoId($data['correct']); |
824 | 824 | $lines_count = $data['answer'];*/ |
825 | 825 | |
826 | - $windowId = $questionId . '_' . $lines_count; |
|
826 | + $windowId = $questionId.'_'.$lines_count; |
|
827 | 827 | |
828 | - $s .= '<li class="touch-items" id="' . $windowId . '">'; |
|
828 | + $s .= '<li class="touch-items" id="'.$windowId.'">'; |
|
829 | 829 | $s .= Display::div( |
830 | 830 | $parsed_answer, |
831 | 831 | [ |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | Display::tag( |
884 | 884 | 'b', |
885 | 885 | $select_items[$lines_count]['letter'] |
886 | - ) . $select_items[$lines_count]['answer'], |
|
886 | + ).$select_items[$lines_count]['answer'], |
|
887 | 887 | [ |
888 | 888 | 'id' => "window_{$windowId}_answer", |
889 | 889 | 'style' => 'display: none;' |
@@ -1027,7 +1027,7 @@ discard block |
||
1027 | 1027 | |
1028 | 1028 | if ($show_comment) { |
1029 | 1029 | $s .= '</table>'; |
1030 | - } elseif( |
|
1030 | + } elseif ( |
|
1031 | 1031 | in_array( |
1032 | 1032 | $answerType, |
1033 | 1033 | [ |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | |
1053 | 1053 | for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) { |
1054 | 1054 | $answerCorrect = $objAnswerTmp->isCorrect($answerId); |
1055 | - $windowId = $questionId . '_' . $counterAnswer; |
|
1055 | + $windowId = $questionId.'_'.$counterAnswer; |
|
1056 | 1056 | |
1057 | 1057 | if ($answerCorrect) { |
1058 | 1058 | $s .= Display::div( |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | $course = api_get_course_info(); |
1098 | 1098 | $doc_id = DocumentManager::get_document_id( |
1099 | 1099 | $course, |
1100 | - '/images/' . $pictureName |
|
1100 | + '/images/'.$pictureName |
|
1101 | 1101 | ); |
1102 | 1102 | if (is_numeric($doc_id)) { |
1103 | 1103 | $images_folder_visibility = api_get_item_visibility( |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | echo " |
1123 | 1123 | <script> |
1124 | 1124 | $(document).on('ready', function () { |
1125 | - new " . ($answerType == HOT_SPOT ? "HotspotQuestion" : "DelineationQuestion" ) . "({ |
|
1125 | + new " . ($answerType == HOT_SPOT ? "HotspotQuestion" : "DelineationQuestion")."({ |
|
1126 | 1126 | questionId: $questionId, |
1127 | 1127 | exerciseId: $exerciseId, |
1128 | 1128 | selector: '#hotspot-preview-$questionId', |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | if ($answerType != HOT_SPOT_DELINEATION) { |
1157 | 1157 | $answerList = ' |
1158 | 1158 | <div class="well well-sm"> |
1159 | - <h5 class="page-header">' . get_lang('HotspotZones') . '</h5> |
|
1159 | + <h5 class="page-header">' . get_lang('HotspotZones').'</h5> |
|
1160 | 1160 | <ol> |
1161 | 1161 | '; |
1162 | 1162 | |
@@ -1181,7 +1181,7 @@ discard block |
||
1181 | 1181 | if (!$only_questions) { |
1182 | 1182 | if ($show_title) { |
1183 | 1183 | TestCategory::displayCategoryAndTitle($objQuestionTmp->id); |
1184 | - echo '<div class="question_title">' . $current_item . '. ' . $questionName . '</div>'; |
|
1184 | + echo '<div class="question_title">'.$current_item.'. '.$questionName.'</div>'; |
|
1185 | 1185 | } |
1186 | 1186 | //@todo I need to the get the feedback type |
1187 | 1187 | echo <<<HOTSPOT |
@@ -1199,7 +1199,7 @@ discard block |
||
1199 | 1199 | <div class=\"hotspot-image\"></div> |
1200 | 1200 | <script> |
1201 | 1201 | $(document).on('ready', function () { |
1202 | - new " . ($answerType == HOT_SPOT_DELINEATION ? 'DelineationQuestion' : 'HotspotQuestion') . "({ |
|
1202 | + new " . ($answerType == HOT_SPOT_DELINEATION ? 'DelineationQuestion' : 'HotspotQuestion')."({ |
|
1203 | 1203 | questionId: $questionId, |
1204 | 1204 | exerciseId: $exe_id, |
1205 | 1205 | selector: '#question_div_' + $questionId + ' .hotspot-image', |
@@ -1318,11 +1318,11 @@ discard block |
||
1318 | 1318 | $lp_id = intval($lp_id); |
1319 | 1319 | $lp_item_id = intval($lp_item_id); |
1320 | 1320 | return |
1321 | - api_get_course_int_id() . '_' . |
|
1322 | - api_get_session_id() . '_' . |
|
1323 | - $exercise_id . '_' . |
|
1324 | - api_get_user_id() . '_' . |
|
1325 | - $lp_id . '_' . |
|
1321 | + api_get_course_int_id().'_'. |
|
1322 | + api_get_session_id().'_'. |
|
1323 | + $exercise_id.'_'. |
|
1324 | + api_get_user_id().'_'. |
|
1325 | + $lp_id.'_'. |
|
1326 | 1326 | $lp_item_id; |
1327 | 1327 | } |
1328 | 1328 | |
@@ -1434,14 +1434,14 @@ discard block |
||
1434 | 1434 | $res = Database::query($sql); |
1435 | 1435 | $result = array(); |
1436 | 1436 | $apiIsAllowedToEdit = api_is_allowed_to_edit(); |
1437 | - $urlBase = api_get_path(WEB_CODE_PATH) . |
|
1438 | - 'exercice/hotpotatoes_exercise_report.php?action=delete&' . |
|
1439 | - api_get_cidreq() . '&id='; |
|
1437 | + $urlBase = api_get_path(WEB_CODE_PATH). |
|
1438 | + 'exercice/hotpotatoes_exercise_report.php?action=delete&'. |
|
1439 | + api_get_cidreq().'&id='; |
|
1440 | 1440 | while ($data = Database::fetch_array($res)) { |
1441 | 1441 | $actions = null; |
1442 | 1442 | |
1443 | 1443 | if ($apiIsAllowedToEdit) { |
1444 | - $url = $urlBase . $data['id'] . '&path=' . $data['exe_name']; |
|
1444 | + $url = $urlBase.$data['id'].'&path='.$data['exe_name']; |
|
1445 | 1445 | $actions = Display::url( |
1446 | 1446 | Display::return_icon('delete.png', get_lang('Delete')), |
1447 | 1447 | $url |
@@ -1457,7 +1457,7 @@ discard block |
||
1457 | 1457 | GroupManager::get_user_group_name($data['user_id']) |
1458 | 1458 | ), |
1459 | 1459 | 'exe_date' => $data['exe_date'], |
1460 | - 'score' => $data['exe_result'] . ' / ' . $data['exe_weighting'], |
|
1460 | + 'score' => $data['exe_result'].' / '.$data['exe_weighting'], |
|
1461 | 1461 | 'actions' => $actions, |
1462 | 1462 | ); |
1463 | 1463 | } |
@@ -1540,18 +1540,18 @@ discard block |
||
1540 | 1540 | $TBL_TRACK_HOTPOTATOES = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); |
1541 | 1541 | $TBL_TRACK_ATTEMPT_RECORDING = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING); |
1542 | 1542 | |
1543 | - $session_id_and = ' AND te.session_id = ' . $sessionId . ' '; |
|
1543 | + $session_id_and = ' AND te.session_id = '.$sessionId.' '; |
|
1544 | 1544 | $exercise_id = intval($exercise_id); |
1545 | 1545 | |
1546 | 1546 | $exercise_where = ''; |
1547 | 1547 | if (!empty($exercise_id)) { |
1548 | - $exercise_where .= ' AND te.exe_exo_id = ' . $exercise_id . ' '; |
|
1548 | + $exercise_where .= ' AND te.exe_exo_id = '.$exercise_id.' '; |
|
1549 | 1549 | } |
1550 | 1550 | |
1551 | 1551 | $hotpotatoe_where = ''; |
1552 | 1552 | if (!empty($_GET['path'])) { |
1553 | 1553 | $hotpotatoe_path = Database::escape_string($_GET['path']); |
1554 | - $hotpotatoe_where .= ' AND exe_name = "' . $hotpotatoe_path . '" '; |
|
1554 | + $hotpotatoe_where .= ' AND exe_name = "'.$hotpotatoe_path.'" '; |
|
1555 | 1555 | } |
1556 | 1556 | |
1557 | 1557 | // sql for chamilo-type tests for teacher / tutor view |
@@ -1563,7 +1563,7 @@ discard block |
||
1563 | 1563 | WHERE |
1564 | 1564 | c_id = $course_id AND |
1565 | 1565 | exe_exo_id = $exercise_id AND |
1566 | - ttte.session_id = " . $sessionId . " |
|
1566 | + ttte.session_id = ".$sessionId." |
|
1567 | 1567 | )"; |
1568 | 1568 | |
1569 | 1569 | if ($is_allowedToEdit) { |
@@ -1586,9 +1586,9 @@ discard block |
||
1586 | 1586 | g.id as group_id |
1587 | 1587 | FROM $TBL_USER u |
1588 | 1588 | INNER JOIN $TBL_GROUP_REL_USER gru |
1589 | - ON (gru.user_id = u.user_id AND gru.c_id=" . $course_id . ") |
|
1589 | + ON (gru.user_id = u.user_id AND gru.c_id=".$course_id.") |
|
1590 | 1590 | INNER JOIN $TBL_GROUP g |
1591 | - ON (gru.group_id = g.id AND g.c_id=" . $course_id . ") |
|
1591 | + ON (gru.group_id = g.id AND g.c_id=".$course_id.") |
|
1592 | 1592 | )"; |
1593 | 1593 | } |
1594 | 1594 | |
@@ -1650,9 +1650,9 @@ discard block |
||
1650 | 1650 | g.id as group_id |
1651 | 1651 | FROM $TBL_USER u |
1652 | 1652 | LEFT OUTER JOIN $TBL_GROUP_REL_USER gru |
1653 | - ON ( gru.user_id = u.user_id AND gru.c_id=" . $course_id . " ) |
|
1653 | + ON ( gru.user_id = u.user_id AND gru.c_id=".$course_id." ) |
|
1654 | 1654 | LEFT OUTER JOIN $TBL_GROUP g |
1655 | - ON (gru.group_id = g.id AND g.c_id = " . $course_id . ") |
|
1655 | + ON (gru.group_id = g.id AND g.c_id = ".$course_id.") |
|
1656 | 1656 | )"; |
1657 | 1657 | } |
1658 | 1658 | |
@@ -1665,12 +1665,12 @@ discard block |
||
1665 | 1665 | ( |
1666 | 1666 | SELECT u.user_id, firstname, lastname, email, username, ' ' as group_name, '' as group_id, official_code |
1667 | 1667 | FROM $TBL_USER u |
1668 | - WHERE u.status NOT IN(" . api_get_users_status_ignored_in_reports('string') . ") |
|
1668 | + WHERE u.status NOT IN(".api_get_users_status_ignored_in_reports('string').") |
|
1669 | 1669 | )"; |
1670 | 1670 | } |
1671 | 1671 | |
1672 | 1672 | $sqlFromOption = " , $TBL_GROUP_REL_USER AS gru "; |
1673 | - $sqlWhereOption = " AND gru.c_id = " . $course_id ." AND gru.user_id = user.user_id "; |
|
1673 | + $sqlWhereOption = " AND gru.c_id = ".$course_id." AND gru.user_id = user.user_id "; |
|
1674 | 1674 | $first_and_last_name = api_is_western_name_order() ? "firstname, lastname" : "lastname, firstname"; |
1675 | 1675 | |
1676 | 1676 | if ($get_count) { |
@@ -1707,8 +1707,8 @@ discard block |
||
1707 | 1707 | ON (user.user_id = exe_user_id) |
1708 | 1708 | WHERE |
1709 | 1709 | te.status != 'incomplete' AND |
1710 | - te.c_id = " . $course_id . " $session_id_and AND |
|
1711 | - ce.active <>-1 AND ce.c_id = " . $course_id . " |
|
1710 | + te.c_id = ".$course_id." $session_id_and AND |
|
1711 | + ce.active <>-1 AND ce.c_id = ".$course_id." |
|
1712 | 1712 | $exercise_where |
1713 | 1713 | $extra_where_conditions |
1714 | 1714 | "; |
@@ -1735,12 +1735,12 @@ discard block |
||
1735 | 1735 | $sqlFromOption |
1736 | 1736 | WHERE |
1737 | 1737 | user.user_id=tth.exe_user_id |
1738 | - AND tth.c_id = " . $course_id . " |
|
1738 | + AND tth.c_id = ".$course_id." |
|
1739 | 1739 | $hotpotatoe_where |
1740 | 1740 | $sqlWhereOption |
1741 | - AND user.status NOT IN(" . api_get_users_status_ignored_in_reports( |
|
1741 | + AND user.status NOT IN(".api_get_users_status_ignored_in_reports( |
|
1742 | 1742 | 'string' |
1743 | - ) . ") |
|
1743 | + ).") |
|
1744 | 1744 | ORDER BY |
1745 | 1745 | tth.c_id ASC, |
1746 | 1746 | tth.exe_date DESC"; |
@@ -1813,12 +1813,12 @@ discard block |
||
1813 | 1813 | |
1814 | 1814 | if ($from_gradebook && ($is_allowedToEdit)) { |
1815 | 1815 | if (in_array( |
1816 | - $results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname'], |
|
1816 | + $results[$i]['username'].$results[$i]['firstname'].$results[$i]['lastname'], |
|
1817 | 1817 | $users_array_id |
1818 | 1818 | )) { |
1819 | 1819 | continue; |
1820 | 1820 | } |
1821 | - $users_array_id[] = $results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname']; |
|
1821 | + $users_array_id[] = $results[$i]['username'].$results[$i]['firstname'].$results[$i]['lastname']; |
|
1822 | 1822 | } |
1823 | 1823 | |
1824 | 1824 | $lp_obj = isset($results[$i]['orig_lp_id']) && isset($lp_list[$results[$i]['orig_lp_id']]) ? $lp_list[$results[$i]['orig_lp_id']] : null; |
@@ -1827,8 +1827,8 @@ discard block |
||
1827 | 1827 | if ($lp_obj) { |
1828 | 1828 | $url = api_get_path( |
1829 | 1829 | WEB_CODE_PATH |
1830 | - ) . 'newscorm/lp_controller.php?' . api_get_cidreq( |
|
1831 | - ) . '&action=view&lp_id=' . $results[$i]['orig_lp_id']; |
|
1830 | + ).'newscorm/lp_controller.php?'.api_get_cidreq( |
|
1831 | + ).'&action=view&lp_id='.$results[$i]['orig_lp_id']; |
|
1832 | 1832 | $lp_name = Display::url( |
1833 | 1833 | $lp_obj['lp_name'], |
1834 | 1834 | $url, |
@@ -1846,7 +1846,7 @@ discard block |
||
1846 | 1846 | ); |
1847 | 1847 | |
1848 | 1848 | foreach ($group_list as $id) { |
1849 | - $group_name_list .= $clean_group_list[$id] . '<br/>'; |
|
1849 | + $group_name_list .= $clean_group_list[$id].'<br/>'; |
|
1850 | 1850 | } |
1851 | 1851 | $results[$i]['group_name'] = $group_name_list; |
1852 | 1852 | } |
@@ -1902,8 +1902,8 @@ discard block |
||
1902 | 1902 | } |
1903 | 1903 | } |
1904 | 1904 | if ($revised) { |
1905 | - $actions .= "<a href='exercise_show.php?" . api_get_cidreq( |
|
1906 | - ) . "&action=edit&id=$id'>" . |
|
1905 | + $actions .= "<a href='exercise_show.php?".api_get_cidreq( |
|
1906 | + )."&action=edit&id=$id'>". |
|
1907 | 1907 | Display:: return_icon( |
1908 | 1908 | 'edit.png', |
1909 | 1909 | get_lang('Edit'), |
@@ -1912,8 +1912,8 @@ discard block |
||
1912 | 1912 | ); |
1913 | 1913 | $actions .= ' '; |
1914 | 1914 | } else { |
1915 | - $actions .= "<a href='exercise_show.php?" . api_get_cidreq( |
|
1916 | - ) . "&action=qualify&id=$id'>" . |
|
1915 | + $actions .= "<a href='exercise_show.php?".api_get_cidreq( |
|
1916 | + )."&action=qualify&id=$id'>". |
|
1917 | 1917 | Display:: return_icon( |
1918 | 1918 | 'quiz.gif', |
1919 | 1919 | get_lang('Qualify') |
@@ -1923,12 +1923,12 @@ discard block |
||
1923 | 1923 | $actions .= "</a>"; |
1924 | 1924 | |
1925 | 1925 | if ($filter == 2) { |
1926 | - $actions .= ' <a href="exercise_history.php?' . api_get_cidreq( |
|
1927 | - ) . '&exe_id=' . $id . '">' . |
|
1926 | + $actions .= ' <a href="exercise_history.php?'.api_get_cidreq( |
|
1927 | + ).'&exe_id='.$id.'">'. |
|
1928 | 1928 | Display:: return_icon( |
1929 | 1929 | 'history.gif', |
1930 | 1930 | get_lang('ViewHistoryChange') |
1931 | - ) . '</a>'; |
|
1931 | + ).'</a>'; |
|
1932 | 1932 | } |
1933 | 1933 | |
1934 | 1934 | //Admin can always delete the attempt |
@@ -1940,32 +1940,32 @@ discard block |
||
1940 | 1940 | date('Y-m-d h:i:s'), |
1941 | 1941 | false |
1942 | 1942 | ); |
1943 | - $actions .= '<a href="http://www.whatsmyip.org/ip-geo-location/?ip=' . $ip . '" target="_blank"> |
|
1943 | + $actions .= '<a href="http://www.whatsmyip.org/ip-geo-location/?ip='.$ip.'" target="_blank"> |
|
1944 | 1944 | '.Display::return_icon('info.png', $ip).' |
1945 | 1945 | </a>'; |
1946 | 1946 | |
1947 | - $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 . '" |
|
1947 | + $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.'" |
|
1948 | 1948 | onclick="javascript:if(!confirm(\'' . sprintf( |
1949 | 1949 | get_lang('DeleteAttempt'), |
1950 | 1950 | $results[$i]['username'], |
1951 | 1951 | $dt |
1952 | - ) . '\')) return false;">' . Display:: return_icon( |
|
1952 | + ).'\')) return false;">'.Display:: return_icon( |
|
1953 | 1953 | 'delete.png', |
1954 | 1954 | get_lang('Delete') |
1955 | - ) . '</a>'; |
|
1955 | + ).'</a>'; |
|
1956 | 1956 | $delete_link = utf8_encode($delete_link); |
1957 | 1957 | |
1958 | 1958 | if (api_is_drh() && !api_is_platform_admin()) { |
1959 | 1959 | $delete_link = null; |
1960 | 1960 | } |
1961 | - $actions .= $delete_link . ' '; |
|
1961 | + $actions .= $delete_link.' '; |
|
1962 | 1962 | } |
1963 | 1963 | |
1964 | 1964 | } else { |
1965 | 1965 | $attempt_url = api_get_path( |
1966 | 1966 | WEB_CODE_PATH |
1967 | - ) . 'exercice/result.php?' . api_get_cidreq( |
|
1968 | - ) . '&id=' . $results[$i]['exe_id'] . '&id_session=' . $sessionId; |
|
1967 | + ).'exercice/result.php?'.api_get_cidreq( |
|
1968 | + ).'&id='.$results[$i]['exe_id'].'&id_session='.$sessionId; |
|
1969 | 1969 | $attempt_link = Display::url( |
1970 | 1970 | get_lang('Show'), |
1971 | 1971 | $attempt_url, |
@@ -2022,7 +2022,7 @@ discard block |
||
2022 | 2022 | $hp_result = round( |
2023 | 2023 | ($hpresults[$i][4] / ($hpresults[$i][5] != 0 ? $hpresults[$i][5] : 1)) * 100, |
2024 | 2024 | 2 |
2025 | - ) . '% (' . $hpresults[$i][4] . ' / ' . $hpresults[$i][5] . ')'; |
|
2025 | + ).'% ('.$hpresults[$i][4].' / '.$hpresults[$i][5].')'; |
|
2026 | 2026 | if ($is_allowedToEdit) { |
2027 | 2027 | $list_info[] = array( |
2028 | 2028 | $hpresults[$i][0], |
@@ -2095,13 +2095,13 @@ discard block |
||
2095 | 2095 | |
2096 | 2096 | $html = null; |
2097 | 2097 | if ($show_percentage) { |
2098 | - $parent = '(' . $score . ' / ' . $weight . ')'; |
|
2099 | - $html = $percentage . "% $parent"; |
|
2098 | + $parent = '('.$score.' / '.$weight.')'; |
|
2099 | + $html = $percentage."% $parent"; |
|
2100 | 2100 | if ($show_only_percentage) { |
2101 | - $html = $percentage . "% "; |
|
2101 | + $html = $percentage."% "; |
|
2102 | 2102 | } |
2103 | 2103 | } else { |
2104 | - $html = $score . ' / ' . $weight; |
|
2104 | + $html = $score.' / '.$weight; |
|
2105 | 2105 | } |
2106 | 2106 | $html = Display::span($html, array('class' => 'score_exercise')); |
2107 | 2107 | |
@@ -2195,7 +2195,7 @@ discard block |
||
2195 | 2195 | { |
2196 | 2196 | $return = '-'; |
2197 | 2197 | if ($value != '') { |
2198 | - $return = float_format($value * 100, 1) . ' %'; |
|
2198 | + $return = float_format($value * 100, 1).' %'; |
|
2199 | 2199 | } |
2200 | 2200 | return $return; |
2201 | 2201 | } |
@@ -2273,7 +2273,7 @@ discard block |
||
2273 | 2273 | } |
2274 | 2274 | |
2275 | 2275 | $needle_where = !empty($search) ? " AND title LIKE '?' " : ''; |
2276 | - $needle = !empty($search) ? "%" . $search . "%" : ''; |
|
2276 | + $needle = !empty($search) ? "%".$search."%" : ''; |
|
2277 | 2277 | |
2278 | 2278 | // Show courses by active status |
2279 | 2279 | $active_sql = ''; |
@@ -2288,7 +2288,7 @@ discard block |
||
2288 | 2288 | if ($search_all_sessions == true) { |
2289 | 2289 | $conditions = array( |
2290 | 2290 | 'where' => array( |
2291 | - $active_sql . ' c_id = ? ' . $needle_where . $time_conditions => array( |
|
2291 | + $active_sql.' c_id = ? '.$needle_where.$time_conditions => array( |
|
2292 | 2292 | $course_id, |
2293 | 2293 | $needle |
2294 | 2294 | ) |
@@ -2299,7 +2299,7 @@ discard block |
||
2299 | 2299 | if ($session_id == 0) { |
2300 | 2300 | $conditions = array( |
2301 | 2301 | 'where' => array( |
2302 | - $active_sql . ' session_id = ? AND c_id = ? ' . $needle_where . $time_conditions => array( |
|
2302 | + $active_sql.' session_id = ? AND c_id = ? '.$needle_where.$time_conditions => array( |
|
2303 | 2303 | $session_id, |
2304 | 2304 | $course_id, |
2305 | 2305 | $needle |
@@ -2310,7 +2310,7 @@ discard block |
||
2310 | 2310 | } else { |
2311 | 2311 | $conditions = array( |
2312 | 2312 | 'where' => array( |
2313 | - $active_sql . ' (session_id = 0 OR session_id = ? ) AND c_id = ? ' . $needle_where . $time_conditions => array( |
|
2313 | + $active_sql.' (session_id = 0 OR session_id = ? ) AND c_id = ? '.$needle_where.$time_conditions => array( |
|
2314 | 2314 | $session_id, |
2315 | 2315 | $course_id, |
2316 | 2316 | $needle |
@@ -2489,7 +2489,7 @@ discard block |
||
2489 | 2489 | |
2490 | 2490 | if ($return_string) { |
2491 | 2491 | if (!empty($position) && !empty($my_ranking)) { |
2492 | - $return_value = $position . '/' . count($my_ranking); |
|
2492 | + $return_value = $position.'/'.count($my_ranking); |
|
2493 | 2493 | } else { |
2494 | 2494 | $return_value = '-'; |
2495 | 2495 | } |
@@ -2569,7 +2569,7 @@ discard block |
||
2569 | 2569 | |
2570 | 2570 | if ($return_string) { |
2571 | 2571 | if (!empty($position) && !empty($my_ranking)) { |
2572 | - return $position . '/' . count($my_ranking); |
|
2572 | + return $position.'/'.count($my_ranking); |
|
2573 | 2573 | } |
2574 | 2574 | } |
2575 | 2575 | return $return_value; |
@@ -2969,7 +2969,7 @@ discard block |
||
2969 | 2969 | $courseCondition = " |
2970 | 2970 | INNER JOIN $courseUser cu |
2971 | 2971 | ON cu.c_id = c.id AND cu.user_id = exe_user_id"; |
2972 | - $courseConditionWhere = " AND relation_type <> 2 AND cu.status = " . STUDENT; |
|
2972 | + $courseConditionWhere = " AND relation_type <> 2 AND cu.status = ".STUDENT; |
|
2973 | 2973 | } else { |
2974 | 2974 | $courseCondition = " |
2975 | 2975 | INNER JOIN $courseUserSession cu |
@@ -3044,7 +3044,7 @@ discard block |
||
3044 | 3044 | $courseCondition = " |
3045 | 3045 | INNER JOIN $courseUser cu |
3046 | 3046 | ON cu.c_id = c.id AND cu.user_id = exe_user_id"; |
3047 | - $courseConditionWhere = " AND relation_type <> 2 AND cu.status = " . STUDENT; |
|
3047 | + $courseConditionWhere = " AND relation_type <> 2 AND cu.status = ".STUDENT; |
|
3048 | 3048 | } else { |
3049 | 3049 | $courseCondition = " |
3050 | 3050 | INNER JOIN $courseUserSession cu |
@@ -3136,7 +3136,7 @@ discard block |
||
3136 | 3136 | $courseCondition = " |
3137 | 3137 | INNER JOIN $courseUser cu |
3138 | 3138 | ON cu.c_id = c.id AND cu.user_id = exe_user_id"; |
3139 | - $courseConditionWhere = " AND relation_type <> 2 AND cu.status = " . STUDENT; |
|
3139 | + $courseConditionWhere = " AND relation_type <> 2 AND cu.status = ".STUDENT; |
|
3140 | 3140 | } else { |
3141 | 3141 | $courseCondition = " |
3142 | 3142 | INNER JOIN $courseUserSession cu |
@@ -3318,7 +3318,7 @@ discard block |
||
3318 | 3318 | } |
3319 | 3319 | } |
3320 | 3320 | // adds the correct word, followed by ] to close the blank |
3321 | - $answer .= ' / <font color="green"><b>' . $real_correct_tags[$i] . '</b></font>]'; |
|
3321 | + $answer .= ' / <font color="green"><b>'.$real_correct_tags[$i].'</b></font>]'; |
|
3322 | 3322 | if (isset ($real_text[$i + 1])) { |
3323 | 3323 | $answer .= $real_text[$i + 1]; |
3324 | 3324 | } |
@@ -3377,13 +3377,13 @@ discard block |
||
3377 | 3377 | // check the default value of option |
3378 | 3378 | $tabSelected = array($in_default => " selected='selected' "); |
3379 | 3379 | $res = ""; |
3380 | - $res .= "<select name='$in_name' id='$in_name' onchange='" . $in_onchange . "' >"; |
|
3381 | - $res .= "<option value='-1'" . $tabSelected["-1"] . ">-- " . get_lang( |
|
3380 | + $res .= "<select name='$in_name' id='$in_name' onchange='".$in_onchange."' >"; |
|
3381 | + $res .= "<option value='-1'".$tabSelected["-1"].">-- ".get_lang( |
|
3382 | 3382 | 'AllGroups' |
3383 | - ) . " --</option>"; |
|
3384 | - $res .= "<option value='0'" . $tabSelected["0"] . ">- " . get_lang( |
|
3383 | + )." --</option>"; |
|
3384 | + $res .= "<option value='0'".$tabSelected["0"].">- ".get_lang( |
|
3385 | 3385 | 'NotInAGroup' |
3386 | - ) . " -</option>"; |
|
3386 | + )." -</option>"; |
|
3387 | 3387 | $tabGroups = GroupManager::get_group_list(); |
3388 | 3388 | $currentCatId = 0; |
3389 | 3389 | for ($i = 0; $i < count($tabGroups); $i++) { |
@@ -3391,10 +3391,10 @@ discard block |
||
3391 | 3391 | $tabGroups[$i]["id"] |
3392 | 3392 | ); |
3393 | 3393 | if ($tabCategory["id"] != $currentCatId) { |
3394 | - $res .= "<option value='-1' disabled='disabled'>" . $tabCategory["title"] . "</option>"; |
|
3394 | + $res .= "<option value='-1' disabled='disabled'>".$tabCategory["title"]."</option>"; |
|
3395 | 3395 | $currentCatId = $tabCategory["id"]; |
3396 | 3396 | } |
3397 | - $res .= "<option " . $tabSelected[$tabGroups[$i]["id"]] . "style='margin-left:40px' value='" . $tabGroups[$i]["id"] . "'>" . $tabGroups[$i]["name"] . "</option>"; |
|
3397 | + $res .= "<option ".$tabSelected[$tabGroups[$i]["id"]]."style='margin-left:40px' value='".$tabGroups[$i]["id"]."'>".$tabGroups[$i]["name"]."</option>"; |
|
3398 | 3398 | } |
3399 | 3399 | $res .= "</select>"; |
3400 | 3400 | return $res; |
@@ -3599,14 +3599,14 @@ discard block |
||
3599 | 3599 | if ($show_results) { |
3600 | 3600 | $comnt = Event::get_comments($exe_id, $questionId); |
3601 | 3601 | if (!empty($comnt)) { |
3602 | - echo '<b>' . get_lang('Feedback') . '</b>'; |
|
3603 | - echo '<div id="question_feedback">' . $comnt . '</div>'; |
|
3602 | + echo '<b>'.get_lang('Feedback').'</b>'; |
|
3603 | + echo '<div id="question_feedback">'.$comnt.'</div>'; |
|
3604 | 3604 | } |
3605 | 3605 | } |
3606 | 3606 | |
3607 | 3607 | if ($show_results) { |
3608 | 3608 | $score = array( |
3609 | - 'result' => get_lang('Score') . " : " . self::show_score( |
|
3609 | + 'result' => get_lang('Score')." : ".self::show_score( |
|
3610 | 3610 | $my_total_score, |
3611 | 3611 | $my_total_weight, |
3612 | 3612 | false, |
@@ -3680,13 +3680,13 @@ discard block |
||
3680 | 3680 | } |
3681 | 3681 | |
3682 | 3682 | if ($show_all_but_expected_answer) { |
3683 | - $exercise_content .= "<div class='normal-message'>" . get_lang( |
|
3683 | + $exercise_content .= "<div class='normal-message'>".get_lang( |
|
3684 | 3684 | "ExerciseWithFeedbackWithoutCorrectionComment" |
3685 | - ) . "</div>"; |
|
3685 | + )."</div>"; |
|
3686 | 3686 | } |
3687 | 3687 | // Remove audio auto play from questions on results page - refs BT#7939 |
3688 | 3688 | $exercise_content = preg_replace( |
3689 | - ['/autoplay[\=\".+\"]+/','/autostart[\=\".+\"]+/'], |
|
3689 | + ['/autoplay[\=\".+\"]+/', '/autostart[\=\".+\"]+/'], |
|
3690 | 3690 | '', |
3691 | 3691 | $exercise_content |
3692 | 3692 | ); |
@@ -3780,11 +3780,11 @@ discard block |
||
3780 | 3780 | $ribbon_total_success_or_error = ' ribbon-total-error'; |
3781 | 3781 | } |
3782 | 3782 | } |
3783 | - $ribbon .= '<div class="total ' . $ribbon_total_success_or_error . '">'; |
|
3783 | + $ribbon .= '<div class="total '.$ribbon_total_success_or_error.'">'; |
|
3784 | 3784 | } else { |
3785 | 3785 | $ribbon .= '<div class="total">'; |
3786 | 3786 | } |
3787 | - $ribbon .= '<h3>' . get_lang('YourTotalScore') . ": "; |
|
3787 | + $ribbon .= '<h3>'.get_lang('YourTotalScore').": "; |
|
3788 | 3788 | $ribbon .= self::show_score($score, $weight, false, true); |
3789 | 3789 | $ribbon .= '</h3>'; |
3790 | 3790 | $ribbon .= '</div>'; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param string Name of common tag to place each line in |
158 | 158 | * @param string Name of the root element. A root element should always be given. |
159 | 159 | * @param string Encoding in which the data is provided |
160 | - * @return void Prompts the user for a file download |
|
160 | + * @return boolean Prompts the user for a file download |
|
161 | 161 | */ |
162 | 162 | public static function export_complex_table_xml( |
163 | 163 | $data, |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @param string $name |
284 | 284 | * @param string $format |
285 | 285 | * |
286 | - * @return bool |
|
286 | + * @return false|null |
|
287 | 287 | */ |
288 | 288 | public static function htmlToOdt($html, $name, $format = 'odt') |
289 | 289 | { |
@@ -3,14 +3,8 @@ |
||
3 | 3 | |
4 | 4 | use Ddeboer\DataImport\Writer\ExcelWriter; |
5 | 5 | use Ddeboer\DataImport\Writer\CsvWriter; |
6 | -use Ddeboer\DataImport\Workflow; |
|
7 | - |
|
8 | -use Ddeboer\DataImport\Reader\CsvReader; |
|
9 | -use Ddeboer\DataImport\Reader\ArrayReader; |
|
10 | -use Ddeboer\DataImport\Writer\ArrayWriter; |
|
11 | 6 | use Chamilo\CoreBundle\Component\Editor\Connector; |
12 | 7 | use Chamilo\CoreBundle\Component\Filesystem\Data; |
13 | -use ChamiloSession as Session; |
|
14 | 8 | use MediaAlchemyst\Alchemyst; |
15 | 9 | use MediaAlchemyst\DriversContainer; |
16 | 10 | use Neutron\TemporaryFilesystem\Manager; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | DocumentManager::file_send_for_download($filePath, true, $filename.'.csv'); |
58 | 58 | exit; |
59 | - } |
|
59 | + } |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Export tabular data to XLS-file |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | DocumentManager::file_send_for_download($filePath, true, $filename.'.xlsx'); |
81 | 81 | exit; |
82 | - } |
|
82 | + } |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Export tabular data to XLS-file (as html table) |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | - * Export tabular data to XML-file |
|
116 | - * @param array Simple array of data to put in XML |
|
117 | - * @param string Name of file to be given to the user |
|
118 | - * @param string Name of common tag to place each line in |
|
119 | - * @param string Name of the root element. A root element should always be given. |
|
120 | - * @param string Encoding in which the data is provided |
|
121 | - */ |
|
115 | + * Export tabular data to XML-file |
|
116 | + * @param array Simple array of data to put in XML |
|
117 | + * @param string Name of file to be given to the user |
|
118 | + * @param string Name of common tag to place each line in |
|
119 | + * @param string Name of the root element. A root element should always be given. |
|
120 | + * @param string Encoding in which the data is provided |
|
121 | + */ |
|
122 | 122 | public static function arrayToXml( |
123 | 123 | $data, |
124 | 124 | $filename = 'export', |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | fclose($handle); |
149 | 149 | DocumentManager :: file_send_for_download($file, true, $filename.'.xml'); |
150 | 150 | exit; |
151 | - } |
|
151 | + } |
|
152 | 152 | |
153 | 153 | /** |
154 | 154 | * Export hierarchical tabular data to XML-file |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | foreach ($data as $row) { |
198 | 198 | $string .= "\n".str_repeat("\t",$level).'<'.$row['name'].'>'; |
199 | 199 | if (is_array($row['value'])) { |
200 | - $string .= self::_export_complex_table_xml_helper($row['value'],$level+1)."\n"; |
|
200 | + $string .= self::_export_complex_table_xml_helper($row['value'],$level+1)."\n"; |
|
201 | 201 | $string .= str_repeat("\t",$level).'</'.$row['name'].'>'; |
202 | 202 | } else { |
203 | 203 | $string .= $row['value']; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | foreach ($data as $row) { |
101 | 101 | $string = implode("</td><td>", $row); |
102 | - $string = '<tr><td>' . $string . '</td></tr>'; |
|
102 | + $string = '<tr><td>'.$string.'</td></tr>'; |
|
103 | 103 | if ($encoding != 'utf-8') { |
104 | 104 | $string = api_convert_encoding($string, $encoding, $systemEncoding); |
105 | 105 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | fwrite($handle, '<'.$wrapper_tagname.'>'); |
174 | 174 | } |
175 | 175 | $s = self::_export_complex_table_xml_helper($data); |
176 | - fwrite($handle,$s); |
|
176 | + fwrite($handle, $s); |
|
177 | 177 | if (!is_null($wrapper_tagname)) { |
178 | 178 | fwrite($handle, '</'.$wrapper_tagname.'>'."\n"); |
179 | 179 | } |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | } |
196 | 196 | $string = ''; |
197 | 197 | foreach ($data as $row) { |
198 | - $string .= "\n".str_repeat("\t",$level).'<'.$row['name'].'>'; |
|
198 | + $string .= "\n".str_repeat("\t", $level).'<'.$row['name'].'>'; |
|
199 | 199 | if (is_array($row['value'])) { |
200 | - $string .= self::_export_complex_table_xml_helper($row['value'],$level+1)."\n"; |
|
201 | - $string .= str_repeat("\t",$level).'</'.$row['name'].'>'; |
|
200 | + $string .= self::_export_complex_table_xml_helper($row['value'], $level + 1)."\n"; |
|
201 | + $string .= str_repeat("\t", $level).'</'.$row['name'].'>'; |
|
202 | 202 | } else { |
203 | 203 | $string .= $row['value']; |
204 | 204 | $string .= '</'.$row['name'].'>'; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
126 | - * @return array |
|
126 | + * @return string[] |
|
127 | 127 | */ |
128 | 128 | public static function getValidExtraFieldTypes() |
129 | 129 | { |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | |
200 | 200 | /** |
201 | 201 | * @param array $conditions |
202 | - * @param null $order_field_options_by |
|
202 | + * @param string $order_field_options_by |
|
203 | 203 | * |
204 | 204 | * @return array |
205 | 205 | */ |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | /** |
238 | 238 | * @param string $variable |
239 | 239 | * |
240 | - * @return array|bool |
|
240 | + * @return integer |
|
241 | 241 | */ |
242 | 242 | public function get_handler_field_info_by_field_variable($variable) |
243 | 243 | { |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | /** |
320 | 320 | * @param string $handler |
321 | 321 | * |
322 | - * @return array |
|
322 | + * @return string[] |
|
323 | 323 | */ |
324 | 324 | public static function get_extra_fields_by_handler($handler) |
325 | 325 | { |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
499 | - * @return array |
|
499 | + * @return string[] |
|
500 | 500 | */ |
501 | 501 | public function get_field_types() |
502 | 502 | { |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | /** |
507 | 507 | * @param int $id |
508 | 508 | * |
509 | - * @return null |
|
509 | + * @return string|null |
|
510 | 510 | */ |
511 | 511 | public function get_field_type_by_id($id) |
512 | 512 | { |
@@ -691,7 +691,6 @@ discard block |
||
691 | 691 | * @param FormValidator $form |
692 | 692 | * @param array $extraData |
693 | 693 | * @param bool $admin_permissions |
694 | - * @param int $user_id |
|
695 | 694 | * @param array $extra |
696 | 695 | * @param int $itemId |
697 | 696 | * @param array $exclude variables of extra field to exclude |
@@ -1592,7 +1591,7 @@ discard block |
||
1592 | 1591 | } |
1593 | 1592 | |
1594 | 1593 | /** |
1595 | - * @return array |
|
1594 | + * @return string[] |
|
1596 | 1595 | */ |
1597 | 1596 | public function getJqgridColumnNames() |
1598 | 1597 | { |
@@ -1832,7 +1831,7 @@ discard block |
||
1832 | 1831 | } |
1833 | 1832 | |
1834 | 1833 | /** |
1835 | - * @param array $columns |
|
1834 | + * @param string[] $columns |
|
1836 | 1835 | * @param array $column_model |
1837 | 1836 | * @param array $extraFields |
1838 | 1837 | * @return array |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | 'changeable', |
20 | 20 | 'filter', |
21 | 21 | 'extra_field_type', |
22 | - /* Enable this when field_loggeable is introduced as a table field (2.0) |
|
22 | + /* Enable this when field_loggeable is introduced as a table field (2.0) |
|
23 | 23 | 'field_loggeable', |
24 | 24 | */ |
25 | 25 | 'created_at' |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | * France:Paris;Bretagne;Marseilles;Lyon|Belgique:Bruxelles;Namur;Liège;Bruges|Peru:Lima;Piura; |
524 | 524 | * into |
525 | 525 | * array( |
526 | - * 'France' => |
|
526 | + * 'France' => |
|
527 | 527 | * array('Paris', 'Bregtane', 'Marseilles'), |
528 | 528 | * 'Belgique' => |
529 | 529 | * array('Namur', 'Liège') |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | |
1185 | 1185 | if ($this->type == 'user') { |
1186 | 1186 | |
1187 | - /* //the magic should be here |
|
1187 | + /* //the magic should be here |
|
1188 | 1188 | $user_tags = UserManager::get_user_tags($user_id, $field_details[0]); |
1189 | 1189 | |
1190 | 1190 | $tag_list = ''; |
@@ -26,19 +26,19 @@ discard block |
||
26 | 26 | ); |
27 | 27 | |
28 | 28 | public $ops = array( |
29 | - 'eq' => '=', //equal |
|
30 | - 'ne' => '<>', //not equal |
|
31 | - 'lt' => '<', //less than |
|
32 | - 'le' => '<=', //less than or equal |
|
33 | - 'gt' => '>', //greater than |
|
34 | - 'ge' => '>=', //greater than or equal |
|
35 | - 'bw' => 'LIKE', //begins with |
|
29 | + 'eq' => '=', //equal |
|
30 | + 'ne' => '<>', //not equal |
|
31 | + 'lt' => '<', //less than |
|
32 | + 'le' => '<=', //less than or equal |
|
33 | + 'gt' => '>', //greater than |
|
34 | + 'ge' => '>=', //greater than or equal |
|
35 | + 'bw' => 'LIKE', //begins with |
|
36 | 36 | 'bn' => 'NOT LIKE', //doesn't begin with |
37 | - 'in' => 'LIKE', //is in |
|
37 | + 'in' => 'LIKE', //is in |
|
38 | 38 | 'ni' => 'NOT LIKE', //is not in |
39 | - 'ew' => 'LIKE', //ends with |
|
39 | + 'ew' => 'LIKE', //ends with |
|
40 | 40 | 'en' => 'NOT LIKE', //doesn't end with |
41 | - 'cn' => 'LIKE', //contains |
|
41 | + 'cn' => 'LIKE', //contains |
|
42 | 42 | 'nc' => 'NOT LIKE' //doesn't contain |
43 | 43 | ); |
44 | 44 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | */ |
324 | 324 | public static function get_extra_fields_by_handler($handler) |
325 | 325 | { |
326 | - $types= array(); |
|
326 | + $types = array(); |
|
327 | 327 | $types[self::FIELD_TYPE_TEXT] = get_lang('FieldTypeText'); |
328 | 328 | $types[self::FIELD_TYPE_TEXTAREA] = get_lang('FieldTypeTextarea'); |
329 | 329 | $types[self::FIELD_TYPE_RADIO] = get_lang('FieldTypeRadio'); |
@@ -962,7 +962,7 @@ discard block |
||
962 | 962 | // chzn-select doesn't work for sessions?? |
963 | 963 | $form->addElement( |
964 | 964 | 'select', |
965 | - 'extra_' . $field_details['variable'], |
|
965 | + 'extra_'.$field_details['variable'], |
|
966 | 966 | $field_details['display_text'], |
967 | 967 | $options, |
968 | 968 | array('id' => 'extra_'.$field_details['variable']) |
@@ -1021,7 +1021,7 @@ discard block |
||
1021 | 1021 | |
1022 | 1022 | if (!$admin_permissions) { |
1023 | 1023 | if ($field_details['visible'] == 0) { |
1024 | - $form->freeze('extra_' . $field_details['variable']); |
|
1024 | + $form->freeze('extra_'.$field_details['variable']); |
|
1025 | 1025 | } |
1026 | 1026 | } |
1027 | 1027 | break; |
@@ -1369,9 +1369,9 @@ discard block |
||
1369 | 1369 | |
1370 | 1370 | if (is_array($extraData) && array_key_exists($fieldVariable, $extraData)) { |
1371 | 1371 | |
1372 | - if (file_exists(api_get_path(SYS_UPLOAD_PATH) . $extraData[$fieldVariable])) { |
|
1372 | + if (file_exists(api_get_path(SYS_UPLOAD_PATH).$extraData[$fieldVariable])) { |
|
1373 | 1373 | $fieldTexts[] = Display::img( |
1374 | - api_get_path(WEB_UPLOAD_PATH) . $extraData[$fieldVariable], |
|
1374 | + api_get_path(WEB_UPLOAD_PATH).$extraData[$fieldVariable], |
|
1375 | 1375 | $field_details['display_text'], |
1376 | 1376 | array('width' => '300') |
1377 | 1377 | ); |
@@ -1388,10 +1388,10 @@ discard block |
||
1388 | 1388 | $form->applyFilter('extra_'.$field_details['variable'], 'stripslashes'); |
1389 | 1389 | $form->applyFilter('extra_'.$field_details['variable'], 'trim'); |
1390 | 1390 | |
1391 | - $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif'); |
|
1391 | + $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif'); |
|
1392 | 1392 | $form->addRule( |
1393 | 1393 | 'extra_'.$field_details['variable'], |
1394 | - get_lang('OnlyImagesAllowed') . ' ('.implode(',', $allowed_picture_types).')', |
|
1394 | + get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', |
|
1395 | 1395 | 'filetype', |
1396 | 1396 | $allowed_picture_types |
1397 | 1397 | ); |
@@ -1433,10 +1433,10 @@ discard block |
||
1433 | 1433 | if (is_array($extraData) && |
1434 | 1434 | array_key_exists($fieldVariable, $extraData) |
1435 | 1435 | ) { |
1436 | - if (file_exists(api_get_path(SYS_UPLOAD_PATH) . $extraData[$fieldVariable])) { |
|
1436 | + if (file_exists(api_get_path(SYS_UPLOAD_PATH).$extraData[$fieldVariable])) { |
|
1437 | 1437 | $fieldTexts[] = Display::url( |
1438 | - api_get_path(WEB_UPLOAD_PATH) . $extraData[$fieldVariable], |
|
1439 | - api_get_path(WEB_UPLOAD_PATH) . $extraData[$fieldVariable], |
|
1438 | + api_get_path(WEB_UPLOAD_PATH).$extraData[$fieldVariable], |
|
1439 | + api_get_path(WEB_UPLOAD_PATH).$extraData[$fieldVariable], |
|
1440 | 1440 | array( |
1441 | 1441 | 'title' => $field_details['display_text'], |
1442 | 1442 | 'target' => '_blank' |
@@ -1486,12 +1486,12 @@ discard block |
||
1486 | 1486 | "extra_{$field_details['variable']}", |
1487 | 1487 | $field_details['display_text'] |
1488 | 1488 | ); |
1489 | - $form->applyFilter('extra_' . $field_details['variable'], 'stripslashes'); |
|
1489 | + $form->applyFilter('extra_'.$field_details['variable'], 'stripslashes'); |
|
1490 | 1490 | |
1491 | 1491 | if (!$admin_permissions) { |
1492 | 1492 | if ($field_details['visible'] == 0) { |
1493 | 1493 | $form->freeze( |
1494 | - 'extra_' . $field_details['variable'] |
|
1494 | + 'extra_'.$field_details['variable'] |
|
1495 | 1495 | ); |
1496 | 1496 | } |
1497 | 1497 | } |
@@ -1502,13 +1502,13 @@ discard block |
||
1502 | 1502 | $field_details['display_text'] |
1503 | 1503 | ); |
1504 | 1504 | $form->applyFilter( |
1505 | - 'extra_' . $field_details['variable'], |
|
1505 | + 'extra_'.$field_details['variable'], |
|
1506 | 1506 | 'stripslashes' |
1507 | 1507 | ); |
1508 | 1508 | if (!$admin_permissions) { |
1509 | 1509 | if ($field_details['visible'] == 0) { |
1510 | 1510 | $form->freeze( |
1511 | - 'extra_' . $field_details['variable'] |
|
1511 | + 'extra_'.$field_details['variable'] |
|
1512 | 1512 | ); |
1513 | 1513 | } |
1514 | 1514 | } |
@@ -1518,12 +1518,12 @@ discard block |
||
1518 | 1518 | "extra_{$field_details['variable']}", |
1519 | 1519 | $field_details['display_text'] |
1520 | 1520 | ); |
1521 | - $form->applyFilter('extra_' . $field_details['variable'], 'stripslashes'); |
|
1521 | + $form->applyFilter('extra_'.$field_details['variable'], 'stripslashes'); |
|
1522 | 1522 | |
1523 | 1523 | if (!$admin_permissions) { |
1524 | 1524 | if ($field_details['visible'] == 0) { |
1525 | 1525 | $form->freeze( |
1526 | - 'extra_' . $field_details['variable'] |
|
1526 | + 'extra_'.$field_details['variable'] |
|
1527 | 1527 | ); |
1528 | 1528 | } |
1529 | 1529 | } |
@@ -1534,13 +1534,13 @@ discard block |
||
1534 | 1534 | $field_details['display_text'] |
1535 | 1535 | ); |
1536 | 1536 | $form->applyFilter( |
1537 | - 'extra_' . $field_details['variable'], |
|
1537 | + 'extra_'.$field_details['variable'], |
|
1538 | 1538 | 'stripslashes' |
1539 | 1539 | ); |
1540 | 1540 | if (!$admin_permissions) { |
1541 | 1541 | if ($field_details['visible'] == 0) { |
1542 | 1542 | $form->freeze( |
1543 | - 'extra_' . $field_details['variable'] |
|
1543 | + 'extra_'.$field_details['variable'] |
|
1544 | 1544 | ); |
1545 | 1545 | } |
1546 | 1546 | } |
@@ -2221,19 +2221,19 @@ discard block |
||
2221 | 2221 | break; |
2222 | 2222 | } |
2223 | 2223 | |
2224 | - if (!file_exists(api_get_path(SYS_UPLOAD_PATH) . $valueData['value'])) { |
|
2224 | + if (!file_exists(api_get_path(SYS_UPLOAD_PATH).$valueData['value'])) { |
|
2225 | 2225 | break; |
2226 | 2226 | } |
2227 | 2227 | |
2228 | 2228 | $image = Display::img( |
2229 | - api_get_path(WEB_UPLOAD_PATH) . $valueData['value'], |
|
2229 | + api_get_path(WEB_UPLOAD_PATH).$valueData['value'], |
|
2230 | 2230 | $field['display_text'], |
2231 | 2231 | array('width' => '300') |
2232 | 2232 | ); |
2233 | 2233 | |
2234 | 2234 | $displayedValue = Display::url( |
2235 | 2235 | $image, |
2236 | - api_get_path(WEB_UPLOAD_PATH) . $valueData['value'], |
|
2236 | + api_get_path(WEB_UPLOAD_PATH).$valueData['value'], |
|
2237 | 2237 | array('target' => '_blank') |
2238 | 2238 | ); |
2239 | 2239 | break; |
@@ -2242,13 +2242,13 @@ discard block |
||
2242 | 2242 | break; |
2243 | 2243 | } |
2244 | 2244 | |
2245 | - if (!file_exists(api_get_path(SYS_UPLOAD_PATH) . $valueData['value'])) { |
|
2245 | + if (!file_exists(api_get_path(SYS_UPLOAD_PATH).$valueData['value'])) { |
|
2246 | 2246 | break; |
2247 | 2247 | } |
2248 | 2248 | |
2249 | 2249 | $displayedValue = Display::url( |
2250 | 2250 | get_lang('Download'), |
2251 | - api_get_path(WEB_UPLOAD_PATH) . $valueData['value'], |
|
2251 | + api_get_path(WEB_UPLOAD_PATH).$valueData['value'], |
|
2252 | 2252 | array( |
2253 | 2253 | 'title' => $field['display_text'], |
2254 | 2254 | 'target' => '_blank' |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | - * @return ExtraField |
|
46 | + * @return string |
|
47 | 47 | */ |
48 | 48 | public function getExtraField() |
49 | 49 | { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * This function is used with $extraField->addElements() |
73 | 73 | * @param array $params array for the insertion into the *_field_values table |
74 | 74 | * |
75 | - * @return mixed false on empty params, void otherwise |
|
75 | + * @return false|null false on empty params, void otherwise |
|
76 | 76 | * @assert (array()) === false |
77 | 77 | */ |
78 | 78 | public function saveFieldValues($params) |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | * @param int $item_id Item ID (It could be a session_id, course_id or user_id) |
501 | 501 | * @param int $field_id Field ID (the ID from the *_field table) |
502 | 502 | * @param bool $transform Whether to transform the result to a human readable strings |
503 | - * @return mixed A structured array with the field_id and field_value, or false on error |
|
503 | + * @return string A structured array with the field_id and field_value, or false on error |
|
504 | 504 | * @assert (-1,-1) === false |
505 | 505 | */ |
506 | 506 | public function get_values_by_handler_and_field_id($item_id, $field_id, $transform = false) |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | * @param int $item_id Item ID from the original table |
594 | 594 | * @param string $field_variable The name of the field we are looking for |
595 | 595 | * @param bool $transform |
596 | - * @param bool $allVisibility |
|
596 | + * @param bool $visibility |
|
597 | 597 | * |
598 | 598 | * @return mixed Array of results, or false on error or not found |
599 | 599 | * @assert (-1,'') === false |
@@ -720,11 +720,11 @@ discard block |
||
720 | 720 | return false; |
721 | 721 | } |
722 | 722 | |
723 | - /** |
|
724 | - * @param int $itemId |
|
725 | - * @param int $fieldId |
|
726 | - * @return array |
|
727 | - */ |
|
723 | + /** |
|
724 | + * @param int $itemId |
|
725 | + * @param int $fieldId |
|
726 | + * @return array |
|
727 | + */ |
|
728 | 728 | public function getAllValuesByItemAndField($itemId, $fieldId) |
729 | 729 | { |
730 | 730 | $fieldId = intval($fieldId); |
@@ -847,7 +847,6 @@ discard block |
||
847 | 847 | /** |
848 | 848 | * Deletes all values from an item |
849 | 849 | * @param int $itemId (session id, course id, etc) |
850 | - |
|
851 | 850 | * @assert (-1,-1) == null |
852 | 851 | */ |
853 | 852 | public function deleteValuesByItem($itemId) |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | break; |
210 | 210 | } |
211 | 211 | |
212 | - $fileName = ExtraField::FIELD_TYPE_FILE_IMAGE . "_{$params['item_id']}.png"; |
|
212 | + $fileName = ExtraField::FIELD_TYPE_FILE_IMAGE."_{$params['item_id']}.png"; |
|
213 | 213 | |
214 | 214 | if (!file_exists($fileDir)) { |
215 | 215 | mkdir($fileDir, $dirPermissions, true); |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | |
218 | 218 | if ($value['error'] == 0) { |
219 | 219 | $imageExtraField = new Image($value['tmp_name']); |
220 | - $imageExtraField->send_image($fileDir . $fileName, -1, 'png'); |
|
220 | + $imageExtraField->send_image($fileDir.$fileName, -1, 'png'); |
|
221 | 221 | $newParams = array( |
222 | 222 | 'item_id' => $params['item_id'], |
223 | 223 | 'field_id' => $extraFieldInfo['id'], |
224 | - 'value' => $fileDirStored . $fileName, |
|
224 | + 'value' => $fileDirStored.$fileName, |
|
225 | 225 | 'comment' => $comment |
226 | 226 | ); |
227 | 227 | |
@@ -247,18 +247,18 @@ discard block |
||
247 | 247 | } |
248 | 248 | |
249 | 249 | $cleanedName = api_replace_dangerous_char($value['name']); |
250 | - $fileName = ExtraField::FIELD_TYPE_FILE . "_{$params['item_id']}_$cleanedName"; |
|
250 | + $fileName = ExtraField::FIELD_TYPE_FILE."_{$params['item_id']}_$cleanedName"; |
|
251 | 251 | if (!file_exists($fileDir)) { |
252 | 252 | mkdir($fileDir, $dirPermissions, true); |
253 | 253 | } |
254 | 254 | |
255 | 255 | if ($value['error'] == 0) { |
256 | - moveUploadedFile($value, $fileDir . $fileName); |
|
256 | + moveUploadedFile($value, $fileDir.$fileName); |
|
257 | 257 | |
258 | 258 | $new_params = array( |
259 | 259 | 'item_id' => $params['item_id'], |
260 | 260 | 'field_id' => $extraFieldInfo['id'], |
261 | - 'value' => $fileDirStored . $fileName |
|
261 | + 'value' => $fileDirStored.$fileName |
|
262 | 262 | ); |
263 | 263 | |
264 | 264 | if ($this->type !== 'session' && $this->type !== 'course') { |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | */ |
381 | 381 | if (false) { |
382 | 382 | global $app; |
383 | - switch($this->type) { |
|
383 | + switch ($this->type) { |
|
384 | 384 | case 'question': |
385 | 385 | $extraFieldValue = new ChamiloLMS\Entity\QuestionFieldValues(); |
386 | 386 | $extraFieldValue->setUserId(api_get_user_id()); |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | */ |
443 | 443 | if (false) { |
444 | 444 | global $app; |
445 | - switch($this->type) { |
|
445 | + switch ($this->type) { |
|
446 | 446 | case 'question': |
447 | 447 | $extraFieldValue = $app['orm.ems']['db_write']->getRepository('ChamiloLMS\Entity\QuestionFieldValues')->find($field_values['id']); |
448 | 448 | $extraFieldValue->setUserId(api_get_user_id()); |
@@ -13,6 +13,8 @@ discard block |
||
13 | 13 | * @param - action (string) - action type require : 'delete' or 'update' |
14 | 14 | * @param - old_path (string) - old path info stored to change |
15 | 15 | * @param - new_path (string) - new path info to substitute |
16 | + * @param string $action |
|
17 | + * @param string $old_path |
|
16 | 18 | * @desc Update the file or directory path in the document db document table |
17 | 19 | * |
18 | 20 | */ |
@@ -76,8 +78,8 @@ discard block |
||
76 | 78 | * Deletes a file or a directory |
77 | 79 | * |
78 | 80 | * @author - Hugues Peeters |
79 | - * @param $file (String) - the path of file or directory to delete |
|
80 | - * @return boolean - true if the delete succeed, false otherwise. |
|
81 | + * @param string $file (String) - the path of file or directory to delete |
|
82 | + * @return boolean|null - true if the delete succeed, false otherwise. |
|
81 | 83 | * @see - delete() uses check_name_exist() and removeDir() functions |
82 | 84 | */ |
83 | 85 | function my_delete($file) |
@@ -162,9 +164,9 @@ discard block |
||
162 | 164 | * Renames a file or a directory |
163 | 165 | * |
164 | 166 | * @author - Hugues Peeters <[email protected]> |
165 | - * @param - $file_path (string) - complete path of the file or the directory |
|
166 | - * @param - $new_file_name (string) - new name for the file or the directory |
|
167 | - * @return - boolean - true if succeed |
|
167 | + * @param string $file_path (string) - complete path of the file or the directory |
|
168 | + * @param string $new_file_name (string) - new name for the file or the directory |
|
169 | + * @return string boolean - true if succeed |
|
168 | 170 | * - boolean - false otherwise |
169 | 171 | * @see - rename() uses the check_name_exist() and php2phps() functions |
170 | 172 | */ |
@@ -327,7 +329,6 @@ discard block |
||
327 | 329 | * Calculation size of a directory |
328 | 330 | * |
329 | 331 | * @returns integer size |
330 | - * @param string $path path to size |
|
331 | 332 | * @param boolean $recursive if true , include subdir in total |
332 | 333 | */ |
333 | 334 | function dirsize($root, $recursive = true) { |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | /* File case */ |
226 | 226 | if (is_file($source)) { |
227 | 227 | if ($forceMove && !$isWindowsOS && $canExec) { |
228 | - exec('mv ' . $source . ' ' . $target . '/' . $file_name); |
|
228 | + exec('mv '.$source.' '.$target.'/'.$file_name); |
|
229 | 229 | } else { |
230 | - copy($source, $target . '/' . $file_name); |
|
230 | + copy($source, $target.'/'.$file_name); |
|
231 | 231 | unlink($source); |
232 | 232 | } |
233 | 233 | return true; |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | } |
279 | 279 | $destination_trail = $destination.'/'.$dir_name; |
280 | 280 | if (is_dir($destination)) { |
281 | - chdir($orig_dir_path) ; |
|
281 | + chdir($orig_dir_path); |
|
282 | 282 | $handle = opendir($orig_dir_path); |
283 | 283 | |
284 | 284 | while ($element = readdir($handle)) { |
@@ -288,14 +288,14 @@ discard block |
||
288 | 288 | copy($element, $destination_trail.'/'.$element); |
289 | 289 | |
290 | 290 | if ($move) { |
291 | - unlink($element) ; |
|
291 | + unlink($element); |
|
292 | 292 | } |
293 | 293 | } elseif (is_dir($element)) { |
294 | 294 | $dir_to_copy[] = $orig_dir_path.'/'.$element; |
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
298 | - closedir($handle) ; |
|
298 | + closedir($handle); |
|
299 | 299 | |
300 | 300 | if (sizeof($dir_to_copy) > 0) { |
301 | 301 | foreach ($dir_to_copy as $this_dir) { |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | } |
305 | 305 | |
306 | 306 | if ($move) { |
307 | - rmdir($orig_dir_path) ; |
|
307 | + rmdir($orig_dir_path); |
|
308 | 308 | } |
309 | 309 | chdir($save_dir); |
310 | 310 | } |
@@ -389,17 +389,17 @@ discard block |
||
389 | 389 | // Recursive operation if subdirectories exist |
390 | 390 | $dir_number = sizeof($dir_array); |
391 | 391 | if ($dir_number > 0) { |
392 | - for ($i = 0 ; $i < $dir_number ; $i++) { |
|
392 | + for ($i = 0; $i < $dir_number; $i++) { |
|
393 | 393 | $sub_dir_array = FileManager::list_all_directories($dir_array[$i]); // Function recursivity |
394 | 394 | if (is_array($dir_array) && is_array($sub_dir_array)) { |
395 | - $dir_array = array_merge($dir_array, $sub_dir_array); // Data merge |
|
395 | + $dir_array = array_merge($dir_array, $sub_dir_array); // Data merge |
|
396 | 396 | } |
397 | 397 | } |
398 | 398 | } |
399 | - $result_array = $dir_array; |
|
400 | - chdir($save_dir) ; |
|
399 | + $result_array = $dir_array; |
|
400 | + chdir($save_dir); |
|
401 | 401 | } |
402 | - return $result_array ; |
|
402 | + return $result_array; |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -444,8 +444,8 @@ discard block |
||
444 | 444 | $buffer = ''; |
445 | 445 | if (file_exists($file_name)) { |
446 | 446 | $fp = fopen($file_name, 'rb'); |
447 | - $buffer = fread ($fp, filesize($file_name)); |
|
448 | - fclose ($fp); |
|
447 | + $buffer = fread($fp, filesize($file_name)); |
|
448 | + fclose($fp); |
|
449 | 449 | } |
450 | 450 | return $buffer; |
451 | 451 | } |
@@ -33,7 +33,9 @@ discard block |
||
33 | 33 | Database::query($query); |
34 | 34 | break; |
35 | 35 | case 'update': |
36 | - if ($new_path[0] == '.') $new_path = substr($new_path, 1); |
|
36 | + if ($new_path[0] == '.') { |
|
37 | + $new_path = substr($new_path, 1); |
|
38 | + } |
|
37 | 39 | $new_path = str_replace('//', '/', $new_path); |
38 | 40 | |
39 | 41 | // Attempt to update - tested & working for root dir |
@@ -379,7 +381,9 @@ discard block |
||
379 | 381 | chdir($path); |
380 | 382 | $handle = opendir($path); |
381 | 383 | while ($element = readdir($handle)) { |
382 | - if ($element == '.' || $element == '..') continue; |
|
384 | + if ($element == '.' || $element == '..') { |
|
385 | + continue; |
|
386 | + } |
|
383 | 387 | // Skip the current and parent directories |
384 | 388 | if (is_dir($element)) { |
385 | 389 | $dir_array[] = $path.'/'.$element; |
@@ -419,7 +423,9 @@ discard block |
||
419 | 423 | chdir($directory); |
420 | 424 | $handle = opendir($directory); |
421 | 425 | while ($element = readdir($handle)) { |
422 | - if ($element == '.' || $element == '..' || $element == '.htaccess') continue; |
|
426 | + if ($element == '.' || $element == '..' || $element == '.htaccess') { |
|
427 | + continue; |
|
428 | + } |
|
423 | 429 | // Skip the current and parent directories |
424 | 430 | if (!is_dir($element)) { |
425 | 431 | $element_array[] = $directory.'/'.$element; |
@@ -469,7 +475,9 @@ discard block |
||
469 | 475 | */ |
470 | 476 | function set_default_settings($upload_path, $filename, $filetype = 'file', $glued_table, $default_visibility = 'v') |
471 | 477 | { |
472 | - if (!$default_visibility) $default_visibility = 'v'; |
|
478 | + if (!$default_visibility) { |
|
479 | + $default_visibility = 'v'; |
|
480 | + } |
|
473 | 481 | |
474 | 482 | // Make sure path is not wrongly formed |
475 | 483 | $upload_path = !empty($upload_path) ? "/$upload_path" : ''; |
@@ -170,37 +170,37 @@ discard block |
||
170 | 170 | */ |
171 | 171 | function my_rename($file_path, $new_file_name) { |
172 | 172 | |
173 | - $save_dir = getcwd(); |
|
174 | - $path = dirname($file_path); |
|
175 | - $old_file_name = basename($file_path); |
|
176 | - $new_file_name = api_replace_dangerous_char($new_file_name); |
|
177 | - |
|
178 | - // If no extension, take the old one |
|
179 | - if ((strpos($new_file_name, '.') === false) && ($dotpos = strrpos($old_file_name, '.'))) { |
|
180 | - $new_file_name .= substr($old_file_name, $dotpos); |
|
181 | - } |
|
182 | - |
|
183 | - // Note: still possible: 'xx.yy' -rename-> '.yy' -rename-> 'zz' |
|
184 | - // This is useful for folder names, where otherwise '.' would be sticky |
|
185 | - |
|
186 | - // Extension PHP is not allowed, change to PHPS |
|
187 | - $new_file_name = php2phps($new_file_name); |
|
188 | - |
|
189 | - if ($new_file_name == $old_file_name) { |
|
190 | - return $old_file_name; |
|
191 | - } |
|
192 | - |
|
193 | - if (strtolower($new_file_name) != strtolower($old_file_name) && check_name_exist($path.'/'.$new_file_name)) { |
|
194 | - return false; |
|
195 | - } |
|
196 | - // On a Windows server, it would be better not to do the above check |
|
197 | - // because it succeeds for some new names resembling the old name. |
|
198 | - // But on Unix/Linux the check must be done because rename overwrites. |
|
199 | - |
|
200 | - chdir($path); |
|
201 | - $res = rename($old_file_name, $new_file_name) ? $new_file_name : false; |
|
202 | - chdir($save_dir); |
|
203 | - return $res; |
|
173 | + $save_dir = getcwd(); |
|
174 | + $path = dirname($file_path); |
|
175 | + $old_file_name = basename($file_path); |
|
176 | + $new_file_name = api_replace_dangerous_char($new_file_name); |
|
177 | + |
|
178 | + // If no extension, take the old one |
|
179 | + if ((strpos($new_file_name, '.') === false) && ($dotpos = strrpos($old_file_name, '.'))) { |
|
180 | + $new_file_name .= substr($old_file_name, $dotpos); |
|
181 | + } |
|
182 | + |
|
183 | + // Note: still possible: 'xx.yy' -rename-> '.yy' -rename-> 'zz' |
|
184 | + // This is useful for folder names, where otherwise '.' would be sticky |
|
185 | + |
|
186 | + // Extension PHP is not allowed, change to PHPS |
|
187 | + $new_file_name = php2phps($new_file_name); |
|
188 | + |
|
189 | + if ($new_file_name == $old_file_name) { |
|
190 | + return $old_file_name; |
|
191 | + } |
|
192 | + |
|
193 | + if (strtolower($new_file_name) != strtolower($old_file_name) && check_name_exist($path.'/'.$new_file_name)) { |
|
194 | + return false; |
|
195 | + } |
|
196 | + // On a Windows server, it would be better not to do the above check |
|
197 | + // because it succeeds for some new names resembling the old name. |
|
198 | + // But on Unix/Linux the check must be done because rename overwrites. |
|
199 | + |
|
200 | + chdir($path); |
|
201 | + $res = rename($old_file_name, $new_file_name) ? $new_file_name : false; |
|
202 | + chdir($save_dir); |
|
203 | + return $res; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -217,38 +217,38 @@ discard block |
||
217 | 217 | */ |
218 | 218 | function move($source, $target, $forceMove = false, $moveContent = false) |
219 | 219 | { |
220 | - if (check_name_exist($source)) { |
|
221 | - $file_name = basename($source); |
|
220 | + if (check_name_exist($source)) { |
|
221 | + $file_name = basename($source); |
|
222 | 222 | $isWindowsOS = api_is_windows_os(); |
223 | 223 | $canExec = function_exists('exec'); |
224 | 224 | |
225 | - /* File case */ |
|
226 | - if (is_file($source)) { |
|
227 | - if ($forceMove && !$isWindowsOS && $canExec) { |
|
228 | - exec('mv ' . $source . ' ' . $target . '/' . $file_name); |
|
229 | - } else { |
|
230 | - copy($source, $target . '/' . $file_name); |
|
231 | - unlink($source); |
|
232 | - } |
|
233 | - return true; |
|
234 | - } elseif (is_dir($source)) { |
|
235 | - /* Directory */ |
|
236 | - if ($forceMove && !$isWindowsOS && $canExec) { |
|
237 | - if ($moveContent) { |
|
238 | - $base = basename($source); |
|
239 | - exec('mv '.$source.'/* '.$target.$base.'/'); |
|
240 | - exec('rm -rf '.$source); |
|
241 | - } else { |
|
242 | - exec('mv $source $target'); |
|
243 | - } |
|
244 | - } else { |
|
245 | - copyDirTo($source, $target); |
|
246 | - } |
|
247 | - return true; |
|
248 | - } |
|
249 | - } else { |
|
250 | - return false; |
|
251 | - } |
|
225 | + /* File case */ |
|
226 | + if (is_file($source)) { |
|
227 | + if ($forceMove && !$isWindowsOS && $canExec) { |
|
228 | + exec('mv ' . $source . ' ' . $target . '/' . $file_name); |
|
229 | + } else { |
|
230 | + copy($source, $target . '/' . $file_name); |
|
231 | + unlink($source); |
|
232 | + } |
|
233 | + return true; |
|
234 | + } elseif (is_dir($source)) { |
|
235 | + /* Directory */ |
|
236 | + if ($forceMove && !$isWindowsOS && $canExec) { |
|
237 | + if ($moveContent) { |
|
238 | + $base = basename($source); |
|
239 | + exec('mv '.$source.'/* '.$target.$base.'/'); |
|
240 | + exec('rm -rf '.$source); |
|
241 | + } else { |
|
242 | + exec('mv $source $target'); |
|
243 | + } |
|
244 | + } else { |
|
245 | + copyDirTo($source, $target); |
|
246 | + } |
|
247 | + return true; |
|
248 | + } |
|
249 | + } else { |
|
250 | + return false; |
|
251 | + } |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -261,54 +261,54 @@ discard block |
||
261 | 261 | */ |
262 | 262 | function copyDirTo($orig_dir_path, $destination, $move = true) |
263 | 263 | { |
264 | - if ($orig_dir_path == $destination) { |
|
265 | - return false; |
|
266 | - } |
|
264 | + if ($orig_dir_path == $destination) { |
|
265 | + return false; |
|
266 | + } |
|
267 | 267 | |
268 | - $save_dir = getcwd(); |
|
269 | - // Extract directory name - create it at destination - update destination trail |
|
270 | - $dir_name = basename($orig_dir_path); |
|
268 | + $save_dir = getcwd(); |
|
269 | + // Extract directory name - create it at destination - update destination trail |
|
270 | + $dir_name = basename($orig_dir_path); |
|
271 | 271 | $dir_to_copy = array(); |
272 | - if (is_dir($orig_dir_path)) { |
|
273 | - if (!is_dir($destination.'/'.$dir_name)) { |
|
274 | - mkdir( |
|
275 | - $destination.'/'.$dir_name, |
|
276 | - api_get_permissions_for_new_directories() |
|
277 | - ); |
|
278 | - } |
|
279 | - $destination_trail = $destination.'/'.$dir_name; |
|
280 | - if (is_dir($destination)) { |
|
281 | - chdir($orig_dir_path) ; |
|
282 | - $handle = opendir($orig_dir_path); |
|
283 | - |
|
284 | - while ($element = readdir($handle)) { |
|
285 | - if ($element == '.' || $element == '..') { |
|
286 | - continue; // Skip the current and parent directories |
|
287 | - } elseif (is_file($element)) { |
|
288 | - copy($element, $destination_trail.'/'.$element); |
|
289 | - |
|
290 | - if ($move) { |
|
291 | - unlink($element) ; |
|
292 | - } |
|
293 | - } elseif (is_dir($element)) { |
|
294 | - $dir_to_copy[] = $orig_dir_path.'/'.$element; |
|
295 | - } |
|
296 | - } |
|
297 | - |
|
298 | - closedir($handle) ; |
|
299 | - |
|
300 | - if (sizeof($dir_to_copy) > 0) { |
|
301 | - foreach ($dir_to_copy as $this_dir) { |
|
302 | - copyDirTo($this_dir, $destination_trail, $move); // Recursivity |
|
303 | - } |
|
304 | - } |
|
305 | - |
|
306 | - if ($move) { |
|
307 | - rmdir($orig_dir_path) ; |
|
308 | - } |
|
309 | - chdir($save_dir); |
|
310 | - } |
|
311 | - } |
|
272 | + if (is_dir($orig_dir_path)) { |
|
273 | + if (!is_dir($destination.'/'.$dir_name)) { |
|
274 | + mkdir( |
|
275 | + $destination.'/'.$dir_name, |
|
276 | + api_get_permissions_for_new_directories() |
|
277 | + ); |
|
278 | + } |
|
279 | + $destination_trail = $destination.'/'.$dir_name; |
|
280 | + if (is_dir($destination)) { |
|
281 | + chdir($orig_dir_path) ; |
|
282 | + $handle = opendir($orig_dir_path); |
|
283 | + |
|
284 | + while ($element = readdir($handle)) { |
|
285 | + if ($element == '.' || $element == '..') { |
|
286 | + continue; // Skip the current and parent directories |
|
287 | + } elseif (is_file($element)) { |
|
288 | + copy($element, $destination_trail.'/'.$element); |
|
289 | + |
|
290 | + if ($move) { |
|
291 | + unlink($element) ; |
|
292 | + } |
|
293 | + } elseif (is_dir($element)) { |
|
294 | + $dir_to_copy[] = $orig_dir_path.'/'.$element; |
|
295 | + } |
|
296 | + } |
|
297 | + |
|
298 | + closedir($handle) ; |
|
299 | + |
|
300 | + if (sizeof($dir_to_copy) > 0) { |
|
301 | + foreach ($dir_to_copy as $this_dir) { |
|
302 | + copyDirTo($this_dir, $destination_trail, $move); // Recursivity |
|
303 | + } |
|
304 | + } |
|
305 | + |
|
306 | + if ($move) { |
|
307 | + rmdir($orig_dir_path) ; |
|
308 | + } |
|
309 | + chdir($save_dir); |
|
310 | + } |
|
311 | + } |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | * @param string $filename filename |
320 | 320 | */ |
321 | 321 | function getextension($filename) { |
322 | - $bouts = explode('.', $filename); |
|
323 | - return array(array_pop($bouts), implode('.', $bouts)); |
|
322 | + $bouts = explode('.', $filename); |
|
323 | + return array(array_pop($bouts), implode('.', $bouts)); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -331,19 +331,19 @@ discard block |
||
331 | 331 | * @param boolean $recursive if true , include subdir in total |
332 | 332 | */ |
333 | 333 | function dirsize($root, $recursive = true) { |
334 | - $dir = @opendir($root); |
|
335 | - $size = 0; |
|
336 | - while ($file = @readdir($dir)) { |
|
337 | - if (!in_array($file, array('.', '..'))) { |
|
338 | - if (is_dir($root.'/'.$file)) { |
|
339 | - $size += $recursive ? dirsize($root.'/'.$file) : 0; |
|
340 | - } else { |
|
341 | - $size += @filesize($root.'/'.$file); |
|
342 | - } |
|
343 | - } |
|
344 | - } |
|
345 | - @closedir($dir); |
|
346 | - return $size; |
|
334 | + $dir = @opendir($root); |
|
335 | + $size = 0; |
|
336 | + while ($file = @readdir($dir)) { |
|
337 | + if (!in_array($file, array('.', '..'))) { |
|
338 | + if (is_dir($root.'/'.$file)) { |
|
339 | + $size += $recursive ? dirsize($root.'/'.$file) : 0; |
|
340 | + } else { |
|
341 | + $size += @filesize($root.'/'.$file); |
|
342 | + } |
|
343 | + } |
|
344 | + } |
|
345 | + @closedir($dir); |
|
346 | + return $size; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /* CLASS FileManager */ |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | */ |
363 | 363 | class FileManager |
364 | 364 | { |
365 | - /** |
|
365 | + /** |
|
366 | 366 | Returns a list of all directories, except the base dir, |
367 | 367 | of the current course. This function uses recursion. |
368 | 368 | |
@@ -370,131 +370,130 @@ discard block |
||
370 | 370 | |
371 | 371 | @author Roan Embrechts |
372 | 372 | @version 1.0.1 |
373 | - */ |
|
374 | - function list_all_directories($path) |
|
373 | + */ |
|
374 | + function list_all_directories($path) |
|
375 | 375 | { |
376 | - $result_array = array(); |
|
377 | - if (is_dir($path)) { |
|
378 | - $save_dir = getcwd(); |
|
379 | - chdir($path); |
|
380 | - $handle = opendir($path); |
|
381 | - while ($element = readdir($handle)) { |
|
382 | - if ($element == '.' || $element == '..') continue; |
|
376 | + $result_array = array(); |
|
377 | + if (is_dir($path)) { |
|
378 | + $save_dir = getcwd(); |
|
379 | + chdir($path); |
|
380 | + $handle = opendir($path); |
|
381 | + while ($element = readdir($handle)) { |
|
382 | + if ($element == '.' || $element == '..') continue; |
|
383 | 383 | // Skip the current and parent directories |
384 | - if (is_dir($element)) { |
|
385 | - $dir_array[] = $path.'/'.$element; |
|
386 | - } |
|
387 | - } |
|
388 | - closedir($handle); |
|
389 | - // Recursive operation if subdirectories exist |
|
390 | - $dir_number = sizeof($dir_array); |
|
391 | - if ($dir_number > 0) { |
|
392 | - for ($i = 0 ; $i < $dir_number ; $i++) { |
|
393 | - $sub_dir_array = FileManager::list_all_directories($dir_array[$i]); // Function recursivity |
|
394 | - if (is_array($dir_array) && is_array($sub_dir_array)) { |
|
395 | - $dir_array = array_merge($dir_array, $sub_dir_array); // Data merge |
|
396 | - } |
|
397 | - } |
|
398 | - } |
|
399 | - $result_array = $dir_array; |
|
400 | - chdir($save_dir) ; |
|
401 | - } |
|
402 | - return $result_array ; |
|
403 | - } |
|
404 | - |
|
405 | - /** |
|
384 | + if (is_dir($element)) { |
|
385 | + $dir_array[] = $path.'/'.$element; |
|
386 | + } |
|
387 | + } |
|
388 | + closedir($handle); |
|
389 | + // Recursive operation if subdirectories exist |
|
390 | + $dir_number = sizeof($dir_array); |
|
391 | + if ($dir_number > 0) { |
|
392 | + for ($i = 0 ; $i < $dir_number ; $i++) { |
|
393 | + $sub_dir_array = FileManager::list_all_directories($dir_array[$i]); // Function recursivity |
|
394 | + if (is_array($dir_array) && is_array($sub_dir_array)) { |
|
395 | + $dir_array = array_merge($dir_array, $sub_dir_array); // Data merge |
|
396 | + } |
|
397 | + } |
|
398 | + } |
|
399 | + $result_array = $dir_array; |
|
400 | + chdir($save_dir) ; |
|
401 | + } |
|
402 | + return $result_array ; |
|
403 | + } |
|
404 | + |
|
405 | + /** |
|
406 | 406 | This function receives a list of directories. |
407 | 407 | It returns a list of all files in these directories |
408 | 408 | |
409 | 409 | @author Roan Embrechts |
410 | 410 | @version 1.0 |
411 | - */ |
|
412 | - function list_all_files($dir_array) |
|
411 | + */ |
|
412 | + function list_all_files($dir_array) |
|
413 | 413 | { |
414 | - $element_array = array(); |
|
415 | - if (is_dir($dir_array)) { |
|
416 | - |
|
417 | - $save_dir = getcwd(); |
|
418 | - foreach ($dir_array as $directory) { |
|
419 | - chdir($directory); |
|
420 | - $handle = opendir($directory); |
|
421 | - while ($element = readdir($handle)) { |
|
422 | - if ($element == '.' || $element == '..' || $element == '.htaccess') continue; |
|
414 | + $element_array = array(); |
|
415 | + if (is_dir($dir_array)) { |
|
416 | + |
|
417 | + $save_dir = getcwd(); |
|
418 | + foreach ($dir_array as $directory) { |
|
419 | + chdir($directory); |
|
420 | + $handle = opendir($directory); |
|
421 | + while ($element = readdir($handle)) { |
|
422 | + if ($element == '.' || $element == '..' || $element == '.htaccess') continue; |
|
423 | 423 | // Skip the current and parent directories |
424 | - if (!is_dir($element)) { |
|
425 | - $element_array[] = $directory.'/'.$element; |
|
426 | - } |
|
427 | - } |
|
428 | - closedir($handle); |
|
429 | - chdir('..'); |
|
430 | - chdir($save_dir); |
|
431 | - } |
|
432 | - } |
|
433 | - |
|
434 | - return $element_array; |
|
435 | - } |
|
436 | - |
|
437 | - /** |
|
424 | + if (!is_dir($element)) { |
|
425 | + $element_array[] = $directory.'/'.$element; |
|
426 | + } |
|
427 | + } |
|
428 | + closedir($handle); |
|
429 | + chdir('..'); |
|
430 | + chdir($save_dir); |
|
431 | + } |
|
432 | + } |
|
433 | + |
|
434 | + return $element_array; |
|
435 | + } |
|
436 | + |
|
437 | + /** |
|
438 | 438 | Loads contents of file $filename into memory and returns them as a string. |
439 | 439 | Function kept for compatibility with older PHP versions. |
440 | 440 | Function is binary safe (is needed on Windows) |
441 | - */ |
|
442 | - function compat_load_file($file_name) |
|
441 | + */ |
|
442 | + function compat_load_file($file_name) |
|
443 | 443 | { |
444 | - $buffer = ''; |
|
445 | - if (file_exists($file_name)) { |
|
446 | - $fp = fopen($file_name, 'rb'); |
|
447 | - $buffer = fread ($fp, filesize($file_name)); |
|
448 | - fclose ($fp); |
|
449 | - } |
|
450 | - return $buffer; |
|
451 | - } |
|
452 | - |
|
453 | - /** |
|
454 | - * Adds file/folder to document table in database |
|
455 | - * improvement from set_default_settings (see below): |
|
456 | - * take all info from function parameters |
|
457 | - * no global variables needed |
|
458 | - * |
|
459 | - * NOTE $glued_table should already have backticks around it |
|
460 | - * (get it from the database library, and it is done automatically) |
|
461 | - * |
|
462 | - * @param path, filename, filetype, |
|
463 | - $glued_table, default_visibility |
|
444 | + $buffer = ''; |
|
445 | + if (file_exists($file_name)) { |
|
446 | + $fp = fopen($file_name, 'rb'); |
|
447 | + $buffer = fread ($fp, filesize($file_name)); |
|
448 | + fclose ($fp); |
|
449 | + } |
|
450 | + return $buffer; |
|
451 | + } |
|
464 | 452 | |
465 | - * action: Adds an entry to the document table with the default settings. |
|
466 | - * @author Olivier Cauberghe <[email protected]> |
|
467 | - * @author Roan Embrechts |
|
468 | - * @version 1.2 |
|
469 | - */ |
|
470 | - function set_default_settings($upload_path, $filename, $filetype = 'file', $glued_table, $default_visibility = 'v') |
|
453 | + /** |
|
454 | + * Adds file/folder to document table in database |
|
455 | + * improvement from set_default_settings (see below): |
|
456 | + * take all info from function parameters |
|
457 | + * no global variables needed |
|
458 | + * |
|
459 | + * NOTE $glued_table should already have backticks around it |
|
460 | + * (get it from the database library, and it is done automatically) |
|
461 | + * |
|
462 | + * @param path, filename, filetype, |
|
463 | + $glued_table, default_visibility |
|
464 | + * action: Adds an entry to the document table with the default settings. |
|
465 | + * @author Olivier Cauberghe <[email protected]> |
|
466 | + * @author Roan Embrechts |
|
467 | + * @version 1.2 |
|
468 | + */ |
|
469 | + function set_default_settings($upload_path, $filename, $filetype = 'file', $glued_table, $default_visibility = 'v') |
|
471 | 470 | { |
472 | - if (!$default_visibility) $default_visibility = 'v'; |
|
473 | - |
|
474 | - // Make sure path is not wrongly formed |
|
475 | - $upload_path = !empty($upload_path) ? "/$upload_path" : ''; |
|
476 | - |
|
477 | - $endchar = substr($filename, strlen($filename) - 1, 1); |
|
478 | - if ($endchar == "\\" || $endchar == '/') { |
|
479 | - $filename = substr($filename, 0, strlen($filename) - 1); |
|
480 | - } |
|
481 | - |
|
482 | - $full_file_name = $upload_path.'/'.$filename; |
|
483 | - $full_file_name = str_replace("//", '/', $full_file_name); |
|
484 | - |
|
485 | - $sql_query = "SELECT count(*) as number_existing FROM $glued_table WHERE path='$full_file_name'"; |
|
486 | - $sql_result = Database::query($sql_query); |
|
487 | - $result = Database::fetch_array($sql_result); |
|
488 | - // Determine which query to execute |
|
489 | - if ($result['number_existing'] > 0) { |
|
490 | - // Entry exists, update |
|
491 | - $query = "UPDATE $glued_table SET path='$full_file_name',visibility='$default_visibility', filetype='$filetype' |
|
471 | + if (!$default_visibility) $default_visibility = 'v'; |
|
472 | + |
|
473 | + // Make sure path is not wrongly formed |
|
474 | + $upload_path = !empty($upload_path) ? "/$upload_path" : ''; |
|
475 | + |
|
476 | + $endchar = substr($filename, strlen($filename) - 1, 1); |
|
477 | + if ($endchar == "\\" || $endchar == '/') { |
|
478 | + $filename = substr($filename, 0, strlen($filename) - 1); |
|
479 | + } |
|
480 | + |
|
481 | + $full_file_name = $upload_path.'/'.$filename; |
|
482 | + $full_file_name = str_replace("//", '/', $full_file_name); |
|
483 | + |
|
484 | + $sql_query = "SELECT count(*) as number_existing FROM $glued_table WHERE path='$full_file_name'"; |
|
485 | + $sql_result = Database::query($sql_query); |
|
486 | + $result = Database::fetch_array($sql_result); |
|
487 | + // Determine which query to execute |
|
488 | + if ($result['number_existing'] > 0) { |
|
489 | + // Entry exists, update |
|
490 | + $query = "UPDATE $glued_table SET path='$full_file_name',visibility='$default_visibility', filetype='$filetype' |
|
492 | 491 | WHERE path='$full_file_name'"; |
493 | - } else { |
|
494 | - // No entry exists, create new one |
|
495 | - $query = "INSERT INTO $glued_table (path,visibility,filetype) |
|
492 | + } else { |
|
493 | + // No entry exists, create new one |
|
494 | + $query = "INSERT INTO $glued_table (path,visibility,filetype) |
|
496 | 495 | VALUES ('$full_file_name','$default_visibility','$filetype')"; |
497 | - } |
|
498 | - Database::query($query); |
|
499 | - } |
|
496 | + } |
|
497 | + Database::query($query); |
|
498 | + } |
|
500 | 499 | } |
@@ -17,6 +17,7 @@ discard block |
||
17 | 17 | * |
18 | 18 | * @author - Hugues Peeters <[email protected]> |
19 | 19 | * @param - file_name (string) name of a file |
20 | + * @param string $file_name |
|
20 | 21 | * @return - the filenam phps'ized |
21 | 22 | */ |
22 | 23 | function php2phps($file_name) { |
@@ -73,7 +74,7 @@ discard block |
||
73 | 74 | * Returns the name without extension, used for the title |
74 | 75 | * |
75 | 76 | * @param string $name |
76 | - * @return name without the extension |
|
77 | + * @return string without the extension |
|
77 | 78 | */ |
78 | 79 | function get_document_title($name) { |
79 | 80 | // If they upload .htaccess... |
@@ -86,7 +87,7 @@ discard block |
||
86 | 87 | * This function checks if the upload succeeded |
87 | 88 | * |
88 | 89 | * @param array $uploaded_file ($_FILES) |
89 | - * @return true if upload succeeded |
|
90 | + * @return boolean if upload succeeded |
|
90 | 91 | */ |
91 | 92 | function process_uploaded_file($uploaded_file, $show_output = true) |
92 | 93 | { |
@@ -698,6 +699,8 @@ discard block |
||
698 | 699 | * @param - dir (string) - Path of the directory |
699 | 700 | * whe the file should be added |
700 | 701 | * @param - max_dir_space (int) - maximum size of the diretory in byte |
702 | + * @param string $dir |
|
703 | + * @param integer $max_dir_space |
|
701 | 704 | * @return - boolean true if there is enough space, |
702 | 705 | * boolean false otherwise |
703 | 706 | * |
@@ -1022,7 +1025,7 @@ discard block |
||
1022 | 1025 | * @param array $courseInfo |
1023 | 1026 | * @param array $userInfo |
1024 | 1027 | * @param array $uploaded_file - follows the $_FILES Structure |
1025 | - * @param string $upload_path - destination of the upload. |
|
1028 | + * @param string $uploadPath - destination of the upload. |
|
1026 | 1029 | * This path is to append to $base_work_dir |
1027 | 1030 | * @param string $base_work_dir - base working directory of the module |
1028 | 1031 | * @param int $maxFilledSpace - amount of bytes to not exceed in the base |
@@ -1201,7 +1204,7 @@ discard block |
||
1201 | 1204 | * @param bool $save_visibility |
1202 | 1205 | * @param int $group_id |
1203 | 1206 | * @param int $session_id Session ID, if any |
1204 | - * @return int id if inserted document |
|
1207 | + * @return string|false id if inserted document |
|
1205 | 1208 | */ |
1206 | 1209 | function add_document( |
1207 | 1210 | $_course, |
@@ -1337,7 +1340,7 @@ discard block |
||
1337 | 1340 | * |
1338 | 1341 | * @author Olivier Cauberghe <[email protected]> |
1339 | 1342 | * @param path+filename eg: /main/document/document.php |
1340 | - * @return The directory depth |
|
1343 | + * @return integer directory depth |
|
1341 | 1344 | */ |
1342 | 1345 | function get_levels($filename) { |
1343 | 1346 | $levels = explode('/', $filename); |
@@ -1354,6 +1357,7 @@ discard block |
||
1354 | 1357 | * @author Olivier Cauberghe <[email protected]> |
1355 | 1358 | * @param path,filename |
1356 | 1359 | * action: Adds an entry to the document table with the default settings. |
1360 | + * @param string $upload_path |
|
1357 | 1361 | */ |
1358 | 1362 | function set_default_settings($upload_path, $filename, $filetype = 'file') |
1359 | 1363 | { |
@@ -1778,6 +1782,7 @@ discard block |
||
1778 | 1782 | |
1779 | 1783 | @author Roan Embrechts |
1780 | 1784 | @version 0.6 |
1785 | + * @param string $buffer |
|
1781 | 1786 | */ |
1782 | 1787 | function api_replace_links_in_string($upload_path, $buffer) { |
1783 | 1788 | // Search for hyperlinks |
@@ -2013,7 +2018,6 @@ discard block |
||
2013 | 2018 | * @param int $groupId |
2014 | 2019 | * @param bool $output |
2015 | 2020 | * @param array $parent |
2016 | - * @param string $uploadPath |
|
2017 | 2021 | * |
2018 | 2022 | */ |
2019 | 2023 | function add_all_documents_in_folder_to_database( |
@@ -993,7 +993,9 @@ |
||
993 | 993 | if ($file != '.' && $file != '..') { |
994 | 994 | |
995 | 995 | $filetype = 'file'; |
996 | - if (is_dir($base_work_dir.$upload_path.'/'.$file)) $filetype = 'folder'; |
|
996 | + if (is_dir($base_work_dir.$upload_path.'/'.$file)) { |
|
997 | + $filetype = 'folder'; |
|
998 | + } |
|
997 | 999 | |
998 | 1000 | $safe_file = api_replace_dangerous_char($file, 'strict'); |
999 | 1001 | @rename($base_work_dir.$upload_path.'/'.$file,$base_work_dir.$upload_path.'/'.$safe_file); |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | $name_no_ext = substr($name, 0, strlen($name) - strlen(strstr($name, $ext))); |
64 | 64 | $n = 0; |
65 | 65 | $unique = ''; |
66 | - while (file_exists($path . $name_no_ext . $unique . $ext)) { |
|
67 | - $unique = '_' . ++$n; |
|
66 | + while (file_exists($path.$name_no_ext.$unique.$ext)) { |
|
67 | + $unique = '_'.++$n; |
|
68 | 68 | } |
69 | - return $name_no_ext . $unique . $ext; |
|
69 | + return $name_no_ext.$unique.$ext; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | // Not used at the moment, but could be handy if we want to limit the size of an upload (e.g. image upload in html editor). |
106 | 106 | $max_file_size = intval($_POST['MAX_FILE_SIZE']); |
107 | 107 | if ($show_output) { |
108 | - Display::display_error_message(get_lang('UplExceedMaxPostSize'). format_file_size($max_file_size)); |
|
108 | + Display::display_error_message(get_lang('UplExceedMaxPostSize').format_file_size($max_file_size)); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | return false; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | case 4: |
120 | 120 | // No file was uploaded. |
121 | 121 | if ($show_output) { |
122 | - Display::display_error_message(get_lang('UplNoFileUploaded').' '. get_lang('UplSelectFileFirst')); |
|
122 | + Display::display_error_message(get_lang('UplNoFileUploaded').' '.get_lang('UplSelectFileFirst')); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | return false; |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | // Display success message with extra info to user |
460 | 460 | if ($output) { |
461 | 461 | Display::display_confirmation_message( |
462 | - get_lang('UplUploadSucceeded') . '<br /> ' . $documentTitle . ' ' . get_lang('UplFileOverwritten'), |
|
462 | + get_lang('UplUploadSucceeded').'<br /> '.$documentTitle.' '.get_lang('UplFileOverwritten'), |
|
463 | 463 | false |
464 | 464 | ); |
465 | 465 | } |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | // Display success message to user |
584 | 584 | if ($output) { |
585 | 585 | Display::display_confirmation_message( |
586 | - get_lang('UplUploadSucceeded') . '<br />' . get_lang('UplFileSavedAs') .' '.$documentTitle, |
|
586 | + get_lang('UplUploadSucceeded').'<br />'.get_lang('UplFileSavedAs').' '.$documentTitle, |
|
587 | 587 | false |
588 | 588 | ); |
589 | 589 | } |
@@ -730,12 +730,12 @@ discard block |
||
730 | 730 | function dir_total_space($dir_path) |
731 | 731 | { |
732 | 732 | $save_dir = getcwd(); |
733 | - chdir($dir_path) ; |
|
733 | + chdir($dir_path); |
|
734 | 734 | $handle = opendir($dir_path); |
735 | 735 | $sumSize = 0; |
736 | 736 | $dirList = array(); |
737 | 737 | while ($element = readdir($handle)) { |
738 | - if ( $element == '.' || $element == '..') { |
|
738 | + if ($element == '.' || $element == '..') { |
|
739 | 739 | continue; // Skip the current and parent directories |
740 | 740 | } |
741 | 741 | if (is_file($element)) { |
@@ -746,11 +746,11 @@ discard block |
||
746 | 746 | } |
747 | 747 | } |
748 | 748 | |
749 | - closedir($handle) ; |
|
749 | + closedir($handle); |
|
750 | 750 | |
751 | 751 | if (sizeof($dirList) > 0) { |
752 | 752 | foreach ($dirList as $j) { |
753 | - $sizeDir = dir_total_space($j); // Recursivity |
|
753 | + $sizeDir = dir_total_space($j); // Recursivity |
|
754 | 754 | $sumSize += $sizeDir; |
755 | 755 | } |
756 | 756 | } |
@@ -784,63 +784,63 @@ discard block |
||
784 | 784 | |
785 | 785 | static $mime_type = array(); |
786 | 786 | |
787 | - $mime_type[] = 'application/msword'; $extension[] = '.doc'; |
|
788 | - $mime_type[] = 'application/rtf'; $extension[] = '.rtf'; |
|
789 | - $mime_type[] = 'application/vnd.ms-powerpoint'; $extension[] = '.ppt'; |
|
790 | - $mime_type[] = 'application/vnd.ms-excel'; $extension[] = '.xls'; |
|
791 | - $mime_type[] = 'application/pdf'; $extension[] = '.pdf'; |
|
792 | - $mime_type[] = 'application/postscript'; $extension[] = '.ps'; |
|
793 | - $mime_type[] = 'application/mac-binhex40'; $extension[] = '.hqx'; |
|
794 | - $mime_type[] = 'application/x-gzip'; $extension[] = 'tar.gz'; |
|
795 | - $mime_type[] = 'application/x-shockwave-flash'; $extension[] = '.swf'; |
|
796 | - $mime_type[] = 'application/x-stuffit'; $extension[] = '.sit'; |
|
797 | - $mime_type[] = 'application/x-tar'; $extension[] = '.tar'; |
|
798 | - $mime_type[] = 'application/zip'; $extension[] = '.zip'; |
|
799 | - $mime_type[] = 'application/x-tar'; $extension[] = '.tar'; |
|
800 | - $mime_type[] = 'text/html'; $extension[] = '.html'; |
|
801 | - $mime_type[] = 'text/plain'; $extension[] = '.txt'; |
|
802 | - $mime_type[] = 'text/rtf'; $extension[] = '.rtf'; |
|
803 | - $mime_type[] = 'img/gif'; $extension[] = '.gif'; |
|
804 | - $mime_type[] = 'img/jpeg'; $extension[] = '.jpg'; |
|
805 | - $mime_type[] = 'img/png'; $extension[] = '.png'; |
|
806 | - $mime_type[] = 'audio/midi'; $extension[] = '.mid'; |
|
807 | - $mime_type[] = 'audio/mpeg'; $extension[] = '.mp3'; |
|
808 | - $mime_type[] = 'audio/x-aiff'; $extension[] = '.aif'; |
|
809 | - $mime_type[] = 'audio/x-pn-realaudio'; $extension[] = '.rm'; |
|
810 | - $mime_type[] = 'audio/x-pn-realaudio-plugin'; $extension[] = '.rpm'; |
|
811 | - $mime_type[] = 'audio/x-wav'; $extension[] = '.wav'; |
|
812 | - $mime_type[] = 'video/mpeg'; $extension[] = '.mpg'; |
|
813 | - $mime_type[] = 'video/mpeg4-generic'; $extension[] = '.mp4'; |
|
814 | - $mime_type[] = 'video/quicktime'; $extension[] = '.mov'; |
|
815 | - $mime_type[] = 'video/x-msvideo'; $extension[] = '.avi'; |
|
816 | - |
|
817 | - $mime_type[] = 'video/x-ms-wmv'; $extension[] = '.wmv'; |
|
818 | - $mime_type[] = 'video/x-flv'; $extension[] = '.flv'; |
|
819 | - $mime_type[] = 'image/svg+xml'; $extension[] = '.svg'; |
|
820 | - $mime_type[] = 'image/svg+xml'; $extension[] = '.svgz'; |
|
821 | - $mime_type[] = 'video/ogg'; $extension[] = '.ogv'; |
|
822 | - $mime_type[] = 'audio/ogg'; $extension[] = '.oga'; |
|
823 | - $mime_type[] = 'application/ogg'; $extension[] = '.ogg'; |
|
824 | - $mime_type[] = 'application/ogg'; $extension[] = '.ogx'; |
|
825 | - $mime_type[] = 'application/x-freemind'; $extension[] = '.mm'; |
|
826 | - |
|
827 | - $mime_type[] = 'application/vnd.ms-word.document.macroEnabled.12'; $extension[] = '.docm'; |
|
828 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; $extension[] = '.docx'; |
|
829 | - $mime_type[] = 'application/vnd.ms-word.template.macroEnabled.12'; $extension[] = '.dotm'; |
|
830 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'; $extension[] = '.dotx'; |
|
831 | - $mime_type[] = 'application/vnd.ms-powerpoint.template.macroEnabled.12'; $extension[] = '.potm'; |
|
832 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.template'; $extension[] = '.potx'; |
|
833 | - $mime_type[] = 'application/vnd.ms-powerpoint.addin.macroEnabled.12'; $extension[] = '.ppam'; |
|
834 | - $mime_type[] = 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12'; $extension[] = '.ppsm'; |
|
835 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'; $extension[] = '.ppsx'; |
|
836 | - $mime_type[] = 'application/vnd.ms-powerpoint.presentation.macroEnabled.12'; $extension[] = '.pptm'; |
|
837 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; $extension[] = '.pptx'; |
|
838 | - $mime_type[] = 'application/vnd.ms-excel.addin.macroEnabled.12'; $extension[] = '.xlam'; |
|
839 | - $mime_type[] = 'application/vnd.ms-excel.sheet.binary.macroEnabled.12'; $extension[] = '.xlsb'; |
|
840 | - $mime_type[] = 'application/vnd.ms-excel.sheet.macroEnabled.12'; $extension[] = '.xlsm'; |
|
841 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $extension[] = '.xlsx'; |
|
842 | - $mime_type[] = 'application/vnd.ms-excel.template.macroEnabled.12'; $extension[] = '.xltm'; |
|
843 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'; $extension[] = '.xltx'; |
|
787 | + $mime_type[] = 'application/msword'; $extension[] = '.doc'; |
|
788 | + $mime_type[] = 'application/rtf'; $extension[] = '.rtf'; |
|
789 | + $mime_type[] = 'application/vnd.ms-powerpoint'; $extension[] = '.ppt'; |
|
790 | + $mime_type[] = 'application/vnd.ms-excel'; $extension[] = '.xls'; |
|
791 | + $mime_type[] = 'application/pdf'; $extension[] = '.pdf'; |
|
792 | + $mime_type[] = 'application/postscript'; $extension[] = '.ps'; |
|
793 | + $mime_type[] = 'application/mac-binhex40'; $extension[] = '.hqx'; |
|
794 | + $mime_type[] = 'application/x-gzip'; $extension[] = 'tar.gz'; |
|
795 | + $mime_type[] = 'application/x-shockwave-flash'; $extension[] = '.swf'; |
|
796 | + $mime_type[] = 'application/x-stuffit'; $extension[] = '.sit'; |
|
797 | + $mime_type[] = 'application/x-tar'; $extension[] = '.tar'; |
|
798 | + $mime_type[] = 'application/zip'; $extension[] = '.zip'; |
|
799 | + $mime_type[] = 'application/x-tar'; $extension[] = '.tar'; |
|
800 | + $mime_type[] = 'text/html'; $extension[] = '.html'; |
|
801 | + $mime_type[] = 'text/plain'; $extension[] = '.txt'; |
|
802 | + $mime_type[] = 'text/rtf'; $extension[] = '.rtf'; |
|
803 | + $mime_type[] = 'img/gif'; $extension[] = '.gif'; |
|
804 | + $mime_type[] = 'img/jpeg'; $extension[] = '.jpg'; |
|
805 | + $mime_type[] = 'img/png'; $extension[] = '.png'; |
|
806 | + $mime_type[] = 'audio/midi'; $extension[] = '.mid'; |
|
807 | + $mime_type[] = 'audio/mpeg'; $extension[] = '.mp3'; |
|
808 | + $mime_type[] = 'audio/x-aiff'; $extension[] = '.aif'; |
|
809 | + $mime_type[] = 'audio/x-pn-realaudio'; $extension[] = '.rm'; |
|
810 | + $mime_type[] = 'audio/x-pn-realaudio-plugin'; $extension[] = '.rpm'; |
|
811 | + $mime_type[] = 'audio/x-wav'; $extension[] = '.wav'; |
|
812 | + $mime_type[] = 'video/mpeg'; $extension[] = '.mpg'; |
|
813 | + $mime_type[] = 'video/mpeg4-generic'; $extension[] = '.mp4'; |
|
814 | + $mime_type[] = 'video/quicktime'; $extension[] = '.mov'; |
|
815 | + $mime_type[] = 'video/x-msvideo'; $extension[] = '.avi'; |
|
816 | + |
|
817 | + $mime_type[] = 'video/x-ms-wmv'; $extension[] = '.wmv'; |
|
818 | + $mime_type[] = 'video/x-flv'; $extension[] = '.flv'; |
|
819 | + $mime_type[] = 'image/svg+xml'; $extension[] = '.svg'; |
|
820 | + $mime_type[] = 'image/svg+xml'; $extension[] = '.svgz'; |
|
821 | + $mime_type[] = 'video/ogg'; $extension[] = '.ogv'; |
|
822 | + $mime_type[] = 'audio/ogg'; $extension[] = '.oga'; |
|
823 | + $mime_type[] = 'application/ogg'; $extension[] = '.ogg'; |
|
824 | + $mime_type[] = 'application/ogg'; $extension[] = '.ogx'; |
|
825 | + $mime_type[] = 'application/x-freemind'; $extension[] = '.mm'; |
|
826 | + |
|
827 | + $mime_type[] = 'application/vnd.ms-word.document.macroEnabled.12'; $extension[] = '.docm'; |
|
828 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; $extension[] = '.docx'; |
|
829 | + $mime_type[] = 'application/vnd.ms-word.template.macroEnabled.12'; $extension[] = '.dotm'; |
|
830 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'; $extension[] = '.dotx'; |
|
831 | + $mime_type[] = 'application/vnd.ms-powerpoint.template.macroEnabled.12'; $extension[] = '.potm'; |
|
832 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.template'; $extension[] = '.potx'; |
|
833 | + $mime_type[] = 'application/vnd.ms-powerpoint.addin.macroEnabled.12'; $extension[] = '.ppam'; |
|
834 | + $mime_type[] = 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12'; $extension[] = '.ppsm'; |
|
835 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'; $extension[] = '.ppsx'; |
|
836 | + $mime_type[] = 'application/vnd.ms-powerpoint.presentation.macroEnabled.12'; $extension[] = '.pptm'; |
|
837 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; $extension[] = '.pptx'; |
|
838 | + $mime_type[] = 'application/vnd.ms-excel.addin.macroEnabled.12'; $extension[] = '.xlam'; |
|
839 | + $mime_type[] = 'application/vnd.ms-excel.sheet.binary.macroEnabled.12'; $extension[] = '.xlsb'; |
|
840 | + $mime_type[] = 'application/vnd.ms-excel.sheet.macroEnabled.12'; $extension[] = '.xlsm'; |
|
841 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $extension[] = '.xlsx'; |
|
842 | + $mime_type[] = 'application/vnd.ms-excel.template.macroEnabled.12'; $extension[] = '.xltm'; |
|
843 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'; $extension[] = '.xltx'; |
|
844 | 844 | |
845 | 845 | // Test on PC (files with no extension get application/octet-stream) |
846 | 846 | //$mime_type[] = 'application/octet-stream'; $extension[] = '.ext'; |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | |
850 | 850 | foreach ($mime_type as $key => & $type) { |
851 | 851 | if ($type == $file_type) { |
852 | - $file_name .= $extension[$key]; |
|
852 | + $file_name .= $extension[$key]; |
|
853 | 853 | break; |
854 | 854 | } |
855 | 855 | } |
@@ -957,12 +957,12 @@ discard block |
||
957 | 957 | } |
958 | 958 | |
959 | 959 | // It happens on Linux that $upload_path sometimes doesn't start with '/' |
960 | - if ($upload_path[0] != '/' && substr($base_work_dir,-1,1) != '/') { |
|
960 | + if ($upload_path[0] != '/' && substr($base_work_dir, -1, 1) != '/') { |
|
961 | 961 | $upload_path = '/'.$upload_path; |
962 | 962 | } |
963 | 963 | |
964 | 964 | if ($upload_path[strlen($upload_path) - 1] == '/') { |
965 | - $upload_path=substr($upload_path, 0, -1); |
|
965 | + $upload_path = substr($upload_path, 0, -1); |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | /* Uncompressing phase */ |
@@ -974,15 +974,15 @@ discard block |
||
974 | 974 | - add it to the database |
975 | 975 | - parse & change relative html links |
976 | 976 | */ |
977 | - if (PHP_OS == 'Linux' && ! get_cfg_var('safe_mode') && false) { // *** UGent, changed by OC *** |
|
977 | + if (PHP_OS == 'Linux' && !get_cfg_var('safe_mode') && false) { // *** UGent, changed by OC *** |
|
978 | 978 | // Shell Method - if this is possible, it gains some speed |
979 | - exec("unzip -d \"".$base_work_dir.$upload_path."/\"".$uploaded_file['name']." " .$uploaded_file['tmp_name']); |
|
979 | + exec("unzip -d \"".$base_work_dir.$upload_path."/\"".$uploaded_file['name']." ".$uploaded_file['tmp_name']); |
|
980 | 980 | } else { |
981 | 981 | // PHP method - slower... |
982 | 982 | $save_dir = getcwd(); |
983 | 983 | chdir($base_work_dir.$upload_path); |
984 | 984 | $unzippingState = $zip_file->extract(); |
985 | - for ($j=0; $j < count($unzippingState); $j++) { |
|
985 | + for ($j = 0; $j < count($unzippingState); $j++) { |
|
986 | 986 | $state = $unzippingState[$j]; |
987 | 987 | |
988 | 988 | // Fix relative links in html files |
@@ -996,8 +996,8 @@ discard block |
||
996 | 996 | if (is_dir($base_work_dir.$upload_path.'/'.$file)) $filetype = 'folder'; |
997 | 997 | |
998 | 998 | $safe_file = api_replace_dangerous_char($file, 'strict'); |
999 | - @rename($base_work_dir.$upload_path.'/'.$file,$base_work_dir.$upload_path.'/'.$safe_file); |
|
1000 | - set_default_settings($upload_path, $safe_file,$filetype); |
|
999 | + @rename($base_work_dir.$upload_path.'/'.$file, $base_work_dir.$upload_path.'/'.$safe_file); |
|
1000 | + set_default_settings($upload_path, $safe_file, $filetype); |
|
1001 | 1001 | } |
1002 | 1002 | } |
1003 | 1003 | |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | $zip = new PclZip($uploaded_file['tmp_name']); |
1048 | 1048 | |
1049 | 1049 | // Check the zip content (real size and file extension) |
1050 | - $zip_content_array = (array)$zip->listContent(); |
|
1050 | + $zip_content_array = (array) $zip->listContent(); |
|
1051 | 1051 | |
1052 | 1052 | $realSize = 0; |
1053 | 1053 | foreach ($zip_content_array as & $this_content) { |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | function filter_extension(&$filename) |
1144 | 1144 | { |
1145 | 1145 | if (substr($filename, -1) == '/') { |
1146 | - return 1; // Authorize directories |
|
1146 | + return 1; // Authorize directories |
|
1147 | 1147 | } |
1148 | 1148 | $blacklist = api_get_setting('upload_extensions_list_type'); |
1149 | 1149 | if ($blacklist != 'whitelist') { // if = blacklist |
@@ -1369,9 +1369,9 @@ discard block |
||
1369 | 1369 | $upload_path = str_replace('//', '/', $upload_path); |
1370 | 1370 | |
1371 | 1371 | if ($upload_path == '/') { |
1372 | - $upload_path=''; |
|
1372 | + $upload_path = ''; |
|
1373 | 1373 | } elseif (!empty($upload_path) && $upload_path[0] != '/') { |
1374 | - $upload_path="/$upload_path"; |
|
1374 | + $upload_path = "/$upload_path"; |
|
1375 | 1375 | } |
1376 | 1376 | |
1377 | 1377 | $endchar = substr($filename, strlen($filename) - 1, 1); |
@@ -1409,7 +1409,7 @@ discard block |
||
1409 | 1409 | $img_path_list = array(); |
1410 | 1410 | |
1411 | 1411 | if (!$fp = fopen($html_file, 'r')) { |
1412 | - return ; |
|
1412 | + return; |
|
1413 | 1413 | } |
1414 | 1414 | |
1415 | 1415 | // Aearch and store occurences of the <img> tag in an array |
@@ -1429,7 +1429,7 @@ discard block |
||
1429 | 1429 | $img_tag_list = $matches[0]; |
1430 | 1430 | } |
1431 | 1431 | |
1432 | - fclose ($fp); |
|
1432 | + fclose($fp); |
|
1433 | 1433 | unset($buffer); |
1434 | 1434 | |
1435 | 1435 | // Search the image file path from all the <IMG> tag detected |
@@ -1529,7 +1529,7 @@ discard block |
||
1529 | 1529 | |
1530 | 1530 | if (!is_dir($base_work_dir.$systemFolderName)) { |
1531 | 1531 | $result = mkdir( |
1532 | - $base_work_dir . $systemFolderName, |
|
1532 | + $base_work_dir.$systemFolderName, |
|
1533 | 1533 | api_get_permissions_for_new_directories(), |
1534 | 1534 | true |
1535 | 1535 | ); |
@@ -1542,7 +1542,7 @@ discard block |
||
1542 | 1542 | WHERE |
1543 | 1543 | c_id = $course_id AND |
1544 | 1544 | ( |
1545 | - path = '" . $systemFolderName . "' |
|
1545 | + path = '".$systemFolderName."' |
|
1546 | 1546 | ) |
1547 | 1547 | "; |
1548 | 1548 | |
@@ -1695,7 +1695,7 @@ discard block |
||
1695 | 1695 | |
1696 | 1696 | // Fix the image tags |
1697 | 1697 | |
1698 | - for ($i = 0, $fileNb = count($original_img_path); $i < $fileNb ; $i++) { |
|
1698 | + for ($i = 0, $fileNb = count($original_img_path); $i < $fileNb; $i++) { |
|
1699 | 1699 | $replace_what = $original_img_path[$i]; |
1700 | 1700 | // We only need the directory and the filename /path/to/file_html_files/missing_file.gif -> file_html_files/missing_file.gif |
1701 | 1701 | $exploded_file_path = explode('/', $new_img_path[$i]); |
@@ -1736,7 +1736,7 @@ discard block |
||
1736 | 1736 | .'</body>' |
1737 | 1737 | .'</html>'; |
1738 | 1738 | if (file_exists($file_path)) { |
1739 | - if (!($fp = fopen ($file_path, 'w'))) { |
|
1739 | + if (!($fp = fopen($file_path, 'w'))) { |
|
1740 | 1740 | return false; |
1741 | 1741 | } |
1742 | 1742 | return fwrite($fp, $file_content); |
@@ -1756,7 +1756,7 @@ discard block |
||
1756 | 1756 | // Open the file |
1757 | 1757 | if (file_exists($full_file_name)) { |
1758 | 1758 | $fp = fopen($full_file_name, 'r'); |
1759 | - $buffer = fread ($fp, filesize ($full_file_name)); |
|
1759 | + $buffer = fread($fp, filesize($full_file_name)); |
|
1760 | 1760 | |
1761 | 1761 | // Parse the contents |
1762 | 1762 | $new_html_content = api_replace_links_in_string($upload_path, $buffer); |
@@ -1899,7 +1899,7 @@ discard block |
||
1899 | 1899 | |
1900 | 1900 | foreach ($tag_list as & $this_tag) { |
1901 | 1901 | //Display::display_normal_message(htmlentities($this_tag)); //debug |
1902 | - if ( preg_match("~".$param_name."[\s]*=[\s]*[\"]{1}([^\"]+)[\"]{1}~i", $this_tag, $matches)) { |
|
1902 | + if (preg_match("~".$param_name."[\s]*=[\s]*[\"]{1}([^\"]+)[\"]{1}~i", $this_tag, $matches)) { |
|
1903 | 1903 | $file_path_list[] = $matches[1]; // older |
1904 | 1904 | $href_list[] = $matches[0]; // to also add target="_self" |
1905 | 1905 | } |
@@ -1920,9 +1920,9 @@ discard block |
||
1920 | 1920 | |
1921 | 1921 | // Fix the link to use download.php or showinframes.php |
1922 | 1922 | if (preg_match("/<a([\s]*[\"\/:'=a-z0-9]*){5}href[^<]*>/i", $tag_list[$count])) { |
1923 | - $replace_by[$count] = " $param_name =\"showinframes.php?file=" . $upload_path.$file_path_list[$count]."\" target=\"_self\" "; |
|
1923 | + $replace_by[$count] = " $param_name =\"showinframes.php?file=".$upload_path.$file_path_list[$count]."\" target=\"_self\" "; |
|
1924 | 1924 | } else { |
1925 | - $replace_by[$count] = " $param_name =\"download.php?doc_url=" . $upload_path.$file_path_list[$count]."\" "; |
|
1925 | + $replace_by[$count] = " $param_name =\"download.php?doc_url=".$upload_path.$file_path_list[$count]."\" "; |
|
1926 | 1926 | } |
1927 | 1927 | } else { |
1928 | 1928 | // "mailto" or url already fixed, leave as is |
@@ -1931,7 +1931,7 @@ discard block |
||
1931 | 1931 | } |
1932 | 1932 | } elseif ($is_absolute_hyperlink) { |
1933 | 1933 | //$message .= "Absolute hyperlink, don't change, add target=_self: "; |
1934 | - $replace_by[$count] = " $param_name=\"" . $file_path_list[$count] . "\" target =\"_self\""; |
|
1934 | + $replace_by[$count] = " $param_name=\"".$file_path_list[$count]."\" target =\"_self\""; |
|
1935 | 1935 | } else { |
1936 | 1936 | // Don't change anything |
1937 | 1937 | //$message .= "Local anchor, don't change: "; |
@@ -1976,7 +1976,7 @@ discard block |
||
1976 | 1976 | { |
1977 | 1977 | // Do we need a / or not? |
1978 | 1978 | $added_slash = ($upload_path == '/') ? '' : '/'; |
1979 | - $folder_id = DocumentManager::get_document_id(api_get_course_info(), $upload_path); |
|
1979 | + $folder_id = DocumentManager::get_document_id(api_get_course_info(), $upload_path); |
|
1980 | 1980 | // Build the form |
1981 | 1981 | $form = "<p><strong>".get_lang('MissingImagesDetected')."</strong></p>" |
1982 | 1982 | ."<form method=\"post\" action=\"".api_get_self()."\" enctype=\"multipart/form-data\">" |
@@ -145,6 +145,7 @@ |
||
145 | 145 | |
146 | 146 | /** |
147 | 147 | * @param array $dates result of parseDateRange() |
148 | + * @param string $format |
|
148 | 149 | * |
149 | 150 | * @return bool |
150 | 151 | */ |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | class DateRangePicker extends HTML_QuickForm_text |
8 | 8 | { |
9 | 9 | /** |
10 | - * Constructor |
|
11 | - */ |
|
10 | + * Constructor |
|
11 | + */ |
|
12 | 12 | public function __construct($elementName = null, $elementLabel = null, $attributes = null) |
13 | 13 | { |
14 | 14 | if (!isset($attributes['id'])) { |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | - * @param array $dates result of parseDateRange() |
|
148 | - * |
|
149 | - * @return bool |
|
150 | - */ |
|
147 | + * @param array $dates result of parseDateRange() |
|
148 | + * |
|
149 | + * @return bool |
|
150 | + */ |
|
151 | 151 | public function validateDates($dates, $format = null) |
152 | 152 | { |
153 | 153 | if (empty($dates['start']) || empty($dates['end'])) { |
@@ -88,7 +88,7 @@ |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | $timePicker = 'true'; |
91 | - $timePickerValue = $this->getAttribute('timePicker'); |
|
91 | + $timePickerValue = $this->getAttribute('timePicker'); |
|
92 | 92 | if (!empty($timePickerValue)) { |
93 | 93 | $timePicker = $timePickerValue; |
94 | 94 | } |