本文整理汇总了PHP中ilObjMediaObject::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjMediaObject::getId方法的具体用法?PHP ilObjMediaObject::getId怎么用?PHP ilObjMediaObject::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilObjMediaObject
的用法示例。
在下文中一共展示了ilObjMediaObject::getId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: showNews
/**
* show news
*/
function showNews()
{
global $lng, $ilCtrl, $ilUser;
// workaround for dynamic mode (if cache is disabled, showNews has no data)
if (empty(self::$st_data)) {
$this->setData($this->getNewsData());
}
$news_set = new ilSetting("news");
$enable_internal_rss = $news_set->get("enable_rss_for_internal");
include_once "./Services/News/classes/class.ilNewsItem.php";
$news = new ilNewsItem($_GET["news_id"]);
$tpl = new ilTemplate("tpl.show_news.html", true, true, "Services/News");
// get current item in data set
$previous = $next = "";
reset($this->data);
$c = current($this->data);
$curr_cnt = 1;
while ($c["id"] > 0 && $c["id"] != $_GET["news_id"]) {
$previous = $c;
$c = next($this->data);
$curr_cnt++;
}
// collect news items to show
$news_list = array();
if (is_array($c["aggregation"])) {
//$agg_obj_id = ilObject::_lookupObjId($c["agg_ref_id"]);
//$agg_obj_type = ilObject::_lookupType($agg_obj_id);
//$agg_obj_title = ilObject::_lookupObjId($agg_obj_id);
$news_list[] = array("ref_id" => $c["agg_ref_id"], "agg_ref_id" => $c["agg_ref_id"], "aggregation" => $c["aggregation"], "user_id" => "", "content_type" => "text", "mob_id" => 0, "visibility" => "", "content" => "", "content_long" => "", "update_date" => $news->getUpdateDate(), "creation_date" => "", "content_is_lang_var" => false, "loc_context" => $_GET["news_context"], "context_obj_type" => $news->getContextObjType(), "title" => "");
foreach ($c["aggregation"] as $c_item) {
ilNewsItem::_setRead($ilUser->getId(), $c_item["id"]);
$c_item["loc_context"] = $c_item["ref_id"];
$c_item["loc_stop"] = $_GET["news_context"];
$news_list[] = $c_item;
}
} else {
$news_list[] = array("ref_id" => $_GET["news_context"], "user_id" => $news->getUserId(), "content_type" => $news->getContentType(), "mob_id" => $news->getMobId(), "visibility" => $news->getVisibility(), "priority" => $news->getPriority(), "content" => $news->getContent(), "content_long" => $news->getContentLong(), "update_date" => $news->getUpdateDate(), "creation_date" => $news->getCreationDate(), "context_sub_obj_type" => $news->getContextSubObjType(), "context_obj_type" => $news->getContextObjType(), "context_sub_obj_id" => $news->getContextSubObjId(), "content_is_lang_var" => $news->getContentIsLangVar(), "content_text_is_lang_var" => $news->getContentTextIsLangVar(), "loc_context" => $_GET["news_context"], "title" => $news->getTitle());
ilNewsItem::_setRead($ilUser->getId(), $_GET["news_id"]);
}
foreach ($news_list as $item) {
// user
if ($item["user_id"] > 0 && ilObject::_exists($item["user_id"])) {
// get login
if (ilObjUser::_exists($item["user_id"])) {
$user = new ilObjUser($item["user_id"]);
$displayname = $user->getLogin();
} else {
// this should actually not happen, since news entries
// should be deleted when the user is going to be removed
$displayname = "<" . strtolower($lng->txt("deleted")) . ">";
}
$tpl->setCurrentBlock("user_info");
$tpl->setVariable("VAL_AUTHOR", $displayname);
$tpl->setVariable("TXT_AUTHOR", $lng->txt("author"));
$tpl->parseCurrentBlock();
}
// media player
if ($item["content_type"] == NEWS_AUDIO && $item["mob_id"] > 0 && ilObject::_exists($item["mob_id"])) {
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
include_once "./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php";
$mob = new ilObjMediaObject($item["mob_id"]);
$med = $mob->getMediaItem("Standard");
$mpl = new ilMediaPlayerGUI();
if (strcasecmp("Reference", $med->getLocationType()) == 0) {
$mpl->setFile($med->getLocation());
} else {
$mpl->setFile(ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation());
}
$mpl->setDisplayHeight($med->getHeight());
$tpl->setCurrentBlock("player");
$tpl->setVariable("PLAYER", $mpl->getMp3PlayerHtml());
$tpl->parseCurrentBlock();
}
// access
if ($enable_internal_rss && $item["visibility"] != "") {
$obj_id = ilObject::_lookupObjId($item["ref_id"]);
$tpl->setCurrentBlock("access");
$tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility"));
if ($item["visibility"] == NEWS_PUBLIC || $item["priority"] == 0 && ilBlockSetting::_lookup("news", "public_notifications", 0, $obj_id)) {
$tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
} else {
$tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
}
$tpl->parseCurrentBlock();
}
// content
if (trim($item["content"]) != "") {
$tpl->setCurrentBlock("content");
$tpl->setVariable("VAL_CONTENT", nl2br($this->makeClickable(ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"]))));
//$tpl->setVariable("VAL_CONTENT", nl2br($item["content"]));
$tpl->parseCurrentBlock();
}
if (trim($item["content_long"]) != "") {
$tpl->setCurrentBlock("long");
$tpl->setVariable("VAL_LONG_CONTENT", $this->makeClickable($item["content_long"]));
$tpl->parseCurrentBlock();
}
//.........这里部分代码省略.........
示例3: deliverMobFile
/**
* Deliver mob file
*
* @param
* @return
*/
function deliverMobFile($a_purpose = "Standard", $a_increase_download_cnt = false)
{
$mob = $this->getMobId();
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
$mob = new ilObjMediaObject($mob);
$mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
// check purpose
if (!$mob->hasPurposeItem($a_purpose)) {
return false;
}
$m_item = $mob->getMediaItem($a_purpose);
if ($m_item->getLocationType() != "Reference") {
$file = $mob_dir . "/" . $m_item->getLocation();
if (file_exists($file) && is_file($file)) {
if ($a_increase_download_cnt) {
$this->increaseDownloadCounter();
}
ilUtil::deliverFile($file, $m_item->getLocation());
} else {
ilUtil::sendFailure("File not found!", true);
return false;
}
} else {
if ($a_increase_download_cnt) {
$this->increaseDownloadCounter();
}
ilUtil::redirect($m_item->getLocation());
}
}
示例4: getFirstMediaObjectAsTag
protected function getFirstMediaObjectAsTag($a_width = 144, $a_height = 144, $a_export_directory = null)
{
$this->obj->buildDom();
$mob_ids = $this->obj->collectMediaObjects();
if ($mob_ids) {
require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
foreach ($mob_ids as $mob_id) {
$mob_obj = new ilObjMediaObject($mob_id);
$mob_item = $mob_obj->getMediaItem("Standard");
if (stristr($mob_item->getFormat(), "image")) {
$mob_size = $mob_item->getOriginalSize();
if ($mob_size["width"] >= $a_width || $mob_size["height"] >= $a_height) {
if (!$a_export_directory) {
$mob_dir = ilObjMediaObject::_getDirectory($mob_obj->getId());
} else {
// see ilCOPageHTMLExport::exportHTMLMOB()
$mob_dir = "./mobs/mm_" . $mob_obj->getId();
}
$mob_res = self::parseImage($mob_size["width"], $mob_size["height"], $a_width, $a_height);
return '<img' . ' src="' . $mob_dir . "/" . $mob_item->getLocation() . '"' . ' width="' . $mob_res[0] . '"' . ' height="' . $mob_res[1] . '"' . ' class="ilBlogListItemSnippetPreviewImage ilFloatLeft noMirror"' . ' />';
}
}
}
}
}
示例5: 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();
}
示例6: extractPreviewImageObject
/**
* Extract preview image
*
* @param
* @return
*/
function extractPreviewImageObject()
{
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());
try {
$sec = (int) $_POST["sec"];
if ($sec < 0) {
$sec = 0;
}
if ($mob->getVideoPreviewPic() != "") {
$mob->removeAdditionalFile($mob->getVideoPreviewPic(true));
}
include_once "./Services/MediaObjects/classes/class.ilFFmpeg.php";
$med = $mob->getMediaItem("Standard");
$mob_file = ilObjMediaObject::_getDirectory($mob->getId()) . "/" . $med->getLocation();
$new_file = ilFFmpeg::extractImage($mob_file, "mob_vpreview.png", ilObjMediaObject::_getDirectory($mob->getId()), $sec);
if ($new_file != "") {
ilUtil::sendInfo($this->lng->txt("mcst_image_extracted"), true);
} else {
ilUtil::sendFailure($this->lng->txt("mcst_no_extraction_possible"), true);
}
} catch (ilException $e) {
if (DEVMODE == 1) {
$ret = ilFFmpeg::getLastReturnValues();
$add = is_array($ret) && count($ret) > 0 ? "<br />" . implode($ret, "<br />") : "";
}
ilUtil::sendFailure($e->getMessage() . $add, true);
}
$ilCtrl->redirect($this, "editCastItem");
}
示例7: 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"]);
}
示例8: parseHTML
/**
* function parses stored value in database to a html output for eg. the record list gui.
* @param $value
* @return mixed
*/
public function parseHTML($value, ilDataCollectionRecordField $record_field)
{
switch ($this->id) {
case self::INPUTFORMAT_DATETIME:
$html = ilDatePresentation::formatDate(new ilDate($value, IL_CAL_DATETIME));
break;
case self::INPUTFORMAT_FILE:
global $ilCtrl;
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>";
break;
case self::INPUTFORMAT_MOB:
$mob = new ilObjMediaObject($value, false);
$dir = ilObjMediaObject::_getDirectory($mob->getId());
$media_item = $mob->getMediaItem('Standard');
if (!$media_item->location) {
$html = "";
break;
}
$html = '<img src="' . $dir . "/" . $media_item->location . '" />';
break;
case self::INPUTFORMAT_BOOLEAN:
switch ($value) {
case 0:
$im = ilUtil::getImagePath('icon_not_ok.png');
break;
case 1:
$im = ilUtil::getImagePath('icon_ok.png');
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;
}
if (strlen($link) > self::LINK_MAX_LENGTH) {
$link = substr($value, 0, (self::LINK_MAX_LENGTH - 3) / 2);
$link .= "...";
$link .= substr($value, -(self::LINK_MAX_LENGTH - 3) / 2);
}
$html = "<a target='_blank' href='" . $value . "'>" . $link . "</a>";
} else {
$html = $value;
}
// BEGIN EASTEREGG
/*if(strtolower($value) == "nyan it plx!"){
$link = ilLink::_getLink($_GET['ref_id']);
$html = "<a href='http://nyanit.com/".$link."'>Data Collections rock!</a>";
}*/
// END EASTEREGG
break;
default:
$html = $value;
break;
}
return $html;
}
示例9: configureFile
/**
* Configures the file for the updateFloorPlanInfosWithFile and addFloorPlan function.
*
* @param ilObjMediaObject $a_mediaObj
* @param array $a_newfile
*
* @return array with format and filename
*/
private function configureFile($a_mediaObj, $a_newfile = NULL)
{
if ($this->mobjMock) {
return $a_newfile;
}
$mob_dir = ilObjMediaObject::_getDirectory($a_mediaObj->getId());
if (!is_dir($mob_dir)) {
$a_mediaObj->createDirectory();
}
$file_name = ilUtil::getASCIIFilename($a_newfile["name"]);
$file_name_mod = str_replace(" ", "_", $file_name);
$file = $mob_dir . "/" . $file_name_mod;
// construct file path
ilUtil::moveUploadedFile($a_newfile["tmp_name"], $file_name_mod, $file);
ilUtil::renameExecutables($mob_dir);
$format = ilObjMediaObject::getMimeType($file);
return array("format" => $format, "filename" => $file_name_mod);
}
示例10: 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]);
//.........这里部分代码省略.........
示例11: fillRow
/**
* Standard Version of Fill Row. Most likely to
* be overwritten by derived class.
*/
protected function fillRow($a_set)
{
global $lng, $ilCtrl, $ilAccess;
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
$news_set = new ilSetting("news");
$enable_internal_rss = $news_set->get("enable_rss_for_internal");
// access
if ($enable_internal_rss && !$this->presentation_mode) {
$this->tpl->setCurrentBlock("access");
$this->tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility"));
if ($a_set["visibility"] == NEWS_PUBLIC) {
$this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
} else {
$this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
}
$this->tpl->parseCurrentBlock();
}
$ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", "");
if (ilObject::_exists($a_set["mob_id"])) {
if ($a_set["update_date"] != "") {
$this->tpl->setCurrentBlock("last_update");
$this->tpl->setVariable("TXT_LAST_UPDATE", $lng->txt("last_update"));
$this->tpl->setVariable("VAL_LAST_UPDATE", ilDatePresentation::formatDate(new ilDateTime($a_set["update_date"], IL_CAL_DATETIME)));
$this->tpl->parseCurrentBlock();
}
$mob = new ilObjMediaObject($a_set["mob_id"]);
$med = $mob->getMediaItem("Standard");
$this->tpl->setVariable("VAL_TITLE", $a_set["title"]);
$this->tpl->setVariable("VAL_DESCRIPTION", $a_set["content"]);
$this->tpl->setVariable("TXT_CREATED", $lng->txt("created"));
$this->tpl->setVariable("VAL_CREATED", ilDatePresentation::formatDate(new ilDateTime($a_set["creation_date"], IL_CAL_DATETIME)));
$this->tpl->setVariable("TXT_DURATION", $lng->txt("mcst_play_time"));
if ($a_set["playtime"] != "00:00:00") {
$this->tpl->setVariable("VAL_DURATION", $a_set["playtime"]);
} else {
$this->tpl->setVariable("VAL_DURATION", "-");
}
if (!$this->edit_order) {
if ($this->downloadable) {
$ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", $a_set["id"]);
// to keep always the order of the purposes
// iterate through purposes and display the according mediaitems
foreach (ilObjMediaCast::$purposes as $purpose) {
$a_mob = $mob->getMediaItem($purpose);
if (!is_object($a_mob)) {
continue;
}
$ilCtrl->setParameterByClass("ilobjmediacastgui", "purpose", $a_mob->getPurpose());
$file = ilObjMediaObject::_lookupItemPath($a_mob->getMobId(), false, false, $a_mob->getPurpose());
if (is_file($file)) {
$size = filesize($file);
$size = ", " . sprintf("%.1f MB", $size / 1024 / 1024);
}
$format = $a_mob->getFormat() != "" ? $a_mob->getFormat() : "audio/mpeg";
$this->tpl->setCurrentBlock("downloadable");
$this->tpl->setVariable("TXT_DOWNLOAD", $lng->txt("mcst_download_" . strtolower($a_mob->getPurpose())));
$this->tpl->setVariable("CMD_DOWNLOAD", $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "downloadItem"));
$this->tpl->setVariable("TITLE_DOWNLOAD", "(" . $format . $size . ")");
$this->tpl->parseCurrentBlock();
}
}
include_once "./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php";
$mpl = new ilMediaPlayerGUI();
if (is_object($med)) {
if (strcasecmp("Reference", $med->getLocationType()) == 0) {
$mpl->setFile($med->getLocation());
} else {
$mpl->setFile(ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation());
}
$mpl->setMimeType($med->getFormat());
//$mpl->setDisplayHeight($med->getHeight());
$mpl->setDisplayWidth("640");
$mpl->setDisplayHeight("480");
$mpl->setVideoPreviewPic($mob->getVideoPreviewPic());
$mpl->setTitle($a_set["title"]);
$mpl->setDescription($a_set["content"]);
$med_alt = $mob->getMediaItem("VideoAlternative");
if (is_object($med_alt)) {
$mpl->setAlternativeVideoFile(ilObjMediaObject::_getURL($mob->getId()) . "/" . $med_alt->getLocation());
$mpl->setAlternativeVideoMimeType($med_alt->getFormat());
}
}
//$this->tpl->setVariable("PLAYER", $mpl->getMp3PlayerHtml());
$this->tpl->setVariable("PLAYER", $mpl->getPreviewHtml());
// edit link
$ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", $a_set["id"]);
if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) && !$this->presentation_mode) {
$this->tpl->setCurrentBlock("edit");
$this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
$this->tpl->setVariable("CMD_EDIT", $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "editCastItem"));
if (!is_int(strpos($med->getFormat(), "image/"))) {
$this->tpl->setVariable("TXT_DET_PLAYTIME", $lng->txt("mcst_det_playtime"));
$this->tpl->setVariable("CMD_DET_PLAYTIME", $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "determinePlaytime"));
}
$this->tpl->parseCurrentBlock();
$this->tpl->setCurrentBlock("edit_checkbox");
//.........这里部分代码省略.........
示例12: 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;
}
}
示例13: 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;
}
//.........这里部分代码省略.........