本文整理汇总了PHP中ilObjFile::setDescription方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjFile::setDescription方法的具体用法?PHP ilObjFile::setDescription怎么用?PHP ilObjFile::setDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilObjFile
的用法示例。
在下文中一共展示了ilObjFile::setDescription方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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();
}
示例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();
}
示例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;
}
示例5: 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;
}
示例6: 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());
}
}