Beispiel #1
0
        /**
         * Prepare the temporary destination directory that'll be zipped and exported.
         * Existing SCORM, documents, as well as required or helper javascript files and XML schemas
         * are copied into the directory.
         * No manifest created yet.
         *
         * @return False on error, true otherwise.
         * @see createManifest
         * @author Thanos Kyritsis <*****@*****.**>
         * @author Amand Tihon <*****@*****.**>
         */
        function prepare() {
            global $clarolineRepositorySys, $claro_stylesheet;
            global $langErrorCopyScormFiles, $langErrorCreatingDirectory, $langErrorCopyingScorm, $langErrorCopyAttachedFile;
            // (re)create fresh directory

            claro_delete_file($this->destDir);
            if (
                    !claro_mkdir($this->destDir, CLARO_FILE_PERMISSIONS, true) || !claro_mkdir($this->destDir . "/common", CLARO_FILE_PERMISSIONS, true) || !claro_mkdir($this->destDir . "/extend", CLARO_FILE_PERMISSIONS, true) || !claro_mkdir($this->destDir . "/unique", CLARO_FILE_PERMISSIONS, true) || !claro_mkdir($this->destDir . "/vocab", CLARO_FILE_PERMISSIONS, true)
            ) {
                $this->error[] = $langErrorCreatingDirectory . $this->destDir;
                return false;
            }

            // Copy usual files (.css, .js, .xsd, etc)
            if (
                    !claro_copy_file('modules/learnPath/export/APIWrapper.js', $this->destDir) || !claro_copy_file('template/default/CSS/bootstrap-custom.css', $this->destDir) || !claro_copy_file('modules/learnPath/export/XMLSchema.dtd', $this->destDir) || !claro_copy_file('modules/learnPath/export/adlcp_v1p3.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/adlnav_v1p3.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/adlseq_v1p3.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/datatypes.dtd', $this->destDir) || !claro_copy_file('modules/learnPath/export/ims_xml.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/imscp_v1p1.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/imsss_v1p0.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/imsss_v1p0auxresource.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/imsss_v1p0control.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/imsss_v1p0delivery.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/imsss_v1p0limit.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/imsss_v1p0objective.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/imsss_v1p0random.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/imsss_v1p0rollup.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/imsss_v1p0seqrule.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/imsss_v1p0util.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/lom.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/lomCustom.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/lomLoose.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/lomStrict.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/scores.js', $this->destDir) || !claro_copy_file('modules/learnPath/export/xml.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export/common/anyElement.xsd', $this->destDir . "/common") || !claro_copy_file('modules/learnPath/export/common/dataTypes.xsd', $this->destDir . "/common") || !claro_copy_file('modules/learnPath/export/common/elementNames.xsd', $this->destDir . "/common") || !claro_copy_file('modules/learnPath/export/common/elementTypes.xsd', $this->destDir . "/common") || !claro_copy_file('modules/learnPath/export/common/rootElement.xsd', $this->destDir . "/common") || !claro_copy_file('modules/learnPath/export/common/vocabTypes.xsd', $this->destDir . "/common") || !claro_copy_file('modules/learnPath/export/common/vocabValues.xsd', $this->destDir . "/common") || !claro_copy_file('modules/learnPath/export/extend/custom.xsd', $this->destDir . "/extend") || !claro_copy_file('modules/learnPath/export/extend/strict.xsd', $this->destDir . "/extend") || !claro_copy_file('modules/learnPath/export/unique/loose.xsd', $this->destDir . "/unique") || !claro_copy_file('modules/learnPath/export/unique/strict.xsd', $this->destDir . "/unique") || !claro_copy_file('modules/learnPath/export/vocab/custom.xsd', $this->destDir . "/vocab") || !claro_copy_file('modules/learnPath/export/vocab/loose.xsd', $this->destDir . "/vocab") || !claro_copy_file('modules/learnPath/export/vocab/strict.xsd', $this->destDir . "/vocab")
            ) {
                $this->error[] = $langErrorCopyScormFiles;
                return false;
            }


            // Copy SCORM package, if needed
            if ($this->fromScorm) {
                // Copy the scorm directory as OrigScorm/
                if (
                        !claro_copy_file($this->srcDirScorm, $this->destDir) || !claro_rename_file($this->destDir . '/path_' . $this->id, $this->destDir . '/OrigScorm')) {
                    $this->error[] = $langErrorCopyingScorm;
                    return false;
                }
            }

            // Create destination directory for "pure" documents
            claro_mkdir($this->destDir . '/Documents', CLARO_FILE_PERMISSIONS, true);

            // And for exercises
            claro_mkdir($this->destDir . '/Exercises', CLARO_FILE_PERMISSIONS, true);

            // Copy documents into the created directory
            foreach ($this->resourceMap as $module) {
                if ($module['contentType'] == 'DOCUMENT') {
                    $documentName = basename($module['path']);
                    if (dirname($module['path']) != '/') {
                        $destinationDir = $this->destDir . '/Documents' . dirname($module['path']) . '/';
                    } else {
                        $destinationDir = $this->destDir . '/Documents/';
                    }
                    if (!is_dir($destinationDir)) {
                        claro_mkdir($destinationDir, CLARO_FILE_PERMISSIONS, true);
                    }
                    @copy($this->srcDirDocument . $module['path'], $destinationDir . $documentName);
                } elseif ($module['contentType'] == 'EXERCISE') {
                    if (!$this->prepareQuiz($module['path'], $module['raw_to_pass']))
                        return false;
                }
                elseif ($module['contentType'] == 'MEDIA') {
                    $documentName = basename($module['path']);
                    $destinationDir = $this->destDir . '/Documents/';
                    if (!is_dir($destinationDir)) {
                        claro_mkdir($destinationDir, CLARO_FILE_PERMISSIONS, true);
                    }
                    @copy($this->srcDirVideo . $module['path'], $destinationDir . $documentName);
                }
            }

            // Did we find an mp3 ?
            /* if ( $this->mp3Found)
              {
              if ( !claro_copy_file($clarolineRepositorySys . '/exercise/claroPlayer.swf', $this->destDir) )
              {
              $this->error[] = $langErrorCopyAttachedFile . $clarolineRepositorySys . '/exercise/claroPlayer.swf';

              // This is *NOT* a fatal error.
              // Do *NOT* return false.
              }
              } */


            return true;
        }
