ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCIIMTriggerTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("Services/Table/classes/class.ilTable2GUI.php");
6 include_once("Services/MediaObjects/classes/class.ilImageMapTableGUI.php");
7 
17 {
18 
22  function __construct($a_parent_obj, $a_parent_cmd, $a_pc_media_object,
23  $a_parent_node_name)
24  {
25  global $ilCtrl, $lng, $ilAccess, $lng;
26 
27  $this->setId("cont_iim_tr");
28 
29  $this->parent_node_name = $a_parent_node_name;
30  $this->pc_media_object = $a_pc_media_object;
31  $this->mob = $this->pc_media_object->getMediaObject();
32 
33  $this->areas = array();
34  foreach ($this->pc_media_object->getStandardAliasItem()->getMapAreas() as $a)
35  {
36  $this->area[$a["Id"]] = $a;
37  }
38 
39  $this->ov_files = $this->mob->getFilesOfDirectory("overlays");
40  $this->ov_options = array("" => $lng->txt("please_select"));
41  foreach ($this->ov_files as $of)
42  {
43  $this->ov_options[$of] = $of;
44  }
45  $this->popups = $this->pc_media_object->getPopups();
46  $this->pop_options = array("" => $lng->txt("please_select"));
47  foreach ($this->popups as $k => $p)
48  {
49  $this->pop_options[$p["nr"]] = $p["title"];
50  }
51  parent::__construct($a_parent_obj, $a_parent_cmd, $a_pc_media_object->getMediaObject());
52  $this->setRowTemplate("tpl.iim_trigger_row.html", "Services/COPage");
53  }
54 
58  function initColumns()
59  {
60  $this->addColumn("", "", "1"); // checkbox
61  $this->addColumn($this->lng->txt("title"), "Title", "");
62  $this->addColumn($this->lng->txt("type"), "", "");
63  $this->addColumn($this->lng->txt("cont_coords"), "", "");
64  $this->addColumn($this->lng->txt("cont_overlay_image"), "", "");
65  $this->addColumn($this->lng->txt("cont_content_popup"), "", "");
66  $this->addColumn($this->lng->txt("actions"), "", "");
67  }
68 
72  function initActions()
73  {
74  global $lng;
75 
76  // action commands
77  $this->addMultiCommand("confirmDeleteTrigger", $lng->txt("delete"));
78 
79  $data = $this->getData();
80  if (count($data) > 0)
81  {
82  $this->addCommandButton("updateTrigger", $lng->txt("save"), "", "update_tr_button");
83  }
84  }
85 
86 
90  function getItems()
91  {
92  $triggers = $this->pc_media_object->getTriggers();
93 
94  $triggers = ilUtil::sortArray($triggers, "Title", "asc", false, true);
95  $this->setData($triggers);
96  }
97 
102  protected function fillRow($a_set)
103  {
104  global $lng, $ilCtrl, $ilAccess;
105 //var_dump($a_set);
106 
107  $i = $a_set["Nr"];
108 
109  // command: edit marker position
110  if ($a_set["Overlay"] != "")
111  {
112  $this->tpl->setCurrentBlock("cmd");
113  $this->tpl->setVariable("CMD_ID", "ov_".$i);
114  $this->tpl->setVariable("HREF_CMD", "#");
115  $this->tpl->setVariable("CMD_CLASS", "ov_cmd");
116  $this->tpl->setVariable("TXT_CMD", $lng->txt("cont_edit_overlay_position"));
117  $this->tpl->parseCurrentBlock();
118  }
119 
120  // command: edit marker position
121  if ($a_set["PopupNr"] != "")
122  {
123  $this->tpl->setCurrentBlock("cmd");
124  $this->tpl->setVariable("CMD_ID", "pop_".$i);
125  $this->tpl->setVariable("HREF_CMD", "#");
126  $this->tpl->setVariable("CMD_CLASS", "pop_cmd");
127  $this->tpl->setVariable("TXT_CMD", $lng->txt("cont_edit_popup_position"));
128  $this->tpl->parseCurrentBlock();
129  }
130 
131  if ($a_set["Type"] == ilPCInteractiveImage::AREA)
132  {
133  $this->tpl->setCurrentBlock("coords");
134  $this->tpl->setVariable("VAL_COORDS",
135  implode(explode(",", $this->area[$a_set["Nr"]]["Coords"]), ", "));
136  $this->tpl->parseCurrentBlock();
137 
138  $this->tpl->setVariable("TYPE",
139  $lng->txt("cont_".$this->area[$a_set["Nr"]]["Shape"]));
140  }
141  else
142  {
143  // command: edit marker position
144  $this->tpl->setCurrentBlock("cmd");
145  $this->tpl->setVariable("CMD_ID", "mark_".$i);
146  $this->tpl->setVariable("HREF_CMD", "#");
147  $this->tpl->setVariable("CMD_CLASS", "mark_cmd");
148  $this->tpl->setVariable("TXT_CMD", $lng->txt("cont_edit_marker_position"));
149  $this->tpl->parseCurrentBlock();
150 
151  // marker position
152  $this->tpl->setCurrentBlock("marker_pos");
153  $this->tpl->setVariable("VAR_MARK_POS", "markpos[".$i."]");
154  $this->tpl->setVariable("ID_MARK_POS", "markpos_".$i);
155  $this->tpl->setVariable("VAL_MARK_POS", $a_set["MarkerX"].",".$a_set["MarkerY"]);
156  $this->tpl->setVariable("TXT_MLEFT", $lng->txt("cont_left"));
157  $this->tpl->setVariable("TXT_MTOP", $lng->txt("cont_top"));
158  $this->tpl->parseCurrentBlock();
159 
160  $this->tpl->setVariable("TYPE", $lng->txt("cont_marker"));
161  }
162 
163  $this->tpl->setVariable("CHECKBOX",
164  ilUtil::formCheckBox("", "tr[]", $i));
165  $this->tpl->setVariable("VAR_NAME", "title[".$i."]");
166  $this->tpl->setVariable("VAL_NAME", $a_set["Title"]);
167 
168 
169  $this->tpl->setVariable("VAR_POS", "ovpos[".$i."]");
170  $this->tpl->setVariable("ID_OV_POS", "ovpos_".$i);
171  $this->tpl->setVariable("ID_POP_POS", "poppos_".$i);
172  $this->tpl->setVariable("VAR_POP_POS", "poppos[".$i."]");
173  $this->tpl->setVariable("VAR_POP_SIZE", "popsize[".$i."]");
174  $this->tpl->setVariable("VAL_POS", $a_set["OverlayX"].",".$a_set["OverlayY"]);
175  $this->tpl->setVariable("VAL_POP_POS", $a_set["PopupX"].",".$a_set["PopupY"]);
176  $this->tpl->setVariable("VAL_POP_SIZE", $a_set["PopupWidth"].",".$a_set["PopupHeight"]);
177  $this->tpl->setVariable("TXT_IMG", $lng->txt("image"));
178  $this->tpl->setVariable("TXT_TITLE", $lng->txt("title"));
179  $this->tpl->setVariable("TXT_LEFT", $lng->txt("cont_left"));
180  $this->tpl->setVariable("TXT_TOP", $lng->txt("cont_top"));
181  $this->tpl->setVariable("TXT_WIDTH", $lng->txt("cont_width"));
182  $this->tpl->setVariable("TXT_HEIGHT", $lng->txt("cont_height"));
183  $this->tpl->setVariable("OVERLAY_IMAGE",
184  ilUtil::formSelect($a_set["Overlay"], "ov[".$i."]", $this->ov_options, false, true));
185  $this->tpl->setVariable("CONTENT_POPUP",
186  ilUtil::formSelect($a_set["PopupNr"], "pop[".$i."]", $this->pop_options, false, true));
187  }
188 
189 }
190 ?>