@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * Read and validate the quiz module XML |
| 300 | 300 | * |
| 301 | 301 | * @param resource $moduleXml XML file |
| 302 | - * @return mixed | array if is a valid xml file, false otherwise |
|
| 302 | + * @return string | array if is a valid xml file, false otherwise |
|
| 303 | 303 | */ |
| 304 | 304 | public function readQuizModule($moduleXml) |
| 305 | 305 | { |
@@ -514,8 +514,8 @@ discard block |
||
| 514 | 514 | /** |
| 515 | 515 | * Process Chamilo Unique Answer |
| 516 | 516 | * |
| 517 | - * @param object $objAnswer |
|
| 518 | - * @param object $questionInstance |
|
| 517 | + * @param Answer $objAnswer |
|
| 518 | + * @param Question $questionInstance |
|
| 519 | 519 | * @param array $answerValues |
| 520 | 520 | * @param integer $position |
| 521 | 521 | * @return integer db response |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | * Litle utility to delete the unuseful tags |
| 558 | 558 | * |
| 559 | 559 | * @param $array |
| 560 | - * @param $keys |
|
| 560 | + * @param string[] $keys |
|
| 561 | 561 | */ |
| 562 | 562 | public function traverseArray(&$array, $keys) { |
| 563 | 563 | foreach ($array as $key => &$value) { |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | if ($activity->childNodes->length) { |
| 58 | 58 | $currentItem = []; |
| 59 | 59 | |
| 60 | - foreach($activity->childNodes as $item) { |
|
| 60 | + foreach ($activity->childNodes as $item) { |
|
| 61 | 61 | $currentItem[$item->nodeName] = $item->nodeValue; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $documentPath = $coursePath.'document/'; |
| 162 | 162 | $currentResourceFilePath = $destinationDir.'/files/'; |
| 163 | 163 | $dirs = new RecursiveDirectoryIterator($currentResourceFilePath); |
| 164 | - foreach(new RecursiveIteratorIterator($dirs) as $file) { |
|
| 164 | + foreach (new RecursiveIteratorIterator($dirs) as $file) { |
|
| 165 | 165 | if (is_file($file) && strpos($file, $fileInfo['contenthash']) !== false) { |
| 166 | 166 | $files = []; |
| 167 | 167 | $files['file']['name'] = $fileInfo['filename']; |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | $currentItem = []; |
| 256 | 256 | foreach ($activities as $activity) { |
| 257 | 257 | if ($activity->childNodes->length) { |
| 258 | - foreach($activity->childNodes as $item) { |
|
| 258 | + foreach ($activity->childNodes as $item) { |
|
| 259 | 259 | $currentItem[$item->nodeName] = $item->nodeValue; |
| 260 | 260 | } |
| 261 | 261 | } |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | foreach ($activities as $activity) { |
| 354 | 354 | if ($activity->childNodes->length) { |
| 355 | 355 | $isThisItemThatIWant = false; |
| 356 | - foreach($activity->childNodes as $item) { |
|
| 356 | + foreach ($activity->childNodes as $item) { |
|
| 357 | 357 | if (!$isThisItemThatIWant && $item->nodeName == 'contenthash') { |
| 358 | 358 | $currentItem['contenthash'] = $item->nodeValue; |
| 359 | 359 | } |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | if ($question->childNodes->length) { |
| 408 | 408 | $currentItem['questionid'] = $questionId; |
| 409 | 409 | $questionType = ''; |
| 410 | - foreach($question->childNodes as $item) { |
|
| 410 | + foreach ($question->childNodes as $item) { |
|
| 411 | 411 | $currentItem[$item->nodeName] = $item->nodeValue; |
| 412 | 412 | if ($item->nodeName == 'qtype') { |
| 413 | 413 | $questionType = $item->nodeValue; |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | if ($weighting > 0) { |
| 532 | 532 | $questionWeighting += $weighting; |
| 533 | 533 | } |
| 534 | - $goodAnswer = $correct ? true : false; |
|
| 534 | + $goodAnswer = $correct ? true : false; |
|
| 535 | 535 | |
| 536 | 536 | $objAnswer->createAnswer( |
| 537 | 537 | $answer, |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | if (is_array($value)) { |
| 565 | 565 | $this->traverseArray($value, $keys); |
| 566 | 566 | } else { |
| 567 | - if (in_array($key, $keys)){ |
|
| 567 | + if (in_array($key, $keys)) { |
|
| 568 | 568 | unset($array[$key]); |
| 569 | 569 | } |
| 570 | 570 | } |
@@ -63,10 +63,10 @@ discard block |
||
| 63 | 63 | $name_no_ext = substr($name, 0, strlen($name) - strlen(strstr($name, $ext))); |
| 64 | 64 | $n = 0; |
| 65 | 65 | $unique = ''; |
| 66 | - while (file_exists($path . $name_no_ext . $unique . $ext)) { |
|
| 67 | - $unique = '_' . ++$n; |
|
| 66 | + while (file_exists($path.$name_no_ext.$unique.$ext)) { |
|
| 67 | + $unique = '_'.++$n; |
|
| 68 | 68 | } |
| 69 | - return $name_no_ext . $unique . $ext; |
|
| 69 | + return $name_no_ext.$unique.$ext; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | // Not used at the moment, but could be handy if we want to limit the size of an upload (e.g. image upload in html editor). |
| 106 | 106 | $max_file_size = intval($_POST['MAX_FILE_SIZE']); |
| 107 | 107 | if ($show_output) { |
| 108 | - Display::display_error_message(get_lang('UplExceedMaxPostSize'). format_file_size($max_file_size)); |
|
| 108 | + Display::display_error_message(get_lang('UplExceedMaxPostSize').format_file_size($max_file_size)); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | return false; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | case 4: |
| 120 | 120 | // No file was uploaded. |
| 121 | 121 | if ($show_output) { |
| 122 | - Display::display_error_message(get_lang('UplNoFileUploaded').' '. get_lang('UplSelectFileFirst')); |
|
| 122 | + Display::display_error_message(get_lang('UplNoFileUploaded').' '.get_lang('UplSelectFileFirst')); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | return false; |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | // Display success message with extra info to user |
| 460 | 460 | if ($output) { |
| 461 | 461 | Display::display_confirmation_message( |
| 462 | - get_lang('UplUploadSucceeded') . '<br /> ' . $documentTitle . ' ' . get_lang('UplFileOverwritten'), |
|
| 462 | + get_lang('UplUploadSucceeded').'<br /> '.$documentTitle.' '.get_lang('UplFileOverwritten'), |
|
| 463 | 463 | false |
| 464 | 464 | ); |
| 465 | 465 | } |
@@ -585,14 +585,14 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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\">" |