本文整理汇总了PHP中ilObjMediaObject::update方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjMediaObject::update方法的具体用法?PHP ilObjMediaObject::update怎么用?PHP ilObjMediaObject::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilObjMediaObject
的用法示例。
在下文中一共展示了ilObjMediaObject::update方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convertFileObject
/**
* Convert file object
*
* @param
* @return
*/
function convertFileObject()
{
global $ilCtrl;
$this->checkPermission("write");
$this->mcst_item = new ilNewsItem($_GET["item_id"]);
include_once "./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php";
$mob = new ilObjMediaObject($this->mcst_item->getMobId());
$target_purpose = ilUtil::stripSlashes($_POST["target_purpose"]);
$target_format = ilUtil::stripSlashes($_POST["target_format"]);
try {
include_once "./Services/MediaObjects/classes/class.ilFFmpeg.php";
$med = $mob->getMediaItem("Standard");
$mob_file = ilObjMediaObject::_getDirectory($mob->getId()) . "/" . $med->getLocation();
$new_file = ilFFmpeg::convert($mob_file, $target_format);
$ret = ilFFmpeg::getLastReturnValues();
$pi = pathinfo($new_file);
$med = $mob->getMediaItem($target_purpose);
if (!is_object($med)) {
$med = new ilMediaItem();
$med->setMobId($mob->getId());
$mob->addMediaItem($med);
$mob->update();
$med->setPurpose($target_purpose);
}
$med->setFormat($target_format);
$med->setLocation($pi["basename"]);
$med->setLocationType("LocalFile");
$med->update();
$add = is_array($ret) && count($ret) > 0 ? "<br />" . implode($ret, "<br />") : "";
ilUtil::sendInfo($this->lng->txt("mcst_converted_file") . $add, true);
} catch (ilException $e) {
$ret = ilFFmpeg::getLastReturnValues();
$add = is_array($ret) && count($ret) > 0 ? "<br />" . implode($ret, "<br />") : "";
ilUtil::sendFailure($e->getMessage() . $add, true);
}
$ilCtrl->redirect($this, "editCastItem");
}
示例2: ilObjMediaObject
/**
* Create new media object and update page in db and return new media object
*/
function &_saveTempFileAsMediaObject($name, $tmp_name, $upload = TRUE)
{
// create dummy object in db (we need an id)
$media_object = new ilObjMediaObject();
$media_object->setTitle($name);
$media_object->setDescription("");
$media_object->create();
// determine and create mob directory, move uploaded file to directory
$media_object->createDirectory();
$mob_dir = ilObjMediaObject::_getDirectory($media_object->getId());
$media_item =& new ilMediaItem();
$media_object->addMediaItem($media_item);
$media_item->setPurpose("Standard");
$file = $mob_dir . "/" . $name;
if ($upload) {
ilUtil::moveUploadedFile($tmp_name, $name, $file);
} else {
copy($tmp_name, $file);
}
// get mime type
$format = ilObjMediaObject::getMimeType($file);
$location = $name;
// set real meta and object data
$media_item->setFormat($format);
$media_item->setLocation($location);
$media_item->setLocationType("LocalFile");
$media_object->setTitle($name);
$media_object->setDescription($format);
if (ilUtil::deducibleSize($format)) {
$size = getimagesize($file);
$media_item->setWidth($size[0]);
$media_item->setHeight($size[1]);
}
$media_item->setHAlign("Left");
ilUtil::renameExecutables($mob_dir);
$media_object->update();
return $media_object;
}
示例3: 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();
}
示例4: 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;
}
示例5: 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"]);
}
示例6: updateMediaObject
/**
* Updates the media object with the file informations for the updateFloorPlanInfosWithFile
* and addFloorPlan function.
*
* @param ilObjMediaObject $a_mediaObj
* @param array $a_fileinfo with format and filename
*/
private function updateMediaObject($a_mediaObj, $a_fileinfo)
{
$media_item = $a_mediaObj->getMediaItem("Standard");
$media_item->setFormat($a_fileinfo["format"]);
$media_item->setLocation($a_fileinfo["filename"]);
$media_item->setLocationType("LocalFile");
$a_mediaObj->update();
}
示例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]);
//.........这里部分代码省略.........