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


PHP ilUtil::renameExecutables方法代码示例

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


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

示例1: uploadObject

 /**
  * display status information or report errors messages
  * in case of error
  *
  * @access	public
  */
 function uploadObject()
 {
     global $_FILES, $rbacsystem;
     include_once 'Services/FileSystem/classes/class.ilUploadFiles.php';
     // check create permission
     if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], "sahs")) {
         $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING);
     } elseif ($_FILES["scormfile"]["name"]) {
         // check if file was uploaded
         $source = $_FILES["scormfile"]["tmp_name"];
         if ($source == 'none' || !$source) {
             $this->ilias->raiseError($this->lng->txt("msg_no_file"), $this->ilias->error_obj->MESSAGE);
         }
         // get_cfg_var("upload_max_filesize"); // get the may filesize form t he php.ini
         switch ($__FILES["scormfile"]["error"]) {
             case UPLOAD_ERR_INI_SIZE:
                 $this->ilias->raiseError($this->lng->txt("err_max_file_size_exceeds"), $this->ilias->error_obj->MESSAGE);
                 break;
             case UPLOAD_ERR_FORM_SIZE:
                 $this->ilias->raiseError($this->lng->txt("err_max_file_size_exceeds"), $this->ilias->error_obj->MESSAGE);
                 break;
             case UPLOAD_ERR_PARTIAL:
                 $this->ilias->raiseError($this->lng->txt("err_partial_file_upload"), $this->ilias->error_obj->MESSAGE);
                 break;
             case UPLOAD_ERR_NO_FILE:
                 $this->ilias->raiseError($this->lng->txt("err_no_file_uploaded"), $this->ilias->error_obj->MESSAGE);
                 break;
         }
         $file = pathinfo($_FILES["scormfile"]["name"]);
     } elseif ($_POST["uploaded_file"]) {
         // check if the file is in the upload directory and readable
         if (!ilUploadFiles::_checkUploadFile($_POST["uploaded_file"])) {
             $this->ilias->raiseError($this->lng->txt("upload_error_file_not_found"), $this->ilias->error_obj->MESSAGE);
         }
         $file = pathinfo($_POST["uploaded_file"]);
     } else {
         $this->ilias->raiseError($this->lng->txt("msg_no_file"), $this->ilias->error_obj->MESSAGE);
     }
     $name = substr($file["basename"], 0, strlen($file["basename"]) - strlen($file["extension"]) - 1);
     if ($name == "") {
         $name = $this->lng->txt("no_title");
     }
     // create and insert object in objecttree
     switch ($_POST["sub_type"]) {
         case "scorm2004":
             include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php";
             $newObj = new ilObjSCORM2004LearningModule();
             $newObj->setEditable($_POST["editable"] == 'y');
             $newObj->setImportSequencing($_POST["import_sequencing"]);
             $newObj->setSequencingExpertMode($_POST["import_sequencing"]);
             break;
         case "scorm":
             include_once "./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php";
             $newObj = new ilObjSCORMLearningModule();
             break;
         case "aicc":
             include_once "./Modules/ScormAicc/classes/class.ilObjAICCLearningModule.php";
             $newObj = new ilObjAICCLearningModule();
             break;
         case "hacp":
             include_once "./Modules/ScormAicc/classes/class.ilObjHACPLearningModule.php";
             $newObj = new ilObjHACPLearningModule();
             break;
     }
     $newObj->setTitle($name);
     $newObj->setSubType($_POST["sub_type"]);
     $newObj->setDescription("");
     $newObj->create(true);
     $newObj->createReference();
     $newObj->putInTree($_GET["ref_id"]);
     $newObj->setPermissions($_GET["ref_id"]);
     $newObj->notify("new", $_GET["ref_id"], $_GET["parent_non_rbac_id"], $_GET["ref_id"], $newObj->getRefId());
     // create data directory, copy file to directory
     $newObj->createDataDirectory();
     if ($_FILES["scormfile"]["name"]) {
         // copy uploaded file to data directory
         $file_path = $newObj->getDataDirectory() . "/" . $_FILES["scormfile"]["name"];
         ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"], $_FILES["scormfile"]["name"], $file_path);
     } else {
         // copy uploaded file to data directory
         $file_path = $newObj->getDataDirectory() . "/" . $_POST["uploaded_file"];
         ilUploadFiles::_copyUploadFile($_POST["uploaded_file"], $file_path);
     }
     ilUtil::unzip($file_path);
     ilUtil::renameExecutables($newObj->getDataDirectory());
     $title = $newObj->readObject();
     if ($title != "") {
         ilObject::_writeTitle($newObj->getId(), $title);
         /*$md = new ilMD($newObj->getId(),0, $newObj->getType());
         		if(is_object($md_gen = $md->getGeneral()))
         		{
         			$md_gen->setTitle($title);
         			$md_gen->update();
         		}*/
//.........这里部分代码省略.........
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:101,代码来源:class.ilObjSAHSLearningModuleGUI.php

示例2: suggestedsolution

 /**
  * Allows to add suggested solutions for questions
  *
  * @access public
  */
 public function suggestedsolution()
 {
     global $ilUser;
     global $ilAccess;
     if ($_POST["deleteSuggestedSolution"] == 1) {
         $this->object->deleteSuggestedSolutions();
         ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
         $this->ctrl->redirect($this, "suggestedsolution");
     }
     $save = is_array($_POST["cmd"]) && array_key_exists("suggestedsolution", $_POST["cmd"]) ? TRUE : FALSE;
     $output = "";
     $solution_array = $this->object->getSuggestedSolution(0);
     $options = array("lm" => $this->lng->txt("obj_lm"), "st" => $this->lng->txt("obj_st"), "pg" => $this->lng->txt("obj_pg"), "git" => $this->lng->txt("glossary_term"), "file" => $this->lng->txt("fileDownload"), "text" => $this->lng->txt("solutionText"));
     if (strcmp($_POST["solutiontype"], "file") == 0 && strcmp($solution_array["type"], "file") != 0) {
         $solution_array = array("type" => "file");
     } elseif (strcmp($_POST["solutiontype"], "text") == 0 && strcmp($solution_array["type"], "text") != 0) {
         $solution_array = array("type" => "text", "value" => $this->getSolutionOutput(0, NULL, FALSE, FALSE, TRUE, FALSE, TRUE));
     }
     if ($save && strlen($_POST["filename"])) {
         $solution_array["value"]["filename"] = $_POST["filename"];
     }
     if ($save && strlen($_POST["solutiontext"])) {
         $solution_array["value"] = $_POST["solutiontext"];
     }
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     if (count($solution_array)) {
         $form = new ilPropertyFormGUI();
         $form->setFormAction($this->ctrl->getFormAction($this));
         $form->setTitle($this->lng->txt("solution_hint"));
         $form->setMultipart(TRUE);
         $form->setTableWidth("100%");
         $form->setId("suggestedsolutiondisplay");
         // suggested solution output
         include_once "./Modules/TestQuestionPool/classes/class.ilSolutionTitleInputGUI.php";
         $title = new ilSolutionTitleInputGUI($this->lng->txt("showSuggestedSolution"), "solutiontype");
         $template = new ilTemplate("tpl.il_as_qpl_suggested_solution_input_presentation.html", TRUE, TRUE, "Modules/TestQuestionPool");
         if (strlen($solution_array["internal_link"])) {
             $href = assQuestion::_getInternalLinkHref($solution_array["internal_link"]);
             $template->setCurrentBlock("preview");
             $template->setVariable("TEXT_SOLUTION", $this->lng->txt("suggested_solution"));
             $template->setVariable("VALUE_SOLUTION", " <a href=\"{$href}\" target=\"content\">" . $this->lng->txt("view") . "</a> ");
             $template->parseCurrentBlock();
         } elseif (strcmp($solution_array["type"], "file") == 0 && is_array($solution_array["value"])) {
             $href = $this->object->getSuggestedSolutionPathWeb() . $solution_array["value"]["name"];
             $template->setCurrentBlock("preview");
             $template->setVariable("TEXT_SOLUTION", $this->lng->txt("suggested_solution"));
             $template->setVariable("VALUE_SOLUTION", " <a href=\"{$href}\" target=\"content\">" . ilUtil::prepareFormOutput(strlen($solution_array["value"]["filename"]) ? $solution_array["value"]["filename"] : $solution_array["value"]["name"]) . "</a> ");
             $template->parseCurrentBlock();
         }
         $template->setVariable("TEXT_TYPE", $this->lng->txt("type"));
         $template->setVariable("VALUE_TYPE", $options[$solution_array["type"]]);
         $title->setHtml($template->get());
         $deletesolution = new ilCheckboxInputGUI("", "deleteSuggestedSolution");
         $deletesolution->setOptionTitle($this->lng->txt("deleteSuggestedSolution"));
         $title->addSubItem($deletesolution);
         $form->addItem($title);
         if (strcmp($solution_array["type"], "file") == 0) {
             // file
             $file = new ilFileInputGUI($this->lng->txt("fileDownload"), "file");
             $file->setRequired(TRUE);
             $file->enableFileNameSelection("filename");
             //$file->setSuffixes(array("doc","xls","png","jpg","gif","pdf"));
             if ($_FILES["file"]["tmp_name"] && $file->checkInput()) {
                 if (!file_exists($this->object->getSuggestedSolutionPath())) {
                     ilUtil::makeDirParents($this->object->getSuggestedSolutionPath());
                 }
                 $res = ilUtil::moveUploadedFile($_FILES["file"]["tmp_name"], $_FILES["file"]["name"], $this->object->getSuggestedSolutionPath() . $_FILES["file"]["name"]);
                 if ($res) {
                     ilUtil::renameExecutables($this->object->getSuggestedSolutionPath());
                     // remove an old file download
                     if (is_array($solution_array["value"])) {
                         @unlink($this->object->getSuggestedSolutionPath() . $solution_array["value"]["name"]);
                     }
                     $file->setValue($_FILES["file"]["name"]);
                     $this->object->saveSuggestedSolution("file", "", 0, array("name" => $_FILES["file"]["name"], "type" => $_FILES["file"]["type"], "size" => $_FILES["file"]["size"], "filename" => $_POST["filename"]));
                     $originalexists = $this->object->_questionExistsInPool($this->object->original_id);
                     if (($_GET["calling_test"] || isset($_GET['calling_consumer']) && (int) $_GET['calling_consumer']) && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId())) {
                         return $this->originalSyncForm("suggestedsolution");
                     } else {
                         ilUtil::sendSuccess($this->lng->txt("suggested_solution_added_successfully"), TRUE);
                         $this->ctrl->redirect($this, "suggestedsolution");
                     }
                 } else {
                     // BH: $res as info string? wtf? it holds a bool or something else!!?
                     ilUtil::sendInfo($res);
                 }
             } else {
                 if (is_array($solution_array["value"])) {
                     $file->setValue($solution_array["value"]["name"]);
                     $file->setFilename(strlen($solution_array["value"]["filename"]) ? $solution_array["value"]["filename"] : $solution_array["value"]["name"]);
                 }
             }
             $form->addItem($file);
             $hidden = new ilHiddenInputGUI("solutiontype");
             $hidden->setValue("file");
//.........这里部分代码省略.........
开发者ID:bheyser,项目名称:qplskl,代码行数:101,代码来源:class.assQuestionGUI.php

示例3: updateMediaItem

 /**
  * update media item from form
  *
  * @param IlObjectMediaObject $mob
  * @param IlMediaItem $mediaItem
  * @return string file
  */
 private function updateMediaItem($mob, &$mediaItem)
 {
     $purpose = $mediaItem->getPurpose();
     $url_gui = $this->form_gui->getInput("url_" . $purpose);
     $file_gui = $this->form_gui->getInput("file_" . $purpose);
     if ($url_gui) {
         // http
         $file = $this->form_gui->getInput("url_" . $purpose);
         $title = basename($file);
         $location = $this->form_gui->getInput("url_" . $purpose);
         $locationType = "Reference";
     } elseif ($file_gui["size"] > 0) {
         // lokal
         // determine and create mob directory, move uploaded file to directory
         $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
         if (!is_dir($mob_dir)) {
             $mob->createDirectory();
         }
         $file_name = ilUtil::getASCIIFilename($_FILES['file_' . $purpose]['name']);
         $file_name = str_replace(" ", "_", $file_name);
         $file = $mob_dir . "/" . $file_name;
         $title = $file_name;
         $locationType = "LocalFile";
         $location = $title;
         ilUtil::moveUploadedFile($_FILES['file_' . $purpose]['tmp_name'], $file_name, $file);
         ilUtil::renameExecutables($mob_dir);
     }
     // check if not automatic mimetype detection
     if ($_POST["mimetype_" . $purpose] != "") {
         $mediaItem->setFormat($_POST["mimetype_" . $purpose]);
     } elseif ($mediaItem->getLocation() != "") {
         $format = ilObjMediaObject::getMimeType($mediaItem->getLocation());
         $mediaItem->setFormat($format);
     }
     if (isset($file)) {
         // get mime type, if not already set!
         if (!isset($format)) {
             $format = ilObjMediaObject::getMimeType($file);
         }
         // set real meta and object data
         $mediaItem->setFormat($format);
         $mediaItem->setLocation($location);
         $mediaItem->setLocationType($locationType);
         $mediaItem->setHAlign("Left");
         $mediaItem->setHeight(self::isAudio($format) ? 0 : 180);
     }
     if ($purpose == "Standard") {
         if (isset($title)) {
             $mob->setTitle($title);
         }
         if (isset($format)) {
             $mob->setDescription($format);
         }
     }
     return $file;
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:63,代码来源:class.ilObjMediaCastGUI.php

示例4: uploadAdditionalFile

 /**
  * Create new media object and update page in db and return new media object
  */
 function uploadAdditionalFile($a_name, $tmp_name, $a_subdir = "")
 {
     $a_subdir = str_replace("..", "", $a_subdir);
     $dir = $mob_dir = ilObjMediaObject::_getDirectory($this->getId());
     if ($a_subdir != "") {
         $dir .= "/" . $a_subdir;
     }
     ilUtil::makeDirParents($dir);
     ilUtil::moveUploadedFile($tmp_name, $a_name, $dir . "/" . $a_name);
     ilUtil::renameExecutables($mob_dir);
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:14,代码来源:class.ilObjMediaObject.php

示例5: uploadRoomsAgreement

 /**
  * Uploads a new rooms agreement by using the ILIAS MediaObject Service.
  * If the old file id is given, the old file will be deleted.
  *
  * @param array  $a_newfile   an array containing the input values of the form
  * @param string $a_oldFileId to delete trash
  *
  * @return string uploaded file id
  */
 public function uploadRoomsAgreement($a_newfile, $a_oldFileId = "0")
 {
     if (!empty($a_oldFileId) && $a_oldFileId != "0") {
         $agreementFile = new ilObjMediaObject($a_oldFileId);
         $agreementFile->delete();
     }
     $mediaObj = new ilObjMediaObject();
     $mediaObj->setTitle("RoomSharingRoomsAgreement");
     $mediaObj->setDescription("RoomSharingRoomsAgreement");
     $mediaObj->create();
     $mob_dir = ilObjMediaObject::_getDirectory($mediaObj->getId());
     if (!is_dir($mob_dir)) {
         $mediaObj->createDirectory();
     }
     $file_name = ilUtil::getASCIIFilename($a_newfile["name"]);
     $file_name_mod = str_replace(" ", "_", $file_name);
     $file = $mob_dir . "/" . $file_name_mod;
     ilUtil::moveUploadedFile($a_newfile["tmp_name"], $file_name_mod, $file);
     ilUtil::renameExecutables($mob_dir);
     $format = ilObjMediaObject::getMimeType($file);
     $media_item = new ilMediaItem();
     $mediaObj->addMediaItem($media_item);
     $media_item->setPurpose("Standard");
     $media_item->setFormat($format);
     $media_item->setLocation($file_name_mod);
     $media_item->setLocationType("LocalFile");
     $mediaObj->update();
     return $mediaObj->getId();
 }
开发者ID:studer-raimann,项目名称:RoomSharing,代码行数:38,代码来源:class.ilObjRoomSharing.php

示例6: preview

 function preview()
 {
     global $ilias;
     $export = new ilScorm2004Export($this->object, 'SCORM 2004 3rd');
     $zipfile = $export->buildExportFile();
     $zipPathinfo = pathinfo($zipfile);
     $file_path = $this->object->getDataDirectory() . "/" . $zipPathinfo["basename"];
     copy($zipfile, $file_path);
     unlink($zipfile);
     ilUtil::unzip($file_path, true);
     ilUtil::renameExecutables($this->object->getDataDirectory());
     unlink($file_path);
     include_once "./Modules/Scorm2004/classes/ilSCORM13Package.php";
     $rte_pkg = new ilSCORM13Package();
     $rte_pkg->il_import($this->object->getDataDirectory(), $this->object->getId(), $ilias, false, true);
     //increase module version is it necessary?
     //$this->object->setModuleVersion($module_version+1);
     //$this->object->update();
     //redirect to view player
     ilUtil::redirect("ilias.php?baseClass=ilSAHSPresentationGUI&ref_id=" . $this->object->getRefID() . "&envEditor=1");
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:21,代码来源:class.ilObjSCORM2004LearningModuleGUI.php

示例7: importSave

 function importSave()
 {
     global $_FILES, $rbacsystem;
     global $ilias, $lng;
     // check if file was uploaded
     $source = $_FILES["scormfile"]["tmp_name"];
     if ($source == 'none' || !$source) {
         $ilias->raiseError("No file selected!", $ilias->error_obj->MESSAGE);
     }
     // check create permission
     if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], "sahs")) {
         $ilias->raiseError($lng->txt("no_create_permission"), $ilias->error_obj->WARNING);
     }
     // get_cfg_var("upload_max_filesize"); // get the may filesize form t he php.ini
     switch ($__FILES["scormfile"]["error"]) {
         case UPLOAD_ERR_INI_SIZE:
             $ilias->raiseError($lng->txt("err_max_file_size_exceeds"), $ilias->error_obj->MESSAGE);
             break;
         case UPLOAD_ERR_FORM_SIZE:
             $ilias->raiseError($lng->txt("err_max_file_size_exceeds"), $ilias->error_obj->MESSAGE);
             break;
         case UPLOAD_ERR_PARTIAL:
             $ilias->raiseError($lng->txt("err_partial_file_upload"), $ilias->error_obj->MESSAGE);
             break;
         case UPLOAD_ERR_NO_FILE:
             $ilias->raiseError($lng->txt("err_no_file_uploaded"), $ilias->error_obj->MESSAGE);
             break;
     }
     $file = pathinfo($_FILES["scormfile"]["name"]);
     $name = substr($file["basename"], 0, strlen($file["basename"]) - strlen($file["extension"]) - 1);
     $file_path = $this->slm_object->getDataDirectory() . "/" . $this->node_object->getId() . "/" . $_FILES["scormfile"]["name"];
     ilUtil::createDirectory($this->slm_object->getDataDirectory() . "/" . $this->node_object->getId());
     ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"], $_FILES["scormfile"]["name"], $file_path);
     ilUtil::unzip($file_path);
     ilUtil::renameExecutables($this->slm_object->getDataDirectory() . "/" . $this->node_object->getId());
     include_once "./Modules/Scorm2004/classes/ilSCORM13Package.php";
     $newPack = new ilSCORM13Package();
     $newPack->il_importSco($this->slm_object->getId(), $this->node_object->getId(), $this->slm_object->getDataDirectory() . "/" . $this->node_object->getId());
     $this->ctrl->redirect($this, "showOrganization");
 }
开发者ID:bheyser,项目名称:qplskl,代码行数:40,代码来源:class.ilSCORM2004ScoGUI.php

示例8: dbImportSco


//.........这里部分代码省略.........
                     $media_item->setFormat($xMediaItem->Format);
                     $media_item->setLocation($xMediaItem->Location);
                     $media_item->setLocationType($xMediaItem->Location[Type]);
                     $media_item->setWidth($xMediaItem->Layout[Width]);
                     $media_item->setHeight($xMediaItem->Layout[Height]);
                     $media_item->setHAlign($xMediaItem->Layout[HorizontalAlign]);
                     $media_item->setCaption($xMediaItem->Caption);
                     $media_item->setTextRepresentation($xMediaItem->TextRepresentation);
                     $nr = 0;
                     // add map areas (external links only)
                     foreach ($xMediaItem->MapArea as $n => $v) {
                         if ($v->ExtLink[Href] != "") {
                             include_once "./Services/MediaObjects/classes/class.ilMapArea.php";
                             $ma = new ilMapArea();
                             $map_area = new ilMapArea();
                             $map_area->setShape($v[Shape]);
                             $map_area->setCoords($v[Coords]);
                             $map_area->setLinkType(IL_EXT_LINK);
                             $map_area->setTitle($v->ExtLink);
                             $map_area->setHref($v->ExtLink[Href]);
                             $media_item->addMapArea($map_area);
                         }
                     }
                     if ($media_item->getLocationType() == "LocalFile") {
                         //							$tmp_name = $this->packageFolder."/objects/".$OriginId."/".$xMediaItem->Location;
                         //							copy($tmp_name,  $mob_dir."/".$xMediaItem->Location);
                     }
                 }
                 // copy whole directory
                 ilUtil::rCopy($this->packageFolder . "/objects/" . $OriginId, $mob_dir);
                 // alex: fixed media import: these lines have been
                 // behind the next curly bracket which makes it fail
                 // when no medianode is given. (id=0 -> fatal error)
                 ilUtil::renameExecutables($mob_dir);
                 $media_object->update(true);
                 $ttnode[OriginId] = "il__mob_" . $media_object->getId();
             }
         }
         include_once "./Modules/File/classes/class.ilObjFile.php";
         include_once "./Services/Utilities/classes/class.ilFileUtils.php";
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         $intlinks = $page_xml->xpath("//IntLink");
         foreach ($intlinks as $intlink) {
             if ($intlink[Type] != "File") {
                 continue;
             }
             $path = $this->packageFolder . "/objects/" . str_replace('dfile', 'file', $intlink[Target]);
             if (!is_dir($path)) {
                 continue;
             }
             $ffiles = array();
             ilFileUtils::recursive_dirscan($path, $ffiles);
             $filename = $ffiles[file][0];
             $fileObj = new ilObjFile();
             $fileObj->setType("file");
             $fileObj->setTitle(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
             $fileObj->setFileName(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
             // better use this, mime_content_type is deprecated
             $fileObj->setFileType(ilObjMediaObject::getMimeType($path . "/" . $filename));
             $fileObj->setFileSize(filesize($path . "/" . $filename));
             $fileObj->create();
             $fileObj->createReference();
             //$fileObj->putInTree($_GET["ref_id"]);
             //$fileObj->setPermissions($slm->getId ());
             $fileObj->createDirectory();
             $fileObj->storeUnzipedFile($path . "/" . $filename, ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:67,代码来源:ilSCORM13Package.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: parseValue

 /**
  * Function to parse incoming data from form input value $value. returns the strin/number/etc. to store in the database.
  * @param $value
  * @param ilDataCollectionRecordField $record_field
  * @return int|string
  */
 public function parseValue($value, ilDataCollectionRecordField $record_field)
 {
     $return = false;
     if ($this->id == ilDataCollectionDatatype::INPUTFORMAT_FILE) {
         $file = $value;
         if ($file['tmp_name']) {
             $file_obj = new ilObjFile();
             $file_obj->setType("file");
             $file_obj->setTitle($file["name"]);
             $file_obj->setFileName($file["name"]);
             $file_obj->setFileType(ilMimeTypeUtil::getMimeType("", $file["name"], $file["type"]));
             $file_obj->setFileSize($file["size"]);
             $file_obj->setMode("object");
             $file_obj->create();
             $file_obj->getUploadFile($file["tmp_name"], $file["name"]);
             $file_id = $file_obj->getId();
             $return = $file_id;
         } else {
             $return = $record_field->getValue();
         }
     } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_MOB) {
         if ($value == -1) {
             //marked for deletion.
             return 0;
         }
         $media = $value;
         if ($media['tmp_name']) {
             $mob = new ilObjMediaObject();
             $mob->setTitle($media['name']);
             $mob->create();
             $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
             if (!is_dir($mob_dir)) {
                 $mob->createDirectory();
             }
             $media_item = new ilMediaItem();
             $mob->addMediaItem($media_item);
             $media_item->setPurpose("Standard");
             $file_name = ilUtil::getASCIIFilename($media['name']);
             $file_name = str_replace(" ", "_", $file_name);
             $file = $mob_dir . "/" . $file_name;
             $title = $file_name;
             ilUtil::moveUploadedFile($media['tmp_name'], $file_name, $file);
             ilUtil::renameExecutables($mob_dir);
             list($width, $height, $type, $attr) = getimagesize($file);
             $arr_properties = $record_field->getField()->getProperties();
             $new_width = $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH];
             $new_height = $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT];
             if ($new_width || $new_height) {
                 //only resize if it is bigger, not if it is smaller
                 if ($new_height < $height && $new_width < $width) {
                     //resize proportional
                     if (!$new_height || !$new_width) {
                         $format = ilObjMediaObject::getMimeType($file);
                         $wh = ilObjMediaObject::_determineWidthHeight("", "", $format, "File", $file, "", true, false, $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH], (int) $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT]);
                     } else {
                         $wh['width'] = (int) $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH];
                         $wh['height'] = (int) $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT];
                     }
                 }
                 $location = ilObjMediaObject::_resizeImage($file, $wh['width'], $wh['height'], false);
             } else {
                 $location = $title;
             }
             ilObjMediaObject::_saveUsage($mob->getId(), "dcl:html", $record_field->getRecord()->getTable()->getCollectionObject()->getId());
             $format = ilObjMediaObject::getMimeType($file);
             $media_item->setFormat($format);
             $media_item->setLocation($location);
             $media_item->setLocationType("LocalFile");
             $mob->update();
             $return = $mob->getId();
         } else {
             $return = $record_field->getValue();
         }
     } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_DATETIME) {
         return $value["date"] . " " . $value["time"];
     } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_BOOLEAN) {
         $return = $value ? 1 : 0;
     } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_TEXT) {
         $arr_properties = $record_field->getField()->getProperties();
         if ($arr_properties[ilDataCollectionField::PROPERTYID_TEXTAREA]) {
             $return = nl2br($value);
         } else {
             $return = $value;
         }
     } else {
         if ($this->id == ilDataCollectionDatatype::INPUTFORMAT_NUMBER) {
             $return = $value == '' ? null : $value;
             //SW, Ilias Mantis #0011799: Return null otherwise '' is casted to 0 in DB
         } else {
             $return = $value;
         }
     }
     return $return;
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:100,代码来源:class.ilDataCollectionDatatype.php

