ILIAS  Release_4_0_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  +-----------------------------------------------------------------------------+
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"), "title", "");
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  $this->setDefaultOrderField("title");
73  $this->setDefaultOrderDirection("asc");
74  $this->setEnableTitle(false);
75  }
76 
80  function getItems()
81  {
82  $st_item =& $this->media_object->getMediaItem("Standard");
83  $max = ilMapArea::_getMaxNr($st_item->getId());
84  $areas = array();
85 
86  include_once("./Services/MediaObjects/classes/class.ilMapArea.php");
87  for ($i=1; $i<=$max; $i++)
88  {
89  $area = new ilMapArea($st_item->getId(), $i);
90  $areas[] = array("nr" => $i, "area" => $area, "title" => $area->getTitle());
91  }
92 
93  $this->setData($areas);
94  }
95 
100  protected function fillRow($a_set)
101  {
102  global $lng, $ilCtrl, $ilAccess;
103 
104  $area = $a_set["area"];
105  $i = $a_set["nr"];
106  $this->tpl->setVariable("CHECKBOX",
107  ilUtil::formCheckBox("", "area[]", $i));
108  $this->tpl->setVariable("VAR_NAME", "name_".$i);
109  $this->tpl->setVariable("VAL_NAME", $area->getTitle());
110  $this->tpl->setVariable("VAL_SHAPE", $area->getShape());
111  $this->tpl->setVariable("VAL_COORDS",
112  implode(explode(",", $area->getCoords()), ", "));
113  switch ($area->getLinkType())
114  {
115  case "ext":
116  $this->tpl->setVariable("VAL_LINK", $area->getHRef());
117  break;
118 
119  case "int":
120  $link_str = $this->parent_obj->getMapAreaLinkString($area->getTarget(),
121  $area->getType(), $area->getTargetFrame());
122  $this->tpl->setVariable("VAL_LINK", $link_str);
123  break;
124  }
125  }
126 
127 }
128 ?>