26 public const AREA =
"Area";
30 protected \ILIAS\DI\UIServices
$ui;
32 protected \ILIAS\COPage\PC\InteractiveImage\IIMManager
$manager;
39 public function init(): void
43 $this->
lng = $DIC->language();
45 $this->manager = $DIC->copage()->internal()->domain()->pc()->interactiveImage();
46 $this->htmlTransform = $DIC->copage()->internal()->domain()->htmlTransformUtil();
47 $this->
ui = $DIC->copage()->internal()->gui()->ui();
60 parent::setDomNode($dom_node);
61 $this->iim_node = $dom_node->firstChild;
62 if (isset($this->iim_node)) {
63 $this->med_alias_node = $this->iim_node->firstChild;
65 if (isset($this->med_alias_node)) {
66 $id = $this->med_alias_node->getAttribute(
"OriginId");
68 if ($this->
object->getTypeForObjId($mob_id) ==
"mob") {
83 $this->mediaobject = $a_mediaobject;
113 return $this->
getMediaObject()->getMediaItem(
"Standard")->getThumbnailTarget();
121 $this->
setDomNode($this->dom_doc->createElement(
"PageContent"));
123 $this->iim_node = $this->dom_doc->createElement(
"InteractiveImage");
124 $this->iim_node = $this->
getDomNode()->appendChild($this->iim_node);
125 $this->mal_node = $this->dom_doc->createElement(
"MediaAlias");
126 $this->mal_node = $this->iim_node->appendChild($this->mal_node);
130 $item_node = $this->dom_doc->createElement(
"MediaAliasItem");
131 $item_node = $this->iim_node->appendChild($item_node);
132 $item_node->setAttribute(
"Purpose",
"Standard");
135 $layout_node = $this->dom_doc->createElement(
"Layout");
136 $layout_node = $item_node->appendChild($layout_node);
137 $layout_node->setAttribute(
"HorizontalAlign",
"Left");
140 if ($media_item->getCaption() !=
"") {
141 $cap_node = $this->dom_doc->createElement(
"Caption");
142 $cap_node = $item_node->appendChild($cap_node);
143 $cap_node->setAttribute(
"Align",
"bottom");
144 $this->dom_util->setContent($cap_node, $media_item->getCaption());
148 if ($media_item->getTextRepresentation() !=
"") {
149 $tr_node = $this->dom_doc->createElement(
"TextRepresentation");
150 $tr_node = $item_node->appendChild($tr_node);
151 $this->dom_util->setContent($tr_node, $media_item->getTextRepresentation());
157 $xml = $this->dom_util->dump($this->
getDomNode());
173 if ($title === null) {
174 $title = $lng->
txt(
"cont_new_popup");
178 foreach ($popups as $p) {
179 $max = max($max, (
int) $p[
"nr"]);
182 $new_item = $this->dom_doc->createElement(
"ContentPopup");
183 $new_item->setAttribute(
"Title", $title);
184 $new_item->setAttribute(
"Nr", $max + 1);
185 $new_item = $this->iim_node->appendChild($new_item);
195 foreach ($this->iim_node->childNodes as
$c) {
196 if ($c->nodeName ==
"ContentPopup") {
197 $pc_id = $c->getAttribute(
"PCID");
198 $hier_id = $c->getAttribute(
"HierId");
199 $title = $c->getAttribute(
"Title");
200 $nr = $c->getAttribute(
"Nr");
202 $titles[] = array(
"title" => $title,
218 foreach ($this->iim_node->childNodes as
$c) {
219 if ($c->nodeName ==
"ContentPopup") {
220 $pc_id = $c->getAttribute(
"PCID");
221 $hier_id = $c->getAttribute(
"HierId");
223 $c->setAttribute(
"Title", $a_popups[$k]);
235 foreach ($this->iim_node->childNodes as
$c) {
236 if ($c->nodeName ===
"ContentPopup") {
237 if ($a_pc_id == $c->getAttribute(
"PCID") &&
238 $a_hier_id == $c->getAttribute(
"HierId")) {
239 $c->parentNode->removeChild($c);
247 foreach ($this->iim_node->childNodes as
$c) {
248 if ($c->nodeName ===
"ContentPopup") {
249 if ($nr === $c->getAttribute(
"Nr")) {
250 $c->setAttribute(
"Title", $title);
259 foreach ($this->iim_node->childNodes as
$c) {
260 if ($c->nodeName ===
"ContentPopup") {
261 if ($nr === $c->getAttribute(
"Nr")) {
262 $c->parentNode->removeChild($c);
267 foreach ($tr_nodes as $tr_node) {
268 if ($tr_node->getAttribute(
"PopupNr") === $nr) {
269 $tr_node->removeAttribute(
"PopupNr");
280 string $a_shape_type,
284 string $hl_mode =
"",
285 string $hl_class =
"" 309 string $a_shape_type,
312 string $hl_mode =
"",
313 string $hl_class =
"" 317 foreach ($triggers as $t) {
318 $max = max($max, (
int) $t[
"Nr"]);
331 $attributes = array(
"Type" => self::AREA,
340 "PopupWidth" =>
"150",
341 "PopupHeight" =>
"200" 343 $ma_node = $this->dom_util->addElementToList(
346 array(
"ContentPopup"),
363 foreach ($triggers as $t) {
364 $max = max($max, (
int) $t[
"Nr"]);
368 $title = $lng->
txt(
"cont_new_marker");
372 if ($coords !==
"") {
373 $coord_parts = explode(
",", $coords);
374 $markerx = ($coord_parts[0] ??
"0");
375 $markery = ($coord_parts[1] ??
"0");
378 $attributes = array(
"Type" => self::MARKER,
383 "MarkerX" => $markerx,
384 "MarkerY" => $markery,
388 "PopupWidth" =>
"150",
389 "PopupHeight" =>
"200" 391 $ma_node = $this->dom_util->addElementToList(
394 array(
"ContentPopup"),
404 if ($a_pc_id !=
"") {
405 $path =
"//PageContent[@PCID = '" . $a_pc_id .
"']/InteractiveImage/Trigger";
406 return $this->dom_util->path($this->dom_doc,
$path);
409 $path =
"//PageContent[@HierId = '" . $a_hier_id .
"']/InteractiveImage/Trigger";
410 return $this->dom_util->path($this->dom_doc,
$path);
416 $trigger_arr = array();
417 foreach ($tr_nodes as $tr_node) {
418 $childs = $tr_node->childNodes;
419 $trigger_arr[] = array(
420 "Nr" => $tr_node->getAttribute(
"Nr"),
421 "Type" => $tr_node->getAttribute(
"Type"),
422 "Title" => $tr_node->getAttribute(
"Title"),
423 "OverlayX" => $tr_node->getAttribute(
"OverlayX"),
424 "OverlayY" => $tr_node->getAttribute(
"OverlayY"),
425 "MarkerX" => $tr_node->getAttribute(
"MarkerX"),
426 "MarkerY" => $tr_node->getAttribute(
"MarkerY"),
427 "Overlay" => $tr_node->getAttribute(
"Overlay"),
428 "PopupNr" => $tr_node->getAttribute(
"PopupNr"),
429 "PopupX" => $tr_node->getAttribute(
"PopupX"),
430 "PopupY" => $tr_node->getAttribute(
"PopupY"),
431 "PopupWidth" => $tr_node->getAttribute(
"PopupWidth"),
432 "PopupHeight" => $tr_node->getAttribute(
"PopupHeight"),
433 "PopupPosition" => $tr_node->getAttribute(
"PopupPosition"),
434 "PopupSize" => $tr_node->getAttribute(
"PopupSize")
448 foreach ($this->iim_node->childNodes as
$c) {
449 if ($c->nodeName ===
"Trigger") {
450 if ($a_nr === (
int) $c->getAttribute(
"Nr")) {
451 $c->parentNode->removeChild($c);
466 foreach ($tr_nodes as $tr_node) {
467 if (isset($a_ovs[
"" . $tr_node->getAttribute(
"Nr")])) {
468 $tr_node->setAttribute(
470 $a_ovs[
"" . $tr_node->getAttribute(
"Nr")]
480 ->removeAdditionalFile(
"overlays/" . $file);
482 foreach ($tr_nodes as $tr_node) {
483 if ($tr_node->getAttribute(
"Overlay") === $file) {
484 $tr_node->removeAttribute(
"Overlay");
497 foreach ($tr_nodes as $tr_node) {
498 if (isset($a_pos[
"" . $tr_node->getAttribute(
"Nr")])) {
499 $pos = explode(
",", $a_pos[
"" . $tr_node->getAttribute(
"Nr")]);
500 $tr_node->setAttribute(
"OverlayX", (
int) $pos[0]);
501 $tr_node->setAttribute(
"OverlayY", (
int) $pos[1]);
514 foreach ($tr_nodes as $tr_node) {
515 if ($tr_node->getAttribute(
"Type") == self::MARKER) {
516 if (isset($a_pos[
"" . $tr_node->getAttribute(
"Nr")])) {
517 $pos = explode(
",", $a_pos[
"" . $tr_node->getAttribute(
"Nr")]);
518 $tr_node->setAttribute(
"MarkerX", (
int) $pos[0]);
519 $tr_node->setAttribute(
"MarkerY", (
int) $pos[1]);
533 foreach ($tr_nodes as $tr_node) {
534 if (isset($a_pos[
"" . $tr_node->getAttribute(
"Nr")])) {
535 $pos = explode(
",", $a_pos[
"" . $tr_node->getAttribute(
"Nr")]);
536 $tr_node->setAttribute(
"PopupX", (
int) $pos[0]);
537 $tr_node->setAttribute(
"PopupY", (
int) $pos[1]);
550 foreach ($tr_nodes as $tr_node) {
551 if (isset($a_size[
"" . $tr_node->getAttribute(
"Nr")])) {
552 $size = explode(
",", $a_size[
"" . $tr_node->getAttribute(
"Nr")]);
553 $tr_node->setAttribute(
"PopupWidth", (
int) $size[0]);
554 $tr_node->setAttribute(
"PopupHeight", (
int) $size[1]);
567 foreach ($tr_nodes as $tr_node) {
568 if (isset($a_pops[(
string) $tr_node->getAttribute(
"Nr")])) {
569 $pop = $a_pops[(string) $tr_node->getAttribute(
"Nr")];
570 $tr_node->setAttribute(
"PopupNr", $pop);
583 foreach ($tr_nodes as $tr_node) {
584 if (isset($a_titles[(
string) $tr_node->getAttribute(
"Nr")])) {
585 $tr_node->setAttribute(
587 $a_titles[(
string) $tr_node->getAttribute(
"Nr")]
590 $tr_node->getAttribute(
"Nr"),
591 $a_titles[(string) $tr_node->getAttribute(
"Nr")]
602 $path =
"//PageContent[@PCID = '" . $this->
getPCId() .
"']/InteractiveImage/MediaAliasItem/MapArea[@Id='" . $a_nr .
"']/ExtLink";
603 $res = $this->dom_util->path($this->dom_doc,
$path);
604 if (count(
$res) > 0) {
605 $this->dom_util->setContent(
$res->item(0), $a_title);
610 $path =
"//PageContent[@HierId = '" . $this->hier_id .
"']/InteractiveImage/MediaAliasItem/MapArea[@Id='" . $a_nr .
"']/ExtLink";
611 $res = $this->dom_util->path($this->dom_doc,
$path);
612 if (count(
$res) > 0) {
613 $this->dom_util->setContent(
$res->item(0), $a_title);
619 bool $a_self_ass =
true,
620 bool $a_clone_mobs =
false,
621 int $new_parent_id = 0,
626 $dom_util = $DIC->copage()->internal()->domain()->domUtil();
627 $path =
"//InteractiveImage/MediaAlias";
629 foreach ($nodes as $node) {
630 $or_id = $node->getAttribute(
"OriginId");
633 if (!($inst_id > 0)) {
636 $new_mob = $media_object->duplicate();
637 $node->setAttribute(
"OriginId",
"il__mob_" . $new_mob->getId());
656 $model = new \stdClass();
659 $model->media_item = $alias_item->getModel();
660 $model->overlays = $this->manager->getOverlays($this->
getMediaObject());
667 foreach ($tr_nodes as $tr_node) {
668 if ($tr_node->getAttribute(
"Nr") === $nr) {
675 public function setTriggerProperties(
string $nr,
string $title,
string $shape_type,
string $coords,
string $hl_mode =
"",
string $hl_class =
""): void
679 if ($shape_type ===
"Marker") {
688 $tr_node->setAttribute(
"Type",
"Marker");
689 $tr_node->setAttribute(
693 $coord_parts = explode(
",", $coords);
694 $tr_node->setAttribute(
"MarkerX", ($coord_parts[0] ??
"0"));
695 $tr_node->setAttribute(
"MarkerY", ($coord_parts[1] ??
"0"));
698 $path =
"//PageContent[@HierId = '" . $this->hier_id .
"']/InteractiveImage/MediaAliasItem/MapArea[@Id='" . $nr .
"']";
699 $res = $this->dom_util->path($this->dom_doc,
$path);
700 if ($child =
$res->item(0)) {
701 $child->parentNode->removeChild($child);
708 $tr_node->setAttribute(
"Type",
"Area");
709 $tr_node->removeAttribute(
"MarkerX");
710 $tr_node->removeAttribute(
"MarkerY");
711 $tr_node->setAttribute(
740 $c = explode(
",", $coords);
741 $x = (
int) (
$c[0] ?? 0);
742 $y = (
int) (
$c[1] ?? 0);
743 $tr_node->setAttribute(
"Overlay", $overlay);
744 $tr_node->setAttribute(
"OverlayX", $x);
745 $tr_node->setAttribute(
"OverlayY", $y);
749 public function setTriggerPopup(
string $nr,
string $popup,
string $position,
string $size): void
753 $tr_node->setAttribute(
"PopupNr", $popup);
754 $tr_node->setAttribute(
"PopupPosition", $position);
755 $tr_node->setAttribute(
"PopupSize", $size);
762 bool $a_abstract_only =
false 764 $keep_original =
false;
766 $keep_original =
true;
769 while (!is_null(
$params = $trans->getPlaceholderParams($a_output,
"InteractiveImage;PopupStart"))) {
770 $params = $trans->getPlaceholderParams($a_output,
"InteractiveImage;PopupStart");
773 $inner = $trans->getInnerContentOfPlaceholders(
775 "InteractiveImage;PopupStart",
776 "InteractiveImage;PopupEnd" 778 if ($keep_original) {
781 $pop = $this->
ui->factory()->popover()->standard(
782 $this->
ui->factory()->legacy(
"#####popovercontent#####")
784 $signal_id = $pop->getShowSignal()->getId();
786 $new_inner =
"#####popovercontent#####";
788 $new_inner = str_replace(
789 "#####popovercontent#####",
790 "<div style='position:relative'><div class='copg-iim-popup copg-iim-popup-md' style='display:none;' data-copg-cont-type='iim-popup' data-signal-id='$signal_id' data-copg-page='$par_page' data-copg-popup-nr='$par_pop_nr'>" . $inner .
"</div></div>",
794 $html = $trans->replaceInnerContentAndPlaceholders(
796 "InteractiveImage;PopupStart",
797 "InteractiveImage;PopupEnd",
800 if (is_null($html)) {
807 '<script type="module" src="./Services/COPage/PC/InteractiveImage/js/presentation/src/presentation.js"></script>';
813 <div style=
'position:relative'><div
class=
'copg-iim-popup copg-iim-popup-md' data-copg-cont-type=
'iim-popup'>
814 <div
class=
"ilc_iim_ContentPopup" data-copg-iim-data-type=
"popup"><div
class=
"ilc_Paragraph ilc_text_block_Standard">
816 </div></div></div></div>
828 $st_item = $mob->getMediaItem(
"Standard");
835 $xsl = file_get_contents(
"./Services/COPage/xsl/page.xsl");
837 $args = array(
'/_xml' => $xml,
'/_xsl' => $xsl );
843 $random = new \ilRandom();
845 'media_mode' =>
'enable',
848 'webspace_path' => $wb_path);
849 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", null, $args,
$params);
static getWebspaceDir(string $mode="filesystem")
get webspace directory
getTriggerNode(string $nr)
ilMediaAliasItem $std_alias_item
setType(string $a_type)
Set Type.
deletePopup(string $a_hier_id, string $a_pc_id)
Delete popup.
setTriggerPopupPositions(array $a_pos)
Set trigger popup position.
setMapAreaProperties(ilMediaAliasItem $a_alias_item, string $a_shape_type, string $a_coords, string $a_title, string $a_id, string $hl_mode="", string $hl_class="")
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _extractObjIdOfTarget(string $a_target)
Extract object id out of target.
setTriggerOverlays(array $a_ovs)
Set trigger overlays.
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
deleteOverlay(string $file)
createAlias(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
setDomNode(DOMNode $dom_node)
deletePopupByNr(string $nr)
Content object of ilPageObject (see ILIAS DTD).
setTriggerProperties(string $nr, string $title, string $shape_type, string $coords, string $hl_mode="", string $hl_class="")
ILIAS COPage Html TransformUtil $htmlTransform
setTriggerTitles(array $a_titles)
Set trigger titles.
addTriggerArea(ilMediaAliasItem $a_alias_item, string $a_shape_type, string $a_coords, string $a_title, string $hl_mode="", string $hl_class="")
Add a new trigger.
static _extractInstOfTarget(string $a_target)
Extract installation id out of target.
setTriggerPopup(string $nr, string $popup, string $position, string $size)
setTriggerPopupSize(array $a_size)
Set trigger popup size.
deleteTrigger(ilMediaAliasItem $a_alias_item, int $a_nr)
Delete Trigger.
getPopups()
Get popup captions.
setMediaObject(ilObjMediaObject $a_mediaobject)
savePopups(array $a_popups)
Save popups.
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
ilObjMediaObject $mediaobject
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
setTriggerOverlay(string $nr, string $overlay, string $coords)
saveContentPopupTitle(string $nr, string $title)
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
static handleCopiedContent(DOMDocument $a_domdoc, bool $a_self_ass=true, bool $a_clone_mobs=false, int $new_parent_id=0, int $obj_copy_id=0)
createFromMobId(\ilPageObject $page, int $mob_id, string $hier_id, string $pc_id)
setExtLinkTitle(int $a_nr, string $a_title)
addContentPopup(?string $title=null)
Add a tab.
setTriggerPopups(array $a_pops)
Set trigger popups.
getTriggerNodes(string $a_hier_id, string $a_pc_id="")
setTriggerMarkerPositions(array $a_pos)
Set trigger marker position.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS COPage Dom DomUtil $dom_util
readMediaObject(int $a_mob_id=0)
setTriggerOverlayPositions(array $a_pos)
Set trigger overlay position.
ILIAS COPage PC InteractiveImage IIMManager $manager
modifyPageContentPostXsl(string $a_output, string $a_mode, bool $a_abstract_only=false)
addTriggerMarker(string $title="", string $coords="")
Add a new trigger marker.