ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
5include_once("./Services/Form/classes/class.ilHierarchyFormGUI.php");
6include_once("./Modules/LearningModule/classes/class.ilLMObjTranslation.php");
7
17{
23 function __construct($a_lm_type, $a_lang = "-")
24 {
25 $this->lm_type = $a_lm_type;
26
27 $this->lang = ($a_lang == "")
28 ? "-"
29 : $a_lang;
30 parent::__construct();
31 $this->setCheckboxName("id");
32 }
33
40 function getChildTitle($a_child)
41 {
42 if ($this->lang != "-")
43 {
44 $lmobjtrans = new ilLMObjTranslation($a_child["node_id"], $this->lang);
45 return $lmobjtrans->getTitle();
46 }
47 return $a_child["title"];
48 }
49
56 function getChildInfo($a_child)
57 {
58 if ($this->lang != "-")
59 {
60 return $a_child["title"];
61 }
62 return "";
63 }
64
68 function getMenuItems($a_node, $a_depth, $a_first_child = false, $a_next_sibling = null, $a_childs = null)
69 {
70 global $lng, $ilUser;
71
72 $cmds = array();
73
74 if (!$a_first_child) // drop area of node
75 {
76 if ($a_node["type"] == "pg" || ($a_node["type"] == "st" && count($a_childs) == 0 && $this->getMaxDepth() != 0))
77 {
78 if ($a_node["type"] == "st")
79 {
80 $cmds[] = array("text" => $lng->txt("cont_insert_page"), "cmd" => "insertPage", "multi" => 10,
81 "as_subitem" => true);
82 if ($ilUser->clipboardHasObjectsOfType("pg"))
83 {
84 $cmds[] = array("text" => $lng->txt("cont_insert_page_from_clip"),
85 "cmd" => "insertPageClip", "as_subitem" => true);
86 }
87 }
88 else
89 {
90 $cmds[] = array("text" => $lng->txt("cont_insert_page"), "cmd" => "insertPage", "multi" => 10);
91 if ($ilUser->clipboardHasObjectsOfType("pg"))
92 {
93 $cmds[] = array("text" => $lng->txt("cont_insert_page_from_clip"),
94 "cmd" => "insertPageClip");
95 }
96 }
97 }
98 if ($a_node["type"] != "pg" && $this->getMaxDepth() != 0)
99 {
100 $cmds[] = array("text" => $lng->txt("cont_insert_subchapter"),
101 "cmd" => "insertSubchapter", "multi" => 10);
102 if ($ilUser->clipboardHasObjectsOfType("st"))
103 {
104 $cmds[] = array("text" => $lng->txt("cont_insert_subchapter_from_clip"),
105 "cmd" => "insertSubchapterClip");
106 }
107 }
108
109 if (($a_next_sibling["type"] != "pg" && ($a_depth == 0 || $a_next_sibling["type"] == "st"))
110 || $a_node["type"] == "st")
111 {
112 $cmds[] = array("text" => $lng->txt("cont_insert_chapter"),
113 "cmd" => "insertChapter", "multi" => 10);
114 if ($ilUser->clipboardHasObjectsOfType("st"))
115 {
116 $cmds[] = array("text" => $lng->txt("cont_insert_chapter_from_clip"),
117 "cmd" => "insertChapterClip");
118 }
119 }
120 }
121 else // drop area before first child of node
122 {
123 if ($a_node["type"] == "st" && $this->getMaxDepth() != 0)
124 {
125 $cmds[] = array("text" => $lng->txt("cont_insert_page"),
126 "cmd" => "insertPage", "multi" => 10);
127 if ($ilUser->clipboardHasObjectsOfType("pg"))
128 {
129 $cmds[] = array("text" => $lng->txt("cont_insert_page_from_clip"),
130 "cmd" => "insertPageClip");
131 }
132 }
133 if ($a_childs[0]["type"] != "pg")
134 {
135 $cmds[] = array("text" => $lng->txt("cont_insert_chapter"),
136 "cmd" => "insertChapter", "multi" => 10);
137 if ($ilUser->clipboardHasObjectsOfType("st"))
138 {
139 $cmds[] = array("text" => $lng->txt("cont_insert_chapter_from_clip"),
140 "cmd" => "insertChapterClip");
141 }
142 }
143 }
144
145 return $cmds;
146 }
147
151 function nodeAllowsChilds($a_node)
152 {
153 if ($a_node["type"] == "pg")
154 {
155 return false;
156 }
157 return true;
158 }
159
165 function manageDragAndDrop($a_node, $a_depth, $a_first_child_drop_area = false, $a_next_sibling = null, $a_childs = null)
166 {
167 global $lng;
168
169 $this->makeDragContent($a_node["node_id"], "grp_".$a_node["type"]);
170
171 if (!$a_first_child_drop_area)
172 {
173 if ($a_node["type"] == "pg" || ($a_node["type"] == "st" && count($a_childs) == 0 && $this->getMaxDepth() != 0))
174 {
175 if ($a_node["type"] == "st")
176 {
177 $this->makeDragTarget($a_node["node_id"], "grp_pg", $a_first_child_drop_area,
178 true, "");
179 }
180 else
181 {
182 $this->makeDragTarget($a_node["node_id"], "grp_pg", $a_first_child_drop_area,
183 false, "");
184 }
185 }
186
187 if ($a_node["type"] != "pg" && $this->getMaxDepth() != 0)
188 {
189 $this->makeDragTarget($a_node["node_id"], "grp_st", $a_first_child_drop_area,
190 true, $lng->txt("cont_insert_as_subchapter"));
191 }
192
193 if (($a_next_sibling["type"] != "pg" && ($a_depth == 0 || $a_next_sibling["type"] == "st"))
194 || $a_node["type"] == "st")
195 {
196 $this->makeDragTarget($a_node["node_id"], "grp_st", $a_first_child_drop_area,
197 false, $lng->txt("cont_insert_as_chapter"));
198 }
199 }
200 else
201 {
202 if ($a_node["type"] == "st" && $this->getMaxDepth() != 0)
203 {
204 $this->makeDragTarget($a_node["node_id"], "grp_pg", $a_first_child_drop_area,
205 true);
206 }
207 if ($a_childs[0]["type"] != "pg")
208 {
209 $this->makeDragTarget($a_node["node_id"], "grp_st", $a_first_child_drop_area,
210 true);
211 }
212 }
213 }
214
221 function getChildIcon($a_item)
222 {
223 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
224
225 $img = "icon_".$a_item["type"].".svg";
226
227 if ($a_item["type"] == "pg")
228 {
229 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
230 $lm_set = new ilSetting("lm");
231 $active = ilLMPage::_lookupActive($a_item["node_id"], $this->lm_type,
232 $lm_set->get("time_scheduled_page_activation"));
233
234 // is page scheduled?
235 $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
236 ilLMPage::_isScheduledActivation($a_item["node_id"], $this->lm_type))
237 ? "_sc"
238 : "";
239
240 $img = "icon_pg".$img_sc.".svg";
241
242 if (!$active)
243 {
244 $img = "icon_pg_d".$img_sc.".svg";
245 }
246 else
247 {
248 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
249 $contains_dis = ilLMPage::_lookupContainsDeactivatedElements($a_item["node_id"],
250 $this->lm_type);
251 if ($contains_dis)
252 {
253 $img = "icon_pg_del".$img_sc.".svg";
254 }
255 }
256 }
258 }
259
266 function getChildIconAlt($a_item)
267 {
268 global $lng;
269
270 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
271
272 if ($a_item["type"] == "pg")
273 {
274 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
275 $active = ilLMPage::_lookupActive($a_item["node_id"], $this->lm_type);
276
277 if (!$active)
278 {
279 return $lng->txt("cont_page_deactivated");
280 }
281 else
282 {
283 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
284 $contains_dis = ilLMPage::_lookupContainsDeactivatedElements($a_item["node_id"],
285 $this->lm_type);
286 if ($contains_dis)
287 {
288 return $lng->txt("cont_page_deactivated_elements");
289 }
290 }
291 }
292 return ilUtil::getImagePath("icon_".$a_item["type"].".svg");
293 }
294
301 function getChildCommands($a_item)
302 {
303 global $lng, $ilCtrl;
304
305 $lm_class = ($this->lm_type == "lm")
306 ? "ilobjlearningmodulegui"
307 : "ilobjdlbookgui";
308
309 $commands = array();
310 switch ($a_item["type"])
311 {
312 case "pg":
313 $ilCtrl->setParameterByClass("illmpageobjectgui", "obj_id",
314 $a_item["node_id"]);
315 $commands[] = array("text" => $lng->txt("edit"),
316 "link" => $ilCtrl->getLinkTargetByClass(array($lm_class, "illmpageobjectgui"), "edit"));
317 break;
318
319 case "st":
320 $ilCtrl->setParameterByClass("ilstructureobjectgui", "obj_id",
321 $a_item["node_id"]);
322 $commands[] = array("text" => $lng->txt("edit"),
323 "link" => $ilCtrl->getLinkTargetByClass(array($lm_class, "ilstructureobjectgui"), "view"));
324 break;
325 }
326
327 return $commands;
328 }
329
330}
This class represents a hierarchical form.
getChildIconAlt($a_item)
Get icon alt text.
getMenuItems($a_node, $a_depth, $a_first_child=false, $a_next_sibling=null, $a_childs=null)
Get menu items.
manageDragAndDrop($a_node, $a_depth, $a_first_child_drop_area=false, $a_next_sibling=null, $a_childs=null)
Makes nodes drag and drop content and targets.
__construct($a_lm_type, $a_lang="-")
Constructor.
nodeAllowsChilds($a_node)
Which nodes allow child nodes?
getChildIcon($a_item)
Get icon path for an item.
getChildCommands($a_item)
Get item commands.
This class represents a hierarchical form.
getMaxDepth()
Get Maximum Depth.
setCheckboxName($a_checkboxname)
Set Checkbox Name.
makeDragContent($a_id, $a_group)
Makes a node a drag content.
makeDragTarget($a_id, $a_group, $a_first_child_drop_area=false, $a_as_subitem=false, $a_diss_text="")
Makes a nodes (following droparea) a drag target.
Translation information on lm object.
static _lookupActive($a_id, $a_parent_type, $a_check_scheduled_activation=false, $a_lang="-")
lookup activation status
static _lookupContainsDeactivatedElements($a_id, $a_parent_type, $a_lang="-")
lookup whether page contains deactivated elements
static _isScheduledActivation($a_id, $a_parent_type, $a_lang="-")
Check whether page is activated by time schedule.
ILIAS Setting Class.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$lm_set
global $ilUser
Definition: imgupload.php:15