ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilChapterHierarchyFormGUI.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/Form/classes/class.ilHierarchyFormGUI.php");
6 
16 {
22  function __construct($a_lm_type)
23  {
24  $this->lm_type = $a_lm_type;
25 
27  $this->setCheckboxName("id");
28  }
29 
33  function getMenuItems($a_node, $a_depth, $a_first_child = false, $a_next_sibling = null, $a_childs = null)
34  {
35  global $lng, $ilUser;
36 
37  $cmds = array();
38 
39  if (!$a_first_child) // drop area of node
40  {
41  if ($a_node["type"] == "pg" || ($a_node["type"] == "st" && count($a_childs) == 0 && $this->getMaxDepth() != 0))
42  {
43  if ($a_node["type"] == "st")
44  {
45  $cmds[] = array("text" => $lng->txt("cont_insert_page"), "cmd" => "insertPage", "multi" => 10,
46  "as_subitem" => true);
47  if ($ilUser->clipboardHasObjectsOfType("pg"))
48  {
49  $cmds[] = array("text" => $lng->txt("cont_insert_page_from_clip"),
50  "cmd" => "insertPageClip", "as_subitem" => true);
51  }
52  }
53  else
54  {
55  $cmds[] = array("text" => $lng->txt("cont_insert_page"), "cmd" => "insertPage", "multi" => 10);
56  if ($ilUser->clipboardHasObjectsOfType("pg"))
57  {
58  $cmds[] = array("text" => $lng->txt("cont_insert_page_from_clip"),
59  "cmd" => "insertPageClip");
60  }
61  }
62  }
63  if ($a_node["type"] != "pg" && $this->getMaxDepth() != 0)
64  {
65  $cmds[] = array("text" => $lng->txt("cont_insert_subchapter"),
66  "cmd" => "insertSubchapter", "multi" => 10);
67  if ($ilUser->clipboardHasObjectsOfType("st"))
68  {
69  $cmds[] = array("text" => $lng->txt("cont_insert_subchapter_from_clip"),
70  "cmd" => "insertSubchapterClip");
71  }
72  }
73 
74  if (($a_next_sibling["type"] != "pg" && ($a_depth == 0 || $a_next_sibling["type"] == "st"))
75  || $a_node["type"] == "st")
76  {
77  $cmds[] = array("text" => $lng->txt("cont_insert_chapter"),
78  "cmd" => "insertChapter", "multi" => 10);
79  if ($ilUser->clipboardHasObjectsOfType("st"))
80  {
81  $cmds[] = array("text" => $lng->txt("cont_insert_chapter_from_clip"),
82  "cmd" => "insertChapterClip");
83  }
84  }
85  }
86  else // drop area before first child of node
87  {
88  if ($a_node["type"] == "st" && $this->getMaxDepth() != 0)
89  {
90  $cmds[] = array("text" => $lng->txt("cont_insert_page"),
91  "cmd" => "insertPage", "multi" => 10);
92  if ($ilUser->clipboardHasObjectsOfType("pg"))
93  {
94  $cmds[] = array("text" => $lng->txt("cont_insert_page_from_clip"),
95  "cmd" => "insertPageClip");
96  }
97  }
98  if ($a_childs[0]["type"] != "pg")
99  {
100  $cmds[] = array("text" => $lng->txt("cont_insert_chapter"),
101  "cmd" => "insertChapter", "multi" => 10);
102  if ($ilUser->clipboardHasObjectsOfType("st"))
103  {
104  $cmds[] = array("text" => $lng->txt("cont_insert_chapter_from_clip"),
105  "cmd" => "insertChapterClip");
106  }
107  }
108  }
109 
110  return $cmds;
111  }
112 
116  function nodeAllowsChilds($a_node)
117  {
118  if ($a_node["type"] == "pg")
119  {
120  return false;
121  }
122  return true;
123  }
124 
130  function manageDragAndDrop($a_node, $a_depth, $a_first_child_drop_area = false, $a_next_sibling = null, $a_childs = null)
131  {
132  global $lng;
133 
134  $this->makeDragContent($a_node["node_id"], "grp_".$a_node["type"]);
135 
136  if (!$a_first_child_drop_area)
137  {
138  if ($a_node["type"] == "pg" || ($a_node["type"] == "st" && count($a_childs) == 0 && $this->getMaxDepth() != 0))
139  {
140  if ($a_node["type"] == "st")
141  {
142  $this->makeDragTarget($a_node["node_id"], "grp_pg", $a_first_child_drop_area,
143  true, "");
144  }
145  else
146  {
147  $this->makeDragTarget($a_node["node_id"], "grp_pg", $a_first_child_drop_area,
148  false, "");
149  }
150  }
151 
152  if ($a_node["type"] != "pg" && $this->getMaxDepth() != 0)
153  {
154  $this->makeDragTarget($a_node["node_id"], "grp_st", $a_first_child_drop_area,
155  true, $lng->txt("cont_insert_as_subchapter"));
156  }
157 
158  if (($a_next_sibling["type"] != "pg" && ($a_depth == 0 || $a_next_sibling["type"] == "st"))
159  || $a_node["type"] == "st")
160  {
161  $this->makeDragTarget($a_node["node_id"], "grp_st", $a_first_child_drop_area,
162  false, $lng->txt("cont_insert_as_chapter"));
163  }
164  }
165  else
166  {
167  if ($a_node["type"] == "st" && $this->getMaxDepth() != 0)
168  {
169  $this->makeDragTarget($a_node["node_id"], "grp_pg", $a_first_child_drop_area,
170  true);
171  }
172  if ($a_childs[0]["type"] != "pg")
173  {
174  $this->makeDragTarget($a_node["node_id"], "grp_st", $a_first_child_drop_area,
175  true);
176  }
177  }
178  }
179 
186  function getChildIcon($a_item)
187  {
188  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
189 
190  $img = "icon_".$a_item["type"].".png";
191 
192  if ($a_item["type"] == "pg")
193  {
194  include_once("./Services/COPage/classes/class.ilPageObject.php");
195  $lm_set = new ilSetting("lm");
196  $active = ilPageObject::_lookupActive($a_item["node_id"], $this->lm_type,
197  $lm_set->get("time_scheduled_page_activation"));
198 
199  // is page scheduled?
200  $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
201  ilPageObject::_isScheduledActivation($a_item["node_id"], $this->lm_type))
202  ? "_sc"
203  : "";
204 
205  $img = "icon_pg".$img_sc.".png";
206 
207  if (!$active)
208  {
209  $img = "icon_pg_d".$img_sc.".png";
210  }
211  else
212  {
213  include_once("./Services/COPage/classes/class.ilPageObject.php");
214  $contains_dis = ilPageObject::_lookupContainsDeactivatedElements($a_item["node_id"],
215  $this->lm_type);
216  if ($contains_dis)
217  {
218  $img = "icon_pg_del".$img_sc.".png";
219  }
220  }
221  }
222  return ilUtil::getImagePath($img);
223  }
224 
231  function getChildIconAlt($a_item)
232  {
233  global $lng;
234 
235  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
236 
237  if ($a_item["type"] == "pg")
238  {
239  include_once("./Services/COPage/classes/class.ilPageObject.php");
240  $active = ilPageObject::_lookupActive($a_item["node_id"], $this->lm_type);
241 
242  if (!$active)
243  {
244  return $lng->txt("cont_page_deactivated");
245  }
246  else
247  {
248  include_once("./Services/COPage/classes/class.ilPageObject.php");
249  $contains_dis = ilPageObject::_lookupContainsDeactivatedElements($a_item["node_id"],
250  $this->lm_type);
251  if ($contains_dis)
252  {
253  return $lng->txt("cont_page_deactivated_elements");
254  }
255  }
256  }
257  return ilUtil::getImagePath("icon_".$a_item["type"].".png");
258  }
259 
266  function getChildCommands($a_item)
267  {
268  global $lng, $ilCtrl;
269 
270  $lm_class = ($this->lm_type == "lm")
271  ? "ilobjlearningmodulegui"
272  : "ilobjdlbookgui";
273 
274  $commands = array();
275  switch ($a_item["type"])
276  {
277  case "pg":
278  $ilCtrl->setParameterByClass("illmpageobjectgui", "obj_id",
279  $a_item["node_id"]);
280  $commands[] = array("text" => $lng->txt("edit"),
281  "link" => $ilCtrl->getLinkTargetByClass(array($lm_class, "illmpageobjectgui"), "edit"));
282  break;
283 
284  case "st":
285  $ilCtrl->setParameterByClass("ilstructureobjectgui", "obj_id",
286  $a_item["node_id"]);
287  $commands[] = array("text" => $lng->txt("edit"),
288  "link" => $ilCtrl->getLinkTargetByClass(array($lm_class, "ilstructureobjectgui"), "view"));
289  break;
290  }
291 
292  return $commands;
293  }
294 
295 }