ILIAS  release_8 Revision v8.24
class.ilPCIIMTriggerTableGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 protected array $pop_options;
27 protected array $popups;
28 protected array $ov_files;
29 protected array $areas;
31 protected array $ov_options;
32 protected string $parent_node_name;
34 protected array $area;
35
36 public function __construct(
37 object $a_parent_obj,
38 string $a_parent_cmd,
39 ilPCInteractiveImage $a_pc_media_object,
40 string $a_parent_node_name
41 ) {
42 global $DIC;
43
44 $this->ctrl = $DIC->ctrl();
45 $this->lng = $DIC->language();
46 $this->access = $DIC->access();
47 $lng = $DIC->language();
48
49 $this->setId("cont_iim_tr");
50
51 $this->parent_node_name = $a_parent_node_name;
52 $this->pc_media_object = $a_pc_media_object;
53 $this->mob = $this->pc_media_object->getMediaObject();
54
55 $this->areas = array();
56 foreach ($this->pc_media_object->getStandardAliasItem()->getMapAreas() as $a) {
57 $this->area[$a["Id"]] = $a;
58 }
59
60 $this->ov_files = $this->mob->getFilesOfDirectory("overlays");
61 $this->ov_options = array("" => $lng->txt("please_select"));
62 foreach ($this->ov_files as $of) {
63 $this->ov_options[$of] = $of;
64 }
65 $this->popups = $this->pc_media_object->getPopups();
66 $this->pop_options = array("" => $lng->txt("please_select"));
67 foreach ($this->popups as $k => $p) {
68 $this->pop_options[$p["nr"]] = $p["title"];
69 }
70 parent::__construct($a_parent_obj, $a_parent_cmd, $a_pc_media_object->getMediaObject());
71 $this->setRowTemplate("tpl.iim_trigger_row.html", "Services/COPage");
72 }
73
74 public function initColumns(): void
75 {
76 $this->addColumn("", "", "1"); // checkbox
77 $this->addColumn($this->lng->txt("title"), "Title", "");
78 $this->addColumn($this->lng->txt("type"), "", "");
79 $this->addColumn($this->lng->txt("cont_coords"), "", "");
80 $this->addColumn($this->lng->txt("cont_overlay_image"), "", "");
81 $this->addColumn($this->lng->txt("cont_content_popup"), "", "");
82 $this->addColumn($this->lng->txt("actions"), "", "");
83 }
84
85 public function initActions(): void
86 {
88
89 // action commands
90 $this->addMultiCommand("confirmDeleteTrigger", $lng->txt("delete"));
91
92 $data = $this->getData();
93 if (count($data) > 0) {
94 $this->addCommandButton("updateTrigger", $lng->txt("save"), "", "update_tr_button");
95 }
96 }
97
98 public function getItems(): void
99 {
100 $triggers = $this->pc_media_object->getTriggers();
101
102 $triggers = ilArrayUtil::sortArray($triggers, "Title", "asc", false, true);
103 $this->setData($triggers);
104 }
105
106 protected function fillRow(array $a_set): void
107 {
109
110 $i = $a_set["Nr"];
111
112 // command: edit marker position
113 if ($a_set["Overlay"] != "") {
114 $this->tpl->setCurrentBlock("cmd");
115 $this->tpl->setVariable("CMD_ID", "ov_" . $i);
116 $this->tpl->setVariable("HREF_CMD", "#");
117 $this->tpl->setVariable("CMD_CLASS", "ov_cmd");
118 $this->tpl->setVariable("TXT_CMD", $lng->txt("cont_edit_overlay_position"));
119 $this->tpl->parseCurrentBlock();
120 }
121
122 // command: edit marker position
123 if ($a_set["PopupNr"] != "") {
124 $this->tpl->setCurrentBlock("cmd");
125 $this->tpl->setVariable("CMD_ID", "pop_" . $i);
126 $this->tpl->setVariable("HREF_CMD", "#");
127 $this->tpl->setVariable("CMD_CLASS", "pop_cmd");
128 $this->tpl->setVariable("TXT_CMD", $lng->txt("cont_edit_popup_position"));
129 $this->tpl->parseCurrentBlock();
130 }
131
132 if ($a_set["Type"] == ilPCInteractiveImage::AREA) {
133 $this->tpl->setCurrentBlock("coords");
134 $this->tpl->setVariable(
135 "VAL_COORDS",
136 implode(", ", explode(",", $this->area[$a_set["Nr"]]["Coords"]))
137 );
138 $this->tpl->parseCurrentBlock();
139
140 $this->tpl->setVariable(
141 "TYPE",
142 $lng->txt("cont_" . $this->area[$a_set["Nr"]]["Shape"])
143 );
144 } else {
145 // command: edit marker position
146 $this->tpl->setCurrentBlock("cmd");
147 $this->tpl->setVariable("CMD_ID", "mark_" . $i);
148 $this->tpl->setVariable("HREF_CMD", "#");
149 $this->tpl->setVariable("CMD_CLASS", "mark_cmd");
150 $this->tpl->setVariable("TXT_CMD", $lng->txt("cont_edit_marker_position"));
151 $this->tpl->parseCurrentBlock();
152
153 // marker position
154 $this->tpl->setCurrentBlock("marker_pos");
155 $this->tpl->setVariable("VAR_MARK_POS", "markpos[" . $i . "]");
156 $this->tpl->setVariable("ID_MARK_POS", "markpos_" . $i);
157 $this->tpl->setVariable("VAL_MARK_POS", $a_set["MarkerX"] . "," . $a_set["MarkerY"]);
158 $this->tpl->setVariable("TXT_MLEFT", $lng->txt("cont_left"));
159 $this->tpl->setVariable("TXT_MTOP", $lng->txt("cont_top"));
160 $this->tpl->parseCurrentBlock();
161
162 $this->tpl->setVariable("TYPE", $lng->txt("cont_marker"));
163 }
164
165 $this->tpl->setVariable(
166 "CHECKBOX",
168 );
169 $this->tpl->setVariable("VAR_NAME", "title[" . $i . "]");
170 $this->tpl->setVariable("VAL_NAME", $a_set["Title"]);
171
172
173 $this->tpl->setVariable("VAR_POS", "ovpos[" . $i . "]");
174 $this->tpl->setVariable("ID_OV_POS", "ovpos_" . $i);
175 $this->tpl->setVariable("ID_POP_POS", "poppos_" . $i);
176 $this->tpl->setVariable("VAR_POP_POS", "poppos[" . $i . "]");
177 $this->tpl->setVariable("VAR_POP_SIZE", "popsize[" . $i . "]");
178 $this->tpl->setVariable("VAL_POS", $a_set["OverlayX"] . "," . $a_set["OverlayY"]);
179 $this->tpl->setVariable("VAL_POP_POS", $a_set["PopupX"] . "," . $a_set["PopupY"]);
180 $this->tpl->setVariable("VAL_POP_SIZE", $a_set["PopupWidth"] . "," . $a_set["PopupHeight"]);
181 $this->tpl->setVariable("TXT_IMG", $lng->txt("image"));
182 $this->tpl->setVariable("TXT_TITLE", $lng->txt("title"));
183 $this->tpl->setVariable("TXT_LEFT", $lng->txt("cont_left"));
184 $this->tpl->setVariable("TXT_TOP", $lng->txt("cont_top"));
185 $this->tpl->setVariable("TXT_WIDTH", $lng->txt("cont_width"));
186 $this->tpl->setVariable("TXT_HEIGHT", $lng->txt("cont_height"));
187 $this->tpl->setVariable(
188 "OVERLAY_IMAGE",
189 ilLegacyFormElementsUtil::formSelect($a_set["Overlay"], "ov[" . $i . "]", $this->ov_options, false, true)
190 );
191 $this->tpl->setVariable(
192 "CONTENT_POPUP",
193 ilLegacyFormElementsUtil::formSelect($a_set["PopupNr"], "pop[" . $i . "]", $this->pop_options, false, true)
194 );
195 }
196}
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 formCheckbox(bool $checked, string $varname, string $value, bool $disabled=false)
static formSelect( $selected, string $varname, array $options, bool $multiple=false, bool $direct_text=false, int $size=0, string $style_class="", array $attribs=[], bool $disabled=false)
Builds a select form field with options and shows the selected option first.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(object $a_parent_obj, string $a_parent_cmd, ilPCInteractiveImage $a_pc_media_object, string $a_parent_node_name)
fillRow(array $a_set)
Standard Version of Fill Row.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
addMultiCommand(string $a_cmd, string $a_text)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setData(array $a_data)
Set table data.
ilLanguage $lng
global $DIC
Definition: feed.php:28
$i
Definition: metadata.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples