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


PHP ilObjFile::setFileType方法代码示例

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


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

示例1: newFileItem

 /**
  * insert new file item
  */
 function newFileItem()
 {
     global $lng;
     if ($_FILES["file"]["name"] == "") {
         $_GET["subCmd"] = "-";
         ilUtil::sendFailure($lng->txt("upload_error_file_not_found"));
         return false;
     }
     include_once "./Modules/File/classes/class.ilObjFile.php";
     $fileObj = new ilObjFile();
     $fileObj->setType("file");
     $fileObj->setTitle($_FILES["file"]["name"]);
     $fileObj->setDescription("");
     $fileObj->setFileName($_FILES["file"]["name"]);
     $fileObj->setFileType($_FILES["file"]["type"]);
     $fileObj->setFileSize($_FILES["file"]["size"]);
     $fileObj->setMode("filelist");
     $fileObj->create();
     $fileObj->raiseUploadError(false);
     // upload file to filesystem
     $fileObj->createDirectory();
     $fileObj->getUploadFile($_FILES["file"]["tmp_name"], $_FILES["file"]["name"]);
     $this->file_object =& $fileObj;
     return true;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:28,代码来源:class.ilPCFileItemGUI.php

示例2: saveFileLink

 /**
  * Save file link
  */
 function saveFileLink()
 {
     $mtpl =& new ilTemplate("tpl.link_help.html", true, true, "Modules/LearningModule");
     $mtpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     if ($_FILES["link_file"]["name"] != "") {
         include_once "./Modules/File/classes/class.ilObjFile.php";
         $fileObj = new ilObjFile();
         $fileObj->setType("file");
         $fileObj->setTitle($_FILES["link_file"]["name"]);
         $fileObj->setDescription("");
         $fileObj->setFileName($_FILES["link_file"]["name"]);
         $fileObj->setFileType($_FILES["link_file"]["type"]);
         $fileObj->setFileSize($_FILES["link_file"]["size"]);
         $fileObj->setMode("filelist");
         $fileObj->create();
         // upload file to filesystem
         $fileObj->createDirectory();
         $fileObj->raiseUploadError(false);
         $fileObj->getUploadFile($_FILES["link_file"]["tmp_name"], $_FILES["link_file"]["name"]);
         $this->uploaded_file = $fileObj;
     }
     $this->showLinkHelp();
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:26,代码来源:class.ilInternalLinkGUI.php

示例3: handleFileUpload

 public function handleFileUpload()
 {
     global $tree;
     include_once './Modules/Session/classes/class.ilEventItems.php';
     $ev = new ilEventItems($this->object->getId());
     $items = $ev->getItems();
     $counter = 0;
     while (true) {
         if (!isset($_FILES['files']['name'][$counter])) {
             break;
         }
         if (!strlen($_FILES['files']['name'][$counter])) {
             $counter++;
             continue;
         }
         include_once './Modules/File/classes/class.ilObjFile.php';
         $file = new ilObjFile();
         $file->setTitle(ilUtil::stripSlashes($_FILES['files']['name'][$counter]));
         $file->setDescription('');
         $file->setFileName(ilUtil::stripSlashes($_FILES['files']['name'][$counter]));
         $file->setFileType($_FILES['files']['type'][$counter]);
         $file->setFileSize($_FILES['files']['size'][$counter]);
         $file->create();
         $new_ref_id = $file->createReference();
         $file->putInTree($tree->getParentId($this->object->getRefId()));
         $file->setPermissions($tree->getParentId($this->object->getRefId()));
         $file->createDirectory();
         $file->getUploadFile($_FILES['files']['tmp_name'][$counter], $_FILES['files']['name'][$counter]);
         $items[] = $new_ref_id;
         $counter++;
     }
     $ev->setItems($items);
     $ev->update();
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:34,代码来源:class.ilObjSessionGUI.php

示例4: handleFileUpload


//.........这里部分代码省略.........
         $adopt_structure = $keep_structure;
         include_once "Services/Utilities/classes/class.ilFileUtils.php";
         // Create unzip-directory
         $newDir = ilUtil::ilTempnam();
         ilUtil::makeDir($newDir);
         // Check if permission is granted for creation of object, if necessary
         if ($this->id_type != self::WORKSPACE_NODE_ID) {
             $type = ilObject::_lookupType((int) $this->parent_id, true);
         } else {
             $type = ilObject::_lookupType($this->tree->lookupObjectId($this->parent_id), false);
         }
         $tree = $access_handler = null;
         switch ($type) {
             // workspace structure
             case 'wfld':
             case 'wsrt':
                 $permission = $this->checkPermissionBool("create", "", "wfld");
                 $containerType = "WorkspaceFolder";
                 $tree = $this->tree;
                 $access_handler = $this->getAccessHandler();
                 break;
                 // use categories as structure
             // use categories as structure
             case 'cat':
             case 'root':
                 $permission = $this->checkPermissionBool("create", "", "cat");
                 $containerType = "Category";
                 break;
                 // use folders as structure (in courses)
             // use folders as structure (in courses)
             default:
                 $permission = $this->checkPermissionBool("create", "", "fold");
                 $containerType = "Folder";
                 break;
         }
         try {
             // 	processZipFile (
             //		Dir to unzip,
             //		Path to uploaded file,
             //		should a structure be created (+ permission check)?
             //		ref_id of parent
             //		object that contains files (folder or category)
             //		should sendInfo be persistent?)
             ilFileUtils::processZipFile($newDir, $temp_name, $adopt_structure && $permission, $this->parent_id, $containerType, $tree, $access_handler);
         } catch (ilFileUtilsException $e) {
             $response->error = $e->getMessage();
         } catch (Exception $ex) {
             $response->error = $ex->getMessage();
         }
         ilUtil::delDir($newDir);
         // #15404
         if ($this->id_type != self::WORKSPACE_NODE_ID) {
             foreach (ilFileUtils::getNewObjects() as $parent_ref_id => $objects) {
                 if ($parent_ref_id != $this->parent_id) {
                     continue;
                 }
                 foreach ($objects as $object) {
                     $this->after_creation_callback_objects[] = $object;
                 }
             }
         }
     } else {
         if (trim($title) == "") {
             $title = $filename;
         } else {
             // BEGIN WebDAV: Ensure that object title ends with the filename extension
             $fileExtension = ilObjFileAccess::_getFileExtension($filename);
             $titleExtension = ilObjFileAccess::_getFileExtension($title);
             if ($titleExtension != $fileExtension && strlen($fileExtension) > 0) {
                 $title .= '.' . $fileExtension;
             }
             // END WebDAV: Ensure that object title ends with the filename extension
         }
         // create and insert file in grp_tree
         include_once "./Modules/File/classes/class.ilObjFile.php";
         $fileObj = new ilObjFile();
         $fileObj->setTitle($title);
         $fileObj->setDescription($description);
         $fileObj->setFileName($filename);
         include_once "./Services/Utilities/classes/class.ilMimeTypeUtil.php";
         $fileObj->setFileType(ilMimeTypeUtil::getMimeType("", $filename, $type));
         $fileObj->setFileSize($size);
         $this->object_id = $fileObj->create();
         $this->putObjectInTree($fileObj, $this->parent_id);
         // see uploadFiles()
         if (is_array($this->after_creation_callback_objects)) {
             $this->after_creation_callback_objects[] = $fileObj;
         }
         // upload file to filesystem
         $fileObj->createDirectory();
         $fileObj->raiseUploadError(false);
         $fileObj->getUploadFile($temp_name, $filename);
         $this->handleAutoRating($fileObj);
         // BEGIN ChangeEvent: Record write event.
         require_once './Services/Tracking/classes/class.ilChangeEvent.php';
         ilChangeEvent::_recordWriteEvent($fileObj->getId(), $ilUser->getId(), 'create');
         // END ChangeEvent: Record write event.
     }
     return $response;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:101,代码来源:class.ilObjFileGUI.php

示例5: 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

示例6: dbImportSco


//.........这里部分代码省略.........
                             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)));
             $intlink[Target] = "il__dfile_" . $fileObj->getId();
         }
         $fileitems = $page_xml->xpath("//FileItem/Identifier");
         foreach ($fileitems as $fileitem) {
             $path = $this->packageFolder . "/objects/" . $fileitem[Entry];
             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)));
             $fileitem[Entry] = "il__file_" . $fileObj->getId();
         }
         $pagex = new ilSCORM2004Page($page->getId());
         $ddoc = new DOMDocument();
         $ddoc->async = false;
         $ddoc->preserveWhiteSpace = false;
         $ddoc->formatOutput = false;
         $ddoc->loadXML($page_xml->asXML());
         $xpath = new DOMXPath($ddoc);
         $tnode = $xpath->query('PageContent');
         $t = "<PageObject>";
         foreach ($tnode as $ttnode) {
             $t .= $ddoc->saveXML($ttnode);
         }
         $t .= "</PageObject>";
         foreach ($qtis as $old => $q) {
             $t = str_replace($old, 'il__qst_' . $q['pool'], $t);
         }
         $pagex->setXMLContent($t);
         $pagex->updateFromXML();
     }
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:101,代码来源:ilSCORM13Package.php

