ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilImageMapTableGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("Services/Table/classes/class.ilTable2GUI.php");
6
16{
20 protected $ctrl;
21
25 protected $access;
26
27
31 public function __construct($a_parent_obj, $a_parent_cmd, $a_media_object)
32 {
33 global $DIC;
34
35 $this->ctrl = $DIC->ctrl();
36 $this->lng = $DIC->language();
37 $this->access = $DIC->access();
38 $ilCtrl = $DIC->ctrl();
39 $lng = $DIC->language();
40 $ilAccess = $DIC->access();
41 $lng = $DIC->language();
42
43 parent::__construct($a_parent_obj, $a_parent_cmd);
44 $this->media_object = $a_media_object;
45
46 include_once("./Services/MediaObjects/classes/class.ilMapArea.php");
47 $this->highl_modes = ilMapArea::getAllHighlightModes();
48 $this->highl_classes = ilMapArea::getAllHighlightClasses();
49
50 $this->initColumns();
51 $this->setEnableHeader(true);
52 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
53 $this->setRowTemplate("tpl.image_map_table_row.html", "Services/MediaObjects");
54 $this->getItems();
55
56 // action commands
57 $this->initActions();
58
59 $this->setDefaultOrderField("title");
60 $this->setDefaultOrderDirection("asc");
61 $this->setEnableTitle(false);
62 }
63
67 public function initColumns()
68 {
69 $this->addColumn("", "", "1"); // checkbox
70 $this->addColumn($this->lng->txt("cont_name"), "title", "");
71 $this->addColumn($this->lng->txt("cont_shape"), "", "");
72 $this->addColumn($this->lng->txt("cont_coords"), "", "");
73 $this->addColumn($this->lng->txt("cont_highlight_mode"));
74 $this->addColumn($this->lng->txt("cont_highlight_class"));
75 $this->addColumn($this->lng->txt("cont_link"), "", "");
76 }
77
81 public function initActions()
82 {
84
85 // action commands
86 $this->addMultiCommand("deleteAreas", $lng->txt("delete"));
87 $this->addMultiCommand("editLink", $lng->txt("cont_set_link"));
88 $this->addMultiCommand("editShapeWholePicture", $lng->txt("cont_edit_shape_whole_picture"));
89 $this->addMultiCommand("editShapeRectangle", $lng->txt("cont_edit_shape_rectangle"));
90 $this->addMultiCommand("editShapeCircle", $lng->txt("cont_edit_shape_circle"));
91 $this->addMultiCommand("editShapePolygon", $lng->txt("cont_edit_shape_polygon"));
92
93 $data = $this->getData();
94 if (count($data) > 0) {
95 $this->addCommandButton("updateAreas", $lng->txt("save"));
96 }
97 }
98
99
103 public function getItems()
104 {
105 $st_item = $this->media_object->getMediaItem("Standard");
106 $max = ilMapArea::_getMaxNr($st_item->getId());
107 $areas = array();
108
109 include_once("./Services/MediaObjects/classes/class.ilMapArea.php");
110 for ($i = 1; $i <= $max; $i++) {
111 $area = new ilMapArea($st_item->getId(), $i);
112 $areas[] = array("nr" => $i, "area" => $area, "title" => $area->getTitle());
113 }
114
115 $this->setData($areas);
116 }
117
122 protected function fillRow($a_set)
123 {
126 $ilAccess = $this->access;
127
128 $area = $a_set["area"];
129 $i = $a_set["nr"];
130 $this->tpl->setVariable(
131 "CHECKBOX",
132 ilUtil::formCheckBox("", "area[]", $i)
133 );
134 $this->tpl->setVariable("VAR_NAME", "name_" . $i);
135 $this->tpl->setVariable("VAL_NAME", ilUtil::prepareFormOutput($area->getTitle()));
136 $this->tpl->setVariable("VAL_SHAPE", $area->getShape());
137
138 $this->tpl->setVariable(
139 "VAL_HIGHL_MODE",
141 $area->getHighlightMode(),
142 "hl_mode_" . $i,
143 $this->highl_modes,
144 false,
145 true
146 )
147 );
148 $this->tpl->setVariable(
149 "VAL_HIGHL_CLASS",
151 $area->getHighlightClass(),
152 "hl_class_" . $i,
153 $this->highl_classes,
154 false,
155 true
156 )
157 );
158
159 $this->tpl->setVariable(
160 "VAL_COORDS",
161 implode(", ", explode(",", $area->getCoords()))
162 );
163 switch ($area->getLinkType()) {
164 case "ext":
165 $this->tpl->setVariable("VAL_LINK", $area->getHRef());
166 break;
167
168 case "int":
169 $link_str = $this->parent_obj->getMapAreaLinkString(
170 $area->getTarget(),
171 $area->getType(),
172 $area->getTargetFrame()
173 );
174 $this->tpl->setVariable("VAL_LINK", $link_str);
175 break;
176 }
177 }
178}
An exception for terminatinating execution or to throw for unit testing.
TableGUI class for image map editor.
__construct($a_parent_obj, $a_parent_cmd, $a_media_object)
Constructor.
getItems()
Get items of current folder.
fillRow($a_set)
Standard Version of Fill Row.
Class ilMapArea.
static getAllHighlightClasses()
Get all highlight classes.
static _getMaxNr($a_item_id)
get maximum nr of media item (static)
static getAllHighlightModes()
Get all highlight modes.
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable Header.
setData($a_data)
set table data @access public
setEnableTitle($a_enabletitle)
Set Enable Title.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
global $ilCtrl
Definition: ilias.php:18
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46