33 protected \ILIAS\DI\UIServices
$ui;
40 public function init(): void
44 $this->
user = $DIC->user();
46 $this->
ui = $DIC->ui();
47 $this->
lng = $DIC->language();
48 $this->mob_usage_repo = $DIC->mediaObjects()
52 $this->
ctrl = $DIC->ctrl();
65 $this->hier_id = $a_hier_id;
70 $this->mediaobject = $a_mediaobject;
93 $this->
setDomNode($this->dom_doc->createElement(
"PageContent"));
95 $mob_node = $this->dom_doc->createElement(
"MediaObject");
96 $mob_node = $this->
getDomNode()->appendChild($mob_node);
97 $this->mal_node = $this->dom_doc->createElement(
"MediaAlias");
98 $this->mal_node = $mob_node->appendChild($this->mal_node);
102 $item_node = $this->dom_doc->createElement(
"MediaAliasItem");
103 $item_node = $mob_node->appendChild($item_node);
104 $item_node->setAttribute(
"Purpose",
"Standard");
106 if (is_null($media_item)) {
110 $layout_node = $this->dom_doc->createElement(
"Layout");
111 $layout_node = $item_node->appendChild($layout_node);
112 if ($media_item->getWidth() > 0) {
115 if ($media_item->getHeight() > 0) {
118 $layout_node->setAttribute(
"HorizontalAlign",
"Left");
121 if ($media_item->getCaption() !=
"") {
122 $cap_node = $this->dom_doc->createElement(
"Caption");
123 $cap_node = $item_node->appendChild($cap_node);
124 $cap_node->setAttribute(
"Align",
"bottom");
125 $this->dom_util->setContent($cap_node, $media_item->getCaption());
129 if ($media_item->getTextRepresentation() !=
"") {
130 $tr_node = $this->dom_doc->createElement(
"TextRepresentation");
131 $tr_node = $item_node->appendChild($tr_node);
132 $this->dom_util->setContent($tr_node, $media_item->getTextRepresentation());
135 $pars = $media_item->getParameters();
136 foreach ($pars as $par => $val) {
137 $par_node = $this->dom_doc->createElement(
"Parameter");
138 $par_node = $item_node->appendChild($par_node);
139 $par_node->setAttribute(
"Name", $par);
140 $par_node->setAttribute(
"Value", $val);
144 $fullscreen_item = $this->
getMediaObject()->getMediaItem(
"Fullscreen");
145 if (is_object($fullscreen_item)) {
146 $item_node = $this->dom_doc->createElement(
"MediaAliasItem");
147 $item_node = $mob_node->appendChild($item_node);
148 $item_node->setAttribute(
"Purpose",
"Fullscreen");
151 $layout_node = $this->dom_doc->createElement(
"Layout");
152 $layout_node = $item_node->appendChild($layout_node);
153 if ($fullscreen_item->getWidth() > 0) {
154 $layout_node->setAttribute(
"Width", $fullscreen_item->getWidth());
156 if ($fullscreen_item->getHeight() > 0) {
157 $layout_node->setAttribute(
"Height", $fullscreen_item->getHeight());
161 if ($fullscreen_item->getCaption() !=
"") {
162 $cap_node = $this->dom_doc->createElement(
"Caption");
163 $cap_node = $item_node->appendChild($cap_node);
164 $cap_node->setAttribute(
"Align",
"bottom");
165 $this->dom_util->setContent($cap_node, $fullscreen_item->getCaption());
169 if ($fullscreen_item->getTextRepresentation() !=
"") {
170 $tr_node = $this->dom_doc->createElement(
"TextRepresentation");
171 $tr_node = $item_node->appendChild($tr_node);
172 $this->dom_util->setContent($tr_node, $fullscreen_item->getTextRepresentation());
175 $pars = $fullscreen_item->getParameters();
176 foreach ($pars as $par => $val) {
177 $par_node = $this->dom_doc->createElement(
"Parameter");
178 $par_node = $item_node->appendChild($par_node);
179 $par_node->setAttribute(
"Name", $par);
180 $par_node->setAttribute(
"Value", $val);
189 if (is_object($mal_node) && $mal_node->nodeName ==
"MediaAlias") {
208 return $this->dom_util->dump($this->
getDomNode());
229 $this->dom_util->setAttribute($this->
getMediaAliasNode(),
"CaptionClass", $a_class);
239 return array(
"pc_mob");
262 self::saveMobUsage($a_page, $a_domdoc);
263 foreach ($mob_ids as $mob) {
266 $usages = $mob_obj->getUsages(
false);
267 if (count($usages) == 0) {
292 foreach ($mob_ids as $mob) {
295 $usages = $mob_obj->getUsages(
false);
296 if (count($usages) == 0) {
316 self::saveMobUsage($a_page, $a_old_domdoc, $a_old_nr);
328 $nodes = $xpath->query(
'//MediaAlias');
329 foreach ($nodes as $node) {
330 $id_arr = explode(
"_", $node->getAttribute(
"OriginId"));
331 $mob_id = $id_arr[count($id_arr) - 1];
332 if ($mob_id > 0 && $id_arr[1] ==
"") {
333 $usages[$mob_id] =
true;
339 $nodes = $xpath->query(
'//MediaObject/MetaData/General/Identifier');
340 foreach ($nodes as $node) {
341 $mob_entry = $node->getAttribute(
"Entry");
342 $mob_arr = explode(
"_", $mob_entry);
343 $mob_id = $mob_arr[count($mob_arr) - 1];
344 if ($mob_id > 0 && $mob_arr[1] ==
"") {
345 $usages[$mob_id] =
true;
351 $nodes = $xpath->query(
"//IntLink[@Type='MediaObject']");
352 foreach ($nodes as $node) {
353 $mob_target = $node->getAttribute(
"Target");
354 $mob_arr = explode(
"_", $mob_target);
358 $mob_id = $mob_arr[count($mob_arr) - 1];
359 if ($mob_id > 0 && $mob_arr[1] ==
"") {
360 $usages[$mob_id] =
true;
370 foreach ($usages as $mob_id => $val) {
389 bool $a_abstract_only =
false 393 $this->global_tpl = $DIC[
'tpl'];
396 if ($a_mode ==
"offline") {
400 $page->getParentType() .
":pg",
405 foreach ($mob_ids as $mob_id) {
407 $srts = $mob->getSrtFiles();
408 foreach ($srts as $srt) {
409 if ($ilUser->getLanguage() == $srt[
"language"]) {
411 $a_output = str_replace(
"[[[[[mobsubtitle;il__mob_" . $mob->getId() .
"_Standard]]]]]", $srt_content, $a_output);
417 if ($a_abstract_only) {
421 if ($a_mode ===
"edit") {
422 $a_output = str_replace(
423 "{{{{{Unsupported Media Type}}}}}",
424 $this->
ui->renderer()->render(
425 $this->
ui->factory()->messageBox()->info(
426 $this->
lng->txt(
"copg_unsupported_media_type")
432 $a_output = str_replace(
433 "{{{{{No Media Type}}}}}",
434 '<div class="copg-new-content-placeholder">' .
435 $this->
ui->renderer()->render(
436 $this->
ui->factory()->symbol()->icon()->standard(
"pemed",
"pemed",
'medium')
441 $a_output = str_replace(
442 "{{{{{Unsupported Media Type}}}}}",
446 $a_output = str_replace(
447 "{{{{{No Media Type}}}}}",
455 $suffix =
"-" . $page->getParentType() .
"-" . $page->getId();
456 $modal = $this->
ui->factory()->modal()->roundtrip(
457 $this->
lng->txt(
"cont_fullscreen"),
458 $this->
ui->factory()->legacy()->content(
"<iframe class='il-copg-mob-fullscreen' id='il-copg-mob-fullscreen" . $suffix .
"'></iframe>")
460 $show_signal = $modal->getShowSignal();
464 il.COPagePres.setFullscreenModalShowSignal('$show_signal', '$suffix'); 467 self::$modal_show_signal = $show_signal;
468 self::$modal_suffix = $suffix;
469 $this->global_tpl->addOnloadCode($js);
474 if ($this->
ctrl->isAsynch()) {
475 $html = $this->
ui->renderer()->renderAsync($modal);
477 $html = $this->
ui->renderer()->render($modal);
479 return $a_output .
"<div class='il-copg-mob-fullscreen-modal'>" . $html .
"</div>";
486 if (self::$modal_show_signal !==
"") {
487 $onload_code[] =
"il.COPagePres.setFullscreenModalShowSignal('" . self::$modal_show_signal .
488 "', '" . self::$modal_suffix .
"');";
515 return $std_alias_item;
526 return $std_alias_item;
529 public function checkInstanceEditing():
bool 535 if ($std_alias_item->hasAnyPropertiesSet()) {
540 if ($full_alias_item->hasAnyPropertiesSet()) {
550 if (is_object($mob)) {
551 $usages = $mob->getUsages();
552 $other_usages = array_filter($usages,
function ($usage) use ($page) {
553 return ($usage[
"type"] != $page->getParentType() .
":pg" || $usage[
"id"] != $page->getId());
555 if (count($other_usages) > 0) {
568 int $delete_lower_than_nr
572 $mob_usage_repo = $DIC->mediaObjects()
580 $parent_type .
":pg",
582 $delete_lower_than_nr,
587 $parent_type .
":pg",
589 $delete_lower_than_nr,
593 foreach ($mob_ids as $mob_id) {
595 $log->
debug(
"...check deletion of mob $mob_id. Usages: " . count($usages));
596 if (count($usages) == 0) {
599 $log->
debug(
"Deleting Mob ID: " . $mob_id);
608 bool $a_self_ass =
true,
609 bool $a_clone_mobs =
false,
610 int $new_parent_id = 0,
615 if (!$a_clone_mobs) {
619 $dom_util = $DIC->copage()->internal()->domain()->domUtil();
620 $path =
"//MediaObject/MediaAlias";
622 foreach ($nodes as $node) {
623 $or_id = $node->getAttribute(
"OriginId");
628 if (!($inst_id > 0)) {
631 $new_mob = $media_object->duplicate();
632 $node->setAttribute(
"OriginId",
"il__mob_" . $new_mob->getId());
setType(string $a_type)
Set Type.
static getLogger(string $a_component_id)
Get component logger.
static _extractObjIdOfTarget(string $a_target)
Extract object id out of target.
Content object of ilPageObject (see ILIAS DTD).
static _extractInstOfTarget(string $a_target)
Extract installation id out of target.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
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
setDomNode(DOMNode $node)
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
ILIAS COPage Dom DomUtil $dom_util
static getLocalMaphilightPath()
Get local path of maphilight file.
debug(string $message, array $context=[])
static _lookupType(int $id, bool $reference=false)