Beispiel #2
0
         create_link_file($baseWorkDir . $_REQUEST['file'], $url);
     }
 }
 $directoryName = dirname($_REQUEST['file']);
 if ($directoryName == '/' || $directoryName == '\\') {
     // When the dir is root, PHP dirname leaves a '\' for windows or a '/' for Unix
     $directoryName = '';
 }
 $_REQUEST['newName'] = secure_file_path(trim($_REQUEST['newName']));
 if (!empty($_REQUEST['newName'])) {
     $newPath = $directoryName . '/' . $_REQUEST['newName'];
 } else {
     $newPath = secure_file_path($_REQUEST['file']);
 }
 $oldPath = secure_file_path($_REQUEST['file']);
 $newPath = claro_rename_file($baseWorkDir . $oldPath, $baseWorkDir . $newPath);
 if ($newPath) {
     $newPath = substr($newPath, strlen($baseWorkDir));
     $dialogBox->success(get_lang('Element renamed'));
     if ($courseContext) {
         $newComment = trim($_REQUEST['newComment']);
         // remove spaces
         update_db_info('update', $_REQUEST['file'], array('path' => $newPath, 'comment' => $newComment));
         update_Doc_Path_in_Assets('update', $_REQUEST['file'], $newPath);
         if (!empty($newComment)) {
             $dialogBox->success(get_lang('Comment modified'));
         }
     }
     $ressource['old_uri'] = str_replace('..', '', $_REQUEST['file']);
     $ressource['new_uri'] = $newPath;
     $eventNotifier->notifyCourseEvent('document_file_modified', claro_get_current_course_id(), claro_get_current_tool_id(), $ressource, claro_get_current_group_id(), "0");
        /**
         * Prepare the temporary destination directory that'll be zipped and exported.
         * Existing SCORM, documents, as well as required or helper javascript files and XML schemas
         * are copied into the directory.
         * No manifest created yet.
         *
         * @return False on error, true otherwise.
         * @see createManifest
         * @author Thanos Kyritsis <*****@*****.**>
         * @author Amand Tihon <*****@*****.**>
         */
        function prepare() {
            global $clarolineRepositorySys, $claro_stylesheet;
            global $langErrorCopyScormFiles, $langErrorCreatingDirectory, $langErrorCopyingScorm, $langErrorCopyAttachedFile;

            // (re)create fresh directory
            claro_delete_file($this->destDir);
            if (!claro_mkdir($this->destDir, CLARO_FILE_PERMISSIONS, true)) {
                $this->error[] = $langErrorCreatingDirectory . $this->destDir;
                return false;
            }
            // Copy usual files (.css, .js, .xsd, etc)
            if (
                    !claro_copy_file('modules/learnPath/export12/APIWrapper.js', $this->destDir) || !claro_copy_file('template/default/CSS/bootstrap-custom.css', $this->destDir) || !claro_copy_file('modules/learnPath/export12/scores.js', $this->destDir) || !claro_copy_file('modules/learnPath/export12/ims_xml.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export12/imscp_rootv1p1p2.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export12/imsmd_rootv1p2p1.xsd', $this->destDir) || !claro_copy_file('modules/learnPath/export12/adlcp_rootv1p2.xsd', $this->destDir)) {
                $this->error[] = $langErrorCopyScormFiles;
                return false;
            }


            // Copy SCORM package, if needed
            if ($this->fromScorm) {
                // Copy the scorm directory as OrigScorm/
                if (
                        !claro_copy_file($this->srcDirScorm, $this->destDir) || !claro_rename_file($this->destDir . '/path_' . $this->id, $this->destDir . '/OrigScorm')) {
                    $this->error[] = $langErrorCopyingScorm;
                    return false;
                }
            }

            // Create destination directory for "pure" documents
            claro_mkdir($this->destDir . '/Documents', CLARO_FILE_PERMISSIONS, true);

            // And for exercises
            claro_mkdir($this->destDir . '/Exercises', CLARO_FILE_PERMISSIONS, true);

            // Copy documents into the created directory
            foreach ($this->resourceMap as $module) {
                if ($module['contentType'] == 'DOCUMENT') {
                    $documentName = basename($module['path']);
                    if (dirname($module['path']) != '/') {
                        $destinationDir = $this->destDir . '/Documents' . dirname($module['path']) . '/';
                    } else {
                        $destinationDir = $this->destDir . '/Documents/';
                    }
                    if (!is_dir($destinationDir)) {
                        claro_mkdir($destinationDir, CLARO_FILE_PERMISSIONS, true);
                    }
                    @copy($this->srcDirDocument . $module['path'], $destinationDir . $documentName);
                } elseif ($module['contentType'] == 'EXERCISE') {
                    if (!$this->prepareQuiz($module['path'], $module['raw_to_pass'])) {
                        return false;
                    }
                }
                elseif ($module['contentType'] == 'MEDIA') {
                    $documentName = basename($module['path']);
                    $destinationDir = $this->destDir . '/Documents/';
                    if (!is_dir($destinationDir)) {
                        claro_mkdir($destinationDir, CLARO_FILE_PERMISSIONS, true);
                    }
                    @copy($this->srcDirVideo . $module['path'], $destinationDir . $documentName);
                }
            }

            // Did we find an mp3 ?
            if ($this->mp3Found) {
                if (!claro_copy_file($clarolineRepositorySys . '/exercise/claroPlayer.swf', $this->destDir)) {
                    $this->error[] = $langErrorCopyAttachedFile . $clarolineRepositorySys . '/exercise/claroPlayer.swf';

                    // This is *NOT* a fatal error.
                    // Do *NOT* return false.
                }
            }


            return true;
        }
Beispiel #4
0
 /**
  * Prepare the temporary destination directory that'll be zipped and exported.
  * Existing SCORM, documents, as well as required or helper javascript files and XML schemas
  * are copied into the directory.
  * No manifest created yet.
  *
  * @return False on error, true otherwise.
  * @see createManifest
  * @author Amand Tihon <*****@*****.**>
  */
 public function prepare()
 {
     global $claro_stylesheet;
     // (re)create fresh directory
     claro_delete_file($this->destDir);
     if (!claro_mkdir($this->destDir, CLARO_FILE_PERMISSIONS, true)) {
         $this->error[] = get_lang('Unable to create directory : ') . $this->destDir;
         return false;
     }
     // Copy SCORM package, if needed
     if ($this->fromScorm && file_exists($this->srcDirScorm)) {
         // Copy the scorm directory as OrigScorm/
         if (!claro_copy_file($this->srcDirScorm, $this->destDir) || !claro_rename_file($this->destDir . '/path_' . $this->id, $this->destDir . '/OrigScorm')) {
             $this->error[] = get_lang('Error copying existing SCORM content');
             return false;
         } else {
             return true;
         }
     }
     // Check css to use
     if (file_exists(get_path('clarolineRepositorySys') . '../platform/css/' . $claro_stylesheet)) {
         $claro_stylesheet_path = get_path('clarolineRepositorySys') . '../platform/css/' . $claro_stylesheet;
     } elseif (file_exists(get_path('clarolineRepositorySys') . '../web/css/' . $claro_stylesheet)) {
         $claro_stylesheet_path = get_path('clarolineRepositorySys') . '../web/css/' . $claro_stylesheet;
     }
     // Copy usual files (.css, .js, .xsd, etc)
     if (!claro_copy_file($claro_stylesheet_path, $this->destDir) || !claro_copy_file(dirname(__FILE__) . '/../export/APIWrapper.js', $this->destDir) || !claro_copy_file(dirname(__FILE__) . '/../export/scores.js', $this->destDir) || !claro_copy_file(dirname(__FILE__) . '/../export/ims_xml.xsd', $this->destDir) || !claro_copy_file(dirname(__FILE__) . '/../export/imscp_rootv1p1p2.xsd', $this->destDir) || !claro_copy_file(dirname(__FILE__) . '/../export/imsmd_rootv1p2p1.xsd', $this->destDir) || !claro_copy_file(dirname(__FILE__) . '/../export/adlcp_rootv1p2.xsd', $this->destDir) || !claro_copy_file(get_path('clarolineRepositorySys') . '../web/js/jquery.js', $this->destDir) || !claro_copy_file(get_path('clarolineRepositorySys') . '../web/js/claroline.js', $this->destDir) || !claro_copy_file(get_path('clarolineRepositorySys') . '../web/js/claroline.ui.js', $this->destDir)) {
         $this->error[] = get_lang('Error when copying needed SCORM files');
         return false;
     }
     // Copy SCORM package, if needed
     if ($this->fromScorm && file_exists($this->srcDirScorm)) {
         // Copy the scorm directory as OrigScorm/
         if (!claro_copy_file($this->srcDirScorm, $this->destDir) || !claro_rename_file($this->destDir . '/path_' . $this->id, $this->destDir . '/OrigScorm')) {
             $this->error[] = get_lang('Error copying existing SCORM content');
             return false;
         }
     }
     // Create destination directory for "pure" documents
     claro_mkdir($this->destDir . '/Documents');
     // And for exercises
     claro_mkdir($this->destDir . '/Exercises');
     // Copy documents into the created directory
     foreach ($this->resourceMap as $module) {
         if ($module['contentType'] == 'DOCUMENT') {
             if (dirname($module['path']) != '/') {
                 $destinationDir = $this->destDir . '/Documents' . dirname($module['path']);
             } else {
                 $destinationDir = $this->destDir . '/Documents';
             }
             if (!is_dir($destinationDir)) {
                 claro_mkdir($destinationDir, CLARO_FILE_PERMISSIONS, true);
             }
             if (!empty($module['path'])) {
                 claro_copy_file($this->srcDirDocument . $module['path'], $destinationDir);
             }
             // TODO : If it's an html document, parse it and add the embed object (img, ...)
         } elseif ($module['contentType'] == 'EXERCISE') {
             if (!$this->prepareQuiz($module['path'], $module['raw_to_pass'])) {
                 return false;
             }
         }
     }
     // Did we find an mp3 ?
     if ($this->mp3Found) {
         if (!claro_copy_file(get_module_path('CLQWZ') . '/claroPlayer.swf', $this->destDir)) {
             $this->error[] = get_lang('Unable to copy file : %filename', array('%filename' => get_module_path('CLQWZ') . '/claroPlayer.swf'));
             // This is *NOT* a fatal error.
             // Do *NOT* return false.
         }
     }
     return true;
 }