Browse Source

Merge remote-tracking branch 'origin/1.11.x'

jmontoyaa 8 years ago
parent
commit
9fae6f74a5

+ 1 - 1
main/document/document.php

@@ -1736,7 +1736,7 @@ if (!$is_certificate_mode) {
 $table_footer = '';
 $total_size = 0;
 $sortable_data = array();
-
+$row = array();
 if (isset($documentAndFolders) && is_array($documentAndFolders)) {
     if ($groupId == 0 ||
         GroupManager::user_has_access(

+ 5 - 4
main/inc/lib/MoodleImport.php

@@ -627,10 +627,11 @@ class MoodleImport
     {
         if ($importedFiles) {
             foreach ($importedFiles as $old => $new) {
-                $text = str_replace($old, $new, $text);
-                $old = str_replace(' ', '%20', $old);
-                $text = str_replace($old, $new, $text);
-                //$text = utf8_encode($text);
+                // Ofaj fix moodle file names
+                // In some questions moodle text contains file with name like:
+                // Bild%20Check-In-Formular%20Ausfu%CC%88llen.jpg"
+                // rawurlencode function transforms '' (whitespace) to %20 and so on
+                $text = str_replace(rawurlencode($old), $new, $text);
             }
         }
 

+ 2 - 0
main/install/configuration.dist.php

@@ -259,4 +259,6 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
 //$_configuration['sync_db_with_schema'] = false;
 // Load course notifications in user_portal.php using ajax
 //$_configuration['user_portal_load_notification_by_ajax'] = false;
+// When exporting a LP, all files and folders in the same path of an html will be exported too.
+//$_configuration['add_all_files_in_lp_export'] = false;
 

+ 33 - 3
main/lp/learnpath.class.php

@@ -7,6 +7,7 @@ use Chamilo\CourseBundle\Component\CourseCopy\CourseBuilder;
 use Chamilo\CourseBundle\Component\CourseCopy\CourseRestorer;
 use Gedmo\Sortable\Entity\Repository\SortableRepository;
 use Symfony\Component\Filesystem\Filesystem;
+use Symfony\Component\Finder\Finder;
 
 /**
  * Class learnpath
@@ -9170,7 +9171,9 @@ class learnpath
             closedir($handle);
         }
         $zip_files = $zip_files_abs = $zip_files_dist = array();
-        if (is_dir($current_course_path.'/scorm/'.$this->path) && is_file($current_course_path.'/scorm/'.$this->path.'/imsmanifest.xml')) {
+        if (is_dir($current_course_path.'/scorm/'.$this->path) &&
+            is_file($current_course_path.'/scorm/'.$this->path.'/imsmanifest.xml')
+        ) {
             // Remove the possible . at the end of the path.
             $dest_path_to_lp = substr($this->path, -1) == '.' ? substr($this->path, 0, -1) : $this->path;
             $dest_path_to_scorm_folder = str_replace('//','/',$temp_zip_dir.'/scorm/'.$dest_path_to_lp);
@@ -9517,7 +9520,6 @@ class learnpath
                 $resources->appendChild($my_resource);
                 $zip_files[] = $my_file_path;
             } else {
-
                 // If the item is a quiz or a link or whatever non-exportable, we include a step indicating it.
                 switch ($item->type) {
                     case TOOL_LINK:
@@ -9833,21 +9835,26 @@ class learnpath
         $root->appendChild($resources);
         $xmldoc->appendChild($root);
 
+        $copyAll = api_get_configuration_value('add_all_files_in_lp_export');
 
         // TODO: Add a readme file here, with a short description and a link to the Reload player
         // then add the file to the zip, then destroy the file (this is done automatically).
         // http://www.reload.ac.uk/scormplayer.html - once done, don't forget to close FS#138
+
         foreach ($zip_files as $file_path) {
             if (empty($file_path)) {
                 continue;
             }
 
+            $filePath = $sys_course_path.$_course['path'].'/'.$file_path;
             $dest_file = $archive_path.$temp_dir_short.'/'.$file_path;
+
             if (!empty($path_to_remove) && !empty($path_to_replace)) {
                 $dest_file = str_replace($path_to_remove, $path_to_replace, $dest_file);
             }
             $this->create_path($dest_file);
-            @copy($sys_course_path.$_course['path'].'/'.$file_path, $dest_file);
+            @copy($filePath, $dest_file);
+
             // Check if the file needs a link update.
             if (in_array($file_path, array_keys($link_updates))) {
                 $string = file_get_contents($dest_file);
@@ -9880,6 +9887,29 @@ class learnpath
                 }
                 file_put_contents($dest_file, $string);
             }
+
+            if (file_exists($filePath) && $copyAll) {
+                $extension = $this->get_extension($filePath);
+                if (in_array($extension, ['html', 'html'])) {
+                    $containerOrigin = dirname($filePath);
+                    $containerDestination = dirname($dest_file);
+
+                    $finder = new Finder();
+                    $finder->files()->in($containerOrigin)
+                        ->exclude('share_folder')
+                        ->exclude('chat_files')
+                        ->exclude('certificates');
+
+                    if (is_dir($containerOrigin) && is_dir($containerDestination)) {
+                        $fs = new Filesystem();
+                        $fs->mirror(
+                            $containerOrigin,
+                            $containerDestination,
+                            $finder
+                        );
+                    }
+                }
+            }
         }
 
         foreach ($zip_files_abs as $file_path) {