ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilImageMapTableGUI.php
Go to the documentation of this file.
1<?php
2
25{
27 protected array $highl_classes;
28 protected array $highl_modes;
30
31 public function __construct(
32 object $a_parent_obj,
33 string $a_parent_cmd,
34 ilObjMediaObject $a_media_object
35 ) {
36 global $DIC;
37
38 $this->ctrl = $DIC->ctrl();
39 $this->lng = $DIC->language();
40 $this->access = $DIC->access();
41 $ilCtrl = $DIC->ctrl();
42
43 parent::__construct($a_parent_obj, $a_parent_cmd);
44 $this->media_object = $a_media_object;
45
46 $this->highl_modes = ilMapArea::getAllHighlightModes();
47 $this->highl_classes = ilMapArea::getAllHighlightClasses();
48
49 $this->initColumns();
50 $this->setEnableHeader(true);
51 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
52 $this->setRowTemplate("tpl.image_map_table_row.html", "components/ILIAS/MediaObjects");
53 $this->getItems();
54
55 // action commands
56 $this->initActions();
57
58 $this->setDefaultOrderField("title");
59 $this->setDefaultOrderDirection("asc");
60 $this->setEnableTitle(false);
61 }
62
63 public function initColumns(): void
64 {
65 $this->addColumn("", "", "1"); // checkbox
66 $this->addColumn($this->lng->txt("cont_name"), "title", "");
67 $this->addColumn($this->lng->txt("cont_shape"), "", "");
68 $this->addColumn($this->lng->txt("cont_coords"), "", "");
69 $this->addColumn($this->lng->txt("cont_highlight_mode"));
70 $this->addColumn($this->lng->txt("cont_highlight_class"));
71 $this->addColumn($this->lng->txt("cont_link"), "", "");
72 }
73
74 public function initActions(): void
75 {
77
78 // action commands
79 $this->addMultiCommand("deleteAreas", $lng->txt("delete"));
80 $this->addMultiCommand("editLink", $lng->txt("cont_set_link"));
81 $this->addMultiCommand("editShapeWholePicture", $lng->txt("cont_edit_shape_whole_picture"));
82 $this->addMultiCommand("editShapeRectangle", $lng->txt("cont_edit_shape_rectangle"));
83 $this->addMultiCommand("editShapeCircle", $lng->txt("cont_edit_shape_circle"));
84 $this->addMultiCommand("editShapePolygon", $lng->txt("cont_edit_shape_polygon"));
85
86 $data = $this->getData();
87 if (count($data) > 0) {
88 $this->addCommandButton("updateAreas", $lng->txt("save"));
89 }
90 }
91
92 public function getItems(): void
93 {
94 $st_item = $this->media_object->getMediaItem("Standard");
95 $max = ilMapArea::_getMaxNr($st_item->getId());
96 $areas = array();
97
98 for ($i = 1; $i <= $max; $i++) {
99 $area = new ilMapArea($st_item->getId(), $i);
100 $areas[] = array("nr" => $i, "area" => $area, "title" => $area->getTitle());
101 }
102
103 $this->setData($areas);
104 }
105
106 protected function fillRow(array $a_set): void
107 {
108 $area = $a_set["area"];
109 $i = $a_set["nr"];
110 $this->tpl->setVariable(
111 "CHECKBOX",
113 );
114 $this->tpl->setVariable("VAR_NAME", "name_" . $i);
115 $this->tpl->setVariable("VAL_NAME", ilLegacyFormElementsUtil::prepareFormOutput($area->getTitle()));
116 $this->tpl->setVariable("VAL_SHAPE", $area->getShape());
117
118 $this->tpl->setVariable(
119 "VAL_HIGHL_MODE",
121 $area->getHighlightMode(),
122 "hl_mode_" . $i,
123 $this->highl_modes,
124 false,
125 true
126 )
127 );
128 $this->tpl->setVariable(
129 "VAL_HIGHL_CLASS",
131 $area->getHighlightClass(),
132 "hl_class_" . $i,
133 $this->highl_classes,
134 false,
135 true
136 )
137 );
138
139 $this->tpl->setVariable(
140 "VAL_COORDS",
141 implode(", ", explode(",", $area->getCoords()))
142 );
143 switch ($area->getLinkType()) {
144 case "ext":
145 $this->tpl->setVariable("VAL_LINK", $area->getHRef());
146 break;
147
148 case "int":
149 $link_str = $this->parent_obj->getMapAreaLinkString(
150 $area->getTarget(),
151 $area->getType(),
152 $area->getTargetFrame()
153 );
154 $this->tpl->setVariable("VAL_LINK", $link_str);
155 break;
156 }
157 }
158}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilObjMediaObject $media_object
fillRow(array $a_set)
Standard Version of Fill Row.
__construct(object $a_parent_obj, string $a_parent_cmd, ilObjMediaObject $a_media_object)
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 prepareFormOutput($a_str, bool $a_strip=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.
Class ilMapArea.
static getAllHighlightClasses()
static _getMaxNr(int $a_item_id)
get maximum nr of media item (static)
static getAllHighlightModes()
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="")
setEnableTitle(bool $a_enabletitle)
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
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)
setEnableHeader(bool $a_enableheader)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
ilLanguage $lng
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26