ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
5 include_once("Services/Table/classes/class.ilTable2GUI.php");
6 
16 {
17 
21  function __construct($a_parent_obj, $a_parent_cmd, $a_media_object)
22  {
23  global $ilCtrl, $lng, $ilAccess, $lng;
24 
25  parent::__construct($a_parent_obj, $a_parent_cmd);
26  $this->media_object = $a_media_object;
27 
28  include_once("./Services/MediaObjects/classes/class.ilMapArea.php");
29  $this->highl_modes = ilMapArea::getAllHighlightModes();
30  $this->highl_classes = ilMapArea::getAllHighlightClasses();
31 
32  $this->initColumns();
33  $this->setEnableHeader(true);
34  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
35  $this->setRowTemplate("tpl.image_map_table_row.html", "Services/MediaObjects");
36  $this->getItems();
37 
38  // action commands
39  $this->initActions();
40 
41  $this->setDefaultOrderField("title");
42  $this->setDefaultOrderDirection("asc");
43  $this->setEnableTitle(false);
44  }
45 
49  function initColumns()
50  {
51  $this->addColumn("", "", "1"); // checkbox
52  $this->addColumn($this->lng->txt("cont_name"), "title", "");
53  $this->addColumn($this->lng->txt("cont_shape"), "", "");
54  $this->addColumn($this->lng->txt("cont_coords"), "", "");
55  $this->addColumn($this->lng->txt("cont_highlight_mode"));
56  $this->addColumn($this->lng->txt("cont_highlight_class"));
57  $this->addColumn($this->lng->txt("cont_link"), "", "");
58  }
59 
63  function initActions()
64  {
65  global $lng;
66 
67  // action commands
68  $this->addMultiCommand("deleteAreas", $lng->txt("delete"));
69  $this->addMultiCommand("editLink", $lng->txt("cont_set_link"));
70  $this->addMultiCommand("editShapeWholePicture", $lng->txt("cont_edit_shape_whole_picture"));
71  $this->addMultiCommand("editShapeRectangle", $lng->txt("cont_edit_shape_rectangle"));
72  $this->addMultiCommand("editShapeCircle", $lng->txt("cont_edit_shape_circle"));
73  $this->addMultiCommand("editShapePolygon", $lng->txt("cont_edit_shape_polygon"));
74 
75  $data = $this->getData();
76  if (count($data) > 0)
77  {
78  $this->addCommandButton("updateAreas", $lng->txt("save"));
79  }
80  }
81 
82 
86  function getItems()
87  {
88  $st_item =& $this->media_object->getMediaItem("Standard");
89  $max = ilMapArea::_getMaxNr($st_item->getId());
90  $areas = array();
91 
92  include_once("./Services/MediaObjects/classes/class.ilMapArea.php");
93  for ($i=1; $i<=$max; $i++)
94  {
95  $area = new ilMapArea($st_item->getId(), $i);
96  $areas[] = array("nr" => $i, "area" => $area, "title" => $area->getTitle());
97  }
98 
99  $this->setData($areas);
100  }
101 
106  protected function fillRow($a_set)
107  {
108  global $lng, $ilCtrl, $ilAccess;
109 
110  $area = $a_set["area"];
111  $i = $a_set["nr"];
112  $this->tpl->setVariable("CHECKBOX",
113  ilUtil::formCheckBox("", "area[]", $i));
114  $this->tpl->setVariable("VAR_NAME", "name_".$i);
115  $this->tpl->setVariable("VAL_NAME", $area->getTitle());
116  $this->tpl->setVariable("VAL_SHAPE", $area->getShape());
117 
118  $this->tpl->setVariable("VAL_HIGHL_MODE",
119  ilUtil::formSelect($area->getHighlightMode(), "hl_mode_".$i,
120  $this->highl_modes, false, true));
121  $this->tpl->setVariable("VAL_HIGHL_CLASS",
122  ilUtil::formSelect($area->getHighlightClass(), "hl_class_".$i,
123  $this->highl_classes, false, true));
124 
125  $this->tpl->setVariable("VAL_COORDS",
126  implode(explode(",", $area->getCoords()), ", "));
127  switch ($area->getLinkType())
128  {
129  case "ext":
130  $this->tpl->setVariable("VAL_LINK", $area->getHRef());
131  break;
132 
133  case "int":
134  $link_str = $this->parent_obj->getMapAreaLinkString($area->getTarget(),
135  $area->getType(), $area->getTargetFrame());
136  $this->tpl->setVariable("VAL_LINK", $link_str);
137  break;
138  }
139  }
140 
141 }
142 ?>