当前位置: 首页>>代码示例>>PHP>>正文


PHP ilUtil::unzip方法代码示例

本文整理汇总了PHP中ilUtil::unzip方法的典型用法代码示例。如果您正苦于以下问题:PHP ilUtil::unzip方法的具体用法?PHP ilUtil::unzip怎么用?PHP ilUtil::unzip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ilUtil的用法示例。


在下文中一共展示了ilUtil::unzip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getXmlRepresentation

 /**
  * Get xml representation
  *
  * @param	string		entity
  * @param	string		target release
  * @param	string		id
  * @return	string		xml string
  */
 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
 {
     $refs = ilObject::_getAllReferences($a_id);
     $svy_ref_id = current($refs);
     include_once './Modules/Survey/classes/class.ilObjSurvey.php';
     $svy = new ilObjSurvey($a_id, false);
     $svy->loadFromDb();
     include_once "./Modules/Survey/classes/class.ilSurveyExport.php";
     $svy_exp = new ilSurveyExport($svy, 'xml');
     $zip = $svy_exp->buildExportFile();
     // Unzip, since survey deletes this dir
     ilUtil::unzip($zip);
     $GLOBALS['ilLog']->write(__METHOD__ . ': Created zip file ' . $zip);
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:22,代码来源:class.ilSurveyExporter.php

示例2: downloadAllDeliveredFiles

 /**
  * Download all submitted files of an assignment (all user)
  *
  * @param	$members		array of user names, key is user id
  */
 function downloadAllDeliveredFiles($a_exc_id, $a_ass_id, $members)
 {
     global $lng, $ilObjDataCache, $ilias;
     include_once "./Services/Utilities/classes/class.ilUtil.php";
     include_once "./Modules/Exercise/classes/class.ilFSStorageExercise.php";
     $storage = new ilFSStorageExercise($a_exc_id, $a_ass_id);
     $storage->create();
     ksort($members);
     //$savepath = $this->getExercisePath() . "/" . $this->obj_id . "/";
     $savepath = $storage->getAbsoluteSubmissionPath();
     $cdir = getcwd();
     // important check: if the directory does not exist
     // ILIAS stays in the current directory (echoing only a warning)
     // and the zip command below archives the whole ILIAS directory
     // (including the data directory) and sends a mega file to the user :-o
     if (!is_dir($savepath)) {
         return;
     }
     // Safe mode fix
     //		chdir($this->getExercisePath());
     chdir($storage->getTempPath());
     $zip = PATH_TO_ZIP;
     // check first, if we have enough free disk space to copy all files to temporary directory
     $tmpdir = ilUtil::ilTempnam();
     ilUtil::makeDir($tmpdir);
     chdir($tmpdir);
     $dirsize = 0;
     foreach ($members as $id => $object) {
         $directory = $savepath . DIRECTORY_SEPARATOR . $id;
         $dirsize += ilUtil::dirsize($directory);
     }
     if ($dirsize > disk_free_space($tmpdir)) {
         return -1;
     }
     $ass_type = self::lookupType($a_ass_id);
     // copy all member directories to the temporary folder
     // switch from id to member name and append the login if the member name is double
     // ensure that no illegal filenames will be created
     // remove timestamp from filename
     $cache = array();
     foreach ($members as $id => $user) {
         $sourcedir = $savepath . DIRECTORY_SEPARATOR . $id;
         if (!is_dir($sourcedir)) {
             continue;
         }
         $userName = ilObjUser::_lookupName($id);
         $directory = ilUtil::getASCIIFilename(trim($userName["lastname"]) . "_" . trim($userName["firstname"]));
         if (array_key_exists($directory, $cache)) {
             // first try is to append the login;
             $directory = ilUtil::getASCIIFilename($directory . "_" . trim(ilObjUser::_lookupLogin($id)));
             if (array_key_exists($directory, $cache)) {
                 // second and secure: append the user id as well.
                 $directory .= "_" . $id;
             }
         }
         $cache[$directory] = $directory;
         ilUtil::makeDir($directory);
         $sourcefiles = scandir($sourcedir);
         foreach ($sourcefiles as $sourcefile) {
             if ($sourcefile == "." || $sourcefile == "..") {
                 continue;
             }
             $targetfile = trim(basename($sourcefile));
             $pos = strpos($targetfile, "_");
             if ($pos !== false) {
                 $targetfile = substr($targetfile, $pos + 1);
             }
             $targetfile = $directory . DIRECTORY_SEPARATOR . $targetfile;
             $sourcefile = $sourcedir . DIRECTORY_SEPARATOR . $sourcefile;
             if (!copy($sourcefile, $targetfile)) {
                 //echo 'Could not copy '.$sourcefile.' to '.$targetfile;
                 $ilias->raiseError('Could not copy ' . basename($sourcefile) . " to '" . $targetfile . "'.", $ilias->error_obj->MESSAGE);
             } else {
                 // preserve time stamp
                 touch($targetfile, filectime($sourcefile));
                 // blogs and portfolios are stored as zip and have to be unzipped
                 if ($ass_type == ilExAssignment::TYPE_PORTFOLIO || $ass_type == ilExAssignment::TYPE_BLOG) {
                     ilUtil::unzip($targetfile);
                     unlink($targetfile);
                 }
             }
         }
     }
     $tmpfile = ilUtil::ilTempnam();
     $tmpzipfile = $tmpfile . ".zip";
     // Safe mode fix
     $zipcmd = $zip . " -r " . ilUtil::escapeShellArg($tmpzipfile) . " .";
     exec($zipcmd);
     ilUtil::delDir($tmpdir);
     $assTitle = ilExAssignment::lookupTitle($a_ass_id);
     chdir($cdir);
     ilUtil::deliverFile($tmpzipfile, (strlen($assTitle) == 0 ? strtolower($lng->txt("exc_assignment")) : $assTitle) . ".zip", "", false, true);
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:98,代码来源:class.ilExAssignment.php

示例3: uploadTstObject

 /**
  * imports test and question(s)
  */
 function uploadTstObject()
 {
     if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK) {
         ilUtil::sendFailure($this->lng->txt("error_upload"));
         $this->createObject();
         return;
     }
     include_once "./Modules/Test/classes/class.ilObjTest.php";
     // create import directory
     $basedir = ilObjTest::_createImportDirectory();
     // copy uploaded file to import directory
     $file = pathinfo($_FILES["xmldoc"]["name"]);
     $full_path = $basedir . "/" . $_FILES["xmldoc"]["name"];
     ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
     // unzip file
     ilUtil::unzip($full_path);
     // determine filenames of xml files
     $subdir = basename($file["basename"], "." . $file["extension"]);
     ilObjTest::_setImportDirectory($basedir);
     $xml_file = ilObjTest::_getImportDirectory() . '/' . $subdir . '/' . $subdir . ".xml";
     $qti_file = ilObjTest::_getImportDirectory() . '/' . $subdir . '/' . preg_replace("/test|tst/", "qti", $subdir) . ".xml";
     $results_file = ilObjTest::_getImportDirectory() . '/' . $subdir . '/' . preg_replace("/test|tst/", "results", $subdir) . ".xml";
     if (!is_file($qti_file)) {
         ilUtil::delDir($basedir);
         ilUtil::sendFailure($this->lng->txt("tst_import_non_ilias_zip"));
         $this->createObject();
         return;
     }
     // start verification of QTI files
     include_once "./Services/QTI/classes/class.ilQTIParser.php";
     $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
     $result = $qtiParser->startParsing();
     $founditems =& $qtiParser->getFoundItems();
     if (count($founditems) == 0) {
         // nothing found
         // delete import directory
         ilUtil::delDir($basedir);
         ilUtil::sendInfo($this->lng->txt("tst_import_no_items"));
         $this->createObject();
         return;
     }
     $complete = 0;
     $incomplete = 0;
     foreach ($founditems as $item) {
         if (strlen($item["type"])) {
             $complete++;
         } else {
             $incomplete++;
         }
     }
     if ($complete == 0) {
         // delete import directory
         ilUtil::delDir($basedir);
         ilUtil::sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
         $this->createObject();
         return;
     }
     $_SESSION["tst_import_results_file"] = $results_file;
     $_SESSION["tst_import_xml_file"] = $xml_file;
     $_SESSION["tst_import_qti_file"] = $qti_file;
     $_SESSION["tst_import_subdir"] = $subdir;
     // display of found questions
     $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tst_import_verification.html", "Modules/Test");
     $row_class = array("tblrow1", "tblrow2");
     $counter = 0;
     foreach ($founditems as $item) {
         $this->tpl->setCurrentBlock("verification_row");
         $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
         $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
         $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
         include_once "./Services/QTI/classes/class.ilQTIItem.php";
         switch ($item["type"]) {
             case "MULTIPLE CHOICE QUESTION":
             case QT_MULTIPLE_CHOICE_MR:
                 //$this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_multiple_choice"));
                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMultipleChoice"));
                 break;
             case "SINGLE CHOICE QUESTION":
             case QT_MULTIPLE_CHOICE_SR:
                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assSingleChoice"));
                 break;
             case KPRIM_CHOICE_QUESTION_IDENTIFIER:
             case QT_KPRIM_CHOICE:
                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assKprimChoice"));
                 break;
             case "NUMERIC QUESTION":
             case QT_NUMERIC:
                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assNumeric"));
                 break;
             case "TEXTSUBSET QUESTION":
             case QT_TEXTSUBSET:
                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextSubset"));
                 break;
             case "CLOZE QUESTION":
             case QT_CLOZE:
                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assClozeTest"));
                 break;
//.........这里部分代码省略.........
开发者ID:bheyser,项目名称:qplskl,代码行数:101,代码来源:class.ilObjTestGUI.php

示例4: addSubitems

 /**
  * Add subitems
  * @param object $a_id
  * @param object $a_type
  * @return 
  */
 protected function addSubitems($a_id, $a_type, $a_target_release)
 {
     $GLOBALS['ilLog']->write(__METHOD__);
     $set_number = 1;
     foreach ($this->eo->getSubitemsForExport() as $ref_id) {
         // get last export file
         $obj_id = ilObject::_lookupObjId($ref_id);
         $expi = ilExportFileInfo::lookupLastExport($obj_id, 'xml', $a_target_release);
         if (!$expi instanceof ilExportFileInfo) {
             $GLOBALS['ilLog']->write(__METHOD__ . ': Cannot find export file for refId ' . $ref_id . ', type ' . ilObject::_lookupType($a_id));
             continue;
         }
         $exp_dir = ilExport::_getExportDirectory($obj_id, 'xml', ilObject::_lookupType($obj_id));
         $exp_full = $exp_dir . DIRECTORY_SEPARATOR . $expi->getFilename();
         $GLOBALS['ilLog']->write(__METHOD__ . ': zip path ' . $exp_full);
         // Unzip
         ilUtil::unzip($exp_full, true, false);
         // create set directory
         ilUtil::makeDirParents($this->cont_export_dir . DIRECTORY_SEPARATOR . 'set_' . $set_number);
         // cut .zip
         $new_path_rel = 'set_' . $set_number . DIRECTORY_SEPARATOR . $expi->getBasename();
         $new_path_abs = $this->cont_export_dir . DIRECTORY_SEPARATOR . $new_path_rel;
         $GLOBALS['ilLog']->write(__METHOD__ . ': ' . $new_path_rel . ' ' . $new_path_abs);
         // Move export
         rename($exp_dir . DIRECTORY_SEPARATOR . $expi->getBasename(), $new_path_abs);
         $GLOBALS['ilLog']->write($exp_dir . DIRECTORY_SEPARATOR . $expi->getBasename() . ' -> ' . $new_path_abs);
         // Delete latest container xml of source
         if ($a_id == $obj_id) {
             $expi->delete();
             if (file_exists($exp_full)) {
                 $GLOBALS['ilLog']->write(__METHOD__ . ': Deleting' . $exp_full);
                 unlink($exp_full);
             }
         }
         $this->cont_manifest_writer->xmlElement('ExportSet', array('Path' => $new_path_rel, 'Type' => ilObject::_lookupType($obj_id)));
         ++$set_number;
     }
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:44,代码来源:class.ilExportContainer.php

示例5: importUserRoleAssignmentObject

 /**
  * display form for user import
  */
 function importUserRoleAssignmentObject()
 {
     global $ilUser, $rbacreview, $tpl, $lng, $ilCtrl;
     // Blind out tabs for local user import
     if ($_GET["baseClass"] == 'ilRepositoryGUI') {
         $this->tabs_gui->clearTargets();
     }
     $this->initUserImportForm();
     if ($this->form->checkInput()) {
         include_once './Services/AccessControl/classes/class.ilObjRole.php';
         include_once './Services/User/classes/class.ilUserImportParser.php';
         global $rbacreview, $rbacsystem, $tree, $lng;
         $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_import_roles.html", "Services/User");
         $import_dir = $this->getImportDir();
         // recreate user import directory
         if (@is_dir($import_dir)) {
             ilUtil::delDir($import_dir);
         }
         ilUtil::makeDir($import_dir);
         // move uploaded file to user import directory
         $file_name = $_FILES["importFile"]["name"];
         $parts = pathinfo($file_name);
         $full_path = $import_dir . "/" . $file_name;
         // check if import file exists
         if (!is_file($_FILES["importFile"]["tmp_name"])) {
             ilUtil::delDir($import_dir);
             $this->ilias->raiseError($this->lng->txt("no_import_file_found"), $this->ilias->error_obj->MESSAGE);
         }
         ilUtil::moveUploadedFile($_FILES["importFile"]["tmp_name"], $_FILES["importFile"]["name"], $full_path);
         // handle zip file
         if (strtolower($parts["extension"]) == "zip") {
             // unzip file
             ilUtil::unzip($full_path);
             $xml_file = null;
             $file_list = ilUtil::getDir($import_dir);
             foreach ($file_list as $a_file) {
                 if (substr($a_file['entry'], -4) == '.xml') {
                     $xml_file = $import_dir . "/" . $a_file['entry'];
                     break;
                 }
             }
             if (is_null($xml_file)) {
                 $subdir = basename($parts["basename"], "." . $parts["extension"]);
                 $xml_file = $import_dir . "/" . $subdir . "/" . $subdir . ".xml";
             }
         } else {
             $xml_file = $full_path;
         }
         // check xml file
         if (!is_file($xml_file)) {
             ilUtil::delDir($import_dir);
             $this->ilias->raiseError($this->lng->txt("no_xml_file_found_in_zip") . " " . $subdir . "/" . $subdir . ".xml", $this->ilias->error_obj->MESSAGE);
         }
         require_once "./Services/User/classes/class.ilUserImportParser.php";
         // Verify the data
         // ---------------
         $importParser = new ilUserImportParser($xml_file, IL_VERIFY);
         $importParser->startParsing();
         switch ($importParser->getErrorLevel()) {
             case IL_IMPORT_SUCCESS:
                 break;
             case IL_IMPORT_WARNING:
                 $this->tpl->setVariable("IMPORT_LOG", $importParser->getProtocolAsHTML($lng->txt("verification_warning_log")));
                 break;
             case IL_IMPORT_FAILURE:
                 ilUtil::delDir($import_dir);
                 $this->ilias->raiseError($lng->txt("verification_failed") . $importParser->getProtocolAsHTML($lng->txt("verification_failure_log")), $this->ilias->error_obj->MESSAGE);
                 return;
         }
         // Create the role selection form
         // ------------------------------
         $this->tpl->setCurrentBlock("role_selection_form");
         $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
         $this->tpl->setVariable("TXT_IMPORT_USERS", $this->lng->txt("import_users"));
         $this->tpl->setVariable("TXT_IMPORT_FILE", $this->lng->txt("import_file"));
         $this->tpl->setVariable("IMPORT_FILE", $file_name);
         $this->tpl->setVariable("TXT_USER_ELEMENT_COUNT", $this->lng->txt("num_users"));
         $this->tpl->setVariable("USER_ELEMENT_COUNT", $importParser->getUserCount());
         $this->tpl->setVariable("TXT_ROLE_ASSIGNMENT", $this->lng->txt("role_assignment"));
         $this->tpl->setVariable("BTN_IMPORT", $this->lng->txt("import"));
         $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
         $this->tpl->setVariable("XML_FILE_NAME", $xml_file);
         // Extract the roles
         $importParser = new ilUserImportParser($xml_file, IL_EXTRACT_ROLES);
         $importParser->startParsing();
         $roles = $importParser->getCollectedRoles();
         // get global roles
         $all_gl_roles = $rbacreview->getRoleListByObject(ROLE_FOLDER_ID);
         $gl_roles = array();
         $roles_of_user = $rbacreview->assignedRoles($ilUser->getId());
         foreach ($all_gl_roles as $obj_data) {
             // check assignment permission if called from local admin
             if ($this->object->getRefId() != USER_FOLDER_ID) {
                 if (!in_array(SYSTEM_ROLE_ID, $roles_of_user) && !ilObjRole::_getAssignUsersStatus($obj_data['obj_id'])) {
                     continue;
                 }
             }
//.........这里部分代码省略.........
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:101,代码来源:class.ilObjUserFolderGUI.php

示例6: importObject

 /**
  * Import repository object export file
  *
  * @param	string		absolute filename of temporary upload file
  */
 public final function importObject($a_new_obj, $a_tmp_file, $a_filename, $a_type, $a_comp = "", $a_copy_file = false)
 {
     // create temporary directory
     $tmpdir = ilUtil::ilTempnam();
     ilUtil::makeDir($tmpdir);
     if ($a_copy_file) {
         copy($a_tmp_file, $tmpdir . "/" . $a_filename);
     } else {
         ilUtil::moveUploadedFile($a_tmp_file, $a_filename, $tmpdir . "/" . $a_filename);
     }
     ilUtil::unzip($tmpdir . "/" . $a_filename);
     $dir = $tmpdir . "/" . substr($a_filename, 0, strlen($a_filename) - 4);
     $GLOBALS['ilLog']->write(__METHOD__ . ': do import with dir ' . $dir);
     $new_id = $this->doImportObject($dir, $a_type, $a_comp, $tmpdir);
     // delete temporary directory
     ilUtil::delDir($tmpdir);
     return $new_id;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:23,代码来源:class.ilImport.php

示例7: uploadQplObject

 /**
  * imports question(s) into the questionpool
  */
 function uploadQplObject($questions_only = false)
 {
     $this->ctrl->setParameter($this, 'new_type', $_REQUEST['new_type']);
     if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK) {
         ilUtil::sendFailure($this->lng->txt("error_upload"), true);
         if (!$questions_only) {
             $this->ctrl->redirect($this, 'create');
         }
         return false;
     }
     // create import directory
     include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
     $basedir = ilObjQuestionPool::_createImportDirectory();
     // copy uploaded file to import directory
     $file = pathinfo($_FILES["xmldoc"]["name"]);
     $full_path = $basedir . "/" . $_FILES["xmldoc"]["name"];
     $GLOBALS['ilLog']->write(__METHOD__ . ": full path " . $full_path);
     include_once "./Services/Utilities/classes/class.ilUtil.php";
     ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
     $GLOBALS['ilLog']->write(__METHOD__ . ": full path " . $full_path);
     if (strcmp($_FILES["xmldoc"]["type"], "text/xml") == 0) {
         $qti_file = $full_path;
         ilObjTest::_setImportDirectory($basedir);
     } else {
         // unzip file
         ilUtil::unzip($full_path);
         // determine filenames of xml files
         $subdir = basename($file["basename"], "." . $file["extension"]);
         ilObjQuestionPool::_setImportDirectory($basedir);
         $xml_file = ilObjQuestionPool::_getImportDirectory() . '/' . $subdir . '/' . $subdir . ".xml";
         $qti_file = ilObjQuestionPool::_getImportDirectory() . '/' . $subdir . '/' . str_replace("qpl", "qti", $subdir) . ".xml";
     }
     // start verification of QTI files
     include_once "./Services/QTI/classes/class.ilQTIParser.php";
     $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
     $result = $qtiParser->startParsing();
     $founditems =& $qtiParser->getFoundItems();
     if (count($founditems) == 0) {
         // nothing found
         // delete import directory
         ilUtil::delDir($basedir);
         ilUtil::sendFailure($this->lng->txt("qpl_import_no_items"), true);
         if (!$questions_only) {
             $this->ctrl->redirect($this, 'create');
         }
         return false;
     }
     $complete = 0;
     $incomplete = 0;
     foreach ($founditems as $item) {
         if (strlen($item["type"])) {
             $complete++;
         } else {
             $incomplete++;
         }
     }
     if ($complete == 0) {
         // delete import directory
         ilUtil::delDir($basedir);
         ilUtil::sendFailure($this->lng->txt("qpl_import_non_ilias_files"), true);
         if (!$questions_only) {
             $this->ctrl->redirect($this, 'create');
         }
         return false;
     }
     $_SESSION["qpl_import_xml_file"] = $xml_file;
     $_SESSION["qpl_import_qti_file"] = $qti_file;
     $_SESSION["qpl_import_subdir"] = $subdir;
     // display of found questions
     $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.qpl_import_verification.html", "Modules/TestQuestionPool");
     $row_class = array("tblrow1", "tblrow2");
     $counter = 0;
     foreach ($founditems as $item) {
         $this->tpl->setCurrentBlock("verification_row");
         $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
         $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
         $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
         include_once "./Services/QTI/classes/class.ilQTIItem.php";
         switch ($item["type"]) {
             case CLOZE_TEST_IDENTIFIER:
                 $type = $this->lng->txt("assClozeTest");
                 break;
             case IMAGEMAP_QUESTION_IDENTIFIER:
                 $type = $this->lng->txt("assImagemapQuestion");
                 break;
             case JAVAAPPLET_QUESTION_IDENTIFIER:
                 $type = $this->lng->txt("assJavaApplet");
                 break;
             case MATCHING_QUESTION_IDENTIFIER:
                 $type = $this->lng->txt("assMatchingQuestion");
                 break;
             case MULTIPLE_CHOICE_QUESTION_IDENTIFIER:
                 $type = $this->lng->txt("assMultipleChoice");
                 break;
             case KPRIM_CHOICE_QUESTION_IDENTIFIER:
                 $type = $this->lng->txt("assKprimChoice");
                 break;
//.........这里部分代码省略.........
开发者ID:arlendotcn,项目名称:ilias,代码行数:101,代码来源:class.ilObjQuestionPoolGUI.php

示例8: importObject

 /**
  * Imports a survey from XML into the ILIAS database
  *
  * @return boolean True, if the import succeeds, false otherwise
  * @access public
  */
 function importObject($file_info, $svy_qpl_id)
 {
     if ($svy_qpl_id < 1) {
         $svy_qpl_id = -1;
     }
     // check if file was uploaded
     $source = $file_info["tmp_name"];
     $error = "";
     if ($source == 'none' || !$source || $file_info["error"] > UPLOAD_ERR_OK) {
         $error = $this->lng->txt("import_no_file_selected");
     }
     // check correct file type
     $isXml = FALSE;
     $isZip = FALSE;
     if (strcmp($file_info["type"], "text/xml") == 0 || strcmp($file_info["type"], "application/xml") == 0) {
         $isXml = TRUE;
     }
     // too many different mime-types, so we use the suffix
     $suffix = pathinfo($file_info["name"]);
     if (strcmp(strtolower($suffix["extension"]), "zip") == 0) {
         $isZip = TRUE;
     }
     if (!$isXml && !$isZip) {
         $error = $this->lng->txt("import_wrong_file_type");
         global $ilLog;
         $ilLog->write("Survey: Import error. Filetype was \"" . $file_info["type"] . "\"");
     }
     if (strlen($error) == 0) {
         // import file as a survey
         $import_dir = $this->getImportDirectory();
         $import_subdir = "";
         $importfile = "";
         include_once "./Services/Utilities/classes/class.ilUtil.php";
         if ($isZip) {
             $importfile = $import_dir . "/" . $file_info["name"];
             ilUtil::moveUploadedFile($source, $file_info["name"], $importfile);
             ilUtil::unzip($importfile);
             $found = $this->locateImportFiles($import_dir);
             if (!(strlen($found["dir"]) > 0 && strlen($found["xml"]) > 0)) {
                 $error = $this->lng->txt("wrong_import_file_structure");
                 return $error;
             }
             $importfile = $found["xml"];
             $import_subdir = $found["dir"];
         } else {
             $importfile = tempnam($import_dir, "survey_import");
             ilUtil::moveUploadedFile($source, $file_info["name"], $importfile);
         }
         $fh = fopen($importfile, "r");
         if (!$fh) {
             $error = $this->lng->txt("import_error_opening_file");
             return $error;
         }
         $xml = fread($fh, filesize($importfile));
         $result = fclose($fh);
         if (!$result) {
             $error = $this->lng->txt("import_error_closing_file");
             return $error;
         }
         unset($_SESSION["import_mob_xhtml"]);
         if (strpos($xml, "questestinterop")) {
             include_once "./Services/Survey/classes/class.SurveyImportParserPre38.php";
             $import = new SurveyImportParserPre38($svy_qpl_id, "", TRUE);
             $import->setSurveyObject($this);
             $import->setXMLContent($xml);
             $import->startParsing();
         } else {
             include_once "./Services/Survey/classes/class.SurveyImportParser.php";
             $import = new SurveyImportParser($svy_qpl_id, "", TRUE);
             $import->setSurveyObject($this);
             $import->setXMLContent($xml);
             $import->startParsing();
         }
         if (is_array($_SESSION["import_mob_xhtml"])) {
             include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
             include_once "./Services/RTE/classes/class.ilRTE.php";
             include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
             foreach ($_SESSION["import_mob_xhtml"] as $mob) {
                 $importfile = $import_subdir . "/" . $mob["uri"];
                 if (file_exists($importfile)) {
                     $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
                     ilObjMediaObject::_saveUsage($media_object->getId(), "svy:html", $this->getId());
                     $this->setIntroduction(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $this->getIntroduction()));
                     $this->setOutro(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $this->getOutro()));
                 } else {
                     global $ilLog;
                     $ilLog->write("Error: Could not open XHTML mob file for test introduction during test import. File {$importfile} does not exist!");
                 }
             }
             $this->setIntroduction(ilRTE::_replaceMediaObjectImageSrc($this->getIntroduction(), 1));
             $this->setOutro(ilRTE::_replaceMediaObjectImageSrc($this->getOutro(), 1));
             $this->saveToDb();
         }
         // delete import directory
//.........这里部分代码省略.........
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:101,代码来源:class.ilObjSurvey.php

示例9: unzipFile

 /**
  * delete object file
  */
 function unzipFile()
 {
     global $lng;
     if (isset($_GET["upfile"])) {
         $file = basename($_GET["upfile"]);
     } else {
         if (!isset($_POST["file"])) {
             $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
         }
         if (count($_POST["file"]) > 1) {
             $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"), $this->ilias->error_obj->MESSAGE);
         }
         $file = basename($_POST["file"][0]);
     }
     $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
     $cur_dir = !empty($cur_subdir) ? $this->main_dir . "/" . $cur_subdir : $this->main_dir;
     $file = $cur_dir . "/" . ilUtil::stripSlashes($file);
     if (@is_file($file)) {
         $cur_files = array_keys(ilUtil::getDir($cur_dir));
         if ($this->getAllowDirectories()) {
             ilUtil::unzip($file, true);
         } else {
             ilUtil::unzip($file, true, true);
         }
         $new_files = array_keys(ilUtil::getDir($cur_dir));
         $diff = array_diff($new_files, $cur_files);
         if (sizeof($diff)) {
             if ($this->getAllowDirectories()) {
                 include_once "./Services/Utilities/classes/class.ilFileUtils.php";
                 $new_files = array();
                 foreach ($diff as $new_item) {
                     if (is_dir($cur_dir . "/" . $new_item)) {
                         ilFileUtils::recursive_dirscan($cur_dir . "/" . $new_item, $new_files);
                     }
                 }
                 if (is_array($new_files["path"])) {
                     foreach ($new_files["path"] as $idx => $path) {
                         $path = substr($path, strlen($this->main_dir) + 1);
                         $diff[] = $path . $new_files["file"][$idx];
                     }
                 }
             }
             $this->setPerformedCommand("unzip_file", array("name" => substr($file, strlen($this->main_dir) + 1), "added" => $diff));
         }
     }
     ilUtil::renameExecutables($this->main_dir);
     $this->ctrl->saveParameter($this, "cdir");
     ilUtil::sendSuccess($lng->txt("cont_file_unzipped"), true);
     $this->ctrl->redirect($this, "listFiles");
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:53,代码来源:class.ilFileSystemGUI.php

示例10: importCertificate

 /**
  * Reads an import ZIP file and creates a certificate of it
  *
  * @return boolean TRUE if the import succeeds, FALSE otherwise
  */
 public function importCertificate($zipfile, $filename)
 {
     include_once "./Services/Utilities/classes/class.ilUtil.php";
     $importpath = $this->createArchiveDirectory();
     if (!ilUtil::moveUploadedFile($zipfile, $filename, $importpath . $filename)) {
         ilUtil::delDir($importpath);
         return FALSE;
     }
     ilUtil::unzip($importpath . $filename, TRUE);
     $subdir = str_replace(".zip", "", strtolower($filename)) . "/";
     $copydir = "";
     if (is_dir($importpath . $subdir)) {
         $dirinfo = ilUtil::getDir($importpath . $subdir);
         $copydir = $importpath . $subdir;
     } else {
         $dirinfo = ilUtil::getDir($importpath);
         $copydir = $importpath;
     }
     $xmlfiles = 0;
     $otherfiles = 0;
     foreach ($dirinfo as $file) {
         if (strcmp($file["type"], "file") == 0) {
             if (strpos($file["entry"], ".xml") !== FALSE) {
                 $xmlfiles++;
             } else {
                 if (strpos($file["entry"], ".zip") !== FALSE) {
                 } else {
                     $otherfiles++;
                 }
             }
         }
     }
     // if one XML file is in the archive, we try to import it
     if ($xmlfiles == 1) {
         foreach ($dirinfo as $file) {
             if (strcmp($file["type"], "file") == 0) {
                 if (strpos($file["entry"], ".xml") !== FALSE) {
                     $xsl = file_get_contents($copydir . $file["entry"]);
                     // as long as we cannot make RPC calls in a given directory, we have
                     // to add the complete path to every url
                     $xsl = preg_replace("/url\\([']{0,1}(.*?)[']{0,1}\\)/", "url(" . $this->getAdapter()->getCertificatePath() . "\${1})", $xsl);
                     $this->saveCertificate($xsl);
                 } else {
                     if (strpos($file["entry"], ".zip") !== FALSE) {
                     } else {
                         @copy($copydir . $file["entry"], $this->getAdapter()->getCertificatePath() . $file["entry"]);
                         if (strcmp($this->getBackgroundImagePath(), $this->getAdapter()->getCertificatePath() . $file["entry"]) == 0) {
                             // upload of the background image, create a preview
                             ilUtil::convertImage($this->getBackgroundImagePath(), $this->getBackgroundImageThumbPath(), "JPEG", 100);
                         }
                     }
                 }
             }
         }
     } else {
         ilUtil::delDir($importpath);
         return FALSE;
     }
     ilUtil::delDir($importpath);
     return TRUE;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:66,代码来源:class.ilCertificate.php

示例11: _importCategories

 /**
  * import categories (static, also called by RootFolderGUI)
  */
 function _importCategories($a_ref_id, $withrol_tmp)
 {
     global $lng;
     require_once "./Modules/Category/classes/class.ilCategoryImportParser.php";
     $import_dir = ilObjCategoryGUI::_getImportDir();
     // create user import directory if necessary
     if (!@is_dir($import_dir)) {
         ilUtil::createDirectory($import_dir);
     }
     // move uploaded file to user import directory
     $file_name = $_FILES["importFile"]["name"];
     // added to prevent empty file names
     if (!strcmp($file_name, "")) {
         ilUtil::sendFailure($lng->txt("no_import_file_found"), true);
         $this->ctrl->redirect($this);
     }
     $parts = pathinfo($file_name);
     $full_path = $import_dir . "/" . $file_name;
     //move_uploaded_file($_FILES["importFile"]["tmp_name"], $full_path);
     ilUtil::moveUploadedFile($_FILES["importFile"]["tmp_name"], $file_name, $full_path);
     // unzip file
     ilUtil::unzip($full_path);
     $subdir = basename($parts["basename"], "." . $parts["extension"]);
     $xml_file = $import_dir . "/" . $subdir . "/" . $subdir . ".xml";
     // CategoryImportParser
     //var_dump($_POST);
     $importParser = new ilCategoryImportParser($xml_file, $a_ref_id, $withrol_tmp);
     $importParser->startParsing();
     ilUtil::sendSuccess($lng->txt("categories_imported"), true);
     $this->ctrl->redirect($this);
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:34,代码来源:class.ilObjCategoryGUI.php

示例12: unzip

 function unzip()
 {
     foreach ($this->getFiles() as $file_data) {
         ilUtil::unzip($file_data["abs_path"]);
         return true;
     }
     return false;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:8,代码来源:class.ilFileDataImportMail.php

示例13: importFileObject

 /**
  * display status information or report errors messages
  * in case of error
  *
  * @access	public
  */
 function importFileObject()
 {
     $new_type = $_REQUEST["new_type"];
     // create permission is already checked in createObject. This check here is done to prevent hacking attempts
     if (!$this->checkPermissionBool("create", "", $new_type)) {
         $ilErr->raiseError($this->lng->txt("no_create_permission"));
     }
     $this->lng->loadLanguageModule($new_type);
     $this->ctrl->setParameter($this, "new_type", $new_type);
     $form = $this->initImportForm($new_type);
     if ($form->checkInput()) {
         $this->ctrl->setParameter($this, "new_type", "");
         $upload = $_FILES["importfile"];
         // create and insert object in objecttree
         include_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
         $newObj = new ilObjGlossary();
         $newObj->setType($new_type);
         $newObj->setTitle($upload["name"]);
         $newObj->create(true);
         $this->putObjectInTree($newObj);
         // create import directory
         $newObj->createImportDirectory();
         // copy uploaded file to import directory
         $file = pathinfo($upload["name"]);
         $full_path = $newObj->getImportDirectory() . "/" . $upload["name"];
         ilUtil::moveUploadedFile($upload["tmp_name"], $upload["name"], $full_path);
         // unzip file
         ilUtil::unzip($full_path);
         // determine filename of xml file
         $subdir = basename($file["basename"], "." . $file["extension"]);
         $xml_file = $newObj->getImportDirectory() . "/" . $subdir . "/" . $subdir . ".xml";
         // check whether this is a new export file.
         // this is the case if manifest.xml exits
         //echo "1-".$newObj->getImportDirectory()."/".$subdir."/manifest.xml"."-";
         if (is_file($newObj->getImportDirectory() . "/" . $subdir . "/manifest.xml")) {
             include_once "./Services/Export/classes/class.ilImport.php";
             $imp = new ilImport((int) $_GET["ref_id"]);
             $map = $imp->getMapping();
             $map->addMapping("Modules/Glossary", "glo", "new_id", $newObj->getId());
             $imp->importObject($newObj, $full_path, $upload["name"], "glo", "Modules/Glossary", true);
             ilUtil::sendSuccess($this->lng->txt("glo_added"), true);
             ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=" . $newObj->getRefId());
         }
         // check whether subdirectory exists within zip file
         if (!is_dir($newObj->getImportDirectory() . "/" . $subdir)) {
             $this->ilias->raiseError(sprintf($this->lng->txt("cont_no_subdir_in_zip"), $subdir), $this->ilias->error_obj->MESSAGE);
         }
         // check whether xml file exists within zip file
         if (!is_file($xml_file)) {
             $this->ilias->raiseError(sprintf($this->lng->txt("cont_zip_file_invalid"), $subdir . "/" . $subdir . ".xml"), $this->ilias->error_obj->MESSAGE);
         }
         include_once "./Modules/LearningModule/classes/class.ilContObjParser.php";
         $contParser = new ilContObjParser($newObj, $xml_file, $subdir);
         $contParser->startParsing();
         ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
         // delete import directory
         ilUtil::delDir($newObj->getImportDirectory());
         ilUtil::sendSuccess($this->lng->txt("glo_added"), true);
         ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=" . $newObj->getRefId());
     }
     // display form to correct errors
     $form->setValuesByPost();
     $tpl->setContent($form->getHtml());
 }
开发者ID:bheyser,项目名称:qplskl,代码行数:70,代码来源:class.ilObjGlossaryGUI.php

示例14: unpackImportFile

 function unpackImportFile()
 {
     return ilUtil::unzip($this->getCoursePath() . '/import/crs_' . $this->course_id . '/' . $this->import_file_info['basename']);
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:4,代码来源:class.ilFileDataCourse.php

示例15: unpackImportFile

 function unpackImportFile()
 {
     return ilUtil::unzip($this->getGroupPath() . '/import/' . $this->import_file_info['basename']);
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:4,代码来源:class.ilFileDataGroup.php


注:本文中的ilUtil::unzip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。