ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilImageMapTableGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once("Services/Table/classes/class.ilTable2GUI.php");
25 
35 {
36 
40  function __construct($a_parent_obj, $a_parent_cmd, $a_media_object)
41  {
42  global $ilCtrl, $lng, $ilAccess, $lng;
43 
44  parent::__construct($a_parent_obj, $a_parent_cmd);
45  $this->media_object = $a_media_object;
46 
47  $this->addColumn("", "", "1"); // checkbox
48  $this->addColumn($this->lng->txt("cont_name"), "", "");
49  $this->addColumn($this->lng->txt("cont_shape"), "", "");
50  $this->addColumn($this->lng->txt("cont_coords"), "", "");
51  $this->addColumn($this->lng->txt("cont_link"), "", "");
52  $this->setEnableHeader(true);
53  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
54  $this->setRowTemplate("tpl.image_map_table_row.html", "Services/MediaObjects");
55  $this->getItems();
56 
57  // action commands
58  $this->addMultiCommand("deleteAreas", $lng->txt("delete"));
59  $this->addMultiCommand("editLink", $lng->txt("cont_set_link"));
60  $this->addMultiCommand("editShapeRectangle", $lng->txt("cont_edit_shape_rectangle"));
61  $this->addMultiCommand("editShapeCircle", $lng->txt("cont_edit_shape_circle"));
62  $this->addMultiCommand("editShapePolygon", $lng->txt("cont_edit_shape_polygon"));
63 
64  $data = $this->getData();
65  if (count($data) > 0)
66  {
67  $this->addCommandButton("updateAreas", $this->lng->txt("cont_update_names"));
68  }
69  $this->addCommandButton("addRectangle", $this->lng->txt("cont_add_rectangle"));
70  $this->addCommandButton("addCircle", $this->lng->txt("cont_add_circle"));
71  $this->addCommandButton("addPolygon", $this->lng->txt("cont_add_polygon"));
72 
73  $this->setEnableTitle(false);
74  }
75 
79  function getItems()
80  {
81  $st_item =& $this->media_object->getMediaItem("Standard");
82  $max = ilMapArea::_getMaxNr($st_item->getId());
83  $areas = array();
84 
85  include_once("./Services/MediaObjects/classes/class.ilMapArea.php");
86  for ($i=1; $i<=$max; $i++)
87  {
88  $area = new ilMapArea($st_item->getId(), $i);
89  $areas[] = array("nr" => $i, "area" => $area);
90  }
91 
92  $this->setData($areas);
93  }
94 
99  protected function fillRow($a_set)
100  {
101  global $lng, $ilCtrl, $ilAccess;
102 
103  $area = $a_set["area"];
104  $i = $a_set["nr"];
105  $this->tpl->setVariable("CHECKBOX",
106  ilUtil::formCheckBox("", "area[]", $i));
107  $this->tpl->setVariable("VAR_NAME", "name_".$i);
108  $this->tpl->setVariable("VAL_NAME", $area->getTitle());
109  $this->tpl->setVariable("VAL_SHAPE", $area->getShape());
110  $this->tpl->setVariable("VAL_COORDS",
111  implode(explode(",", $area->getCoords()), ", "));
112  switch ($area->getLinkType())
113  {
114  case "ext":
115  $this->tpl->setVariable("VAL_LINK", $area->getHRef());
116  break;
117 
118  case "int":
119  $link_str = $this->parent_obj->getMapAreaLinkString($area->getTarget(),
120  $area->getType(), $area->getTargetFrame());
121  $this->tpl->setVariable("VAL_LINK", $link_str);
122  break;
123  }
124  }
125 
126 }
127 ?>