本文整理汇总了PHP中ilObjFile::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjFile::getId方法的具体用法?PHP ilObjFile::getId怎么用?PHP ilObjFile::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilObjFile
的用法示例。
在下文中一共展示了ilObjFile::getId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateFileContents
/**
* update file according to filename and version and create history entry
* has to be called after (!) file save for new objects, since file storage will be initialised with obj id.
*
*/
public function updateFileContents()
{
if ($this->setFileContents()) {
require_once "./Services/History/classes/class.ilHistory.php";
ilHistory::_createEntry($this->file->getId(), "replace", $this->file->getFilename() . "," . $this->file->getVersion());
$this->file->addNewsNotification("file_updated");
}
}
示例2: start
function start()
{
$this->__buildHeader();
$attribs = array("obj_id" => "il_" . IL_INST_ID . "_file_" . $this->file->getId(), "version" => $this->file->getVersion(), "size" => $this->file->getFileSize(), "type" => $this->file->getFileType());
$this->xmlStartTag("File", $attribs);
$this->xmlElement("Filename", null, $this->file->getFileName());
$this->xmlElement("Title", null, $this->file->getTitle());
$this->xmlElement("Description", null, $this->file->getDescription());
$this->xmlElement("Rating", null, (int) $this->file->hasRating());
if ($this->attachFileContents) {
$filename = $this->file->getDirectory($this->file->getVersion()) . "/" . $this->file->getFileName();
if (@is_file($filename)) {
if ($this->attachFileContents == ilFileXMLWriter::$CONTENT_ATTACH_COPY) {
$attribs = array("mode" => "COPY");
copy($filename, $this->target_dir_absolute . "/" . $this->file->getFileName());
$content = $this->target_dir_relative . "/" . $this->file->getFileName();
$this->xmlElement("Content", $attribs, $content);
} elseif ($this->attachFileContents == ilFileXMLWriter::$CONTENT_ATTACH_REST) {
$attribs = array('mode' => "REST");
include_once './Services/WebServices/Rest/classes/class.ilRestFileStorage.php';
$fs = new ilRestFileStorage();
$tmpname = $fs->storeFileForRest(base64_encode(@file_get_contents($filename)));
$this->xmlElement("Content", $attribs, $tmpname);
} else {
$content = @file_get_contents($filename);
$attribs = array("mode" => "PLAIN");
if ($this->attachFileContents == ilFileXMLWriter::$CONTENT_ATTACH_ZLIB_ENCODED) {
$attribs["mode"] = "ZLIB";
$content = @gzcompress($content, 9);
} elseif ($this->attachFileContents == ilFileXMLWriter::$CONTENT_ATTACH_GZIP_ENCODED) {
$attribs["mode"] = "GZIP";
$content = @gzencode($content, 9);
}
$content = base64_encode($content);
$this->xmlElement("Content", $attribs, $content);
}
}
}
include_once "./Services/History/classes/class.ilHistory.php";
$versions = ilHistory::_getEntriesForObject($this->file->getId(), $this->file->getType());
if (count($versions)) {
$this->xmlStartTag("Versions");
foreach ($versions as $version) {
$info_params = $version["info_params"];
list($filename, $history_id) = split(",", $info_params);
$attribs = array("id" => $history_id, "date" => ilUtil::date_mysql2time($version["date"]), "usr_id" => "il_" . IL_INST_ID . "_usr_" . $version["user_id"]);
$this->xmlElement("Version", $attribs);
}
$this->xmlEndTag("Versions");
}
$this->xmlEndTag("File");
$this->__buildFooter();
return true;
}
示例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");
}
示例4: create
/**
* create new file list in dom and update page in db
*/
function create()
{
include_once "./Modules/File/classes/class.ilObjFile.php";
// from personal workspace
if (substr($_POST["file_ref_id"], 0, 4) == "wsp_") {
$fileObj = new ilObjFile(substr($_POST["file_ref_id"], 4), false);
} else {
if ($_POST["file_ref_id"] == 0) {
$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();
// upload file to filesystem
$fileObj->createDirectory();
$fileObj->raiseUploadError(false);
$fileObj->getUploadFile($_FILES["file"]["tmp_name"], $_FILES["file"]["name"]);
} else {
$fileObj = new ilObjFile($_POST["file_ref_id"]);
}
}
$_SESSION["il_text_lang_" . $_GET["ref_id"]] = $_POST["flst_language"];
//echo "::".is_object($this->dom).":";
$this->content_obj = new ilPCFileList($this->dom);
$this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
$this->content_obj->setListTitle(ilUtil::stripSlashes($_POST["flst_title"]), $_POST["flst_language"]);
$this->content_obj->appendItem($fileObj->getId(), $fileObj->getFileName(), $fileObj->getFileType());
$this->updated = $this->pg_obj->update();
if ($this->updated === true) {
$this->ctrl->returnToParent($this, "jump" . $this->hier_id);
} else {
$this->insert();
}
}
示例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;
}
示例6: 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]);
//.........这里部分代码省略.........
示例7: handleQuotaUpdate
protected static function handleQuotaUpdate(ilObjFile $a_file)
{
include_once "Services/MediaObjects/classes/class.ilObjMediaObject.php";
$mob = new ilObjMediaObject();
// file itself could be workspace item
$parent_obj_ids = array($a_file->getId());
foreach ($a_file->getUsages() as $item) {
$parent_obj_id = $mob->getParentObjectIdForUsage($item);
if ($parent_obj_id && !in_array($parent_obj_id, $parent_obj_ids)) {
$parent_obj_ids[] = $parent_obj_id;
}
}
include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
ilDiskQuotaHandler::handleUpdatedSourceObject($a_file->getType(), $a_file->getId(), $a_file->getDiskUsage(), $parent_obj_ids);
}
示例8: parseHTML
/**
* function parses stored value in database to a html output for eg. the record list gui.
*
* @param $value
* @param ilDataCollectionRecordField $record_field
*
* @return mixed
*/
public function parseHTML($value, ilDataCollectionRecordField $record_field, $link = true)
{
global $ilAccess, $ilCtrl, $lng;
switch ($this->id) {
case self::INPUTFORMAT_DATETIME:
$html = ilDatePresentation::formatDate(new ilDate($value, IL_CAL_DATETIME));
break;
case self::INPUTFORMAT_FILE:
if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
$html = "";
break;
}
$file_obj = new ilObjFile($value, false);
$ilCtrl->setParameterByClass("ildatacollectionrecordlistgui", "record_id", $record_field->getRecord()->getId());
$ilCtrl->setParameterByClass("ildatacollectionrecordlistgui", "field_id", $record_field->getField()->getId());
$html = '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordlistgui", "sendFile") . '">' . $file_obj->getFileName() . '</a>';
if (ilPreview::hasPreview($file_obj->getId())) {
ilPreview::createPreview($file_obj);
// Create preview if not already existing
$preview = new ilPreviewGUI((int) $_GET['ref_id'], ilPreviewGUI::CONTEXT_REPOSITORY, $file_obj->getId(), $ilAccess);
$preview_status = ilPreview::lookupRenderStatus($file_obj->getId());
$preview_status_class = "";
$preview_text_topic = "preview_show";
if ($preview_status == ilPreview::RENDER_STATUS_NONE) {
$preview_status_class = "ilPreviewStatusNone";
$preview_text_topic = "preview_none";
}
$wrapper_html_id = 'record_field_' . $record_field->getId();
$script_preview_click = $preview->getJSCall($wrapper_html_id);
$preview_title = $lng->txt($preview_text_topic);
$preview_icon = ilUtil::getImagePath("preview.png", "Services/Preview");
$html = '<div id="' . $wrapper_html_id . '">' . $html;
$html .= '<span class="il_ContainerItemPreview ' . $preview_status_class . '"><a href="javascript:void(0);" onclick="' . $script_preview_click . '" title="' . $preview_title . '"><img src="' . $preview_icon . '" height="16" width="16"></a></span></div>';
}
break;
case self::INPUTFORMAT_MOB:
$mob = new ilObjMediaObject($value, false);
$med = $mob->getMediaItem('Standard');
if (!$med->location) {
$html = "";
break;
}
$arr_properties = $record_field->getField()->getProperties();
$is_linked_field = $arr_properties[ilDataCollectionField::PROPERTYID_LINK_DETAIL_PAGE_MOB];
$has_view = ilDataCollectionRecordViewViewdefinition::getIdByTableId($record_field->getRecord()->getTableId());
if (in_array($med->getSuffix(), array('jpg', 'jpeg', 'png', 'gif'))) {
// Image
$dir = ilObjMediaObject::_getDirectory($mob->getId());
$width = (int) $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH];
$height = (int) $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT];
$html = ilUtil::img($dir . "/" . $med->location, '', $width, $height);
if ($is_linked_field and $has_view and $link) {
$ilCtrl->setParameterByClass('ildatacollectionrecordviewgui', 'record_id', $record_field->getRecord()->getId());
$html = '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord') . '">' . $html . '</a>';
}
} else {
// Video/Audio
$mpl = new ilMediaPlayerGUI($med->getId(), '');
$mpl->setFile(ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation());
$mpl->setMimeType($med->getFormat());
$mpl->setDisplayWidth((int) $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH] . 'px');
$mpl->setDisplayHeight((int) $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT] . 'px');
$mpl->setVideoPreviewPic($mob->getVideoPreviewPic());
$html = $mpl->getPreviewHtml();
if ($is_linked_field and $has_view) {
global $lng;
$ilCtrl->setParameterByClass('ildatacollectionrecordviewgui', 'record_id', $record_field->getRecord()->getId());
$html = $html . '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord') . '">' . $lng->txt('details') . '</a>';
}
}
break;
case self::INPUTFORMAT_BOOLEAN:
switch ($value) {
case 0:
$im = ilUtil::getImagePath('icon_not_ok.svg');
break;
case 1:
$im = ilUtil::getImagePath('icon_ok.svg');
break;
}
$html = "<img src='" . $im . "'>";
break;
case ilDataCollectionDatatype::INPUTFORMAT_TEXT:
//Property URL
$arr_properties = $record_field->getField()->getProperties();
if ($arr_properties[ilDataCollectionField::PROPERTYID_URL]) {
$link = $value;
if (preg_match("/^[a-z0-9!#\$%&'*+=?^_`{|}~-]+(?:\\.[a-z0-9!#\$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\$/i", $value)) {
$value = "mailto:" . $value;
} elseif (!preg_match('~(^(news|(ht|f)tp(s?)\\://){1}\\S+)~i', $value)) {
return $link;
}
//.........这里部分代码省略.........
示例9: 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);
}
}