Completed
Pull Request — 1.11.x (#1293)
by José
387:57 queued 349:55
created
main/inc/lib/fileUpload.lib.php 1 patch
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
     $name_no_ext = substr($name, 0, strlen($name) - strlen(strstr($name, $ext)));
64 64
     $n = 0;
65 65
     $unique = '';
66
-    while (file_exists($path . $name_no_ext . $unique . $ext)) {
67
-        $unique = '_' . ++$n;
66
+    while (file_exists($path.$name_no_ext.$unique.$ext)) {
67
+        $unique = '_'.++$n;
68 68
     }
69
-    return $name_no_ext . $unique . $ext;
69
+    return $name_no_ext.$unique.$ext;
70 70
 }
71 71
 
72 72
 /**
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
                 // Not used at the moment, but could be handy if we want to limit the size of an upload (e.g. image upload in html editor).
106 106
                 $max_file_size = intval($_POST['MAX_FILE_SIZE']);
107 107
                 if ($show_output) {
108
-                    Display::display_error_message(get_lang('UplExceedMaxPostSize'). format_file_size($max_file_size));
108
+                    Display::display_error_message(get_lang('UplExceedMaxPostSize').format_file_size($max_file_size));
109 109
                 }
110 110
 
111 111
                 return false;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
             case 4:
120 120
                 // No file was uploaded.
121 121
                 if ($show_output) {
122
-                    Display::display_error_message(get_lang('UplNoFileUploaded').' '. get_lang('UplSelectFileFirst'));
122
+                    Display::display_error_message(get_lang('UplNoFileUploaded').' '.get_lang('UplSelectFileFirst'));
123 123
                 }
124 124
 
125 125
                 return false;
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
                             // Display success message with extra info to user
460 460
                             if ($output) {
461 461
                                 Display::display_confirmation_message(
462
-                                    get_lang('UplUploadSucceeded') . '<br /> ' . $documentTitle . ' ' . get_lang('UplFileOverwritten'),
462
+                                    get_lang('UplUploadSucceeded').'<br /> '.$documentTitle.' '.get_lang('UplFileOverwritten'),
463 463
                                     false
464 464
                                 );
465 465
                             }
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
                         // Display success message to user
584 584
                         if ($output) {
585 585
                             Display::display_confirmation_message(
586
-                                get_lang('UplUploadSucceeded') . '<br />' . get_lang('UplFileSavedAs') .' '.$documentTitle,
586
+                                get_lang('UplUploadSucceeded').'<br />'.get_lang('UplFileSavedAs').' '.$documentTitle,
587 587
                                 false
588 588
                             );
589 589
                         }
@@ -730,12 +730,12 @@  discard block
 block discarded – undo
730 730
 function dir_total_space($dir_path)
731 731
 {
732 732
     $save_dir = getcwd();
733
-    chdir($dir_path) ;
733
+    chdir($dir_path);
734 734
     $handle = opendir($dir_path);
735 735
     $sumSize = 0;
736 736
     $dirList = array();
737 737
     while ($element = readdir($handle)) {
738
-        if ( $element == '.' || $element == '..') {
738
+        if ($element == '.' || $element == '..') {
739 739
             continue; // Skip the current and parent directories
740 740
         }
741 741
         if (is_file($element)) {
@@ -746,11 +746,11 @@  discard block
 block discarded – undo
746 746
         }
747 747
     }
748 748
 
749
-    closedir($handle) ;
749
+    closedir($handle);
750 750
 
751 751
     if (sizeof($dirList) > 0) {
752 752
         foreach ($dirList as $j) {
753
-            $sizeDir = dir_total_space($j);	// Recursivity
753
+            $sizeDir = dir_total_space($j); // Recursivity
754 754
             $sumSize += $sizeDir;
755 755
         }
756 756
     }
@@ -784,63 +784,63 @@  discard block
 block discarded – undo
784 784
 
785 785
         static $mime_type = array();
786 786
 
787
-        $mime_type[] = 'application/msword';             $extension[] = '.doc';
788
-        $mime_type[] = 'application/rtf';                $extension[] = '.rtf';
789
-        $mime_type[] = 'application/vnd.ms-powerpoint';  $extension[] = '.ppt';
790
-        $mime_type[] = 'application/vnd.ms-excel';       $extension[] = '.xls';
791
-        $mime_type[] = 'application/pdf';                $extension[] = '.pdf';
792
-        $mime_type[] = 'application/postscript';         $extension[] = '.ps';
793
-        $mime_type[] = 'application/mac-binhex40';       $extension[] = '.hqx';
794
-        $mime_type[] = 'application/x-gzip';             $extension[] = 'tar.gz';
795
-        $mime_type[] = 'application/x-shockwave-flash';  $extension[] = '.swf';
796
-        $mime_type[] = 'application/x-stuffit';          $extension[] = '.sit';
797
-        $mime_type[] = 'application/x-tar';              $extension[] = '.tar';
798
-        $mime_type[] = 'application/zip';                $extension[] = '.zip';
799
-        $mime_type[] = 'application/x-tar';              $extension[] = '.tar';
800
-        $mime_type[] = 'text/html';                      $extension[] = '.html';
801
-        $mime_type[] = 'text/plain';                     $extension[] = '.txt';
802
-        $mime_type[] = 'text/rtf';                       $extension[] = '.rtf';
803
-        $mime_type[] = 'img/gif';                        $extension[] = '.gif';
804
-        $mime_type[] = 'img/jpeg';                       $extension[] = '.jpg';
805
-        $mime_type[] = 'img/png';                        $extension[] = '.png';
806
-        $mime_type[] = 'audio/midi';                     $extension[] = '.mid';
807
-        $mime_type[] = 'audio/mpeg';                     $extension[] = '.mp3';
808
-        $mime_type[] = 'audio/x-aiff';                   $extension[] = '.aif';
809
-        $mime_type[] = 'audio/x-pn-realaudio';           $extension[] = '.rm';
810
-        $mime_type[] = 'audio/x-pn-realaudio-plugin';    $extension[] = '.rpm';
811
-        $mime_type[] = 'audio/x-wav';                    $extension[] = '.wav';
812
-        $mime_type[] = 'video/mpeg';                     $extension[] = '.mpg';
813
-        $mime_type[] = 'video/mpeg4-generic';            $extension[] = '.mp4';
814
-        $mime_type[] = 'video/quicktime';                $extension[] = '.mov';
815
-        $mime_type[] = 'video/x-msvideo';                $extension[] = '.avi';
816
-
817
-        $mime_type[] = 'video/x-ms-wmv';                 $extension[] = '.wmv';
818
-        $mime_type[] = 'video/x-flv';                    $extension[] = '.flv';
819
-        $mime_type[] = 'image/svg+xml';                  $extension[] = '.svg';
820
-        $mime_type[] = 'image/svg+xml';                  $extension[] = '.svgz';
821
-        $mime_type[] = 'video/ogg';                  	 $extension[] = '.ogv';
822
-        $mime_type[] = 'audio/ogg';                  	 $extension[] = '.oga';
823
-        $mime_type[] = 'application/ogg';                $extension[] = '.ogg';
824
-        $mime_type[] = 'application/ogg';                $extension[] = '.ogx';
825
-        $mime_type[] = 'application/x-freemind';         $extension[] = '.mm';
826
-
827
-        $mime_type[] = 'application/vnd.ms-word.document.macroEnabled.12';							$extension[] = '.docm';
828
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';	$extension[] = '.docx';
829
-        $mime_type[] = 'application/vnd.ms-word.template.macroEnabled.12';							$extension[] = '.dotm';
830
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template';	$extension[] = '.dotx';
831
-        $mime_type[] = 'application/vnd.ms-powerpoint.template.macroEnabled.12';					$extension[] = '.potm';
832
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.template';		$extension[] = '.potx';
833
-        $mime_type[] = 'application/vnd.ms-powerpoint.addin.macroEnabled.12';						$extension[] = '.ppam';
834
-        $mime_type[] = 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12';					$extension[] = '.ppsm';
835
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow';	$extension[] = '.ppsx';
836
-        $mime_type[] = 'application/vnd.ms-powerpoint.presentation.macroEnabled.12';				$extension[] = '.pptm';
837
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';	$extension[] = '.pptx';
838
-        $mime_type[] = 'application/vnd.ms-excel.addin.macroEnabled.12';							$extension[] = '.xlam';
839
-        $mime_type[] = 'application/vnd.ms-excel.sheet.binary.macroEnabled.12';						$extension[] = '.xlsb';
840
-        $mime_type[] = 'application/vnd.ms-excel.sheet.macroEnabled.12';							$extension[] = '.xlsm';
841
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';			$extension[] = '.xlsx';
842
-        $mime_type[] = 'application/vnd.ms-excel.template.macroEnabled.12';							$extension[] = '.xltm';
843
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template';		$extension[] = '.xltx';
787
+        $mime_type[] = 'application/msword'; $extension[] = '.doc';
788
+        $mime_type[] = 'application/rtf'; $extension[] = '.rtf';
789
+        $mime_type[] = 'application/vnd.ms-powerpoint'; $extension[] = '.ppt';
790
+        $mime_type[] = 'application/vnd.ms-excel'; $extension[] = '.xls';
791
+        $mime_type[] = 'application/pdf'; $extension[] = '.pdf';
792
+        $mime_type[] = 'application/postscript'; $extension[] = '.ps';
793
+        $mime_type[] = 'application/mac-binhex40'; $extension[] = '.hqx';
794
+        $mime_type[] = 'application/x-gzip'; $extension[] = 'tar.gz';
795
+        $mime_type[] = 'application/x-shockwave-flash'; $extension[] = '.swf';
796
+        $mime_type[] = 'application/x-stuffit'; $extension[] = '.sit';
797
+        $mime_type[] = 'application/x-tar'; $extension[] = '.tar';
798
+        $mime_type[] = 'application/zip'; $extension[] = '.zip';
799
+        $mime_type[] = 'application/x-tar'; $extension[] = '.tar';
800
+        $mime_type[] = 'text/html'; $extension[] = '.html';
801
+        $mime_type[] = 'text/plain'; $extension[] = '.txt';
802
+        $mime_type[] = 'text/rtf'; $extension[] = '.rtf';
803
+        $mime_type[] = 'img/gif'; $extension[] = '.gif';
804
+        $mime_type[] = 'img/jpeg'; $extension[] = '.jpg';
805
+        $mime_type[] = 'img/png'; $extension[] = '.png';
806
+        $mime_type[] = 'audio/midi'; $extension[] = '.mid';
807
+        $mime_type[] = 'audio/mpeg'; $extension[] = '.mp3';
808
+        $mime_type[] = 'audio/x-aiff'; $extension[] = '.aif';
809
+        $mime_type[] = 'audio/x-pn-realaudio'; $extension[] = '.rm';
810
+        $mime_type[] = 'audio/x-pn-realaudio-plugin'; $extension[] = '.rpm';
811
+        $mime_type[] = 'audio/x-wav'; $extension[] = '.wav';
812
+        $mime_type[] = 'video/mpeg'; $extension[] = '.mpg';
813
+        $mime_type[] = 'video/mpeg4-generic'; $extension[] = '.mp4';
814
+        $mime_type[] = 'video/quicktime'; $extension[] = '.mov';
815
+        $mime_type[] = 'video/x-msvideo'; $extension[] = '.avi';
816
+
817
+        $mime_type[] = 'video/x-ms-wmv'; $extension[] = '.wmv';
818
+        $mime_type[] = 'video/x-flv'; $extension[] = '.flv';
819
+        $mime_type[] = 'image/svg+xml'; $extension[] = '.svg';
820
+        $mime_type[] = 'image/svg+xml'; $extension[] = '.svgz';
821
+        $mime_type[] = 'video/ogg'; $extension[] = '.ogv';
822
+        $mime_type[] = 'audio/ogg'; $extension[] = '.oga';
823
+        $mime_type[] = 'application/ogg'; $extension[] = '.ogg';
824
+        $mime_type[] = 'application/ogg'; $extension[] = '.ogx';
825
+        $mime_type[] = 'application/x-freemind'; $extension[] = '.mm';
826
+
827
+        $mime_type[] = 'application/vnd.ms-word.document.macroEnabled.12'; $extension[] = '.docm';
828
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; $extension[] = '.docx';
829
+        $mime_type[] = 'application/vnd.ms-word.template.macroEnabled.12'; $extension[] = '.dotm';
830
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'; $extension[] = '.dotx';
831
+        $mime_type[] = 'application/vnd.ms-powerpoint.template.macroEnabled.12'; $extension[] = '.potm';
832
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.template'; $extension[] = '.potx';
833
+        $mime_type[] = 'application/vnd.ms-powerpoint.addin.macroEnabled.12'; $extension[] = '.ppam';
834
+        $mime_type[] = 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12'; $extension[] = '.ppsm';
835
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'; $extension[] = '.ppsx';
836
+        $mime_type[] = 'application/vnd.ms-powerpoint.presentation.macroEnabled.12'; $extension[] = '.pptm';
837
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; $extension[] = '.pptx';
838
+        $mime_type[] = 'application/vnd.ms-excel.addin.macroEnabled.12'; $extension[] = '.xlam';
839
+        $mime_type[] = 'application/vnd.ms-excel.sheet.binary.macroEnabled.12'; $extension[] = '.xlsb';
840
+        $mime_type[] = 'application/vnd.ms-excel.sheet.macroEnabled.12'; $extension[] = '.xlsm';
841
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $extension[] = '.xlsx';
842
+        $mime_type[] = 'application/vnd.ms-excel.template.macroEnabled.12'; $extension[] = '.xltm';
843
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'; $extension[] = '.xltx';
844 844
 
845 845
         // Test on PC (files with no extension get application/octet-stream)
846 846
         //$mime_type[] = 'application/octet-stream';      $extension[] = '.ext';
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
 
850 850
         foreach ($mime_type as $key => & $type) {
851 851
             if ($type == $file_type) {
852
-                $file_name .=  $extension[$key];
852
+                $file_name .= $extension[$key];
853 853
                 break;
854 854
             }
855 855
         }
@@ -957,12 +957,12 @@  discard block
 block discarded – undo
957 957
         }
958 958
 
959 959
         // It happens on Linux that $upload_path sometimes doesn't start with '/'
960
-        if ($upload_path[0] != '/' && substr($base_work_dir,-1,1) != '/') {
960
+        if ($upload_path[0] != '/' && substr($base_work_dir, -1, 1) != '/') {
961 961
             $upload_path = '/'.$upload_path;
962 962
         }
963 963
 
964 964
         if ($upload_path[strlen($upload_path) - 1] == '/') {
965
-            $upload_path=substr($upload_path, 0, -1);
965
+            $upload_path = substr($upload_path, 0, -1);
966 966
         }
967 967
 
968 968
         /*	Uncompressing phase */
@@ -974,15 +974,15 @@  discard block
 block discarded – undo
974 974
             - add it to the database
975 975
             - parse & change relative html links
976 976
         */
977
-        if (PHP_OS == 'Linux' && ! get_cfg_var('safe_mode') && false) { // *** UGent, changed by OC ***
977
+        if (PHP_OS == 'Linux' && !get_cfg_var('safe_mode') && false) { // *** UGent, changed by OC ***
978 978
             // Shell Method - if this is possible, it gains some speed
979
-            exec("unzip -d \"".$base_work_dir.$upload_path."/\"".$uploaded_file['name']." " .$uploaded_file['tmp_name']);
979
+            exec("unzip -d \"".$base_work_dir.$upload_path."/\"".$uploaded_file['name']." ".$uploaded_file['tmp_name']);
980 980
         } else {
981 981
             // PHP method - slower...
982 982
             $save_dir = getcwd();
983 983
             chdir($base_work_dir.$upload_path);
984 984
             $unzippingState = $zip_file->extract();
985
-            for ($j=0; $j < count($unzippingState); $j++) {
985
+            for ($j = 0; $j < count($unzippingState); $j++) {
986 986
                 $state = $unzippingState[$j];
987 987
 
988 988
                 // Fix relative links in html files
@@ -996,8 +996,8 @@  discard block
 block discarded – undo
996 996
                         if (is_dir($base_work_dir.$upload_path.'/'.$file)) $filetype = 'folder';
997 997
 
998 998
                         $safe_file = api_replace_dangerous_char($file, 'strict');
999
-                        @rename($base_work_dir.$upload_path.'/'.$file,$base_work_dir.$upload_path.'/'.$safe_file);
1000
-                        set_default_settings($upload_path, $safe_file,$filetype);
999
+                        @rename($base_work_dir.$upload_path.'/'.$file, $base_work_dir.$upload_path.'/'.$safe_file);
1000
+                        set_default_settings($upload_path, $safe_file, $filetype);
1001 1001
                     }
1002 1002
                 }
1003 1003
 
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
     $zip = new PclZip($uploaded_file['tmp_name']);
1048 1048
 
1049 1049
     // Check the zip content (real size and file extension)
1050
-    $zip_content_array = (array)$zip->listContent();
1050
+    $zip_content_array = (array) $zip->listContent();
1051 1051
 
1052 1052
     $realSize = 0;
1053 1053
     foreach ($zip_content_array as & $this_content) {
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 function filter_extension(&$filename)
1144 1144
 {
1145 1145
     if (substr($filename, -1) == '/') {
1146
-        return 1;  // Authorize directories
1146
+        return 1; // Authorize directories
1147 1147
     }
1148 1148
     $blacklist = api_get_setting('upload_extensions_list_type');
1149 1149
     if ($blacklist != 'whitelist') { // if = blacklist
@@ -1369,9 +1369,9 @@  discard block
 block discarded – undo
1369 1369
     $upload_path = str_replace('//', '/', $upload_path);
1370 1370
 
1371 1371
     if ($upload_path == '/') {
1372
-        $upload_path='';
1372
+        $upload_path = '';
1373 1373
     } elseif (!empty($upload_path) && $upload_path[0] != '/') {
1374
-        $upload_path="/$upload_path";
1374
+        $upload_path = "/$upload_path";
1375 1375
     }
1376 1376
 
1377 1377
     $endchar = substr($filename, strlen($filename) - 1, 1);
@@ -1409,7 +1409,7 @@  discard block
 block discarded – undo
1409 1409
     $img_path_list = array();
1410 1410
 
1411 1411
     if (!$fp = fopen($html_file, 'r')) {
1412
-        return ;
1412
+        return;
1413 1413
     }
1414 1414
 
1415 1415
     // Aearch and store occurences of the <img> tag in an array
@@ -1429,7 +1429,7 @@  discard block
 block discarded – undo
1429 1429
         $img_tag_list = $matches[0];
1430 1430
     }
1431 1431
 
1432
-    fclose ($fp);
1432
+    fclose($fp);
1433 1433
     unset($buffer);
1434 1434
 
1435 1435
     // Search the image file path from all the <IMG> tag detected
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
 
1530 1530
     if (!is_dir($base_work_dir.$systemFolderName)) {
1531 1531
         $result = mkdir(
1532
-            $base_work_dir . $systemFolderName,
1532
+            $base_work_dir.$systemFolderName,
1533 1533
             api_get_permissions_for_new_directories(),
1534 1534
             true
1535 1535
         );
@@ -1542,7 +1542,7 @@  discard block
 block discarded – undo
1542 1542
                     WHERE
1543 1543
                         c_id = $course_id AND
1544 1544
                         (
1545
-                            path = '" . $systemFolderName . "'
1545
+                            path = '".$systemFolderName."'
1546 1546
                         )
1547 1547
             ";
1548 1548
 
@@ -1695,7 +1695,7 @@  discard block
 block discarded – undo
1695 1695
 
1696 1696
     // Fix the image tags
1697 1697
 
1698
-    for ($i = 0, $fileNb = count($original_img_path); $i < $fileNb ; $i++) {
1698
+    for ($i = 0, $fileNb = count($original_img_path); $i < $fileNb; $i++) {
1699 1699
         $replace_what = $original_img_path[$i];
1700 1700
         // We only need the directory and the filename /path/to/file_html_files/missing_file.gif -> file_html_files/missing_file.gif
1701 1701
         $exploded_file_path = explode('/', $new_img_path[$i]);
@@ -1736,7 +1736,7 @@  discard block
 block discarded – undo
1736 1736
         .'</body>'
1737 1737
         .'</html>';
1738 1738
     if (file_exists($file_path)) {
1739
-        if (!($fp = fopen ($file_path, 'w'))) {
1739
+        if (!($fp = fopen($file_path, 'w'))) {
1740 1740
             return false;
1741 1741
         }
1742 1742
         return fwrite($fp, $file_content);
@@ -1756,7 +1756,7 @@  discard block
 block discarded – undo
1756 1756
     // Open the file
1757 1757
     if (file_exists($full_file_name)) {
1758 1758
         $fp = fopen($full_file_name, 'r');
1759
-        $buffer = fread ($fp, filesize ($full_file_name));
1759
+        $buffer = fread($fp, filesize($full_file_name));
1760 1760
 
1761 1761
         // Parse the contents
1762 1762
         $new_html_content = api_replace_links_in_string($upload_path, $buffer);
@@ -1899,7 +1899,7 @@  discard block
 block discarded – undo
1899 1899
 
1900 1900
         foreach ($tag_list as & $this_tag) {
1901 1901
             //Display::display_normal_message(htmlentities($this_tag)); //debug
1902
-            if ( preg_match("~".$param_name."[\s]*=[\s]*[\"]{1}([^\"]+)[\"]{1}~i", $this_tag, $matches)) {
1902
+            if (preg_match("~".$param_name."[\s]*=[\s]*[\"]{1}([^\"]+)[\"]{1}~i", $this_tag, $matches)) {
1903 1903
                 $file_path_list[] = $matches[1]; // older
1904 1904
                 $href_list[] = $matches[0]; // to also add target="_self"
1905 1905
             }
@@ -1920,9 +1920,9 @@  discard block
 block discarded – undo
1920 1920
 
1921 1921
                 // Fix the link to use download.php or showinframes.php
1922 1922
                 if (preg_match("/<a([\s]*[\"\/:'=a-z0-9]*){5}href[^<]*>/i", $tag_list[$count])) {
1923
-                    $replace_by[$count] = " $param_name =\"showinframes.php?file=" . $upload_path.$file_path_list[$count]."\" target=\"_self\" ";
1923
+                    $replace_by[$count] = " $param_name =\"showinframes.php?file=".$upload_path.$file_path_list[$count]."\" target=\"_self\" ";
1924 1924
                 } else {
1925
-                    $replace_by[$count] = " $param_name =\"download.php?doc_url=" . $upload_path.$file_path_list[$count]."\" ";
1925
+                    $replace_by[$count] = " $param_name =\"download.php?doc_url=".$upload_path.$file_path_list[$count]."\" ";
1926 1926
                 }
1927 1927
             } else {
1928 1928
                 // "mailto" or url already fixed, leave as is
@@ -1931,7 +1931,7 @@  discard block
 block discarded – undo
1931 1931
             }
1932 1932
         } elseif ($is_absolute_hyperlink) {
1933 1933
             //$message .= "Absolute hyperlink, don't change, add target=_self: ";
1934
-            $replace_by[$count] = " $param_name=\"" . $file_path_list[$count] . "\" target =\"_self\"";
1934
+            $replace_by[$count] = " $param_name=\"".$file_path_list[$count]."\" target =\"_self\"";
1935 1935
         } else {
1936 1936
             // Don't change anything
1937 1937
             //$message .= "Local anchor, don't change: ";
@@ -1976,7 +1976,7 @@  discard block
 block discarded – undo
1976 1976
 {
1977 1977
     // Do we need a / or not?
1978 1978
     $added_slash = ($upload_path == '/') ? '' : '/';
1979
-    $folder_id      = DocumentManager::get_document_id(api_get_course_info(), $upload_path);
1979
+    $folder_id = DocumentManager::get_document_id(api_get_course_info(), $upload_path);
1980 1980
     // Build the form
1981 1981
     $form = "<p><strong>".get_lang('MissingImagesDetected')."</strong></p>"
1982 1982
         ."<form method=\"post\" action=\"".api_get_self()."\" enctype=\"multipart/form-data\">"
Please login to merge, or discard this patch.
main/inc/lib/formvalidator/Element/SelectTheme.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@
 block discarded – undo
9 9
 	/**
10 10
 	 * Class constructor
11 11
 	 */
12
-	public function __construct($elementName=null, $elementLabel=null, $options=null, $attributes=null)
12
+	public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null)
13 13
 	{
14 14
 		parent::__construct($elementName, $elementLabel, $options, $attributes);
15 15
 		// Get all languages
16 16
 		$themes = api_get_themes();
17 17
 		$this->_options = array();
18 18
 		$this->_values = array();
19
-		$this->addOption('--',''); // no theme select
20
-		for ($i=0; $i< count($themes[0]); $i++) {
21
-			$this->addOption($themes[1][$i],$themes[0][$i]);
19
+		$this->addOption('--', ''); // no theme select
20
+		for ($i = 0; $i < count($themes[0]); $i++) {
21
+			$this->addOption($themes[1][$i], $themes[0][$i]);
22 22
 		}
23 23
 	}
24 24
 }
Please login to merge, or discard this patch.
main/gradebook/lib/fe/scoredisplayform.class.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -14,28 +14,28 @@  discard block
 block discarded – undo
14 14
 	 * @param $form_name
15 15
 	 * @param null $action
16 16
 	 */
17
-	public function __construct($form_name, $action= null)
17
+	public function __construct($form_name, $action = null)
18 18
 	{
19 19
 		parent :: __construct($form_name, 'post', $action);
20 20
 		$displayscore = ScoreDisplay :: instance();
21 21
 		$customdisplays = $displayscore->get_custom_score_display_settings();
22 22
 
23
-		$nr_items = (count($customdisplays)!='0') ? count($customdisplays) : '1';
24
-		$this->setDefaults(array (
23
+		$nr_items = (count($customdisplays) != '0') ? count($customdisplays) : '1';
24
+		$this->setDefaults(array(
25 25
             'scorecolpercent' => $displayscore->get_color_split_value()
26 26
 		));
27 27
 
28 28
 		$this->addElement('hidden', 'maxvalue', '100');
29 29
 		$this->addElement('hidden', 'minvalue', '0');
30
-		$counter= 1;
30
+		$counter = 1;
31 31
 
32 32
 		//setting the default values
33 33
 
34
-		if(is_array($customdisplays)) {
34
+		if (is_array($customdisplays)) {
35 35
 			foreach ($customdisplays as $customdisplay) {
36
-				$this->setDefaults(array (
37
-					'endscore[' . $counter . ']' => $customdisplay['score'],
38
-					'displaytext[' . $counter . ']' => $customdisplay['display']
36
+				$this->setDefaults(array(
37
+					'endscore['.$counter.']' => $customdisplay['score'],
38
+					'displaytext['.$counter.']' => $customdisplay['display']
39 39
 				));
40 40
 				$counter++;
41 41
 			}
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		$this->addElement('header', get_lang('ScoreEdit'));
47 47
 
48 48
         if ($displayscore->is_coloring_enabled()) {
49
-            $this->addElement('html', '<b>' . get_lang('ScoreColor') . '</b>');
49
+            $this->addElement('html', '<b>'.get_lang('ScoreColor').'</b>');
50 50
             $this->addElement('text', 'scorecolpercent', array(get_lang('Below'), get_lang('WillColorRed'), '%'), array(
51 51
                 'size' => 5,
52 52
                 'maxlength' => 5,
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
             }
59 59
 
60 60
             $this->addRule('scorecolpercent', get_lang('OnlyNumbers'), 'numeric');
61
-            $this->addRule(array('scorecolpercent','maxvalue'), get_lang('Over100'), 'compare', '<=');
62
-            $this->addRule(array('scorecolpercent','minvalue'), get_lang('UnderMin'), 'compare', '>');
61
+            $this->addRule(array('scorecolpercent', 'maxvalue'), get_lang('Over100'), 'compare', '<=');
62
+            $this->addRule(array('scorecolpercent', 'minvalue'), get_lang('UnderMin'), 'compare', '>');
63 63
         }
64 64
 
65 65
 		//Settings for the scoring system
66 66
 
67 67
 		if ($displayscore->is_custom()) {
68
-            $this->addElement('html', '<br /><b>' . get_lang('ScoringSystem') . '</b>');
68
+            $this->addElement('html', '<br /><b>'.get_lang('ScoringSystem').'</b>');
69 69
 			$this->addElement('static', null, null, get_lang('ScoreInfo'));
70 70
 			$this->setDefaults(array(
71 71
 				'beginscore' => '0'
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
 				'input-size' => 2
78 78
 			));
79 79
 
80
-			for ($counter= 1; $counter <= 20; $counter++) {
81
-				$renderer =& $this->defaultRenderer();
80
+			for ($counter = 1; $counter <= 20; $counter++) {
81
+				$renderer = & $this->defaultRenderer();
82 82
 				$elementTemplateTwoLabel =
83
-				'<div id=' . $counter . ' style="display: '.(($counter<=$nr_items)?'inline':'none').';">
83
+				'<div id='.$counter.' style="display: '.(($counter <= $nr_items) ? 'inline' : 'none').';">
84 84
 
85 85
 				<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->
86 86
 
@@ -105,39 +105,39 @@  discard block
 block discarded – undo
105 105
 
106 106
 				';
107 107
 
108
-				$elementTemplateTwoLabel2 ='
108
+				$elementTemplateTwoLabel2 = '
109 109
 				<div class="col-sm-2">
110 110
 					<!-- BEGIN error --><span class="form_error">{error}</span>
111 111
 					<!-- END error -->
112 112
 					{element}
113 113
 				</div>
114 114
 				<div class="col-sm-1">
115
-                    <a href="javascript:plusItem(' . ($counter+1) . ')">
116
-                    <img style="display: '.(($counter>=$nr_items)?'inline':'none').';" id="plus-' . ($counter+1) . '" src="'.Display::returnIconPath('add.png').'" alt="'.get_lang('Add').'" title="'.get_lang('Add').'"></a>
117
-        			<a href="javascript:minItem(' . ($counter) . ')">
118
-        			<img style="display: '.(($counter>=$nr_items && $counter!=1)?'inline':'none').';" id="min-' . $counter . '" src="'.Display::returnIconPath('delete.png').'" alt="'.get_lang('Delete').'" title="'.get_lang('Delete').'"></a>
115
+                    <a href="javascript:plusItem(' . ($counter + 1).')">
116
+                    <img style="display: '.(($counter >= $nr_items) ? 'inline' : 'none').';" id="plus-'.($counter + 1).'" src="'.Display::returnIconPath('add.png').'" alt="'.get_lang('Add').'" title="'.get_lang('Add').'"></a>
117
+        			<a href="javascript:minItem(' . ($counter).')">
118
+        			<img style="display: '.(($counter >= $nr_items && $counter != 1) ? 'inline' : 'none').';" id="min-'.$counter.'" src="'.Display::returnIconPath('delete.png').'" alt="'.get_lang('Delete').'" title="'.get_lang('Delete').'"></a>
119 119
 				</div>
120 120
 				</div>
121 121
 				</div>';
122 122
 
123 123
 				$scorebetw = array();
124
-				$this->addElement('text', 'endscore[' . $counter . ']', null, array (
124
+				$this->addElement('text', 'endscore['.$counter.']', null, array(
125 125
 					'size' => 5,
126 126
 					'maxlength' => 5,
127 127
 					'id' => 'txta-'.$counter,
128 128
 					'input-size' => 2
129 129
 				));
130 130
 
131
-				$this->addElement('text', 'displaytext[' . $counter . ']', null,array (
131
+				$this->addElement('text', 'displaytext['.$counter.']', null, array(
132 132
 					'size' => 40,
133 133
 					'maxlength' => 40,
134 134
 					'id' => 'txtb-'.$counter
135 135
 				));
136
-				$renderer->setElementTemplate($elementTemplateTwoLabel, 'endscore[' . $counter . ']');
137
-				$renderer->setElementTemplate($elementTemplateTwoLabel2, 'displaytext[' . $counter . ']');
138
-				$this->addRule('endscore[' . $counter . ']', get_lang('OnlyNumbers'), 'numeric');
139
-				$this->addRule(array ('endscore[' . $counter . ']', 'maxvalue'), get_lang('Over100'), 'compare', '<=');
140
-				$this->addRule(array ('endscore[' . $counter . ']', 'minvalue'), get_lang('UnderMin'), 'compare', '>');
136
+				$renderer->setElementTemplate($elementTemplateTwoLabel, 'endscore['.$counter.']');
137
+				$renderer->setElementTemplate($elementTemplateTwoLabel2, 'displaytext['.$counter.']');
138
+				$this->addRule('endscore['.$counter.']', get_lang('OnlyNumbers'), 'numeric');
139
+				$this->addRule(array('endscore['.$counter.']', 'maxvalue'), get_lang('Over100'), 'compare', '<=');
140
+				$this->addRule(array('endscore['.$counter.']', 'minvalue'), get_lang('UnderMin'), 'compare', '>');
141 141
 			}
142 142
 		}
143 143
 
Please login to merge, or discard this patch.
main/gradebook/lib/fe/userform.class.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 class UserForm extends FormValidator
11 11
 {
12
-	const TYPE_USER_INFO= 1;
12
+	const TYPE_USER_INFO = 1;
13 13
 	const TYPE_SIMPLE_SEARCH = 3;
14 14
 	/**
15 15
 	 * Builds a form containing form items based on a given parameter
@@ -19,15 +19,15 @@  discard block
 block discarded – undo
19 19
 	 * @param method
20 20
 	 * @param action
21 21
 	 */
22
-	public function __construct($form_type, $user, $form_name, $method= 'post', $action= null)
22
+	public function __construct($form_type, $user, $form_name, $method = 'post', $action = null)
23 23
 	{
24 24
 		parent :: __construct($form_name, $method, $action);
25
-		$this->form_type= $form_type;
25
+		$this->form_type = $form_type;
26 26
 		if (isset ($user)) {
27
-			$this->user_info= $user;
27
+			$this->user_info = $user;
28 28
 		}
29 29
 		if (isset ($result_object)) {
30
-			$this->result_object= $result_object;
30
+			$this->result_object = $result_object;
31 31
 		}
32 32
 		if ($this->form_type == self :: TYPE_USER_INFO) {
33 33
 			$this->build_user_info_form();
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 				'keyword' => Security::remove_XSS($_GET['search'])
46 46
 			));
47 47
 		}
48
-		$renderer =& $this->defaultRenderer();
48
+		$renderer = & $this->defaultRenderer();
49 49
 		$renderer->setCustomElementTemplate('<span>{element}</span> ');
50
-		$this->addElement('text','keyword','');
50
+		$this->addElement('text', 'keyword', '');
51 51
 		$this->addButtonSearch(get_lang('Search'), 'submit');
52 52
 	}
53 53
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 			$this->addElement('static', 'fname', get_lang('FirstName'), $this->user_info['firstname']);
62 62
 		}
63 63
 		$this->addElement('static', 'uname', get_lang('UserName'), $this->user_info['username']);
64
-		$this->addElement('static', 'email', get_lang('Email'), '<a href="mailto:' . $this->user_info['email'] . '">' . $this->user_info['email'] . '</a>');
64
+		$this->addElement('static', 'email', get_lang('Email'), '<a href="mailto:'.$this->user_info['email'].'">'.$this->user_info['email'].'</a>');
65 65
 		$this->addElement('static', 'ofcode', get_lang('OfficialCode'), $this->user_info['official_code']);
66 66
 		$this->addElement('static', 'phone', get_lang('Phone'), $this->user_info['phone']);
67 67
 		$this->addButtonSave(get_lang('Back'), 'submit');
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		parent :: display();
73 73
 	}
74 74
 
75
-	function setDefaults($defaults= array(), $filter = null)
75
+	function setDefaults($defaults = array(), $filter = null)
76 76
 	{
77 77
 		parent :: setDefaults($defaults, $filter);
78 78
 	}
Please login to merge, or discard this patch.
main/gradebook/lib/fe/dataform.class.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 	 * @param method
22 22
 	 * @param action
23 23
 	 */
24
-	public function __construct($form_type, $form_name, $method = 'post', $action = null, $target='', $locked_status)
24
+	public function __construct($form_type, $form_name, $method = 'post', $action = null, $target = '', $locked_status)
25 25
 	{
26
-		parent :: __construct($form_name, $method, $action,$target);
26
+		parent :: __construct($form_name, $method, $action, $target);
27 27
 		$this->form_type = $form_type;
28 28
 		if ($this->form_type == self :: TYPE_IMPORT) {
29 29
 			$this->build_import_form();
@@ -41,13 +41,13 @@  discard block
 block discarded – undo
41 41
 
42 42
 	protected function build_pdf_export_form()
43 43
 	{
44
-		$renderer =& $this->defaultRenderer();
44
+		$renderer = & $this->defaultRenderer();
45 45
 		$renderer->setCustomElementTemplate('<span>{element}</span>');
46 46
 		$this->addElement('header', get_lang('ChooseOrientation'));
47 47
 		$this->addElement('radio', 'orientation', null, get_lang('Portrait'), 'portrait');
48 48
 		$this->addElement('radio', 'orientation', null, get_lang('Landscape'), 'landscape');
49 49
 		$this->addButtonExport(get_lang('Export'));
50
-		$this->setDefaults(array (
50
+		$this->setDefaults(array(
51 51
 			'orientation' => 'portrait'
52 52
 		));
53 53
 	}
@@ -59,19 +59,19 @@  discard block
 block discarded – undo
59 59
 		$this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml');
60 60
 		$this->addElement('radio', 'file_type', null, 'PDF (Portable Document Format)', 'pdf');
61 61
 		$this->addButtonExport(get_lang('Export'));
62
-		$this->setDefaults(array (
62
+		$this->setDefaults(array(
63 63
 			'file_type' => 'csv'
64 64
 		));
65 65
 	}
66 66
 
67
-	protected function build_export_form_option($show_pdf=true)
67
+	protected function build_export_form_option($show_pdf = true)
68 68
 	{
69 69
 		$this->addElement('header', get_lang('ChooseFormat'));
70 70
 		$this->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV (Comma-Separated Values)', 'csv');
71 71
 		$this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml');
72
-		$this->addElement('radio', 'file_type', Display::return_icon('info3.gif',get_lang('ToExportMustLockEvaluation')), 'PDF (Portable Document Format)', 'pdf', array('disabled'));
72
+		$this->addElement('radio', 'file_type', Display::return_icon('info3.gif', get_lang('ToExportMustLockEvaluation')), 'PDF (Portable Document Format)', 'pdf', array('disabled'));
73 73
 		$this->addButtonExport(get_lang('Export'));
74
-		$this->setDefaults(array (
74
+		$this->setDefaults(array(
75 75
 			'file_type' => 'csv'
76 76
 		));
77 77
 	}
@@ -80,16 +80,16 @@  discard block
 block discarded – undo
80 80
 	{
81 81
 		$this->addElement('hidden', 'formSent');
82 82
 		$this->addElement('header', get_lang('ImportFileLocation'));
83
-		$this->addElement('file', 'import_file',get_lang('Location'));
84
-		$allowed_file_types = array (
83
+		$this->addElement('file', 'import_file', get_lang('Location'));
84
+		$allowed_file_types = array(
85 85
 			'xml',
86 86
 			'csv'
87 87
 		);
88 88
 		//$this->addRule('file', get_lang('InvalidExtension') . ' (' . implode(',', $allowed_file_types) . ')', 'filetype', $allowed_file_types);
89
-		$this->addElement('radio', 'file_type', get_lang('FileType'), 'CSV (<a href="docs/example_csv.html" target="_blank">' . get_lang('ExampleCSVFile') . '</a>)', 'csv');
90
-		$this->addElement('radio', 'file_type', null, 'XML (<a href="docs/example_xml.html" target="_blank">' . get_lang('ExampleXMLFile') . '</a>)', 'xml');
91
-		$this->addElement('checkbox','overwrite', null,get_lang('OverwriteScores'));
92
-		$this->addElement('checkbox','ignoreerrors',null,get_lang('IgnoreErrors'));
89
+		$this->addElement('radio', 'file_type', get_lang('FileType'), 'CSV (<a href="docs/example_csv.html" target="_blank">'.get_lang('ExampleCSVFile').'</a>)', 'csv');
90
+		$this->addElement('radio', 'file_type', null, 'XML (<a href="docs/example_xml.html" target="_blank">'.get_lang('ExampleXMLFile').'</a>)', 'xml');
91
+		$this->addElement('checkbox', 'overwrite', null, get_lang('OverwriteScores'));
92
+		$this->addElement('checkbox', 'ignoreerrors', null, get_lang('IgnoreErrors'));
93 93
 		$this->addButtonImport(get_lang('Ok'));
94 94
 		$this->setDefaults(array(
95 95
 			'formSent' => '1',
Please login to merge, or discard this patch.
app/Resources/public/assets/ckeditor/samples/old/assets/posteddata.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,18 +27,18 @@
 block discarded – undo
27 27
 
28 28
 if (!empty($_POST))
29 29
 {
30
-	foreach ( $_POST as $key => $value )
30
+	foreach ($_POST as $key => $value)
31 31
 	{
32
-		if ( ( !is_string($value) && !is_numeric($value) ) || !is_string($key) )
32
+		if ((!is_string($value) && !is_numeric($value)) || !is_string($key))
33 33
 			continue;
34 34
 
35
-		if ( get_magic_quotes_gpc() )
36
-			$value = htmlspecialchars( stripslashes((string)$value) );
35
+		if (get_magic_quotes_gpc())
36
+			$value = htmlspecialchars(stripslashes((string) $value));
37 37
 		else
38
-			$value = htmlspecialchars( (string)$value );
38
+			$value = htmlspecialchars((string) $value);
39 39
 ?>
40 40
 		<tr>
41
-			<th style="vertical-align: top"><?php echo htmlspecialchars( (string)$key ); ?></th>
41
+			<th style="vertical-align: top"><?php echo htmlspecialchars((string) $key); ?></th>
42 42
 			<td><pre class="samples"><?php echo $value; ?></pre></td>
43 43
 		</tr>
44 44
 	<?php
Please login to merge, or discard this patch.
main/admin/configure_homepage.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 {
20 20
 	$post = strpos($file_logged_in, "_logged_in");
21 21
 	if ($post !== false) {
22
-		$file_logged_out = str_replace('_logged_in','', $file_logged_in);
22
+		$file_logged_out = str_replace('_logged_in', '', $file_logged_in);
23 23
 		//variables initialization
24 24
 		$data_logged_out = array();
25 25
 		$data_logged_in  = array();
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 		//we read the file with all links
28 28
 		$file = file($file_logged_in);
29 29
 		foreach ($file as $line) {
30
-			$line = str_replace("\n", '',$line);
30
+			$line = str_replace("\n", '', $line);
31 31
 			//not logged user only sees public links
32
-			if (!preg_match('/::private/',$line)) {
32
+			if (!preg_match('/::private/', $line)) {
33 33
 				$data_logged_out[] = $line;
34 34
 			}
35 35
 			//logged user only sees all links
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
75 75
 $tool_name = get_lang('ConfigureHomePage');
76 76
 $_languages = api_get_languages();
77
-$selfUrl =  api_get_self();
77
+$selfUrl = api_get_self();
78 78
 $interbreadcrumb[] = array(
79 79
 	'url' => 'index.php',
80 80
 	'name' => get_lang('PlatformAdmin')
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 				}
263 263
 
264 264
 				if (EventsMail::check_if_using_class('portal_homepage_edited')) {
265
-					EventsDispatcher::events('portal_homepage_edited',array('about_user' => api_get_user_id()));
265
+					EventsDispatcher::events('portal_homepage_edited', array('about_user' => api_get_user_id()));
266 266
 				}
267 267
 				Event::addEvent(
268 268
 					LOG_HOMEPAGE_CHANGED,
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
 				if ($link_url == 'http://' || $link_url == 'https://') {
395 395
 					$link_url = '';
396 396
 				} elseif (!empty($link_url) && !strstr($link_url, '://')) {
397
-					$link_url='http://'.$link_url;
397
+					$link_url = 'http://'.$link_url;
398 398
 				}
399
-				$menuf = ($action == 'insert_tabs' || $action == 'edit_tabs')? $mtloggedin : $menuf;
399
+				$menuf = ($action == 'insert_tabs' || $action == 'edit_tabs') ? $mtloggedin : $menuf;
400 400
 
401 401
 				if (!is_writable($homep.$menuf.'_'.$lang.$ext)) {
402 402
 					$errorMsg = get_lang('HomePageFilesNotWritable');
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 					}
415 415
 					// If the typical language suffix is not found in the file name,
416 416
 					// replace the ".html" suffix by "_en.html" or the active menu language
417
-					if (!strstr($filename,'_'.$lang.$ext)) {
417
+					if (!strstr($filename, '_'.$lang.$ext)) {
418 418
 						$filename = str_replace($ext, '_'.$lang.$ext, $filename);
419 419
 					}
420 420
 					// Get the contents of home_menu_en.html (or active menu language
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 					//
437 437
 					// If the given link url is empty, then replace the link url by a link to the link file created
438 438
 
439
-					if (empty($link_url) || $link_url == 'http://' ||  $link_url == 'https://') {
439
+					if (empty($link_url) || $link_url == 'http://' || $link_url == 'https://') {
440 440
 						$link_url = api_get_path(WEB_PATH).'index.php?include='.urlencode($filename);
441 441
 						// If the file doesn't exist, then create it and
442 442
 						// fill it with default text
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 					}
456 456
 					// If the requested action is to edit a link, open the file and
457 457
 					// write to it (if the file doesn't exist, create it)
458
-					if (in_array($action, array('edit_link'))  && !empty($link_html)) {
458
+					if (in_array($action, array('edit_link')) && !empty($link_html)) {
459 459
 						$fp = @fopen($homep.$filename, 'w');
460 460
 						if ($fp) {
461 461
 							fputs($fp, $link_html);
@@ -482,10 +482,10 @@  discard block
 block discarded – undo
482 482
 								break;
483 483
 							}
484 484
 						}
485
-						$home_menu[$insert_where + 1] = '<li ' . $class_add_in_tab . '><a href="'.$link_url.'" target="'.($target_blank ? '_blank' : '_self').'">'. $link_name .'</a></li>';
485
+						$home_menu[$insert_where + 1] = '<li '.$class_add_in_tab.'><a href="'.$link_url.'" target="'.($target_blank ? '_blank' : '_self').'">'.$link_name.'</a></li>';
486 486
 					} else {
487 487
 						// If the request is about a link edition, change the link
488
-						$home_menu[$link_index]='<li ' . $class_add_in_tab . '><a href="'.$link_url.'" target="'.($target_blank?'_blank':'_self').'">'. $link_name .'</a></li>';
488
+						$home_menu[$link_index] = '<li '.$class_add_in_tab.'><a href="'.$link_url.'" target="'.($target_blank ? '_blank' : '_self').'">'.$link_name.'</a></li>';
489 489
 					}
490 490
 					// Re-build the file from the home_menu array
491 491
 					$home_menu = implode("\n", $home_menu);
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 				Event::addEvent(
540 540
 					LOG_HOMEPAGE_CHANGED,
541 541
 					$action,
542
-					cut($link_name . ':' . $link_url, 254),
542
+					cut($link_name.':'.$link_url, 254),
543 543
 					api_get_utc_datetime(),
544 544
 					api_get_user_id()
545 545
 				);
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 				// A link is deleted by getting the file into an array, removing the
563 563
 				// link and re-writing the array to the file
564 564
 				$link_index = intval($_GET['link_index']);
565
-				$menuf = ($action == 'delete_tabs')? $mtloggedin : $menuf;
565
+				$menuf = ($action == 'delete_tabs') ? $mtloggedin : $menuf;
566 566
 				$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
567 567
 				if (empty($home_menu)) {
568 568
 					$home_menu = array();
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 				fclose($fp);
584 584
 				if (file_exists($homep.$menuf.$ext)) {
585 585
 					if (is_writable($homep.$menuf.$ext)) {
586
-						$fpo = fopen($homep.$menuf.$ext,'w');
586
+						$fpo = fopen($homep.$menuf.$ext, 'w');
587 587
 						fputs($fpo, $home_menu);
588 588
 						home_tabs($homep.$menuf.$ext);
589 589
 						fclose($fpo);
@@ -596,9 +596,9 @@  discard block
 block discarded – undo
596 596
 				// This request is only the preparation for the update of the home_top
597 597
 				$home_top = '';
598 598
 				if (is_file($homep.$topf.'_'.$lang.$ext) && is_readable($homep.$topf.'_'.$lang.$ext)) {
599
-					$home_top = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
599
+					$home_top = @(string) file_get_contents($homep.$topf.'_'.$lang.$ext);
600 600
 				} elseif (is_file($homep.$topf.$lang.$ext) && is_readable($homep.$topf.$lang.$ext)) {
601
-					$home_top = @(string)file_get_contents($homep.$topf.$lang.$ext);
601
+					$home_top = @(string) file_get_contents($homep.$topf.$lang.$ext);
602 602
 				} else {
603 603
 					$errorMsg = get_lang('HomePageFilesNotReadable');
604 604
 				}
@@ -626,9 +626,9 @@  discard block
 block discarded – undo
626 626
 				// This request is the preparation for the update of the home_news page
627 627
 				$home_news = '';
628 628
 				if (is_file($homep.$newsf.'_'.$lang.$ext) && is_readable($homep.$newsf.'_'.$lang.$ext)) {
629
-					$home_news = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
629
+					$home_news = @(string) file_get_contents($homep.$newsf.'_'.$lang.$ext);
630 630
 				} elseif (is_file($homep.$newsf.$lang.$ext) && is_readable($homep.$newsf.$lang.$ext)) {
631
-					$home_news = @(string)file_get_contents($homep.$newsf.$lang.$ext);
631
+					$home_news = @(string) file_get_contents($homep.$newsf.$lang.$ext);
632 632
 				} else {
633 633
 					$errorMsg = get_lang('HomePageFilesNotReadable');
634 634
 				}
@@ -637,10 +637,10 @@  discard block
 block discarded – undo
637 637
 			case 'insert_link':
638 638
 				// This request is the preparation for the addition of an item in home_menu
639 639
 				$home_menu = '';
640
-				$menuf = ($action == 'edit_tabs')? $mtloggedin : $menuf;
640
+				$menuf = ($action == 'edit_tabs') ? $mtloggedin : $menuf;
641 641
 				if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
642 642
 					$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
643
-				} elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
643
+				} elseif (is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
644 644
 					$home_menu = @file($homep.$menuf.$lang.$ext);
645 645
 				} else {
646 646
 					$errorMsg = get_lang('HomePageFilesNotReadable');
@@ -681,10 +681,10 @@  discard block
 block discarded – undo
681 681
 			case 'edit_link':
682 682
 				// This request is the preparation for the edition of the links array
683 683
 				$home_menu = '';
684
-				$menuf = ($action == 'edit_tabs')? $mtloggedin : $menuf;
684
+				$menuf = ($action == 'edit_tabs') ? $mtloggedin : $menuf;
685 685
 				if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
686 686
 					$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
687
-				} elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
687
+				} elseif (is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
688 688
 					$home_menu = @file($homep.$menuf.$lang.$ext);
689 689
 				} else {
690 690
 					$errorMsg = get_lang('HomePageFilesNotReadable');
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 						$link_name = strip_tags($enreg);
748 748
 
749 749
 						// Get the contents of "href" attribute in $link_url
750
-						$enreg = explode('href="',$enreg);
750
+						$enreg = explode('href="', $enreg);
751 751
 						list($link_url) = explode('"', $enreg[sizeof($enreg) - 1]);
752 752
 
753 753
 						// If the link contains the web root of this portal, then strip
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 	case 'open_link':
786 786
 		if (!empty($link)) {
787 787
 			// $link is only set in case of action=open_link and is filtered
788
-			$open = @(string)file_get_contents($homep.$link);
788
+			$open = @(string) file_get_contents($homep.$link);
789 789
 			$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
790 790
 			echo $open;
791 791
 		}
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
 		}
850 850
 		$default = array();
851 851
 		$form = new FormValidator('configure_homepage_'.$action, 'post', $selfUrl.'?action='.$action, '', array('style' => 'margin: 0px;'));
852
-		$renderer =& $form->defaultRenderer();
852
+		$renderer = & $form->defaultRenderer();
853 853
 
854 854
 		$form->addElement('header', '', $tool_name);
855 855
 		$form->addElement('hidden', 'formSent', '1');
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 
871 871
 		if ($action == 'insert_link' || $action == 'insert_tabs') {
872 872
 			$add_in_tab = 1;
873
-			if (is_array($home_menu)){
873
+			if (is_array($home_menu)) {
874 874
 				foreach ($home_menu as $key => $enreg) {
875 875
 					if (strlen($enreg = trim(strip_tags($enreg))) > 0) {
876 876
 						$options[$key] = get_lang('After').' &quot;'.$enreg.'&quot;';
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 				}
881 881
 			}
882 882
 			$default['insert_link'] = $selected;
883
-			$form->addElement('select', 'insert_where', get_lang('InsertThisLink') , $options);
883
+			$form->addElement('select', 'insert_where', get_lang('InsertThisLink'), $options);
884 884
 		}
885 885
 
886 886
 		$target_blank_checkbox = $form->addElement('checkbox', 'target_blank', null, get_lang('OpenInNewWindow'), 1);
@@ -895,15 +895,15 @@  discard block
 block discarded – undo
895 895
 		if ($action == 'edit_link' && (empty($link_url) || $link_url == 'http://' || $link_url == 'https://')) {
896 896
 			$default['link_html'] = isset($_POST['link_html']) ? $_POST['link_html'] : $link_html;
897 897
 			$form->addHtmlEditor('link_html', get_lang('Content'), false, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
898
-            $form->addButtonSave(get_lang('Save'),'submit');
898
+            $form->addButtonSave(get_lang('Save'), 'submit');
899 899
 
900 900
 		} else {
901
-			if (in_array($action, array('edit_tabs','insert_tabs'))) {
901
+			if (in_array($action, array('edit_tabs', 'insert_tabs'))) {
902 902
 				$default['link_html'] = isset($_POST['link_html']) ? $_POST['link_html'] : (!empty($link_html) ? $link_html : '');
903 903
 				$form->addHtmlEditor('link_html', get_lang('Content'), false, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
904 904
 			}
905 905
 			$form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'), array('id' => 'all_langs'));
906
-			$form->addElement('html','<table id="table_langs" style="margin-left:159px;"><tr>');
906
+			$form->addElement('html', '<table id="table_langs" style="margin-left:159px;"><tr>');
907 907
 			$i = 0;
908 908
 			foreach ($_languages['name'] as $key => $value) {
909 909
 				$i++;
@@ -916,8 +916,8 @@  discard block
 block discarded – undo
916 916
 				}
917 917
 				$form->addElement('html', $html_langs);
918 918
 			}
919
-			$form->addElement('html','</tr></table><br/>');
920
-            $form->addButtonSave(get_lang('Save'),'submit');
919
+			$form->addElement('html', '</tr></table><br/>');
920
+            $form->addButtonSave(get_lang('Save'), 'submit');
921 921
 		}
922 922
 
923 923
 		$form->setDefaults($default);
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
 			$open = $home_top;
932 932
 		} else {
933 933
 			$name = $newsf;
934
-			$open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
934
+			$open = @(string) file_get_contents($homep.$newsf.'_'.$lang.$ext);
935 935
 		}
936 936
 		$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
937 937
 
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 			'',
948 948
 			array('style' => 'margin: 0px;')
949 949
 		);
950
-		$renderer =& $form->defaultRenderer();
950
+		$renderer = & $form->defaultRenderer();
951 951
 		$renderer->setHeaderTemplate('');
952 952
 		$renderer->setFormTemplate('<form{attributes}><table border="0" cellpadding="5" cellspacing="0" width="100%">{content}</table></form>');
953 953
 		$renderer->setCustomElementTemplate('<tr><td>{element}</td></tr>');
@@ -973,8 +973,8 @@  discard block
 block discarded – undo
973 973
 
974 974
 		$default[$name] = str_replace('{rel_path}', api_get_path(REL_PATH), $open);
975 975
 		$form->addHtmlEditor($name, '', true, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
976
-		$form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'),array('id' => 'all_langs'));
977
-		$form->addElement('html','<table id="table_langs" style="margin-left:5px;"><tr>');
976
+		$form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'), array('id' => 'all_langs'));
977
+		$form->addElement('html', '<table id="table_langs" style="margin-left:5px;"><tr>');
978 978
 
979 979
 		$currentLanguage = api_get_interface_language();
980 980
 		$i = 0;
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
 			$i++;
984 984
 
985 985
 			$checked = null;
986
-			if ($languageGet == $lang_name)  {
986
+			if ($languageGet == $lang_name) {
987 987
 				$checked = "checked";
988 988
 			}
989 989
 			$html_langs = '<td width="300">';
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
 			}
995 995
 			$form->addElement('html', $html_langs);
996 996
 		}
997
-		$form->addElement('html','</tr></table><br/>');
997
+		$form->addElement('html', '</tr></table><br/>');
998 998
 		$form->addButtonSave(get_lang('Save'));
999 999
 		$form->setDefaults($default);
1000 1000
 		$form->display();
@@ -1047,9 +1047,9 @@  discard block
 block discarded – undo
1047 1047
                                 <?php
1048 1048
                                     $home_notice = '';
1049 1049
                                     if (file_exists($homep.$noticef.'_'.$lang.$ext)) {
1050
-                                        $home_notice = @(string)file_get_contents($homep.$noticef.'_'.$lang.$ext);
1050
+                                        $home_notice = @(string) file_get_contents($homep.$noticef.'_'.$lang.$ext);
1051 1051
                                     } else {
1052
-                                        $home_notice = @(string)file_get_contents($homep.$noticef.$ext);
1052
+                                        $home_notice = @(string) file_get_contents($homep.$noticef.$ext);
1053 1053
                                     }
1054 1054
                                     $home_notice = api_to_system_encoding($home_notice, api_detect_encoding(strip_tags($home_notice)));
1055 1055
                                     echo '<div class="homepage_notice">';
@@ -1074,7 +1074,7 @@  discard block
 block discarded – undo
1074 1074
                     </div>
1075 1075
                     <div id="links-list" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
1076 1076
                         <div class="panel-body">
1077
-                            <a href="<?php echo $selfUrl; ?>?action=insert_link"><?php echo Display::return_icon('add.png', get_lang('InsertLink')).'&nbsp;'. get_lang('InsertLink'); ?>
1077
+                            <a href="<?php echo $selfUrl; ?>?action=insert_link"><?php echo Display::return_icon('add.png', get_lang('InsertLink')).'&nbsp;'.get_lang('InsertLink'); ?>
1078 1078
                             </a>
1079 1079
                             <ul class="menulist">
1080 1080
                                 <?php
@@ -1113,16 +1113,16 @@  discard block
 block discarded – undo
1113 1113
         <div class="col-md-9">
1114 1114
             <div class="actions">
1115 1115
 		<a href="<?php echo $selfUrl; ?>?action=edit_top&language=<?php echo $languageGet; ?>">
1116
-                    <?php echo Display::return_icon('edit.png', get_lang('EditHomePage'),null,ICON_SIZE_SMALL).'&nbsp;'. get_lang('EditHomePage'); ?>
1116
+                    <?php echo Display::return_icon('edit.png', get_lang('EditHomePage'), null, ICON_SIZE_SMALL).'&nbsp;'.get_lang('EditHomePage'); ?>
1117 1117
 		</a>
1118 1118
             </div>
1119 1119
             <section id="homepage-home">
1120 1120
                 <?php
1121 1121
                 //print home_top contents
1122 1122
                 if (file_exists($homep.$topf.'_'.$lang.$ext)) {
1123
-                    $home_top_temp = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
1123
+                    $home_top_temp = @(string) file_get_contents($homep.$topf.'_'.$lang.$ext);
1124 1124
                 } else {
1125
-                    $home_top_temp = @(string)file_get_contents($homep.$topf.$ext);
1125
+                    $home_top_temp = @(string) file_get_contents($homep.$topf.$ext);
1126 1126
                 }
1127 1127
                 $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
1128 1128
                 $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
@@ -1158,11 +1158,11 @@  discard block
 block discarded – undo
1158 1158
 
1159 1159
             <?php
1160 1160
 		if (file_exists($homep.$newsf.'_'.$lang.$ext)) {
1161
-                    $open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
1161
+                    $open = @(string) file_get_contents($homep.$newsf.'_'.$lang.$ext);
1162 1162
                     $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
1163 1163
                     echo $open;
1164 1164
 		} else {
1165
-                    $open = @(string)file_get_contents($homep.$newsf.$ext);
1165
+                    $open = @(string) file_get_contents($homep.$newsf.$ext);
1166 1166
                     $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
1167 1167
                     echo $open;
1168 1168
 		}
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
                             $tab_string = str_replace(array('href="'.api_get_path(WEB_PATH).'index.php?include=', '</li>'),
1200 1200
                                 array('href="'.api_get_path(WEB_CODE_PATH).'admin/'.basename($selfUrl).'?action=open_link&link=', $edit_link.$delete_link.'</li>'),
1201 1201
 				$enreg);
1202
-                            $tab_string = str_replace(array('<li>', '</li>','class="hide_menu"', 'hide_menu'), '', $tab_string);
1202
+                            $tab_string = str_replace(array('<li>', '</li>', 'class="hide_menu"', 'hide_menu'), '', $tab_string);
1203 1203
 				$link_list .= Display::tag('li', $tab_string, array('class' => 'list-group-item'));
1204 1204
 				$tab_counter++;
1205 1205
 			}
@@ -1207,7 +1207,7 @@  discard block
 block discarded – undo
1207 1207
             ?>
1208 1208
             <div class="actions">
1209 1209
 		<a href="<?php echo $selfUrl; ?>?action=insert_tabs">
1210
-                    <?php echo Display::return_icon('add.png', get_lang('InsertLink')) .'&nbsp;'. get_lang('InsertLink'); ?>
1210
+                    <?php echo Display::return_icon('add.png', get_lang('InsertLink')).'&nbsp;'.get_lang('InsertLink'); ?>
1211 1211
                 </a>
1212 1212
             </div>
1213 1213
             <?php
Please login to merge, or discard this patch.
main/glossary/glossary_ajax_request.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
         $glossary_all_data = implode('[|.|_|.|-|.|]', $glossary_all_data);
42 42
         echo api_xml_http_response_encode($glossary_all_data);
43 43
     }
44
-} elseif(isset($_POST['glossary_name'])) {
44
+} elseif (isset($_POST['glossary_name'])) {
45 45
     $my_glossary_name = Security::remove_XSS($_POST['glossary_name']);
46 46
     $my_glossary_name = api_convert_encoding($my_glossary_name, $charset, 'UTF-8');
47 47
     $my_glossary_name = trim($my_glossary_name);
Please login to merge, or discard this patch.
plugin/vchamilo/views/manage.testdatapath.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
 $dataroot = $_REQUEST['dataroot'];
24 24
 
25 25
 $absalternatecourse = vchamilo_get_config('vchamilo', 'course_real_root');
26
-if (!empty($absalternatecourse)){
26
+if (!empty($absalternatecourse)) {
27 27
     // this is the relocated case
28 28
     $coursedir = str_replace('//', '/', $absalternatecourse.'/'.$dataroot);
29 29
 } else {
Please login to merge, or discard this patch.