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


PHP ilObjFile::create方法代码示例

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


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

 /**
  * add an File with id.
  *
  * @param string $session_id    current session
  * @param int $target_id refid of parent in repository
  * @param string $file_xml   qti xml description of test
  *
  * @return int reference id in the tree, 0 if not successful
  */
 function addFile($sid, $target_id, $file_xml)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     global $rbacsystem, $tree, $ilLog, $ilAccess;
     if (!($target_obj =& ilObjectFactory::getInstanceByRefId($target_id, false))) {
         return $this->__raiseError('No valid target given.', 'Client');
     }
     if (ilObject::_isInTrash($target_id)) {
         return $this->__raiseError("Parent with ID {$target_id} has been deleted.", 'CLIENT_TARGET_DELETED');
     }
     // Check access
     $allowed_types = array('cat', 'grp', 'crs', 'fold', 'root');
     if (!in_array($target_obj->getType(), $allowed_types)) {
         return $this->__raiseError('No valid target type. Target must be reference id of "course, group, category or folder"', 'Client');
     }
     if (!$ilAccess->checkAccess('create', '', $target_id, "file")) {
         return $this->__raiseError('No permission to create Files in target  ' . $target_id . '!', 'Client');
     }
     // create object, put it into the tree and use the parser to update the settings
     include_once './Modules/File/classes/class.ilFileXMLParser.php';
     include_once './Modules/File/classes/class.ilFileException.php';
     include_once './Modules/File/classes/class.ilObjFile.php';
     $file = new ilObjFile();
     try {
         $fileXMLParser = new ilFileXMLParser($file, $file_xml);
         if ($fileXMLParser->start()) {
             global $ilLog;
             $ilLog->write(__METHOD__ . ': File type: ' . $file->getFileType());
             $file->create();
             $file->createReference();
             $file->putInTree($target_id);
             $file->setPermissions($target_id);
             // we now can save the file contents since we know the obj id now.
             $fileXMLParser->setFileContents();
             #$file->update();
             return $file->getRefId();
         } else {
             return $this->__raiseError("Could not add file", "Server");
         }
     } catch (ilFileException $exception) {
         return $this->__raiseError($exception->getMessage(), $exception->getCode() == ilFileException::$ID_MISMATCH ? "Client" : "Server");
     }
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:56,代码来源:class.ilSoapFileAdministration.php

示例3: importXmlRepresentation

 /**
  * Import XML
  *
  * @param
  * @return
  */
 function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
 {
     include_once './Modules/File/classes/class.ilObjFile.php';
     // case i container
     if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
         $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
     } else {
         $newObj = new ilObjFile();
         $newObj->create(true);
     }
     include_once "./Modules/File/classes/class.ilFileXMLParser.php";
     $parser = new ilFileXMLParser($newObj, $a_xml);
     $parser->setImportDirectory($this->getImportDirectory());
     $parser->startParsing();
     $newObj->createProperties(false, false);
     $parser->setFileContents();
     $this->current_obj = $newObj;
     $newObj->update();
     // this is necessary for case ii (e.g. wiki import)
     $a_mapping->addMapping("Modules/File", "file", $a_id, $newObj->getId());
     $a_mapping->addMapping("Services/MetaData", "md", $a_id . ":0:file", $newObj->getId() . ":0:file");
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:28,代码来源:class.ilFileImporter.php

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