示例11: createMediaFromUploadDir

 /**
  * Create media object from upload directory
  */
 function createMediaFromUploadDir()
 {
     $mset = new ilSetting("mobs");
     $upload_dir = trim($mset->get("upload_dir"));
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     if (is_array($_POST["file"]) && ilMainMenuGUI::_checkAdministrationPermission()) {
         foreach ($_POST["file"] as $f) {
             $f = str_replace("..", "", $f);
             $fullpath = $upload_dir . "/" . $f;
             $mob = new ilObjMediaObject();
             $mob->setTitle(basename($fullpath));
             $mob->setDescription("");
             $mob->create();
             // determine and create mob directory, move uploaded file to directory
             //$mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob->getId();
             $mob->createDirectory();
             $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
             $media_item = new ilMediaItem();
             $mob->addMediaItem($media_item);
             $media_item->setPurpose("Standard");
             $file = $mob_dir . "/" . basename($fullpath);
             ilUtil::moveUploadedFile($fullpath, basename($fullpath), $file, false, $_POST["action"]);
             // get mime type
             $format = ilObjMediaObject::getMimeType($file);
             $location = basename($fullpath);
             // set real meta and object data
             $media_item->setFormat($format);
             $media_item->setLocation($location);
             $media_item->setLocationType("LocalFile");
             $mob->setDescription($format);
             // determine width and height of known image types
             $wh = ilObjMediaObject::_determineWidthHeight(500, 400, $format, "File", $mob_dir . "/" . $location, $media_item->getLocation(), true, true, "", "");
             $media_item->setWidth($wh["width"]);
             $media_item->setHeight($wh["height"]);
             if ($wh["info"] != "") {
                 //				ilUtil::sendInfo($wh["info"], true);
             }
             $media_item->setHAlign("Left");
             ilUtil::renameExecutables($mob_dir);
             $mob->update();
             // put it into current folder
             $mep_item = new ilMediaPoolItem();
             $mep_item->setTitle($mob->getTitle());
             $mep_item->setType("mob");
             $mep_item->setForeignId($mob->getId());
             $mep_item->create();
             $tree = $this->object->getTree();
             $parent = $_GET["mepitem_id"] == "" ? $tree->getRootId() : $_GET["mepitem_id"];
             $tree->insertNode($mep_item->getId(), $parent);
         }
     }
     ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=" . $_GET["ref_id"] . "&mepitem_id=" . $_GET["mepitem_id"]);
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:56,代码来源:class.ilObjMediaPoolGUI.php

示例12: create

 /**
  * Create new content element
  */
 function create()
 {
     global $ilCtrl, $lng;
     $this->content_obj = new ilPCInteractiveImage($this->getPage());
     $this->content_obj->createMediaObject();
     $media_obj = $this->content_obj->getMediaObject();
     $media_obj->setTitle($_FILES['image_file']['name']);
     $media_obj->create();
     $mob_dir = ilObjMediaObject::_getDirectory($media_obj->getId());
     //		$media_obj->setStandardType("File");
     $media_obj->createDirectory();
     $media_item = new ilMediaItem();
     $media_obj->addMediaItem($media_item);
     $media_item->setPurpose("Standard");
     $file = $mob_dir . "/" . $_FILES['image_file']['name'];
     ilUtil::moveUploadedFile($_FILES['image_file']['tmp_name'], $_FILES['image_file']['name'], $file);
     // get mime type
     $format = ilObjMediaObject::getMimeType($file);
     $location = $_FILES['image_file']['name'];
     // set real meta and object data
     $media_item->setFormat($format);
     $media_item->setLocation($location);
     $media_item->setLocationType("LocalFile");
     ilUtil::renameExecutables($mob_dir);
     $media_obj->update();
     $this->content_obj->createAlias($this->pg_obj, $this->hier_id, $this->pc_id);
     $this->updated = $this->pg_obj->update();
     if ($this->updated === true) {
         $this->pg_obj->stripHierIDs();
         $this->pg_obj->addHierIDs();
         $ilCtrl->setParameter($this, "hier_id", $this->content_obj->readHierId());
         $ilCtrl->setParameter($this, "pc_id", $this->content_obj->readPCId());
         $this->content_obj->setHierId($this->content_obj->readHierId());
         $this->setHierId($this->content_obj->readHierId());
         $this->content_obj->setPCId($this->content_obj->readPCId());
         ilUtil::sendSuccess($lng->txt("cont_saved_interactive_image"), true);
         $this->ctrl->redirectByClass("ilpcinteractiveimagegui", "edit");
         //$this->ctrl->returnToParent($this, "jump".$this->hier_id);
     } else {
         $this->insert();
     }
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:45,代码来源:class.ilPCInteractiveImageGUI.php

示例13: configureFile

 /**
  * Configures the file for the updateFloorPlanInfosWithFile and addFloorPlan function.
  *
  * @param ilObjMediaObject $a_mediaObj
  * @param array            $a_newfile
  *
  * @return array with format and filename
  */
 private function configureFile($a_mediaObj, $a_newfile = NULL)
 {
     if ($this->mobjMock) {
         return $a_newfile;
     }
     $mob_dir = ilObjMediaObject::_getDirectory($a_mediaObj->getId());
     if (!is_dir($mob_dir)) {
         $a_mediaObj->createDirectory();
     }
     $file_name = ilUtil::getASCIIFilename($a_newfile["name"]);
     $file_name_mod = str_replace(" ", "_", $file_name);
     $file = $mob_dir . "/" . $file_name_mod;
     // construct file path
     ilUtil::moveUploadedFile($a_newfile["tmp_name"], $file_name_mod, $file);
     ilUtil::renameExecutables($mob_dir);
     $format = ilObjMediaObject::getMimeType($file);
     return array("format" => $format, "filename" => $file_name_mod);
 }
开发者ID:studer-raimann,项目名称:RoomSharing,代码行数:26,代码来源:class.ilRoomSharingFloorPlans.php

示例14: populateByDirectoy

 /**
  * Populate by directory. Add a filename to do a special check for
  * ILIAS HTML export files. If the corresponding directory is found
  * within the passed directory path (i.e. "htlm_<id>") this
  * subdirectory is used instead.
  *
  * @param
  * @return
  */
 function populateByDirectoy($a_dir, $a_filename = "")
 {
     preg_match("/.*htlm_([0-9]*)\\.zip/", $a_filename, $match);
     if (is_dir($a_dir . "/htlm_" . $match[1])) {
         $a_dir = $a_dir . "/htlm_" . $match[1];
     }
     ilUtil::rCopy($a_dir, $this->getDataDirectory());
     ilUtil::renameExecutables($this->getDataDirectory());
 }
开发者ID:bheyser,项目名称:qplskl,代码行数:18,代码来源:class.ilObjFileBasedLM.php

示例15: newModuleVersionUpload

 function newModuleVersionUpload()
 {
     global $_FILES, $rbacsystem;
     $unzip = PATH_TO_UNZIP;
     $tocheck = "imsmanifest.xml";
     include_once 'Services/FileSystem/classes/class.ilUploadFiles.php';
     // check create permission before because the uploaded file will be copied
     if (!$rbacsystem->checkAccess("write", $_GET["ref_id"])) {
         $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING);
     } elseif ($_FILES["scormfile"]["name"]) {
         // check if file was uploaded
         $source = $_FILES["scormfile"]["tmp_name"];
         if ($source == 'none' || !$source) {
             ilUtil::sendInfo($this->lng->txt("upload_error_file_not_found"), true);
             $this->newModuleVersion();
             return;
         }
     } elseif ($_POST["uploaded_file"]) {
         // check if the file is in the ftp directory and readable
         if (!ilUploadFiles::_checkUploadFile($_POST["uploaded_file"])) {
             $this->ilias->raiseError($this->lng->txt("upload_error_file_not_found"), $this->ilias->error_obj->MESSAGE);
         }
         // copy the uploaded file to the client web dir to analyze the imsmanifest
         // the copy will be moved to the lm directory or deleted
         $source = CLIENT_WEB_DIR . "/" . $_POST["uploaded_file"];
         ilUploadFiles::_copyUploadFile($_POST["uploaded_file"], $source);
         $source_is_copy = true;
     } else {
         ilUtil::sendInfo($this->lng->txt("upload_error_file_not_found"), true);
         $this->newModuleVersion();
         return;
     }
     // fim.
     //unzip the imsmanifest-file from new uploaded file
     $pathinfo = pathinfo($source);
     $dir = $pathinfo["dirname"];
     $file = $pathinfo["basename"];
     $cdir = getcwd();
     chdir($dir);
     //we need more flexible unzip here than ILIAS standard classes allow
     $unzipcmd = $unzip . " -o " . ilUtil::escapeShellArg($source) . " " . $tocheck;
     exec($unzipcmd);
     chdir($cdir);
     $tmp_file = $dir . "/" . $tocheck . "." . $_GET["ref_id"];
     rename($dir . "/" . $tocheck, $tmp_file);
     $new_manifest = file_get_contents($tmp_file);
     //remove temp file
     unlink($tmp_file);
     //get old manifest file
     $old_manifest = file_get_contents($this->object->getDataDirectory() . "/" . $tocheck);
     //reload fixed version of file
     $check = '/xmlns="http:\\/\\/www.imsglobal.org\\/xsd\\/imscp_v1p1"/';
     $replace = "xmlns=\"http://www.imsproject.org/xsd/imscp_rootv1p1p2\"";
     $reload_manifest = preg_replace($check, $replace, $new_manifest);
     //do testing for converted versions as well as earlier ILIAS version messed up utf8 conversion
     if (strcmp($new_manifest, $old_manifest) == 0 || strcmp(utf8_encode($new_manifest), $old_manifest) == 0 || strcmp($reload_manifest, $old_manifest) == 0 || strcmp(utf8_encode($reload_manifest), $old_manifest) == 0) {
         //get exisiting module version
         $module_version = $this->object->getModuleVersion();
         if ($_FILES["scormfile"]["name"]) {
             //build targetdir in lm_data
             $file_path = $this->object->getDataDirectory() . "/" . $_FILES["scormfile"]["name"] . "." . $module_version;
             //move to data directory and add subfix for versioning
             ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"], $_FILES["scormfile"]["name"], $file_path);
         } else {
             //build targetdir in lm_data
             $file_path = $this->object->getDataDirectory() . "/" . $_POST["uploaded_file"] . "." . $module_version;
             // move the already copied file to the lm_data directory
             rename($source, $file_path);
         }
         //unzip and replace old extracted files
         ilUtil::unzip($file_path, true);
         ilUtil::renameExecutables($this->object->getDataDirectory());
         //(security)
         //increase module version
         $this->object->setModuleVersion($module_version + 1);
         $this->object->update();
         //redirect to properties and display success
         ilUtil::sendInfo($this->lng->txt("cont_new_module_added"), true);
         ilUtil::redirect("ilias.php?baseClass=ilSAHSEditGUI&ref_id=" . $_GET["ref_id"]);
         exit;
     } else {
         if ($source_is_copy) {
             unlink($source);
         }
         ilUtil::sendInfo($this->lng->txt("cont_invalid_new_module"), true);
         $this->newModuleVersion();
     }
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:88,代码来源:class.ilObjSCORMLearningModuleGUI.php


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