本文整理汇总了PHP中ilObjMediaObject::setTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjMediaObject::setTitle方法的具体用法?PHP ilObjMediaObject::setTitle怎么用?PHP ilObjMediaObject::setTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilObjMediaObject
的用法示例。
在下文中一共展示了ilObjMediaObject::setTitle方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadRoomsAgreement
/**
* Uploads a new rooms agreement by using the ILIAS MediaObject Service.
* If the old file id is given, the old file will be deleted.
*
* @param array $a_newfile an array containing the input values of the form
* @param string $a_oldFileId to delete trash
*
* @return string uploaded file id
*/
public function uploadRoomsAgreement($a_newfile, $a_oldFileId = "0")
{
if (!empty($a_oldFileId) && $a_oldFileId != "0") {
$agreementFile = new ilObjMediaObject($a_oldFileId);
$agreementFile->delete();
}
$mediaObj = new ilObjMediaObject();
$mediaObj->setTitle("RoomSharingRoomsAgreement");
$mediaObj->setDescription("RoomSharingRoomsAgreement");
$mediaObj->create();
$mob_dir = ilObjMediaObject::_getDirectory($mediaObj->getId());
if (!is_dir($mob_dir)) {
$mediaObj->createDirectory();
}
$file_name = ilUtil::getASCIIFilename($a_newfile["name"]);
$file_name_mod = str_replace(" ", "_", $file_name);
$file = $mob_dir . "/" . $file_name_mod;
ilUtil::moveUploadedFile($a_newfile["tmp_name"], $file_name_mod, $file);
ilUtil::renameExecutables($mob_dir);
$format = ilObjMediaObject::getMimeType($file);
$media_item = new ilMediaItem();
$mediaObj->addMediaItem($media_item);
$media_item->setPurpose("Standard");
$media_item->setFormat($format);
$media_item->setLocation($file_name_mod);
$media_item->setLocationType("LocalFile");
$mediaObj->update();
return $mediaObj->getId();
}
示例2: duplicate
/**
* Duplicate media object, return new media object
*/
function duplicate()
{
$new_obj = new ilObjMediaObject();
$new_obj->setTitle($this->getTitle());
$new_obj->setDescription($this->getDescription());
// media items
foreach ($this->getMediaItems() as $key => $val) {
$new_obj->addMediaItem($val);
}
$new_obj->create(false, true);
// files
$new_obj->createDirectory();
self::_createThumbnailDirectory($new_obj->getId());
ilUtil::rCopy(ilObjMediaObject::_getDirectory($this->getId()), ilObjMediaObject::_getDirectory($new_obj->getId()));
ilUtil::rCopy(ilObjMediaObject::_getThumbnailDirectory($this->getId()), ilObjMediaObject::_getThumbnailDirectory($new_obj->getId()));
// meta data
include_once "Services/MetaData/classes/class.ilMD.php";
$md = new ilMD(0, $this->getId(), "mob");
$new_md = $md->cloneMD(0, $new_obj->getId(), "mob");
return $new_obj;
}
示例3: 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;
}
示例4: createMediaFromUploadDir
/**
* Create media object from upload directory
*/
function createMediaFromUploadDir()
{
$mset = new ilSetting("mobs");
$upload_dir = trim($mset->get("upload_dir"));
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
if (is_array($_POST["file"]) && ilMainMenuGUI::_checkAdministrationPermission()) {
foreach ($_POST["file"] as $f) {
$f = str_replace("..", "", $f);
$fullpath = $upload_dir . "/" . $f;
$mob = new ilObjMediaObject();
$mob->setTitle(basename($fullpath));
$mob->setDescription("");
$mob->create();
// determine and create mob directory, move uploaded file to directory
//$mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob->getId();
$mob->createDirectory();
$mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
$media_item = new ilMediaItem();
$mob->addMediaItem($media_item);
$media_item->setPurpose("Standard");
$file = $mob_dir . "/" . basename($fullpath);
ilUtil::moveUploadedFile($fullpath, basename($fullpath), $file, false, $_POST["action"]);
// get mime type
$format = ilObjMediaObject::getMimeType($file);
$location = basename($fullpath);
// set real meta and object data
$media_item->setFormat($format);
$media_item->setLocation($location);
$media_item->setLocationType("LocalFile");
$mob->setDescription($format);
// determine width and height of known image types
$wh = ilObjMediaObject::_determineWidthHeight(500, 400, $format, "File", $mob_dir . "/" . $location, $media_item->getLocation(), true, true, "", "");
$media_item->setWidth($wh["width"]);
$media_item->setHeight($wh["height"]);
if ($wh["info"] != "") {
// ilUtil::sendInfo($wh["info"], true);
}
$media_item->setHAlign("Left");
ilUtil::renameExecutables($mob_dir);
$mob->update();
// put it into current folder
$mep_item = new ilMediaPoolItem();
$mep_item->setTitle($mob->getTitle());
$mep_item->setType("mob");
$mep_item->setForeignId($mob->getId());
$mep_item->create();
$tree = $this->object->getTree();
$parent = $_GET["mepitem_id"] == "" ? $tree->getRootId() : $_GET["mepitem_id"];
$tree->insertNode($mep_item->getId(), $parent);
}
}
ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=" . $_GET["ref_id"] . "&mepitem_id=" . $_GET["mepitem_id"]);
}
示例5: updateFloorPlanInfos
/**
* This function updates the information of a floor plan, which means
* that a new title and a new description will be added. The old floor plan
* (file) will be kept.
*
* @param type $a_file_id the id of the floor plan
* @param type $a_title the new title of the floor plan
* @param type $a_desc the new description for the floor plan
*/
public function updateFloorPlanInfos($a_file_id, $a_title, $a_desc)
{
if (!$this->permission->checkPrivilege(PRIVC::EDIT_FLOORPLANS)) {
ilUtil::sendFailure($this->lng->txt("rep_robj_xrs_no_permission_for_action"), true);
$this->ctrl->redirectByClass('ilinfoscreengui', 'showSummary', 'showSummary');
return false;
}
if ($this->isTitleForUpdateAlreadyTaken($a_title, $a_file_id)) {
throw new ilRoomSharingFloorplanException("rep_robj_xrs_floor_plan_title_is_already_taken");
}
$media_obj = new ilObjMediaObject($a_file_id);
$media_obj->setTitle($a_title);
$media_item = $media_obj->getMediaItem("Standard");
$media_item->setCaption($a_desc);
$media_obj->update();
}
示例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: importRecord
/**
* Import record
*
* @param
* @return
*/
function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
{
//echo $a_entity;
//var_dump($a_rec);
switch ($a_entity) {
case "mob":
//var_dump($a_rec);
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
$newObj = new ilObjMediaObject();
$newObj->setType("mob");
$newObj->setTitle($a_rec["Title"]);
$newObj->setDescription($a_rec["Description"]);
$newObj->create();
$newObj->createDirectory();
ilObjMediaObject::_createThumbnailDirectory($newObj->getId());
$this->current_mob = $newObj;
$dir = str_replace("..", "", $a_rec["Dir"]);
if ($dir != "" && $this->getImportDirectory() != "") {
$source_dir = $this->getImportDirectory() . "/" . $dir;
$target_dir = $dir = ilObjMediaObject::_getDirectory($newObj->getId());
ilUtil::rCopy($source_dir, $target_dir);
}
$a_mapping->addMapping("Services/MediaObjects", "mob", $a_rec["Id"], $newObj->getId());
//echo "<br>++add++"."0:".$a_rec["Id"].":mob+0:".$newObj->getId().":mob"."+";
$a_mapping->addMapping("Services/MetaData", "md", "0:" . $a_rec["Id"] . ":mob", "0:" . $newObj->getId() . ":mob");
break;
case "mob_media_item":
// determine parent mob
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
$mob_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob", $a_rec["MobId"]);
if (is_object($this->current_mob) && $this->current_mob->getId() == $mob_id) {
$mob = $this->current_mob;
} else {
$mob = new ilObjMediaObject($mob_id);
}
include_once "./Services/MediaObjects/classes/class.ilMediaItem.php";
$newObj = new ilMediaItem();
$newObj->setMobId($mob_id);
$newObj->setWidth($a_rec["Width"]);
$newObj->setHeight($a_rec["Height"]);
$newObj->setCaption($a_rec["Caption"]);
$newObj->setNr($a_rec["Nr"]);
$newObj->setPurpose($a_rec["Purpose"]);
$newObj->setLocation($a_rec["Location"]);
$newObj->setLocationType($a_rec["LocationType"]);
$newObj->setFormat($a_rec["Format"]);
$newObj->setTextRepresentation($a_rec["TextRepresentation"]);
$newObj->create();
$this->current_media_item = $newObj;
$a_mapping->addMapping("Services/MediaObjects", "mob_media_item", $a_rec["Id"], $newObj->getId());
break;
case "mob_mi_parameter":
// get media item
include_once "./Services/MediaObjects/classes/class.ilMediaItem.php";
$med_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob_media_item", $a_rec["MiId"]);
if (is_object($this->current_media_item) && $this->current_media_item->getId() == $med_id) {
$med = $this->current_media_item;
} else {
$med = new ilMediaItem($med_id);
}
$med->writeParameter($a_rec["Name"], $a_rec["Value"]);
break;
case "mob_mi_map_area":
// get media item
include_once "./Services/MediaObjects/classes/class.ilMediaItem.php";
$med_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob_media_item", $a_rec["MiId"]);
if (is_object($this->current_media_item) && $this->current_media_item->getId() == $med_id) {
$med = $this->current_media_item;
} else {
$med = new ilMediaItem($med_id);
}
include_once "./Services/MediaObjects/classes/class.ilMapArea.php";
$map_area = new ilMapArea();
$map_area->setItemId($med_id);
$map_area->setNr($a_rec["Nr"]);
$map_area->setShape($a_rec["Shape"]);
$map_area->setCoords($a_rec["Coords"]);
$map_area->setLinkType($a_rec["LinkType"]);
$map_area->setTitle($a_rec["Title"]);
$map_area->setHref($a_rec["Href"]);
$map_area->setTarget($a_rec["Target"]);
$map_area->setType($a_rec["Type"]);
$map_area->setTargetFrame($a_rec["TargetFrame"]);
$map_area->setHighlightMode($a_rec["HighlightMode"]);
$map_area->setHighlightClass($a_rec["HighlightClass"]);
$map_area->create();
break;
}
}