Completed
Pull Request — 1.11.x (#1285)
by José
478:06 queued 439:54
created
main/inc/lib/fileUpload.lib.php 1 patch
Spacing   +95 added lines, -95 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
                             }
@@ -585,14 +585,14 @@  discard block
 block discarded – undo
585 585
                             if (isset($_POST['moodle_import'])) {
586 586
                                 Display::addFlash(
587 587
                                     Display::display_confirmation_message(
588
-                                        get_lang('UplUploadSucceeded') . '<br />' . get_lang('UplFileSavedAs') . ' ' . $documentTitle,
588
+                                        get_lang('UplUploadSucceeded').'<br />'.get_lang('UplFileSavedAs').' '.$documentTitle,
589 589
                                         false,
590 590
                                         true
591 591
                                     )
592 592
                                 );
593 593
                             } else {
594 594
                                 Display::display_confirmation_message(
595
-                                    get_lang('UplUploadSucceeded') . '<br />' . get_lang('UplFileSavedAs') . ' ' . $documentTitle,
595
+                                    get_lang('UplUploadSucceeded').'<br />'.get_lang('UplFileSavedAs').' '.$documentTitle,
596 596
                                     false
597 597
                                 );
598 598
                             }
@@ -669,14 +669,14 @@  discard block
 block discarded – undo
669 669
                                 if (isset($_POST['moodle_import'])) {
670 670
                                     Display::addFlash(
671 671
                                         Display::display_confirmation_message(
672
-                                            get_lang('UplUploadSucceeded') . '<br /> ' . $documentTitle,
672
+                                            get_lang('UplUploadSucceeded').'<br /> '.$documentTitle,
673 673
                                             false,
674 674
                                             true
675 675
                                         )
676 676
                                     );
677 677
                                 } else {
678 678
                                     Display::display_confirmation_message(
679
-                                        get_lang('UplUploadSucceeded') . '<br /> ' . $documentTitle,
679
+                                        get_lang('UplUploadSucceeded').'<br /> '.$documentTitle,
680 680
                                         false
681 681
                                     );
682 682
                                 }
@@ -755,12 +755,12 @@  discard block
 block discarded – undo
755 755
 function dir_total_space($dir_path)
