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