示例7: createFile

 /**	
  * Creates a dav file as a child of this object.
  *
  * @param	string		the name of the file.
  * @return	ilObjectDAV	returns the created object, or null if creation failed.
  */
 function createFile($name)
 {
     global $tree;
     // create and insert Folder in tree
     require_once 'Modules/File/classes/class.ilObjFile.php';
     $newObj = new ilObjFile(0);
     $newObj->setType($this->getILIASFileType());
     $newObj->setTitle($name);
     $newObj->setFileName($name);
     include_once "./Services/Utilities/classes/class.ilMimeTypeUtil.php";
     $mime = ilMimeTypeUtil::getMimeType("", $name, 'application/octet-stream');
     //$newObj->setFileType('application/octet-stream');
     $newObj->setFileType($mime);
     //$newObj->setDescription('');
     $newObj->create();
     $newObj->createReference();
     $newObj->setPermissions($this->getRefId());
     $newObj->putInTree($this->getRefId());
     //$newObj->createDirectory();
     require_once 'class.ilObjFileDAV.php';
     $objDAV = new ilObjFileDAV($newObj->getRefId(), $newObj);
     /*		
     $fs = $objDAV->getContentOutputStream();
     fwrite($fs,' ');
     fclose($fs);
     */
     return $objDAV;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:34,代码来源:class.ilObjectDAV.php

示例8: handlerEndTag

 /**
  * handler for end of element
  *
  * @param	resource	$a_xml_parser		xml parser
  * @param	string		$a_name				element name
  */
 function handlerEndTag($a_xml_parser, $a_name)
 {
     $this->cdata = trim($this->cdata);
     $GLOBALS['ilLog']->write(__METHOD__ . ': ' . $this->cdata);
     switch ($a_name) {
         case 'File':
             $this->result = true;
             break;
         case 'Filename':
             if (strlen($this->cdata) == 0) {
                 throw new ilFileException("Filename ist missing!");
             }
             $this->file->setFilename($this->cdata);
             $this->file->setTitle($this->cdata);
             break;
         case 'Title':
             $this->file->setTitle(trim($this->cdata));
             break;
         case 'Description':
             $this->file->setDescription(trim($this->cdata));
             break;
         case 'Content':
             $GLOBALS['ilLog']->write($this->mode);
             $this->isReadingFile = false;
             $baseDecodedFilename = ilUtil::ilTempnam();
             if ($this->mode == ilFileXMLParser::$CONTENT_COPY) {
                 $this->tmpFilename = $this->getImportDirectory() . "/" . $this->cdata;
             } elseif ($this->mode == ilFileXMLParser::$CONTENT_REST) {
                 include_once './Services/WebServices/Rest/classes/class.ilRestFileStorage.php';
                 $storage = new ilRestFileStorage();
                 $this->tmpFilename = $storage->getStoredFilePath($this->cdata);
                 if (!ilFileUtils::fastBase64Decode($this->tmpFilename, $baseDecodedFilename)) {
                     throw new ilFileException("Base64-Decoding failed", ilFileException::$DECOMPRESSION_FAILED);
                 }
                 $this->tmpFilename = $baseDecodedFilename;
             } else {
                 if (!ilFileUtils::fastBase64Decode($this->tmpFilename, $baseDecodedFilename)) {
                     throw new ilFileException("Base64-Decoding failed", ilFileException::$DECOMPRESSION_FAILED);
                 }
                 if ($this->mode == ilFileXMLParser::$CONTENT_GZ_COMPRESSED) {
                     if (!ilFileUtils::fastGunzip($baseDecodedFilename, $this->tmpFilename)) {
                         throw new ilFileException("Deflating with fastzunzip failed", ilFileException::$DECOMPRESSION_FAILED);
                     }
                     unlink($baseDecodedFilename);
                 } elseif ($this->mode == ilFileXMLParser::$CONTENT_ZLIB_COMPRESSED) {
                     if (!ilFileUtils::fastGunzip($baseDecodedFilename, $this->tmpFilename)) {
                         throw new ilFileException("Deflating with fastDecompress failed", ilFileException::$DECOMPRESSION_FAILED);
                     }
                     unlink($baseDecodedFilename);
                 } else {
                     $this->tmpFilename = $baseDecodedFilename;
                 }
             }
             //$this->content = $content;
             $this->file->setFileSize(filesize($this->tmpFilename));
             // strlen($this->content));
             // if no file type is given => lookup mime type
             if (!$this->file->getFileType()) {
                 global $ilLog;
                 #$ilLog->write(__METHOD__.': Trying to detect mime type...');
                 include_once './Services/Utilities/classes/class.ilFileUtils.php';
                 $this->file->setFileType(ilFileUtils::_lookupMimeType($this->tmpFilename));
             }
             break;
     }
     $this->cdata = '';
     return;
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:74,代码来源:class.ilFileXMLParser.php

示例9: save

 /**
  * save object
  *
  * @access	public
  */
 function save()
 {
     global $objDefinition, $ilUser;
     if (!$this->checkPermissionBool("create", "", "file")) {
         $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE);
     }
     $single_form_gui = $this->initSingleUploadForm();
     if ($single_form_gui->checkInput()) {
         $title = $single_form_gui->getInput("title");
         $description = $single_form_gui->getInput("description");
         $upload_file = $single_form_gui->getInput("upload_file");
         if (trim($title) == "") {
             $title = $upload_file["name"];
         } else {
             // BEGIN WebDAV: Ensure that object title ends with the filename extension
             $fileExtension = ilObjFileAccess::_getFileExtension($upload_file["name"]);
             $titleExtension = ilObjFileAccess::_getFileExtension($title);
             if ($titleExtension != $fileExtension && strlen($fileExtension) > 0) {
                 $title .= '.' . $fileExtension;
             }
             // END WebDAV: Ensure that object title ends with the filename extension
         }
         // create and insert file in grp_tree
         include_once "./Modules/File/classes/class.ilObjFile.php";
         $fileObj = new ilObjFile();
         $fileObj->setTitle($title);
         $fileObj->setDescription($description);
         $fileObj->setFileName($upload_file["name"]);
         //$fileObj->setFileType($upload_file["type"]);
         include_once "./Services/Utilities/classes/class.ilMimeTypeUtil.php";
         $fileObj->setFileType(ilMimeTypeUtil::getMimeType("", $upload_file["name"], $upload_file["type"]));
         $fileObj->setFileSize($upload_file["size"]);
         $this->object_id = $fileObj->create();
         $this->putObjectInTree($fileObj, $this->parent_id);
         // upload file to filesystem
         $fileObj->createDirectory();
         $fileObj->getUploadFile($upload_file["tmp_name"], $upload_file["name"]);
         // BEGIN ChangeEvent: Record write event.
         require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
         ilChangeEvent::_recordWriteEvent($fileObj->getId(), $ilUser->getId(), 'create');
         // END ChangeEvent: Record write event.
         ilUtil::sendSuccess($this->lng->txt("file_added"), true);
         if ($this->ctrl->getCmd() == "saveAndMeta") {
             $this->ctrl->setParameter($this, "new_type", "");
             $target = $this->ctrl->getLinkTargetByClass(array("ilobjfilegui", "ilmdeditorgui"), "listSection", "", false, false);
             ilUtil::redirect($target);
         } else {
             $this->ctrl->returnToParent($this);
         }
     } else {
         $single_form_gui->setValuesByPost();
         $this->tpl->setContent($single_form_gui->getHTML());
     }
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:59,代码来源:class.ilObjFileGUI.php

示例10: createFile

 /**
  * Creates and inserts file object into tree
  *
  * @author Jan Hippchen
  * @version 1.6.9.07	
  * @param string $filename Name of the object
  * @param string $path Path to file 
  * @param integer $ref_id ref_id of parent
  */
 function createFile($filename, $path, $ref_id, $tree = null, $access_handler = null)
 {
     global $rbacsystem;
     if (!$access_handler) {
         $permission = $rbacsystem->checkAccess("create", $ref_id, "file");
     } else {
         $permission = $access_handler->checkAccess("create", "", $ref_id, "file");
     }
     if ($permission) {
         // create and insert file in grp_tree
         include_once "./Modules/File/classes/class.ilObjFile.php";
         $fileObj = new ilObjFile();
         $fileObj->setType($this->type);
         $fileObj->setTitle(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
         $fileObj->setFileName(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
         // better use this, mime_content_type is deprecated
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         $fileObj->setFileType(ilObjMediaObject::getMimeType($path . "/" . $filename));
         $fileObj->setFileSize(filesize($path . "/" . $filename));
         $fileObj->create();
         // repository
         if (!$access_handler) {
             $fileObj->createReference();
             $fileObj->putInTree($ref_id);
             $fileObj->setPermissions($ref_id);
             self::$new_files[$ref_id][] = $fileObj;
         } else {
             $node_id = $tree->insertObject($ref_id, $fileObj->getId());
             $access_handler->setPermissions($ref_id, $node_id);
         }
         // upload file to filesystem
         $fileObj->createDirectory();
         $fileObj->storeUnzipedFile($path . "/" . $filename, ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
     } else {
         $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE);
     }
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:46,代码来源:class.ilFileUtils.php


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