Completed
Push — 1.10.x ( 501d19...0db498 )
by Yannick
89:35 queued 49:03
created
main/inc/lib/display.lib.php 4 patches
Doc Comments   +26 added lines, -15 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -666,9 +666,10 @@
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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 {
@@ -528,22 +528,22 @@  discard block
 block discarded – undo
528 528
         }
529 529
 
530 530
         if ($filter) {
531
-        	$message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding());
531
+            $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding());
532 532
         }
533 533
 
534 534
         $class = "";
535 535
         switch($type) {
536 536
             case 'warning':
537 537
                $class .= 'alert alert-warning';
538
-               break;
538
+                break;
539 539
             case 'error':
540 540
                $class .= 'alert alert-danger';
541
-               break;
541
+                break;
542 542
             case 'confirmation':
543 543
             case 'confirm':
544 544
             case 'success':
545 545
                 $class .= 'alert alert-success';
546
-               break;
546
+                break;
547 547
             case 'normal':
548 548
             default:
549 549
                 $class .= 'alert alert-info';
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
      * @param array    additional attributes (for instance height, width, onclick, ...)
687 687
      * @param integer  The wanted width of the icon (to be looked for in the corresponding img/icons/ folder)
688 688
      * @return void
689
-    */
689
+     */
690 690
     public static function display_icon(
691 691
         $image,
692 692
         $alt_text = '',
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
      * @author Julio Montoya 2010 Function improved, adding image constants
723 723
      * @author Yannick Warnier 2011 Added size handler
724 724
      * @version Feb 2011
725
-    */
725
+     */
726 726
     public static function return_icon(
727 727
         $image,
728 728
         $alt_text = '',
@@ -911,14 +911,14 @@  discard block
 block discarded – undo
911 911
      */
912 912
     public static function input($type, $name, $value, $attributes = array())
913 913
     {
914
-         if (isset($type)) {
915
-             $attributes['type']= $type;
916
-         }
917
-         if (isset($name)) {
918
-             $attributes['name']= $name;
919
-         }
920
-         if (isset($value)) {
921
-             $attributes['value']= $value;
914
+            if (isset($type)) {
915
+                $attributes['type']= $type;
916
+            }
917
+            if (isset($name)) {
918
+                $attributes['name']= $name;
919
+            }
920
+            if (isset($value)) {
921
+                $attributes['value']= $value;
922 922
         }
923 923
         return self::tag('input', '', $attributes);
924 924
     }
@@ -931,10 +931,10 @@  discard block
 block discarded – undo
931 931
      */
932 932
     public static function button($name, $value, $attributes = array())
933 933
     {
934
-    	if (!empty($name)) {
934
+        if (!empty($name)) {
935 935
             $attributes['name'] = $name;
936
-    	}
937
-    	return self::tag('button', $value, $attributes);
936
+        }
937
+        return self::tag('button', $value, $attributes);
938 938
     }
939 939
 
940 940
     /**
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
      * in the $htmlHeadXtra variable before the display_header
1002 1002
      * Add this script
1003 1003
      * @example
1004
-             * <script>
1004
+     * <script>
1005 1005
                     $(function() {
1006 1006
                         $( "#tabs" ).tabs();
1007 1007
                     });
@@ -1062,20 +1062,20 @@  discard block
 block discarded – undo
1062 1062
      */
1063 1063
     public static function tabsOnlyLink($headers, $selected = null)
1064 1064
     {
1065
-         $id = uniqid();
1066
-         $i = 1;
1067
-         $lis = null;
1068
-         foreach ($headers as $item) {
1065
+            $id = uniqid();
1066
+            $i = 1;
1067
+            $lis = null;
1068
+            foreach ($headers as $item) {
1069 1069
             $class = null;
1070 1070
             if ($i == $selected) {
1071 1071
                 $class = 'active';
1072 1072
             }
1073
-             $item = self::tag(
1074
-                 'a',
1075
-                 $item['content'],
1076
-                 array('id' => $id.'-'.$i, 'href' => $item['url'])
1077
-             );
1078
-             $lis .= self::tag('li', $item, array('class' => $class));
1073
+                $item = self::tag(
1074
+                    'a',
1075
+                    $item['content'],
1076
+                    array('id' => $id.'-'.$i, 'href' => $item['url'])
1077
+                );
1078
+                $lis .= self::tag('li', $item, array('class' => $class));
1079 1079
             $i++;
1080 1080
         }
1081 1081
         return self::tag('ul', $lis, array('class' => 'nav nav-tabs tabs-margin'));
@@ -1287,8 +1287,8 @@  discard block
 block discarded – undo
1287 1287
      */
1288 1288
     public static function table($headers, $rows, $attributes = array())
1289 1289
     {
1290
-    	if (empty($attributes)) {
1291
-    		$attributes['class'] = 'data_table';
1290
+        if (empty($attributes)) {
1291
+            $attributes['class'] = 'data_table';
1292 1292
         }
1293 1293
         $table = new HTML_Table($attributes);
1294 1294
         $row = 0;
@@ -1296,17 +1296,17 @@  discard block
 block discarded – undo
1296 1296
 
1297 1297
         // Course headers
1298 1298
         if (!empty($headers)) {
1299
-	        foreach ($headers as $item) {
1300
-	            $table->setHeaderContents($row, $column, $item);
1301
-	            $column++;
1302
-	        }
1303
-	        $row = 1;
1304
-	        $column = 0;
1299
+            foreach ($headers as $item) {
1300
+                $table->setHeaderContents($row, $column, $item);
1301
+                $column++;
1302
+            }
1303
+            $row = 1;
1304
+            $column = 0;
1305 1305
         }
1306 1306
 
1307 1307
         if (!empty($rows)) {
1308
-	        foreach($rows as $content) {
1309
-	            $table->setCellContents($row, $column, $content);
1308
+            foreach($rows as $content) {
1309
+                $table->setCellContents($row, $column, $content);
1310 1310
                 $row++;
1311 1311
             }
1312 1312
         }
@@ -1412,7 +1412,7 @@  discard block
 block discarded – undo
1412 1412
                         //$item_property['tool'] != TOOL_DROPBOX &&
1413 1413
                         $item_property['tool'] != TOOL_NOTEBOOK &&
1414 1414
                         $item_property['tool'] != TOOL_CHAT)
1415
-                   )
1415
+                    )
1416 1416
                 )
1417 1417
                 // Take only what's visible or "invisible but where the user is a teacher" or where the visibility is unset.
1418 1418
                 && ($item_property['visibility'] == '1'
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
                         ($item_property['to_user_id'] != $user_id) &&
1429 1429
                         (!isset($item_property['to_group_id']) || !in_array($item_property['to_group_id'], $group_ids)))
1430 1430
                 ) {
1431
-                   continue;
1431
+                    continue;
1432 1432
                 }
1433 1433
 
1434 1434
                 // If it's a survey, make sure the user's invited. Otherwise drop it.
@@ -1646,21 +1646,21 @@  discard block
 block discarded – undo
1646 1646
      *
1647 1647
      * @param  string  id of the rating ul element
1648 1648
      * @param  string  url that will be added (for jquery see hot_courses.tpl)
1649
-	 * @param	string	point info array see function CourseManager::get_course_ranking()
1650
-	 * @param	bool	add a div wrapper
1651
-	 * @todo	use     templates
1649
+     * @param	string	point info array see function CourseManager::get_course_ranking()
1650
+     * @param	bool	add a div wrapper
1651
+     * @todo	use     templates
1652 1652
      **/
1653 1653
     public static function return_rating_system($id, $url, $point_info = array(), $add_div_wrapper = true)
1654 1654
     {
1655
-		$number_of_users_who_voted = isset($point_info['users_who_voted']) ? $point_info['users_who_voted'] : null;
1656
-		$percentage = isset($point_info['point_average']) ? $point_info['point_average'] : 0;
1655
+        $number_of_users_who_voted = isset($point_info['users_who_voted']) ? $point_info['users_who_voted'] : null;
1656
+        $percentage = isset($point_info['point_average']) ? $point_info['point_average'] : 0;
1657 1657
 
1658
-		if (!empty($percentage)) {
1658
+        if (!empty($percentage)) {
1659 1659
             $percentage = $percentage*125/100;
1660 1660
         }
1661
-		$accesses =  isset($point_info['accesses']) ? $point_info['accesses'] : 0;
1661
+        $accesses =  isset($point_info['accesses']) ? $point_info['accesses'] : 0;
1662 1662
 
1663
-		$star_label = sprintf(get_lang('XStarsOutOf5'), $point_info['point_average_star']);
1663
+        $star_label = sprintf(get_lang('XStarsOutOf5'), $point_info['point_average_star']);
1664 1664
 
1665 1665
         $html = '<ul id="'.$id.'" class="star-rating">
1666 1666
 					<li class="current-rating" style="width:'.$percentage.'px;"></li>
@@ -1671,26 +1671,26 @@  discard block
 block discarded – undo
1671 1671
 					<li><a href="javascript:void(0);" data-link="'.$url.'&amp;star=5" title="'.$star_label.'" class="five-stars">5</a></li>
1672 1672
 				</ul>';
1673 1673
 
1674
-		$labels = array();
1674
+        $labels = array();
1675 1675
 
1676
-		$labels[]= $number_of_users_who_voted == 1 ? $number_of_users_who_voted.' '.get_lang('Vote') : $number_of_users_who_voted.' '.get_lang('Votes');
1677
-		$labels[]= $accesses == 1 ? $accesses.' '.get_lang('Visit') : $accesses.' '.get_lang('Visits');
1678
-		if (!empty($number_of_users_who_voted)) {
1679
-			$labels[]= get_lang('Average').' '.$point_info['point_average_star'].'/5';
1680
-		}
1676
+        $labels[]= $number_of_users_who_voted == 1 ? $number_of_users_who_voted.' '.get_lang('Vote') : $number_of_users_who_voted.' '.get_lang('Votes');
1677
+        $labels[]= $accesses == 1 ? $accesses.' '.get_lang('Visit') : $accesses.' '.get_lang('Visits');
1678
+        if (!empty($number_of_users_who_voted)) {
1679
+            $labels[]= get_lang('Average').' '.$point_info['point_average_star'].'/5';
1680
+        }
1681 1681
 
1682
-		$labels[]= $point_info['user_vote']  ? get_lang('YourVote').' ['.$point_info['user_vote'].']' : get_lang('YourVote'). ' [?] ';
1682
+        $labels[]= $point_info['user_vote']  ? get_lang('YourVote').' ['.$point_info['user_vote'].']' : get_lang('YourVote'). ' [?] ';
1683 1683
 
1684
-		if (!$add_div_wrapper && api_is_anonymous()) {
1685
-			$labels[]= Display::tag('span', get_lang('LoginToVote'), array('class' => 'error'));
1686
-		}
1684
+        if (!$add_div_wrapper && api_is_anonymous()) {
1685
+            $labels[]= Display::tag('span', get_lang('LoginToVote'), array('class' => 'error'));
1686
+        }
1687 1687
 
1688 1688
         $html .= Display::div(implode(' | ', $labels) , array('id' =>  'vote_label_'.$id, 'class' => 'vote_label_info'));
1689 1689
         $html .= ' '.Display::span(' ', array('id' =>  'vote_label2_'.$id));
1690 1690
 
1691 1691
         if ($add_div_wrapper) {
1692
-			$html = Display::div($html, array('id' => 'rating_wrapper_'.$id));
1693
-		}
1692
+            $html = Display::div($html, array('id' => 'rating_wrapper_'.$id));
1693
+        }
1694 1694
 
1695 1695
         return $html;
1696 1696
     }
@@ -1728,8 +1728,8 @@  discard block
 block discarded – undo
1728 1728
         return self::page_header($title, $second_title);
1729 1729
     }
1730 1730
 
1731
-     public static function page_subheader_and_translate($title, $second_title = null)
1732
-     {
1731
+        public static function page_subheader_and_translate($title, $second_title = null)
1732
+        {
1733 1733
         $title = get_lang($title);
1734 1734
         return self::page_subheader($title, $second_title);
1735 1735
     }
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
@@ -775,11 +775,11 @@  discard block
 block discarded – undo
775 775
         // ask for the SVG version directly
776 776
         $testServer = api_get_setting('server_type');
777 777
         if ($testServer == 'test' && $return_only_path == false) {
778
-            $svgImage = substr($image, 0, -3) . 'svg';
779
-            if (is_file($code_path . $theme . 'svg/' . $svgImage)) {
780
-                $icon = $w_code_path . $theme . 'svg/' . $svgImage;
781
-            } elseif (is_file($code_path . 'img/icons/svg/' . $svgImage)) {
782
-                $icon = $w_code_path . 'img/icons/svg/' . $svgImage;
778
+            $svgImage = substr($image, 0, -3).'svg';
779
+            if (is_file($code_path.$theme.'svg/'.$svgImage)) {
780
+                $icon = $w_code_path.$theme.'svg/'.$svgImage;
781
+            } elseif (is_file($code_path.'img/icons/svg/'.$svgImage)) {
782
+                $icon = $w_code_path.'img/icons/svg/'.$svgImage;
783 783
             }
784 784
 
785 785
             if (empty($additional_attributes['height'])) {
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
1467 1467
 
1468 1468
         // Show all tool icons where there is something new.
1469 1469
         $return = '&nbsp;';
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
 block discarded – undo
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
 block discarded – undo
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
                 (
@@ -1605,7 +1605,7 @@  discard block
 block discarded – undo
1605 1605
                 }
1606 1606
 
1607 1607
                 if (api_get_setting('show_session_coach') === 'true') {
1608
-                    $session['coach'] = get_lang('GeneralCoach') . ': ' . api_get_person_name(
1608
+                    $session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name(
1609 1609
                         $session_info['firstname'],
1610 1610
                         $session_info['lastname']
1611 1611
                     );
@@ -1656,9 +1656,9 @@  discard block
 block discarded – undo
1656 1656
 		$percentage = isset($point_info['point_average']) ? $point_info['point_average'] : 0;
1657 1657
 
1658 1658
 		if (!empty($percentage)) {
1659
-            $percentage = $percentage*125/100;
1659
+            $percentage = $percentage * 125 / 100;
1660 1660
         }
1661
-		$accesses =  isset($point_info['accesses']) ? $point_info['accesses'] : 0;
1661
+		$accesses = isset($point_info['accesses']) ? $point_info['accesses'] : 0;
1662 1662
 
1663 1663
 		$star_label = sprintf(get_lang('XStarsOutOf5'), $point_info['point_average_star']);
1664 1664
 
@@ -1673,19 +1673,19 @@  discard block
 block discarded – undo
1673 1673
 
1674 1674
 		$labels = array();
1675 1675
 
1676
-		$labels[]= $number_of_users_who_voted == 1 ? $number_of_users_who_voted.' '.get_lang('Vote') : $number_of_users_who_voted.' '.get_lang('Votes');
1677
-		$labels[]= $accesses == 1 ? $accesses.' '.get_lang('Visit') : $accesses.' '.get_lang('Visits');
1676
+		$labels[] = $number_of_users_who_voted == 1 ? $number_of_users_who_voted.' '.get_lang('Vote') : $number_of_users_who_voted.' '.get_lang('Votes');
1677
+		$labels[] = $accesses == 1 ? $accesses.' '.get_lang('Visit') : $accesses.' '.get_lang('Visits');
1678 1678
 		if (!empty($number_of_users_who_voted)) {
1679
-			$labels[]= get_lang('Average').' '.$point_info['point_average_star'].'/5';
1679
+			$labels[] = get_lang('Average').' '.$point_info['point_average_star'].'/5';
1680 1680
 		}
1681 1681
 
1682
-		$labels[]= $point_info['user_vote']  ? get_lang('YourVote').' ['.$point_info['user_vote'].']' : get_lang('YourVote'). ' [?] ';
1682
+		$labels[] = $point_info['user_vote'] ? get_lang('YourVote').' ['.$point_info['user_vote'].']' : get_lang('YourVote').' [?] ';
1683 1683
 
1684 1684
 		if (!$add_div_wrapper && api_is_anonymous()) {
1685
-			$labels[]= Display::tag('span', get_lang('LoginToVote'), array('class' => 'error'));
1685
+			$labels[] = Display::tag('span', get_lang('LoginToVote'), array('class' => 'error'));
1686 1686
 		}
1687 1687
 
1688
-        $html .= Display::div(implode(' | ', $labels) , array('id' =>  'vote_label_'.$id, 'class' => 'vote_label_info'));
1688
+        $html .= Display::div(implode(' | ', $labels), array('id' =>  'vote_label_'.$id, 'class' => 'vote_label_info'));
1689 1689
         $html .= ' '.Display::span(' ', array('id' =>  'vote_label2_'.$id));
1690 1690
 
1691 1691
         if ($add_div_wrapper) {
@@ -1763,8 +1763,8 @@  discard block
 block discarded – undo
1763 1763
         if (!empty($list)) {
1764 1764
             $html = '<dl class="dl-horizontal">';
1765 1765
             foreach ($list as $item) {
1766
-                $html .= '<dt>' . $item['title'] . '</dt>';
1767
-                $html .= '<dd>' . $item['content'] . '</dd>';
1766
+                $html .= '<dt>'.$item['title'].'</dt>';
1767
+                $html .= '<dd>'.$item['content'].'</dd>';
1768 1768
             }
1769 1769
             $html .= '</dl>';
1770 1770
         }
@@ -1806,7 +1806,7 @@  discard block
 block discarded – undo
1806 1806
      * @param string $type
1807 1807
      * @return null|string
1808 1808
      */
1809
-    public static function badge($count, $type ="warning")
1809
+    public static function badge($count, $type = "warning")
1810 1810
     {
1811 1811
         $class = '';
1812 1812
 
@@ -1882,7 +1882,7 @@  discard block
 block discarded – undo
1882 1882
         if (!empty($content)) {
1883 1883
             $html = '<span class="label '.$class.'">';
1884 1884
             $html .= $content;
1885
-            $html .='</span>';
1885
+            $html .= '</span>';
1886 1886
         }
1887 1887
 
1888 1888
         return $html;
@@ -1903,7 +1903,7 @@  discard block
 block discarded – undo
1903 1903
                     $class = 'class ="active"';
1904 1904
                 }
1905 1905
 
1906
-                if (basename($_SERVER['REQUEST_URI']) == basename($value['url']) ) {
1906
+                if (basename($_SERVER['REQUEST_URI']) == basename($value['url'])) {
1907 1907
                     $class = 'class ="active"';
1908 1908
                 }
1909 1909
                 $html .= "<li $class >";
@@ -2154,7 +2154,7 @@  discard block
 block discarded – undo
2154 2154
         }
2155 2155
         $label = $nextValue + $localCounter + 1;
2156 2156
         if ($isMedia) {
2157
-            $label = ($fixedValue + 1) .' '.chr(97 + $localCounter);
2157
+            $label = ($fixedValue + 1).' '.chr(97 + $localCounter);
2158 2158
             $link_to_show = $link.$fixedValue.'#questionanchor'.$itemId;
2159 2159
         }
2160 2160
         $link = Display::url($label.' ', $link_to_show, $linkAttributes);
@@ -2266,7 +2266,7 @@  discard block
 block discarded – undo
2266 2266
      */
2267 2267
     public static function getVCardUserLink($userId)
2268 2268
     {
2269
-        $vCardUrl = api_get_path(WEB_PATH).'main/social/vcard_export.php?userId='.intval($userId);;
2269
+        $vCardUrl = api_get_path(WEB_PATH).'main/social/vcard_export.php?userId='.intval($userId); ;
2270 2270
 
2271 2271
         return $vCardUrl;
2272 2272
     }
@@ -2284,7 +2284,7 @@  discard block
 block discarded – undo
2284 2284
     {
2285 2285
         $title = !empty($title) ? '<div class="panel-heading"><h3 class="panel-title">'.$title.'</h3>'.$extra.'</div>' : '';
2286 2286
         $footer = !empty($footer) ? '<div class="panel-footer ">'.$footer.'</div>' : '';
2287
-        $styles = ['primary','success','info','warning','danger'];
2287
+        $styles = ['primary', 'success', 'info', 'warning', 'danger'];
2288 2288
         $style = !in_array($style, $styles) ? 'default' : $style;
2289 2289
 
2290 2290
         return '
@@ -2330,7 +2330,7 @@  discard block
 block discarded – undo
2330 2330
         $attributes['title'] = isset($attributes['title']) ? $attributes['title'] : $text;
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
main/inc/lib/export.lib.inc.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'];
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'].'>';
Please login to merge, or discard this patch.
main/inc/lib/extra_field.lib.php 3 patches
Doc Comments   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 = '';
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -26,19 +26,19 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'
Please login to merge, or discard this patch.
main/inc/lib/extra_field_value.lib.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
Indentation   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -720,11 +720,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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)
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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());
Please login to merge, or discard this patch.
main/inc/lib/fileManage.lib.php 4 patches
Doc Comments   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,6 +13,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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" : '';
Please login to merge, or discard this patch.
Indentation   +231 added lines, -232 removed lines patch added patch discarded remove patch
@@ -170,37 +170,37 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
main/inc/lib/formvalidator/Element/DateRangePicker.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -145,6 +145,7 @@
 block discarded – undo
145 145
 
146 146
     /**
147 147
     * @param array $dates result of parseDateRange()
148
+    * @param string $format
148 149
     *
149 150
     * @return bool
150 151
     */
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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'])) {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
main/inc/lib/formvalidator/FormValidator.class.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      * @param string $label
214 214
      * @param array $attributes
215 215
      *
216
-     * @return mixed
216
+     * @return HTML_QuickForm_element
217 217
      */
218 218
     public function addDatePicker($name, $label, $attributes = [])
219 219
     {
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
      * @param string $label
226 226
      * @param array $attributes
227 227
      *
228
-     * @return mixed
228
+     * @return HTML_QuickForm_element
229 229
      */
230 230
     public function addDateTimePicker($name, $label, $attributes = [])
231 231
     {
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
      * @param array  $options
689 689
      * @param array  $attributes
690 690
      *
691
-     * @return HTML_QuickForm_radio
691
+     * @return HTML_QuickForm_group
692 692
      */
693 693
     public function addRadio($name, $label, $options = array(), $attributes = array())
694 694
     {
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
      * @param string $name
818 818
      * @param string $label
819 819
      *
820
-     * @return mixed
820
+     * @return HTML_QuickForm_element
821 821
      */
822 822
     public function addButtonAdvancedSettings($name, $label = '')
823 823
     {
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
     /**
915 915
      * This function has been created for avoiding changes directly within QuickForm class.
916 916
      * When we use it, the element is threated as 'required' to be dealt during validation.
917
-     * @param array $element					The array of elements
917
+     * @param array $elements					The array of elements
918 918
      * @param string $message					The message displayed
919 919
      */
920 920
     public function add_multiple_required_rule($elements, $message)
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         $renderer->setHeaderTemplate('<legend>{header}</legend>');
102 102
 
103 103
         //Set required field template
104
-        $this->setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>');
104
+        $this->setRequiredNote('<span class="form_required">*</span> <small>'.get_lang('ThisFieldIsRequired').'</small>');
105 105
         $noteTemplate = <<<EOT
106 106
 	<div class="form-group">
107 107
 		<div class="col-sm-offset-2 col-sm-10">{requiredNote}</div>
@@ -853,9 +853,9 @@  discard block
 block discarded – undo
853 853
             $label = get_lang('PleaseStandBy');
854 854
         }
855 855
         $this->with_progress_bar = true;
856
-        $this->updateAttributes("onsubmit=\"javascript: myUpload.start('dynamic_div','".Display::returnIconPath('progress_bar.gif')."','" . $label . "','" . $this->getAttribute('id') . "')\"");
857
-        $this->addElement('html', '<script language="javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/upload.js" type="text/javascript"></script>');
858
-        $this->addElement('html', '<script type="text/javascript">var myUpload = new upload(' . (abs(intval($delay)) * 1000) . ');</script>');
856
+        $this->updateAttributes("onsubmit=\"javascript: myUpload.start('dynamic_div','".Display::returnIconPath('progress_bar.gif')."','".$label."','".$this->getAttribute('id')."')\"");
857
+        $this->addElement('html', '<script language="javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/upload.js" type="text/javascript"></script>');
858
+        $this->addElement('html', '<script type="text/javascript">var myUpload = new upload('.(abs(intval($delay)) * 1000).');</script>');
859 859
     }
860 860
 
861 861
     /**
@@ -872,11 +872,11 @@  discard block
 block discarded – undo
872 872
             return;
873 873
         }
874 874
 
875
-        $xajax_upload = new xajax(api_get_path(WEB_LIBRARY_PATH) . 'upload.xajax.php');
875
+        $xajax_upload = new xajax(api_get_path(WEB_LIBRARY_PATH).'upload.xajax.php');
876 876
 
877 877
         $xajax_upload->registerFunction('updateProgress');
878 878
         // IMPORTANT : must be the first element of the form
879
-        $el = $this->insertElementBefore(FormValidator::createElement('html', '<input type="hidden" name="UPLOAD_IDENTIFIER" value="' . $upload_id . '" />'), $element_after);
879
+        $el = $this->insertElementBefore(FormValidator::createElement('html', '<input type="hidden" name="UPLOAD_IDENTIFIER" value="'.$upload_id.'" />'), $element_after);
880 880
 
881 881
         $this->addElement('html', '<br />');
882 882
 
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
         $this->addElement(
885 885
             'html',
886 886
             '<div id="dynamic_div_container" style="display:none">
887
-                <div id="dynamic_div_label">' . get_lang('UploadFile') . '</div>
887
+                <div id="dynamic_div_label">' . get_lang('UploadFile').'</div>
888 888
                 <div id="dynamic_div_frame" style="width:214px; height:12px; border:1px solid grey; background-image:url(' . Display::returnIconPath('real_upload_frame.gif').');">
889 889
                     <div id="dynamic_div_filled" style="width:0%;height:100%;background-image:url(' . Display::returnIconPath('real_upload_step.gif').');background-repeat:repeat-x;background-position:center;"></div>
890 890
                 </div>
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
             $this->addElement('html', '
896 896
 			<div id="dynamic_div_waiter_container" style="display:none">
897 897
 				<div id="dynamic_div_waiter_label">
898
-					' . get_lang('SlideshowConversion') . '
898
+					' . get_lang('SlideshowConversion').'
899 899
 				</div>
900 900
 				<div id="dynamic_div_waiter_frame">
901 901
 					'.Display::return_icon('real_upload_frame.gif').'
@@ -905,18 +905,18 @@  discard block
 block discarded – undo
905 905
         }
906 906
 
907 907
         // Get the xajax code
908
-        $this->addElement('html', $xajax_upload->getJavascript(api_get_path(WEB_LIBRARY_PATH) . 'xajax'));
908
+        $this->addElement('html', $xajax_upload->getJavascript(api_get_path(WEB_LIBRARY_PATH).'xajax'));
909 909
 
910 910
         // Get the upload code
911
-        $this->addElement('html', '<script language="javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/upload.js" type="text/javascript"></script>');
912
-        $this->addElement('html', '<script type="text/javascript">var myUpload = new upload(' . (abs(intval($delay)) * 1000) . ');</script>');
911
+        $this->addElement('html', '<script language="javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/upload.js" type="text/javascript"></script>');
912
+        $this->addElement('html', '<script type="text/javascript">var myUpload = new upload('.(abs(intval($delay)) * 1000).');</script>');
913 913
 
914 914
         if (!$wait_after_upload) {
915 915
             $wait_after_upload = 0;
916 916
         }
917 917
 
918 918
         // Add the upload event
919
-        $this->updateAttributes("onsubmit=\"javascript: myUpload.startRealUpload('dynamic_div','" . $upload_id . "','" . $this->getAttribute('id') . "'," . $wait_after_upload . ")\"");
919
+        $this->updateAttributes("onsubmit=\"javascript: myUpload.startRealUpload('dynamic_div','".$upload_id."','".$this->getAttribute('id')."',".$wait_after_upload.")\"");
920 920
     }
921 921
 
922 922
     /**
@@ -1388,7 +1388,7 @@  discard block
 block discarded – undo
1388 1388
                         .prepend(file.preview);
1389 1389
                     node
1390 1390
                         .append('<br>')
1391
-                        .append($('<span class=\"text-success\"/>').text('" . addslashes(get_lang('UplUploadSucceeded')). "'));
1391
+                        .append($('<span class=\"text-success\"/>').text('" . addslashes(get_lang('UplUploadSucceeded'))."'));
1392 1392
                 }
1393 1393
                 if (file.error) {
1394 1394
                     node
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
                 });
1424 1424
             }).on('fileuploadfail', function (e, data) {
1425 1425
                 $.each(data.files, function (index) {
1426
-                    var failedMessage = '" . addslashes(get_lang('UplUploadFailed')) . "';
1426
+                    var failedMessage = '" . addslashes(get_lang('UplUploadFailed'))."';
1427 1427
                     var error = $('<span class=\"text-danger\"/>').text(failedMessage);
1428 1428
                     $(data.context.children()[index])
1429 1429
                         .append('<br>')
Please login to merge, or discard this patch.
main/inc/lib/formvalidator/Rule/HTML.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,8 +25,7 @@
 block discarded – undo
25 25
      * Get allowed tags
26 26
      * @param int $mode NO_HTML, STUDENT_HTML, TEACHER_HTML,
27 27
      * STUDENT_HTML_FULLPAGE or TEACHER_HTML_FULLPAGE
28
-     * @param boolean $fullpage If true, the allowed tags for full-page editing
29
-     * are returned.
28
+     * @return string
30 29
      */
31 30
     static function get_allowed_tags($mode)
32 31
     {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
      */
17 17
     function validate($html, $mode = NO_HTML)
18 18
     {
19
-        $allowed_tags = self::get_allowed_tags ($mode, $fullpage);
19
+        $allowed_tags = self::get_allowed_tags($mode, $fullpage);
20 20
         $cleaned_html = kses($html, $allowed_tags);
21 21
         return $html == $cleaned_html;
22 22
     }
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         // Include the allowed tags.
34 34
         //include(dirname(__FILE__).'/allowed_tags.inc.php');
35 35
         global $allowed_tags_student, $allowed_tags_student_full_page, $allowed_tags_teacher, $allowed_tags_teacher_full_page;
36
-        switch($mode)
36
+        switch ($mode)
37 37
         {
38 38
             case NO_HTML:
39 39
                 return array();
Please login to merge, or discard this patch.
main/inc/lib/formvalidator/Rule/MaxFileSize.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,6 @@
 block discarded – undo
9 9
 {
10 10
 	/**
11 11
 	 * @param $value array     Uploaded file info (from $_FILES)
12
-	 * @param null $options
13 12
 	 * @return bool
14 13
 	 */
15 14
 	public function validate($elementValue, $maxSize)
Please login to merge, or discard this patch.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,22 +7,22 @@
 block discarded – undo
7 7
  */
8 8
 class HTML_QuickForm_Rule_MaxFileSize extends HTML_QuickForm_Rule
9 9
 {
10
-	/**
11
-	 * @param $value array     Uploaded file info (from $_FILES)
12
-	 * @param null $options
13
-	 * @return bool
14
-	 */
15
-	public function validate($elementValue, $maxSize)
16
-	{
17
-		if (!empty($elementValue['error']) &&
18
-			(UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error'])
19
-		) {
20
-			return false;
21
-		}
22
-		if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) {
23
-			return true;
24
-		}
10
+    /**
11
+     * @param $value array     Uploaded file info (from $_FILES)
12
+     * @param null $options
13
+     * @return bool
14
+     */
15
+    public function validate($elementValue, $maxSize)
16
+    {
17
+        if (!empty($elementValue['error']) &&
18
+            (UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error'])
19
+        ) {
20
+            return false;
21
+        }
22
+        if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) {
23
+            return true;
24
+        }
25 25
 
26
-		return ($maxSize >= @filesize($elementValue['tmp_name']));
27
-	}
26
+        return ($maxSize >= @filesize($elementValue['tmp_name']));
27
+    }
28 28
 }
Please login to merge, or discard this patch.