当前位置: 首页>>代码示例>>PHP>>正文


PHP ilObjMediaObject::addMediaItem方法代码示例

本文整理汇总了PHP中ilObjMediaObject::addMediaItem方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjMediaObject::addMediaItem方法的具体用法?PHP ilObjMediaObject::addMediaItem怎么用?PHP ilObjMediaObject::addMediaItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ilObjMediaObject的用法示例。


在下文中一共展示了ilObjMediaObject::addMediaItem方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:24,代码来源:class.ilObjMediaObject.php

示例2: 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");
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:43,代码来源:class.ilObjMediaCastGUI.php

示例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();
 }
开发者ID:studer-raimann,项目名称:RoomSharing,代码行数:38,代码来源:class.ilObjRoomSharing.php

示例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;
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:100,代码来源:class.ilDataCollectionDatatype.php

示例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"]);
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:56,代码来源:class.ilObjMediaPoolGUI.php

示例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]);
//.........这里部分代码省略.........
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:101,代码来源:ilSCORM13Package.php


注:本文中的ilObjMediaObject::addMediaItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。