ILIAS  release_7 Revision v7.30-3-g800a261c036
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
15{
19 protected $user;
20
24 protected $page_layouts;
25
31 public function __construct($a_lm_type, $a_lang = "-")
32 {
33 global $DIC;
34
35 $this->lng = $DIC->language();
36 $this->user = $DIC->user();
37 $this->ctrl = $DIC->ctrl();
38 $this->lm_type = $a_lm_type;
39
40 $this->lang = ($a_lang == "")
41 ? "-"
42 : $a_lang;
44 $this->setCheckboxName("id");
45
46 $this->page_layouts = ilPageLayout::activeLayouts(
47 false,
49 );
50 }
51
58 public function getChildTitle($a_child)
59 {
60 if ($this->lang != "-") {
61 $lmobjtrans = new ilLMObjTranslation($a_child["node_id"], $this->lang);
62 return $lmobjtrans->getTitle();
63 }
64 return $a_child["title"];
65 }
66
73 public function getChildInfo($a_child)
74 {
75 if ($this->lang != "-") {
76 return $a_child["title"];
77 }
78 return "";
79 }
80
84 public function getMenuItems($a_node, $a_depth, $a_first_child = false, $a_next_sibling = null, $a_childs = null)
85 {
88
89 $cmds = array();
90
91 if ($a_childs == null) {
92 $a_childs = [];
93 }
94
95 if (!$a_first_child) { // drop area of node
96 if ($a_node["type"] == "pg" || ($a_node["type"] == "st" && count($a_childs) == 0 && $this->getMaxDepth() != 0)) {
97 if ($a_node["type"] == "st") {
98 $cmds[] = array("text" => $lng->txt("cont_insert_page"), "cmd" => "insertPage", "multi" => 10,
99 "as_subitem" => true);
100 if (count($this->page_layouts) > 0) {
101 $cmds[] = array("text" => $lng->txt("cont_insert_pagelayout"), "cmd" => "insertTemplate", "multi" => 10,
102 "as_subitem" => true);
103 }
104 if ($ilUser->clipboardHasObjectsOfType("pg")) {
105 $cmds[] = array("text" => $lng->txt("cont_insert_page_from_clip"),
106 "cmd" => "insertPageClip", "as_subitem" => true);
107 }
108 } else {
109 $cmds[] = array("text" => $lng->txt("cont_insert_page"), "cmd" => "insertPage", "multi" => 10);
110 if (count($this->page_layouts) > 0) {
111 $cmds[] = array("text" => $lng->txt("cont_insert_pagelayout"), "cmd" => "insertTemplate", "multi" => 10);
112 }
113 if ($ilUser->clipboardHasObjectsOfType("pg")) {
114 $cmds[] = array("text" => $lng->txt("cont_insert_page_from_clip"),
115 "cmd" => "insertPageClip");
116 }
117 }
118 }
119 if ($a_node["type"] != "pg" && $this->getMaxDepth() != 0) {
120 $cmds[] = array("text" => $lng->txt("cont_insert_subchapter"),
121 "cmd" => "insertSubchapter", "multi" => 10);
122 if ($ilUser->clipboardHasObjectsOfType("st")) {
123 $cmds[] = array("text" => $lng->txt("cont_insert_subchapter_from_clip"),
124 "cmd" => "insertSubchapterClip");
125 }
126 }
127
128 if (($a_next_sibling["type"] != "pg" && ($a_depth == 0 || $a_next_sibling["type"] == "st"))
129 || $a_node["type"] == "st") {
130 $cmds[] = array("text" => $lng->txt("cont_insert_chapter"),
131 "cmd" => "insertChapter", "multi" => 10);
132 if ($ilUser->clipboardHasObjectsOfType("st")) {
133 $cmds[] = array("text" => $lng->txt("cont_insert_chapter_from_clip"),
134 "cmd" => "insertChapterClip");
135 }
136 }
137 } else { // drop area before first child of node
138 if ($a_node["type"] == "st" && $this->getMaxDepth() != 0) {
139 $cmds[] = array("text" => $lng->txt("cont_insert_page"),
140 "cmd" => "insertPage", "multi" => 10);
141 if (count($this->page_layouts) > 0) {
142 $cmds[] = array("text" => $lng->txt("cont_insert_pagelayout"), "cmd" => "insertTemplate", "multi" => 10);
143 }
144 if ($ilUser->clipboardHasObjectsOfType("pg")) {
145 $cmds[] = array("text" => $lng->txt("cont_insert_page_from_clip"),
146 "cmd" => "insertPageClip");
147 }
148 }
149 if ($a_childs[0]["type"] != "pg") {
150 $cmds[] = array("text" => $lng->txt("cont_insert_chapter"),
151 "cmd" => "insertChapter", "multi" => 10);
152 if ($ilUser->clipboardHasObjectsOfType("st")) {
153 $cmds[] = array("text" => $lng->txt("cont_insert_chapter_from_clip"),
154 "cmd" => "insertChapterClip");
155 }
156 }
157 }
158
159 return $cmds;
160 }
161
165 public function nodeAllowsChilds($a_node)
166 {
167 if ($a_node["type"] == "pg") {
168 return false;
169 }
170 return true;
171 }
172
178 public function manageDragAndDrop($a_node, $a_depth, $a_first_child_drop_area = false, $a_next_sibling = null, $a_childs = null)
179 {
181
182 $this->makeDragContent($a_node["node_id"], "grp_" . $a_node["type"]);
183
184 if ($a_childs == null) {
185 $a_childs = [];
186 }
187
188 if (!$a_first_child_drop_area) {
189 if ($a_node["type"] == "pg" || ($a_node["type"] == "st" && count($a_childs) == 0 && $this->getMaxDepth() != 0)) {
190 if ($a_node["type"] == "st") {
191 $this->makeDragTarget(
192 $a_node["node_id"],
193 "grp_pg",
194 $a_first_child_drop_area,
195 true,
196 ""
197 );
198 } else {
199 $this->makeDragTarget(
200 $a_node["node_id"],
201 "grp_pg",
202 $a_first_child_drop_area,
203 false,
204 ""
205 );
206 }
207 }
208
209 if ($a_node["type"] != "pg" && $this->getMaxDepth() != 0) {
210 $this->makeDragTarget(
211 $a_node["node_id"],
212 "grp_st",
213 $a_first_child_drop_area,
214 true,
215 $lng->txt("cont_insert_as_subchapter")
216 );
217 }
218
219 if (($a_next_sibling["type"] != "pg" && ($a_depth == 0 || $a_next_sibling["type"] == "st"))
220 || $a_node["type"] == "st") {
221 $this->makeDragTarget(
222 $a_node["node_id"],
223 "grp_st",
224 $a_first_child_drop_area,
225 false,
226 $lng->txt("cont_insert_as_chapter")
227 );
228 }
229 } else {
230 if ($a_node["type"] == "st" && $this->getMaxDepth() != 0) {
231 $this->makeDragTarget(
232 $a_node["node_id"],
233 "grp_pg",
234 $a_first_child_drop_area,
235 true
236 );
237 }
238 if ($a_childs[0]["type"] != "pg") {
239 $this->makeDragTarget(
240 $a_node["node_id"],
241 "grp_st",
242 $a_first_child_drop_area,
243 true
244 );
245 }
246 }
247 }
248
255 public function getChildIcon($a_item)
256 {
257 $img = "icon_" . $a_item["type"] . ".svg";
258
259 if ($a_item["type"] == "pg") {
260 $lm_set = new ilSetting("lm");
261 $active = ilLMPage::_lookupActive(
262 $a_item["node_id"],
263 $this->lm_type,
264 $lm_set->get("time_scheduled_page_activation")
265 );
266
267 // is page scheduled?
268 $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
269 ilLMPage::_isScheduledActivation($a_item["node_id"], $this->lm_type))
270 ? "_sc"
271 : "";
272
273 $img = "icon_pg" . $img_sc . ".svg";
274
275 if (!$active) {
276 $img = "icon_pg_d" . $img_sc . ".svg";
277 } else {
279 $a_item["node_id"],
280 $this->lm_type
281 );
282 if ($contains_dis) {
283 $img = "icon_pg_del" . $img_sc . ".svg";
284 }
285 }
286 }
288 }
289
296 public function getChildIconAlt($a_item)
297 {
299
300
301 if ($a_item["type"] == "pg") {
302 $active = ilLMPage::_lookupActive($a_item["node_id"], $this->lm_type);
303
304 if (!$active) {
305 return $lng->txt("cont_page_deactivated");
306 } else {
308 $a_item["node_id"],
309 $this->lm_type
310 );
311 if ($contains_dis) {
312 return $lng->txt("cont_page_deactivated_elements");
313 }
314 }
315 }
316 return ilUtil::getImagePath("icon_" . $a_item["type"] . ".svg");
317 }
318
325 public function getChildCommands($a_item)
326 {
328 $ilCtrl = $this->ctrl;
329
330 $lm_class = "ilobjlearningmodulegui";
331
332 $commands = array();
333 switch ($a_item["type"]) {
334 case "pg":
335 $ilCtrl->setParameterByClass(
336 "illmpageobjectgui",
337 "obj_id",
338 $a_item["node_id"]
339 );
340 $commands[] = array("text" => $lng->txt("edit"),
341 "link" => $ilCtrl->getLinkTargetByClass(array($lm_class, "illmpageobjectgui"), "edit"));
342 break;
343
344 case "st":
345 $ilCtrl->setParameterByClass(
346 "ilstructureobjectgui",
347 "obj_id",
348 $a_item["node_id"]
349 );
350 $commands[] = array("text" => $lng->txt("edit"),
351 "link" => $ilCtrl->getLinkTargetByClass(array($lm_class, "ilstructureobjectgui"), "view"));
352 break;
353 }
354
355 return $commands;
356 }
357}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
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 activeLayouts($a_special_page=false, $a_module=null)
Get active layouts.
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 $DIC
Definition: goto.php:24
$img
Definition: imgupload.php:57
$ilUser
Definition: imgupload.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$lm_set