ILIAS  Release_4_1_x_branch Revision 61804
 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  $this->addColumn("", "", "1"); // checkbox
29  $this->addColumn($this->lng->txt("cont_name"), "title", "");
30  $this->addColumn($this->lng->txt("cont_shape"), "", "");
31  $this->addColumn($this->lng->txt("cont_coords"), "", "");
32  $this->addColumn($this->lng->txt("cont_link"), "", "");
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->addMultiCommand("deleteAreas", $lng->txt("delete"));
40  $this->addMultiCommand("editLink", $lng->txt("cont_set_link"));
41  $this->addMultiCommand("editShapeWholePicture", $lng->txt("cont_edit_shape_whole_picture"));
42  $this->addMultiCommand("editShapeRectangle", $lng->txt("cont_edit_shape_rectangle"));
43  $this->addMultiCommand("editShapeCircle", $lng->txt("cont_edit_shape_circle"));
44  $this->addMultiCommand("editShapePolygon", $lng->txt("cont_edit_shape_polygon"));
45 
46  $data = $this->getData();
47  if (count($data) > 0)
48  {
49  $this->addCommandButton("updateAreas", $this->lng->txt("cont_update_names"));
50  }
51 
52  $this->addCommandButton("linkWholePicture", $this->lng->txt("cont_link_whole_picture"));
53  $this->addCommandButton("addRectangle", $this->lng->txt("cont_add_rectangle"));
54  $this->addCommandButton("addCircle", $this->lng->txt("cont_add_circle"));
55  $this->addCommandButton("addPolygon", $this->lng->txt("cont_add_polygon"));
56  $this->setDefaultOrderField("title");
57  $this->setDefaultOrderDirection("asc");
58  $this->setEnableTitle(false);
59  }
60 
64  function getItems()
65  {
66  $st_item =& $this->media_object->getMediaItem("Standard");
67  $max = ilMapArea::_getMaxNr($st_item->getId());
68  $areas = array();
69 
70  include_once("./Services/MediaObjects/classes/class.ilMapArea.php");
71  for ($i=1; $i<=$max; $i++)
72  {
73  $area = new ilMapArea($st_item->getId(), $i);
74  $areas[] = array("nr" => $i, "area" => $area, "title" => $area->getTitle());
75  }
76 
77  $this->setData($areas);
78  }
79 
84  protected function fillRow($a_set)
85  {
86  global $lng, $ilCtrl, $ilAccess;
87 
88  $area = $a_set["area"];
89  $i = $a_set["nr"];
90  $this->tpl->setVariable("CHECKBOX",
91  ilUtil::formCheckBox("", "area[]", $i));
92  $this->tpl->setVariable("VAR_NAME", "name_".$i);
93  $this->tpl->setVariable("VAL_NAME", $area->getTitle());
94  $this->tpl->setVariable("VAL_SHAPE", $area->getShape());
95  $this->tpl->setVariable("VAL_COORDS",
96  implode(explode(",", $area->getCoords()), ", "));
97  switch ($area->getLinkType())
98  {
99  case "ext":
100  $this->tpl->setVariable("VAL_LINK", $area->getHRef());
101  break;
102 
103  case "int":
104  $link_str = $this->parent_obj->getMapAreaLinkString($area->getTarget(),
105  $area->getType(), $area->getTargetFrame());
106  $this->tpl->setVariable("VAL_LINK", $link_str);
107  break;
108  }
109  }
110 
111 }
112 ?>