756 756
 {
757 757
     $save_dir = getcwd();
758
-    chdir($dir_path) ;
758
+    chdir($dir_path);
759 759
     $handle = opendir($dir_path);
760 760
     $sumSize = 0;
761 761
     $dirList = array();
762 762
     while ($element = readdir($handle)) {
763
-        if ( $element == '.' || $element == '..') {
763
+        if ($element == '.' || $element == '..') {
764 764
             continue; // Skip the current and parent directories
765 765
         }
766 766
         if (is_file($element)) {
@@ -771,11 +771,11 @@  discard block
 block discarded – undo
771 771
         }
772 772
     }
773 773
 
774
-    closedir($handle) ;
774
+    closedir($handle);
775 775
 
776 776
     if (sizeof($dirList) > 0) {
777 777
         foreach ($dirList as $j) {
778
-            $sizeDir = dir_total_space($j);	// Recursivity
778
+            $sizeDir = dir_total_space($j); // Recursivity
779 779
             $sumSize += $sizeDir;
780 780
         }
781 781
     }
@@ -809,63 +809,63 @@  discard block
 block discarded – undo
809 809
 
810 810
         static $mime_type = array();
811 811
 
812
-        $mime_type[] = 'application/msword';             $extension[] = '.doc';
813
-        $mime_type[] = 'application/rtf';                $extension[] = '.rtf';
814
-        $mime_type[] = 'application/vnd.ms-powerpoint';  $extension[] = '.ppt';
815
-        $mime_type[] = 'application/vnd.ms-excel';       $extension[] = '.xls';
816
-        $mime_type[] = 'application/pdf';                $extension[] = '.pdf';
817
-        $mime_type[] = 'application/postscript';         $extension[] = '.ps';
818
-        $mime_type[] = 'application/mac-binhex40';       $extension[] = '.hqx';
819
-        $mime_type[] = 'application/x-gzip';             $extension[] = 'tar.gz';
820
-        $mime_type[] = 'application/x-shockwave-flash';  $extension[] = '.swf';
821
-        $mime_type[] = 'application/x-stuffit';          $extension[] = '.sit';
822
-        $mime_type[] = 'application/x-tar';              $extension[] = '.tar';
823
-        $mime_type[] = 'application/zip';                $extension[] = '.zip';
824
-        $mime_type[] = 'application/x-tar';              $extension[] = '.tar';
825
-        $mime_type[] = 'text/html';                      $extension[] = '.html';
826
-        $mime_type[] = 'text/plain';                     $extension[] = '.txt';
827
-        $mime_type[] = 'text/rtf';                       $extension[] = '.rtf';
828
-        $mime_type[] = 'img/gif';                        $extension[] = '.gif';
829
-        $mime_type[] = 'img/jpeg';                       $extension[] = '.jpg';
830
-        $mime_type[] = 'img/png';                        $extension[] = '.png';
831
-        $mime_type[] = 'audio/midi';                     $extension[] = '.mid';
832
-        $mime_type[] = 'audio/mpeg';                     $extension[] = '.mp3';
833
-        $mime_type[] = 'audio/x-aiff';                   $extension[] = '.aif';
834
-        $mime_type[] = 'audio/x-pn-realaudio';           $extension[] = '.rm';
835
-        $mime_type[] = 'audio/x-pn-realaudio-plugin';    $extension[] = '.rpm';
836
-        $mime_type[] = 'audio/x-wav';                    $extension[] = '.wav';
837
-        $mime_type[] = 'video/mpeg';                     $extension[] = '.mpg';
838
-        $mime_type[] = 'video/mpeg4-generic';            $extension[] = '.mp4';
839
-        $mime_type[] = 'video/quicktime';                $extension[] = '.mov';
840
-        $mime_type[] = 'video/x-msvideo';                $extension[] = '.avi';
841
-
842
-        $mime_type[] = 'video/x-ms-wmv';                 $extension[] = '.wmv';
843
-        $mime_type[] = 'video/x-flv';                    $extension[] = '.flv';
844
-        $mime_type[] = 'image/svg+xml';                  $extension[] = '.svg';
845
-        $mime_type[] = 'image/svg+xml';                  $extension[] = '.svgz';
846
-        $mime_type[] = 'video/ogg';                  	 $extension[] = '.ogv';
847
-        $mime_type[] = 'audio/ogg';                  	 $extension[] = '.oga';
848
-        $mime_type[] = 'application/ogg';                $extension[] = '.ogg';
849
-        $mime_type[] = 'application/ogg';                $extension[] = '.ogx';
850
-        $mime_type[] = 'application/x-freemind';         $extension[] = '.mm';
851
-
852
-        $mime_type[] = 'application/vnd.ms-word.document.macroEnabled.12';							$extension[] = '.docm';
853
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';	$extension[] = '.docx';
854
-        $mime_type[] = 'application/vnd.ms-word.template.macroEnabled.12';							$extension[] = '.dotm';
855
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template';	$extension[] = '.dotx';
856
-        $mime_type[] = 'application/vnd.ms-powerpoint.template.macroEnabled.12';					$extension[] = '.potm';
857
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.template';		$extension[] = '.potx';
858
-        $mime_type[] = 'application/vnd.ms-powerpoint.addin.macroEnabled.12';						$extension[] = '.ppam';
859
-        $mime_type[] = 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12';					$extension[] = '.ppsm';
860
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow';	$extension[] = '.ppsx';
861
-        $mime_type[] = 'application/vnd.ms-powerpoint.presentation.macroEnabled.12';				$extension[] = '.pptm';
862
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';	$extension[] = '.pptx';
863
-        $mime_type[] = 'application/vnd.ms-excel.addin.macroEnabled.12';							$extension[] = '.xlam';
864
-        $mime_type[] = 'application/vnd.ms-excel.sheet.binary.macroEnabled.12';						$extension[] = '.xlsb';
865
-        $mime_type[] = 'application/vnd.ms-excel.sheet.macroEnabled.12';							$extension[] = '.xlsm';
866
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';			$extension[] = '.xlsx';
867
-        $mime_type[] = 'application/vnd.ms-excel.template.macroEnabled.12';							$extension[] = '.xltm';
868
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template';		$extension[] = '.xltx';
812
+        $mime_type[] = 'application/msword'; $extension[] = '.doc';
813
+        $mime_type[] = 'application/rtf'; $extension[] = '.rtf';
814
+        $mime_type[] = 'application/vnd.ms-powerpoint'; $extension[] = '.ppt';
815
+        $mime_type[] = 'application/vnd.ms-excel'; $extension[] = '.xls';
816
+        $mime_type[] = 'application/pdf'; $extension[] = '.pdf';
817
+        $mime_type[] = 'application/postscript'; $extension[] = '.ps';
818
+        $mime_type[] = 'application/mac-binhex40'; $extension[] = '.hqx';
819
+        $mime_type[] = 'application/x-gzip'; $extension[] = 'tar.gz';
820
+        $mime_type[] = 'application/x-shockwave-flash'; $extension[] = '.swf';
821
+        $mime_type[] = 'application/x-stuffit'; $extension[] = '.sit';
822
+        $mime_type[] = 'application/x-tar'; $extension[] = '.tar';
823
+        $mime_type[] = 'application/zip'; $extension[] = '.zip';
824
+        $mime_type[] = 'application/x-tar'; $extension[] = '.tar';
825
+        $mime_type[] = 'text/html'; $extension[] = '.html';
826
+        $mime_type[] = 'text/plain'; $extension[] = '.txt';
827
+        $mime_type[] = 'text/rtf'; $extension[] = '.rtf';
828
+        $mime_type[] = 'img/gif'; $extension[] = '.gif';
829
+        $mime_type[] = 'img/jpeg'; $extension[] = '.jpg';
830
+        $mime_type[] = 'img/png'; $extension[] = '.png';
831
+        $mime_type[] = 'audio/midi'; $extension[] = '.mid';
832
+        $mime_type[] = 'audio/mpeg'; $extension[] = '.mp3';
833
+        $mime_type[] = 'audio/x-aiff'; $extension[] = '.aif';
834
+        $mime_type[] = 'audio/x-pn-realaudio'; $extension[] = '.rm';
835
+        $mime_type[] = 'audio/x-pn-realaudio-plugin'; $extension[] = '.rpm';
836
+        $mime_type[] = 'audio/x-wav'; $extension[] = '.wav';
837
+        $mime_type[] = 'video/mpeg'; $extension[] = '.mpg';
838
+        $mime_type[] = 'video/mpeg4-generic'; $extension[] = '.mp4';
839
+        $mime_type[] = 'video/quicktime'; $extension[] = '.mov';
840
+        $mime_type[] = 'video/x-msvideo'; $extension[] = '.avi';
841
+
842
+        $mime_type[] = 'video/x-ms-wmv'; $extension[] = '.wmv';
843
+        $mime_type[] = 'video/x-flv'; $extension[] = '.flv';
844
+        $mime_type[] = 'image/svg+xml'; $extension[] = '.svg';
845
+        $mime_type[] = 'image/svg+xml'; $extension[] = '.svgz';
846
+        $mime_type[] = 'video/ogg'; $extension[] = '.ogv';
847
+        $mime_type[] = 'audio/ogg'; $extension[] = '.oga';
848
+        $mime_type[] = 'application/ogg'; $extension[] = '.ogg';
849
+        $mime_type[] = 'application/ogg'; $extension[] = '.ogx';
850
+        $mime_type[] = 'application/x-freemind'; $extension[] = '.mm';
851
+
852
+        $mime_type[] = 'application/vnd.ms-word.document.macroEnabled.12'; $extension[] = '.docm';
853
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; $extension[] = '.docx';
854
+        $mime_type[] = 'application/vnd.ms-word.template.macroEnabled.12'; $extension[] = '.dotm';
855
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'; $extension[] = '.dotx';
856
+        $mime_type[] = 'application/vnd.ms-powerpoint.template.macroEnabled.12'; $extension[] = '.potm';
857
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.template'; $extension[] = '.potx';
858
+        $mime_type[] = 'application/vnd.ms-powerpoint.addin.macroEnabled.12'; $extension[] = '.ppam';
859
+        $mime_type[] = 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12'; $extension[] = '.ppsm';
860
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'; $extension[] = '.ppsx';
861
+        $mime_type[] = 'application/vnd.ms-powerpoint.presentation.macroEnabled.12'; $extension[] = '.pptm';
862
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; $extension[] = '.pptx';
863
+        $mime_type[] = 'application/vnd.ms-excel.addin.macroEnabled.12'; $extension[] = '.xlam';
864
+        $mime_type[] = 'application/vnd.ms-excel.sheet.binary.macroEnabled.12'; $extension[] = '.xlsb';
865
+        $mime_type[] = 'application/vnd.ms-excel.sheet.macroEnabled.12'; $extension[] = '.xlsm';
866
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $extension[] = '.xlsx';
867
+        $mime_type[] = 'application/vnd.ms-excel.template.macroEnabled.12'; $extension[] = '.xltm';
868
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'; $extension[] = '.xltx';
869 869
 
870 870
         // Test on PC (files with no extension get application/octet-stream)
871 871
         //$mime_type[] = 'application/octet-stream';      $extension[] = '.ext';
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 
875 875
         foreach ($mime_type as $key => & $type) {
876 876
             if ($type == $file_type) {
877
-                $file_name .=  $extension[$key];
877
+                $file_name .= $extension[$key];
878 878
                 break;
879 879
             }
880 880
         }
@@ -982,12 +982,12 @@  discard block
 block discarded – undo
982 982
         }
983 983
 
984 984
         // It happens on Linux that $upload_path sometimes doesn't start with '/'
985
-        if ($upload_path[0] != '/' && substr($base_work_dir,-1,1) != '/') {
985
+        if ($upload_path[0] != '/' && substr($base_work_dir, -1, 1) != '/') {
986 986
             $upload_path = '/'.$upload_path;
987 987
         }
988 988
 
989 989
         if ($upload_path[strlen($upload_path) - 1] == '/') {
990
-            $upload_path=substr($upload_path, 0, -1);
990
+            $upload_path = substr($upload_path, 0, -1);
991 991
         }
992 992
 
993 993
         /*	Uncompressing phase */
@@ -999,15 +999,15 @@  discard block
 block discarded – undo
999 999
             - add it to the database
1000 1000
             - parse & change relative html links
1001 1001
         */
1002
-        if (PHP_OS == 'Linux' && ! get_cfg_var('safe_mode') && false) { // *** UGent, changed by OC ***
1002
+        if (PHP_OS == 'Linux' && !get_cfg_var('safe_mode') && false) { // *** UGent, changed by OC ***
1003 1003
             // Shell Method - if this is possible, it gains some speed
1004
-            exec("unzip -d \"".$base_work_dir.$upload_path."/\"".$uploaded_file['name']." " .$uploaded_file['tmp_name']);
1004
+            exec("unzip -d \"".$base_work_dir.$upload_path."/\"".$uploaded_file['name']." ".$uploaded_file['tmp_name']);
1005 1005
         } else {
1006 1006
             // PHP method - slower...
1007 1007
             $save_dir = getcwd();
1008 1008
             chdir($base_work_dir.$upload_path);
1009 1009
             $unzippingState = $zip_file->extract();
1010
-            for ($j=0; $j < count($unzippingState); $j++) {
1010
+            for ($j = 0; $j < count($unzippingState); $j++) {
1011 1011
                 $state = $unzippingState[$j];
1012 1012
 
1013 1013
                 // Fix relative links in html files
@@ -1021,8 +1021,8 @@  discard block
 block discarded – undo
1021 1021
                         if (is_dir($base_work_dir.$upload_path.'/'.$file)) $filetype = 'folder';
1022 1022
 
1023 1023
                         $safe_file = api_replace_dangerous_char($file, 'strict');
1024
-                        @rename($base_work_dir.$upload_path.'/'.$file,$base_work_dir.$upload_path.'/'.$safe_file);
1025
-                        set_default_settings($upload_path, $safe_file,$filetype);
1024
+                        @rename($base_work_dir.$upload_path.'/'.$file, $base_work_dir.$upload_path.'/'.$safe_file);
1025
+                        set_default_settings($upload_path, $safe_file, $filetype);
1026 1026
                     }
1027 1027
                 }
1028 1028
 
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
     $zip = new PclZip($uploaded_file['tmp_name']);
1073 1073
 
1074 1074
     // Check the zip content (real size and file extension)
1075
-    $zip_content_array = (array)$zip->listContent();
1075
+    $zip_content_array = (array) $zip->listContent();
1076 1076
 
1077 1077
     $realSize = 0;
1078 1078
     foreach ($zip_content_array as & $this_content) {
@@ -1173,7 +1173,7 @@  discard block
 block discarded – undo
1173 1173
 function filter_extension(&$filename)
1174 1174
 {
1175 1175
     if (substr($filename, -1) == '/') {
1176
-        return 1;  // Authorize directories
1176
+        return 1; // Authorize directories
1177 1177
     }
1178 1178
     $blacklist = api_get_setting('upload_extensions_list_type');
1179 1179
     if ($blacklist != 'whitelist') { // if = blacklist
@@ -1399,9 +1399,9 @@  discard block
 block discarded – undo
1399 1399
     $upload_path = str_replace('//', '/', $upload_path);
1400 1400
 
1401 1401
     if ($upload_path == '/') {
1402
-        $upload_path='';
1402
+        $upload_path = '';
1403 1403
     } elseif (!empty($upload_path) && $upload_path[0] != '/') {
1404
-        $upload_path="/$upload_path";
1404
+        $upload_path = "/$upload_path";
1405 1405
     }
1406 1406
 
1407 1407
     $endchar = substr($filename, strlen($filename) - 1, 1);
@@ -1439,7 +1439,7 @@  discard block
 block discarded – undo
1439 1439
     $img_path_list = array();
1440 1440
 
1441 1441
     if (!$fp = fopen($html_file, 'r')) {
1442
-        return ;
1442
+        return;
1443 1443
     }
1444 1444
 
1445 1445
     // Aearch and store occurences of the <img> tag in an array
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
         $img_tag_list = $matches[0];
1460 1460
     }
1461 1461
 
1462
-    fclose ($fp);
1462
+    fclose($fp);
1463 1463
     unset($buffer);
1464 1464
 
1465 1465
     // Search the image file path from all the <IMG> tag detected
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
 
1560 1560
     if (!is_dir($base_work_dir.$systemFolderName)) {
1561 1561
         $result = mkdir(
1562
-            $base_work_dir . $systemFolderName,
1562
+            $base_work_dir.$systemFolderName,
1563 1563
             api_get_permissions_for_new_directories(),
1564 1564
             true
1565 1565
         );
@@ -1572,7 +1572,7 @@  discard block
 block discarded – undo
1572 1572
                     WHERE
1573 1573
                         c_id = $course_id AND
1574 1574
                         (
1575
-                            path = '" . $systemFolderName . "'
1575
+                            path = '".$systemFolderName."'
1576 1576
                         )
1577 1577
             ";
1578 1578
 
@@ -1725,7 +1725,7 @@  discard block
 block discarded – undo
1725 1725
 
1726 1726
     // Fix the image tags
1727 1727
 
1728
-    for ($i = 0, $fileNb = count($original_img_path); $i < $fileNb ; $i++) {
1728
+    for ($i = 0, $fileNb = count($original_img_path); $i < $fileNb; $i++) {
1729 1729
         $replace_what = $original_img_path[$i];
1730 1730
         // We only need the directory and the filename /path/to/file_html_files/missing_file.gif -> file_html_files/missing_file.gif
1731 1731
         $exploded_file_path = explode('/', $new_img_path[$i]);
@@ -1766,7 +1766,7 @@  discard block
 block discarded – undo
1766 1766
         .'</body>'
1767 1767
         .'</html>';
1768 1768
     if (file_exists($file_path)) {
1769
-        if (!($fp = fopen ($file_path, 'w'))) {
1769
+        if (!($fp = fopen($file_path, 'w'))) {
1770 1770
             return false;
1771 1771
         }
1772 1772
         return fwrite($fp, $file_content);
@@ -1786,7 +1786,7 @@  discard block
 block discarded – undo
1786 1786
     // Open the file
1787 1787
     if (file_exists($full_file_name)) {
1788 1788
         $fp = fopen($full_file_name, 'r');
1789
-        $buffer = fread ($fp, filesize ($full_file_name));
1789
+        $buffer = fread($fp, filesize($full_file_name));
1790 1790
 
1791 1791
         // Parse the contents
1792 1792
         $new_html_content = api_replace_links_in_string($upload_path, $buffer);
@@ -1929,7 +1929,7 @@  discard block
 block discarded – undo
1929 1929
 
1930 1930
         foreach ($tag_list as & $this_tag) {
1931 1931
             //Display::display_normal_message(htmlentities($this_tag)); //debug
1932
-            if ( preg_match("~".$param_name."[\s]*=[\s]*[\"]{1}([^\"]+)[\"]{1}~i", $this_tag, $matches)) {
1932
+            if (preg_match("~".$param_name."[\s]*=[\s]*[\"]{1}([^\"]+)[\"]{1}~i", $this_tag, $matches)) {
1933 1933
                 $file_path_list[] = $matches[1]; // older
1934 1934
                 $href_list[] = $matches[0]; // to also add target="_self"
1935 1935
             }
@@ -1950,9 +1950,9 @@  discard block
 block discarded – undo
1950 1950
 
1951 1951
                 // Fix the link to use download.php or showinframes.php
1952 1952
                 if (preg_match("/<a([\s]*[\"\/:'=a-z0-9]*){5}href[^<]*>/i", $tag_list[$count])) {
1953
-                    $replace_by[$count] = " $param_name =\"showinframes.php?file=" . $upload_path.$file_path_list[$count]."\" target=\"_self\" ";
1953
+                    $replace_by[$count] = " $param_name =\"showinframes.php?file=".$upload_path.$file_path_list[$count]."\" target=\"_self\" ";
1954 1954
                 } else {
1955
-                    $replace_by[$count] = " $param_name =\"download.php?doc_url=" . $upload_path.$file_path_list[$count]."\" ";
1955
+                    $replace_by[$count] = " $param_name =\"download.php?doc_url=".$upload_path.$file_path_list[$count]."\" ";
1956 1956
                 }
1957 1957
             } else {
1958 1958
                 // "mailto" or url already fixed, leave as is
@@ -1961,7 +1961,7 @@  discard block
 block discarded – undo
1961 1961
             }
1962 1962
         } elseif ($is_absolute_hyperlink) {
1963 1963
             //$message .= "Absolute hyperlink, don't change, add target=_self: ";
1964
-            $replace_by[$count] = " $param_name=\"" . $file_path_list[$count] . "\" target =\"_self\"";
1964
+            $replace_by[$count] = " $param_name=\"".$file_path_list[$count]."\" target =\"_self\"";
1965 1965
         } else {
1966 1966
             // Don't change anything
1967 1967
             //$message .= "Local anchor, don't change: ";
@@ -2006,7 +2006,7 @@  discard block
 block discarded – undo
2006 2006
 {
2007 2007
     // Do we need a / or not?
2008 2008
     $added_slash = ($upload_path == '/') ? '' : '/';
2009
-    $folder_id      = DocumentManager::get_document_id(api_get_course_info(), $upload_path);
2009
+    $folder_id = DocumentManager::get_document_id(api_get_course_info(), $upload_path);
2010 2010
     // Build the form
2011 2011
     $form = "<p><strong>".get_lang('MissingImagesDetected')."</strong></p>"
2012 2012
         ."<form method=\"post\" action=\"".api_get_self()."\" enctype=\"multipart/form-data\">"
Please login to merge, or discard this patch.
main/inc/lib/MoodleImport.lib.php 2 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
      * Read and validate the quiz module XML
317 317
      *
318 318
      * @param resource $moduleXml XML file
319
-     * @return mixed | array if is a valid xml file, false otherwise
319
+     * @return string | array if is a valid xml file, false otherwise
320 320
      */
321 321
     public function readQuizModule($moduleXml)
322 322
     {
@@ -535,9 +535,9 @@  discard block
 block discarded – undo
535 535
      *
536 536
      * @param array $questionList
537 537
      * @param string $questionType
538
-     * @param object $questionInstance Question/Answer instance
538
+     * @param Question $questionInstance Question/Answer instance
539 539
      * @param array $currentQuestion
540
-     * @return integer db response
540
+     * @return boolean|null db response
541 541
      */
542 542
     public function processAnswers($questionList, $questionType, $questionInstance, $currentQuestion)
543 543
     {
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
     /**
621 621
      * Process Chamilo Unique Answer
622 622
      *
623
-     * @param object $objAnswer
623
+     * @param Answer $objAnswer
624 624
      * @param array $answerValues
625 625
      * @param integer $position
626 626
      * @param integer $questionWeighting
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
     /**
654 654
      * Process Chamilo FillBlanks
655 655
      *
656
-     * @param object $objAnswer
656
+     * @param Answer $objAnswer
657 657
      * @param array $question
658 658
      * @param array $answerValues
659 659
      * @param string $placeholder
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
      * Litle utility to delete the unuseful tags
717 717
      *
718 718
      * @param $array
719
-     * @param $keys
719
+     * @param string[] $keys
720 720
      */
721 721
     public function traverseArray(&$array, $keys) {
722 722
         foreach ($array as $key => &$value) {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
         if ($weighting > 0) {
637 637
             $questionWeighting += $weighting;
638 638
         }
639
-        $goodAnswer =  $correct ? true : false;
639
+        $goodAnswer = $correct ? true : false;
640 640
 
641 641
         $objAnswer->createAnswer(
642 642
             $answer,
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
             if (is_array($value)) {
724 724
                 $this->traverseArray($value, $keys);
725 725
             } else {
726
-                if (in_array($key, $keys)){
726
+                if (in_array($key, $keys)) {
727 727
                     unset($array[$key]);
728 728
                 }
729 729
             }
Please login to merge, or discard this patch.