ILIAS  Release_4_2_x_branch Revision 61807
 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 
29  $this->initColumns();
30  $this->setEnableHeader(true);
31  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
32  $this->setRowTemplate("tpl.image_map_table_row.html", "Services/MediaObjects");
33  $this->getItems();
34 
35  // action commands
36  $this->initActions();
37 
38  $this->setDefaultOrderField("title");
39  $this->setDefaultOrderDirection("asc");
40  $this->setEnableTitle(false);
41  }
42 
46  function initColumns()
47  {
48  $this->addColumn("", "", "1"); // checkbox
49  $this->addColumn($this->lng->txt("cont_name"), "title", "");
50  $this->addColumn($this->lng->txt("cont_shape"), "", "");
51  $this->addColumn($this->lng->txt("cont_coords"), "", "");
52  $this->addColumn($this->lng->txt("cont_link"), "", "");
53  }
54 
58  function initActions()
59  {
60  global $lng;
61 
62  // action commands
63  $this->addMultiCommand("deleteAreas", $lng->txt("delete"));
64  $this->addMultiCommand("editLink", $lng->txt("cont_set_link"));
65  $this->addMultiCommand("editShapeWholePicture", $lng->txt("cont_edit_shape_whole_picture"));
66  $this->addMultiCommand("editShapeRectangle", $lng->txt("cont_edit_shape_rectangle"));
67  $this->addMultiCommand("editShapeCircle", $lng->txt("cont_edit_shape_circle"));
68  $this->addMultiCommand("editShapePolygon", $lng->txt("cont_edit_shape_polygon"));
69 
70  $data = $this->getData();
71  if (count($data) > 0)
72  {
73  $this->addCommandButton("updateAreas", $lng->txt("cont_update_names"));
74  }
75  }
76 
77 
81  function getItems()
82  {
83  $st_item =& $this->media_object->getMediaItem("Standard");
84  $max = ilMapArea::_getMaxNr($st_item->getId());
85  $areas = array();
86 
87  include_once("./Services/MediaObjects/classes/class.ilMapArea.php");
88  for ($i=1; $i<=$max; $i++)
89  {
90  $area = new ilMapArea($st_item->getId(), $i);
91  $areas[] = array("nr" => $i, "area" => $area, "title" => $area->getTitle());
92  }
93 
94  $this->setData($areas);
95  }
96 
101  protected function fillRow($a_set)
102  {
103  global $lng, $ilCtrl, $ilAccess;
104 
105  $area = $a_set["area"];
106  $i = $a_set["nr"];
107  $this->tpl->setVariable("CHECKBOX",
108  ilUtil::formCheckBox("", "area[]", $i));
109  $this->tpl->setVariable("VAR_NAME", "name_".$i);
110  $this->tpl->setVariable("VAL_NAME", $area->getTitle());
111  $this->tpl->setVariable("VAL_SHAPE", $area->getShape());
112  $this->tpl->setVariable("VAL_COORDS",
113  implode(explode(",", $area->getCoords()), ", "));
114  switch ($area->getLinkType())
115  {
116  case "ext":
117  $this->tpl->setVariable("VAL_LINK", $area->getHRef());
118  break;
119 
120  case "int":
121  $link_str = $this->parent_obj->getMapAreaLinkString($area->getTarget(),
122  $area->getType(), $area->getTargetFrame());
123  $this->tpl->setVariable("VAL_LINK", $link_str);
124  break;
125  }
126  }
127 
128 }
129 ?>