示例5: generateFiles

 /**
  * Generate files
  *
  * @param
  * @return
  */
 function generateFiles($a_test_file, $a_files_per_course = 10, $a_title_base = "File")
 {
     global $tree;
     include_once "./Modules/File/classes/class.ilObjFile.php";
     $this->log("Creating Files");
     $a_current = $a_start;
     // get all categories and sort them by depth
     $crs_ref_ids = ilUtil::_getObjectsByOperations("crs", "read", 0, $limit = 1000000);
     $cnt = 1;
     foreach ($crs_ref_ids as $rid) {
         for ($i = 1; $i <= $a_files_per_course; $i++) {
             $this->log($a_title_base . " " . $cnt);
             $fileObj = new ilObjFile();
             $fileObj->setTitle($a_title_base . " " . $cnt);
             $fileObj->setFileName("file_" . $cnt . ".txt");
             $fileObj->create();
             $fileObj->createReference();
             $fileObj->putInTree($rid);
             $fileObj->setPermissions($rid);
             $fileObj->createDirectory();
             $fileObj->getUploadFile($a_test_file, "file_" . $cnt . ".txt");
             $cnt++;
         }
     }
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:31,代码来源:class.ilDataLoader.php

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

示例7: handleFileUpload

 /**
  * Handles the upload of a single file and adds it to the parent object.
  * 
  * @param array $file_upload An array containing the file upload parameters.
  * @return object The response object.
  */
 protected function handleFileUpload($file_upload)
 {
     global $ilUser;
     // file upload params
     $filename = $file_upload["name"];
     $type = $file_upload["type"];
     $size = $file_upload["size"];
     $temp_name = $file_upload["tmp_name"];
     // additional params
     $title = $file_upload["title"];
     $description = $file_upload["description"];
     $extract = $file_upload["extract"];
     $keep_structure = $file_upload["keep_structure"];
     // create answer object
     $response = new stdClass();
     $response->fileName = $filename;
     $response->fileSize = intval($size);
     $response->fileType = $type;
     $response->fileUnzipped = $extract;
     $response->error = null;
     // extract archive?
     if ($extract) {
         $zip_file = $filename;
         $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;
             }
//.........这里部分代码省略.........
开发者ID:arlendotcn,项目名称:ilias,代码行数:101,代码来源:class.ilObjFileGUI.php

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

示例9: dbImportSco

 public function dbImportSco($slm, $sco, $asset = false)
 {
     $qtis = array();
     $d = ilUtil::getDir($this->packageFolder);
     foreach ($d as $f) {
         //continue;
         if ($f[type] == 'file' && substr($f[entry], 0, 4) == 'qti_') {
             include_once "./Services/QTI/classes/class.ilQTIParser.php";
             include_once "./Modules/Test/classes/class.ilObjTest.php";
             $qtiParser = new ilQTIParser($this->packageFolder . "/" . $f[entry], IL_MO_VERIFY_QTI, 0, "");
             $result = $qtiParser->startParsing();
             $founditems =& $qtiParser->getFoundItems();
             //					die(print_r($founditems));
             foreach ($founditems as $qp) {
                 $newObj = new ilObjTest(0, true);
                 // This creates a lot of invalid repository objects for each question
                 // question are not repository objects (see e.g. table object_data), alex 29 Sep 2009
                 //					$newObj->setType ( $qp ['type'] );
                 //					$newObj->setTitle ( $qp ['title'] );
                 //					$newObj->create ( true );
                 //					$newObj->createReference ();
                 //					$newObj->putInTree ($_GET ["ref_id"]);
                 //					$newObj->setPermissions ( $sco->getId ());
                 //					$newObj->notify ("new", $_GET["ref_id"], $sco->getId (), $_GET["ref_id"], $newObj->getRefId () );
                 //					$newObj->mark_schema->flush ();
                 $qtiParser = new ilQTIParser($this->packageFolder . "/" . $f[entry], IL_MO_PARSE_QTI, 0, "");
                 $qtiParser->setTestObject($newObj);
                 $result = $qtiParser->startParsing();
                 //					$newObj->saveToDb ();
                 $qtis = array_merge($qtis, $qtiParser->getImportMapping());
             }
         }
     }
     //exit;
     include_once 'Modules/Scorm2004/classes/class.ilSCORM2004Page.php';
     $doc = new SimpleXMLElement($this->imsmanifest->saveXml());
     $l = $doc->xpath("/ContentObject/MetaData");
     if ($l[0]) {
         include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
         $mdxml =& new ilMDXMLCopier($l[0]->asXML(), $slm->getId(), $sco->getId(), $sco->getType());
         $mdxml->startParsing();
         $mdxml->getMDObject()->update();
     }
     $l = $doc->xpath("/ContentObject/PageObject");
     foreach ($l as $page_xml) {
         $tnode = $page_xml->xpath('MetaData/General/Title');
         $page = new ilSCORM2004PageNode($slm);
         $page->setTitle($tnode[0]);
         $page->setSLMId($slm->getId());
         $page->create(true);
         ilSCORM2004Node::putInTree($page, $sco->getId(), $target);
         $pmd = $page_xml->xpath("MetaData");
         if ($pmd[0]) {
             include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
             $mdxml =& new ilMDXMLCopier($pmd[0]->asXML(), $slm->getId(), $page->getId(), $page->getType());
             $mdxml->startParsing();
             $mdxml->getMDObject()->update();
         }
         $tnode = $page_xml->xpath("//MediaObject/MediaAlias | //InteractiveImage/MediaAlias");
         foreach ($tnode as $ttnode) {
             include_once './Services/MediaObjects/classes/class.ilObjMediaObject.php';
             $OriginId = $ttnode[OriginId];
             $medianodes = $doc->xpath("//MediaObject[MetaData/General/Identifier/@Entry='" . $OriginId . "']");
             $medianode = $medianodes[0];
             if ($medianode) {
                 $media_object = new ilObjMediaObject();
                 $media_object->setTitle($medianode->MetaData->General->Title);
                 $media_object->setDescription($medianode->MetaData->General->Description);
                 $media_object->create(false);
                 $mmd = $medianode->xpath("MetaData");
                 if ($mmd[0]) {
                     include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
                     $mdxml =& new ilMDXMLCopier($mmd[0]->asXML(), 0, $media_object->getId(), $media_object->getType());
                     $mdxml->startParsing();
                     $mdxml->getMDObject()->update();
                 }
                 // determine and create mob directory, move uploaded file to directory
                 $media_object->createDirectory();
                 $mob_dir = ilObjMediaObject::_getDirectory($media_object->getId());
                 foreach ($medianode->MediaItem as $xMediaItem) {
                     $media_item =& new ilMediaItem();
                     $media_object->addMediaItem($media_item);
                     $media_item->setPurpose($xMediaItem[Purpose]);
                     $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]);
//.........这里部分代码省略.........
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:101,代码来源:ilSCORM13Package.php

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

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

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