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


PHP ilObjFile::createReference方法代码示例

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


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

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

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

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

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

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