34 protected \ILIAS\DI\UIServices
$ui;
41 public function init(): void
45 $this->
user = $DIC->user();
47 $this->
ui = $DIC->ui();
48 $this->
lng = $DIC->language();
49 $this->mob_usage_repo =
$DIC->mediaObjects()
53 $this->
ctrl = $DIC->ctrl();
54 $this->mob_manager =
$DIC->mediaObjects()->internal()->domain()->mediaObject();
67 $this->hier_id = $a_hier_id;
72 $this->mediaobject = $a_mediaobject;
95 $this->
setDomNode($this->dom_doc->createElement(
"PageContent"));
97 $mob_node = $this->dom_doc->createElement(
"MediaObject");
99 $this->mal_node = $this->dom_doc->createElement(
"MediaAlias");
100 $this->mal_node =
$mob_node->appendChild($this->mal_node);
104 $item_node = $this->dom_doc->createElement(
"MediaAliasItem");
105 $item_node =
$mob_node->appendChild($item_node);
106 $item_node->setAttribute(
"Purpose",
"Standard");
108 if (is_null($media_item)) {
112 $layout_node = $this->dom_doc->createElement(
"Layout");
113 $layout_node = $item_node->appendChild($layout_node);
114 if ($media_item->getWidth() > 0) {
117 if ($media_item->getHeight() > 0) {
120 $layout_node->setAttribute(
"HorizontalAlign",
"Left");
123 if ($media_item->getCaption() !=
"") {
124 $cap_node = $this->dom_doc->createElement(
"Caption");
125 $cap_node = $item_node->appendChild($cap_node);
126 $cap_node->setAttribute(
"Align",
"bottom");
127 $this->dom_util->setContent($cap_node, $media_item->getCaption());
131 if ($media_item->getTextRepresentation() !=
"") {
132 $tr_node = $this->dom_doc->createElement(
"TextRepresentation");
133 $tr_node = $item_node->appendChild($tr_node);
134 $this->dom_util->setContent($tr_node, $media_item->getTextRepresentation());
137 $pars = $media_item->getParameters();
138 foreach ($pars as $par => $val) {
139 $par_node = $this->dom_doc->createElement(
"Parameter");
140 $par_node = $item_node->appendChild($par_node);
141 $par_node->setAttribute(
"Name", $par);
142 $par_node->setAttribute(
"Value", $val);
146 $fullscreen_item = $this->
getMediaObject()->getMediaItem(
"Fullscreen");
147 if (is_object($fullscreen_item)) {
148 $item_node = $this->dom_doc->createElement(
"MediaAliasItem");
149 $item_node =
$mob_node->appendChild($item_node);
150 $item_node->setAttribute(
"Purpose",
"Fullscreen");
153 $layout_node = $this->dom_doc->createElement(
"Layout");
154 $layout_node = $item_node->appendChild($layout_node);
155 if ($fullscreen_item->getWidth() > 0) {
156 $layout_node->setAttribute(
"Width", $fullscreen_item->getWidth());
158 if ($fullscreen_item->getHeight() > 0) {
159 $layout_node->setAttribute(
"Height", $fullscreen_item->getHeight());
163 if ($fullscreen_item->getCaption() !=
"") {
164 $cap_node = $this->dom_doc->createElement(
"Caption");
165 $cap_node = $item_node->appendChild($cap_node);
166 $cap_node->setAttribute(
"Align",
"bottom");
167 $this->dom_util->setContent($cap_node, $fullscreen_item->getCaption());
171 if ($fullscreen_item->getTextRepresentation() !=
"") {
172 $tr_node = $this->dom_doc->createElement(
"TextRepresentation");
173 $tr_node = $item_node->appendChild($tr_node);
174 $this->dom_util->setContent($tr_node, $fullscreen_item->getTextRepresentation());
177 $pars = $fullscreen_item->getParameters();
178 foreach ($pars as $par => $val) {
179 $par_node = $this->dom_doc->createElement(
"Parameter");
180 $par_node = $item_node->appendChild($par_node);
181 $par_node->setAttribute(
"Name", $par);
182 $par_node->setAttribute(
"Value", $val);
189 if (is_object($this->getChildNode())) {
190 $mal_node = $this->getChildNode()->firstChild;
191 if (is_object($mal_node) && $mal_node->nodeName ==
"MediaAlias") {
205 $this->getMediaAliasNode()?->setAttribute(
"OriginId",
"il__mob_" . $this->getMediaObject()->
getId());
210 return $this->dom_util->dump($this->getDomNode());
215 $this->dom_util->setAttribute($this->getMediaAliasNode(),
"Class", $a_class);
223 return (
string) $this->getMediaAliasNode()?->getAttribute(
"Class");
231 $this->dom_util->setAttribute($this->getMediaAliasNode(),
"CaptionClass", $a_class);
236 return (
string) $this->getMediaAliasNode()?->getAttribute(
"CaptionClass");
241 return array(
"pc_mob");
253 DOMDocument $a_domdoc,
257 if (!$a_page->getImportMode()) {
265 self::saveMobUsage($a_page, $a_domdoc);
266 if (!$a_page->getImportMode()) {
267 foreach ($mob_ids as $mob) {
270 $usages = $mob_obj->getUsages(
false);
271 if (count($usages) == 0) {
283 $a_page->getParentType() .
":pg",
296 foreach ($mob_ids as $mob) {
299 $usages = $mob_obj->getUsages(
false);
300 if (count($usages) == 0) {
316 DOMDocument $a_old_domdoc,
320 self::saveMobUsage($a_page, $a_old_domdoc, $a_old_nr);
325 DOMDocument $a_domdoc,
331 $xpath =
new DOMXPath($a_domdoc);
332 $nodes = $xpath->query(
'//MediaAlias');
333 foreach ($nodes as $node) {
334 $id_arr = explode(
"_", $node->getAttribute(
"OriginId"));
335 $mob_id = $id_arr[count($id_arr) - 1];
336 if ($mob_id > 0 && $id_arr[1] ==
"") {
337 $usages[$mob_id] =
true;
342 $xpath =
new DOMXPath($a_domdoc);
343 $nodes = $xpath->query(
'//MediaObject/MetaData/General/Identifier');
344 foreach ($nodes as $node) {
345 $mob_entry = $node->getAttribute(
"Entry");
346 $mob_arr = explode(
"_", $mob_entry);
347 $mob_id = $mob_arr[count($mob_arr) - 1];
348 if ($mob_id > 0 && $mob_arr[1] ==
"") {
349 $usages[$mob_id] =
true;
354 $xpath =
new DOMXPath($a_domdoc);
355 $nodes = $xpath->query(
"//IntLink[@Type='MediaObject']");
356 foreach ($nodes as $node) {
357 $mob_target = $node->getAttribute(
"Target");
358 $mob_arr = explode(
"_", $mob_target);
362 $mob_id = $mob_arr[count($mob_arr) - 1];
363 if ($mob_id > 0 && $mob_arr[1] ==
"") {
364 $usages[$mob_id] =
true;
374 foreach ($usages as $mob_id => $val) {
393 bool $a_abstract_only =
false
397 $this->global_tpl =
$DIC[
'tpl'];
398 $ilUser = $this->user;
400 if ($a_mode ==
"offline") {
401 $page = $this->getPage();
404 $page->getParentType() .
":pg",
409 foreach ($mob_ids as $mob_id) {
411 $srts = $mob->getSrtFiles();
412 foreach ($srts as $srt) {
413 if ($ilUser->getLanguage() == $srt[
"language"]) {
416 if (is_file($file_path)) {
417 $srt_content = $file_path;
419 $srt_content = $this->mob_manager->getLocationContent(
424 if ($srt_content !==
"") {
425 $a_output = str_replace(
426 "[[[[[mobsubtitle;il__mob_" . $mob->getId() .
"_Standard]]]]]",
436 if ($a_abstract_only) {
440 if ($a_mode ===
"edit") {
441 $a_output = str_replace(
442 "{{{{{Unsupported Media Type}}}}}",
443 $this->
ui->renderer()->render(
444 $this->ui->factory()->messageBox()->info(
445 $this->lng->txt(
"copg_unsupported_media_type")
451 $a_output = str_replace(
452 "{{{{{No Media Type}}}}}",
453 '<div class="copg-new-content-placeholder">' .
454 $this->
ui->renderer()->render(
455 $this->ui->factory()->symbol()->icon()->standard(
"pemed",
"pemed",
'medium')
460 $a_output = str_replace(
461 "{{{{{Unsupported Media Type}}}}}",
465 $a_output = str_replace(
466 "{{{{{No Media Type}}}}}",
473 $page = $this->getPage();
474 $suffix =
"-" . $page->getParentType() .
"-" . $page->getId();
475 $modal = $this->
ui->factory()->modal()->roundtrip(
476 $this->
lng->txt(
"cont_fullscreen"),
477 $this->ui->factory()->legacy()->content(
"<iframe class='il-copg-mob-fullscreen' id='il-copg-mob-fullscreen" . $suffix .
"'></iframe>")
479 $show_signal = $modal->getShowSignal();
483 il.COPagePres.setFullscreenModalShowSignal('$show_signal', '$suffix');
486 self::$modal_show_signal = $show_signal;
487 self::$modal_suffix = $suffix;
488 $this->global_tpl->addOnloadCode($js);
493 if ($this->
ctrl->isAsynch()) {
494 $html = $this->
ui->renderer()->renderAsync($modal);
496 $html = $this->
ui->renderer()->render($modal);
498 return $a_output .
"<div class='il-copg-mob-fullscreen-modal'>" . $html .
"</div>";
505 if (self::$modal_show_signal !==
"") {
506 $onload_code[] =
"il.COPagePres.setFullscreenModalShowSignal('" . self::$modal_show_signal .
507 "', '" . self::$modal_suffix .
"');";
532 return $std_alias_item;
543 return $std_alias_item;
546 public function checkInstanceEditing(): bool
551 $std_alias_item = $this->getStandardMediaAliasItem();
552 if ($std_alias_item->hasAnyPropertiesSet()) {
555 if ($this->getMediaObject()->hasFullscreenItem()) {
556 $full_alias_item = $this->getFullscreenMediaAliasItem();
557 if ($full_alias_item->hasAnyPropertiesSet()) {
565 $mob = $this->getMediaObject();
566 $page = $this->getPage();
567 if (is_object($mob)) {
568 $usages = $mob->getUsages();
569 $other_usages = array_filter($usages,
function ($usage) use ($page) {
570 return ($usage[
"type"] != $page->getParentType() .
":pg" || $usage[
"id"] != $page->getId());
572 if (count($other_usages) > 0) {
585 int $delete_lower_than_nr
589 $mob_usage_repo =
$DIC->mediaObjects()
597 $parent_type .
":pg",
599 $delete_lower_than_nr,
604 $parent_type .
":pg",
606 $delete_lower_than_nr,
610 foreach ($mob_ids as $mob_id) {
612 $log->debug(
"...check deletion of mob $mob_id. Usages: " . count($usages));
613 if (count($usages) == 0) {
616 $log->debug(
"Deleting Mob ID: " . $mob_id);
624 DOMDocument $a_domdoc,
625 bool $a_self_ass =
true,
626 bool $a_clone_mobs =
false,
627 int $new_parent_id = 0,
632 if (!$a_clone_mobs) {
636 $dom_util =
$DIC->copage()->internal()->domain()->domUtil();
637 $path =
"//MediaObject/MediaAlias";
638 $nodes = $dom_util->path($a_domdoc,
$path);
639 foreach ($nodes as $node) {
640 $or_id = $node->getAttribute(
"OriginId");
645 if (!($inst_id > 0)) {
648 $new_mob = $media_object->duplicate();
649 $node->setAttribute(
"OriginId",
"il__mob_" . $new_mob->getId());
static _extractInstOfTarget(string $a_target)
Extract installation id out of target.
static _extractObjIdOfTarget(string $a_target)
Extract object id out of target.
static getLogger(string $a_component_id)
Get component logger.
static _lookupType(int $id, bool $reference=false)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
Content object of ilPageObject (see ILIAS DTD).
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element)
setDomNode(DOMNode $node)
setType(string $a_type)
Set Type.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
insertContent(ilPageContent $a_cont_obj, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="", bool $remove_placeholder=true)
insert a content node before/after a sibling or as first child of a parent
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists('../ilias.ini.php'))