ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 include_once("./Modules/LearningModule/classes/class.ilLMObjTranslation.php");
7 
17 {
21  protected $user;
22 
28  public function __construct($a_lm_type, $a_lang = "-")
29  {
30  global $DIC;
31 
32  $this->lng = $DIC->language();
33  $this->user = $DIC->user();
34  $this->ctrl = $DIC->ctrl();
35  $this->lm_type = $a_lm_type;
36 
37  $this->lang = ($a_lang == "")
38  ? "-"
39  : $a_lang;
40  parent::__construct();
41  $this->setCheckboxName("id");
42  }
43 
50  public function getChildTitle($a_child)
51  {
52  if ($this->lang != "-") {
53  $lmobjtrans = new ilLMObjTranslation($a_child["node_id"], $this->lang);
54  return $lmobjtrans->getTitle();
55  }
56  return $a_child["title"];
57  }
58 
65  public function getChildInfo($a_child)
66  {
67  if ($this->lang != "-") {
68  return $a_child["title"];
69  }
70  return "";
71  }
72 
76  public function getMenuItems($a_node, $a_depth, $a_first_child = false, $a_next_sibling = null, $a_childs = null)
77  {
78  $lng = $this->lng;
80 
81  $cmds = array();
82 
83  if ($a_childs == null) {
84  $a_childs = [];
85  }
86 
87  if (!$a_first_child) { // drop area of node
88  if ($a_node["type"] == "pg" || ($a_node["type"] == "st" && count($a_childs) == 0 && $this->getMaxDepth() != 0)) {
89  if ($a_node["type"] == "st") {
90  $cmds[] = array("text" => $lng->txt("cont_insert_page"), "cmd" => "insertPage", "multi" => 10,
91  "as_subitem" => true);
92  if ($ilUser->clipboardHasObjectsOfType("pg")) {
93  $cmds[] = array("text" => $lng->txt("cont_insert_page_from_clip"),
94  "cmd" => "insertPageClip", "as_subitem" => true);
95  }
96  } else {
97  $cmds[] = array("text" => $lng->txt("cont_insert_page"), "cmd" => "insertPage", "multi" => 10);
98  if ($ilUser->clipboardHasObjectsOfType("pg")) {
99  $cmds[] = array("text" => $lng->txt("cont_insert_page_from_clip"),
100  "cmd" => "insertPageClip");
101  }
102  }
103  }
104  if ($a_node["type"] != "pg" && $this->getMaxDepth() != 0) {
105  $cmds[] = array("text" => $lng->txt("cont_insert_subchapter"),
106  "cmd" => "insertSubchapter", "multi" => 10);
107  if ($ilUser->clipboardHasObjectsOfType("st")) {
108  $cmds[] = array("text" => $lng->txt("cont_insert_subchapter_from_clip"),
109  "cmd" => "insertSubchapterClip");
110  }
111  }
112 
113  if (($a_next_sibling["type"] != "pg" && ($a_depth == 0 || $a_next_sibling["type"] == "st"))
114  || $a_node["type"] == "st") {
115  $cmds[] = array("text" => $lng->txt("cont_insert_chapter"),
116  "cmd" => "insertChapter", "multi" => 10);
117  if ($ilUser->clipboardHasObjectsOfType("st")) {
118  $cmds[] = array("text" => $lng->txt("cont_insert_chapter_from_clip"),
119  "cmd" => "insertChapterClip");
120  }
121  }
122  } else { // drop area before first child of node
123  if ($a_node["type"] == "st" && $this->getMaxDepth() != 0) {
124  $cmds[] = array("text" => $lng->txt("cont_insert_page"),
125  "cmd" => "insertPage", "multi" => 10);
126  if ($ilUser->clipboardHasObjectsOfType("pg")) {
127  $cmds[] = array("text" => $lng->txt("cont_insert_page_from_clip"),
128  "cmd" => "insertPageClip");
129  }
130  }
131  if ($a_childs[0]["type"] != "pg") {
132  $cmds[] = array("text" => $lng->txt("cont_insert_chapter"),
133  "cmd" => "insertChapter", "multi" => 10);
134  if ($ilUser->clipboardHasObjectsOfType("st")) {
135  $cmds[] = array("text" => $lng->txt("cont_insert_chapter_from_clip"),
136  "cmd" => "insertChapterClip");
137  }
138  }
139  }
140 
141  return $cmds;
142  }
143 
147  public function nodeAllowsChilds($a_node)
148  {
149  if ($a_node["type"] == "pg") {
150  return false;
151  }
152  return true;
153  }
154 
160  public function manageDragAndDrop($a_node, $a_depth, $a_first_child_drop_area = false, $a_next_sibling = null, $a_childs = null)
161  {
162  $lng = $this->lng;
163 
164  $this->makeDragContent($a_node["node_id"], "grp_" . $a_node["type"]);
165 
166  if ($a_childs == null) {
167  $a_childs = [];
168  }
169 
170  if (!$a_first_child_drop_area) {
171  if ($a_node["type"] == "pg" || ($a_node["type"] == "st" && count($a_childs) == 0 && $this->getMaxDepth() != 0)) {
172  if ($a_node["type"] == "st") {
173  $this->makeDragTarget(
174  $a_node["node_id"],
175  "grp_pg",
176  $a_first_child_drop_area,
177  true,
178  ""
179  );
180  } else {
181  $this->makeDragTarget(
182  $a_node["node_id"],
183  "grp_pg",
184  $a_first_child_drop_area,
185  false,
186  ""
187  );
188  }
189  }
190 
191  if ($a_node["type"] != "pg" && $this->getMaxDepth() != 0) {
192  $this->makeDragTarget(
193  $a_node["node_id"],
194  "grp_st",
195  $a_first_child_drop_area,
196  true,
197  $lng->txt("cont_insert_as_subchapter")
198  );
199  }
200 
201  if (($a_next_sibling["type"] != "pg" && ($a_depth == 0 || $a_next_sibling["type"] == "st"))
202  || $a_node["type"] == "st") {
203  $this->makeDragTarget(
204  $a_node["node_id"],
205  "grp_st",
206  $a_first_child_drop_area,
207  false,
208  $lng->txt("cont_insert_as_chapter")
209  );
210  }
211  } else {
212  if ($a_node["type"] == "st" && $this->getMaxDepth() != 0) {
213  $this->makeDragTarget(
214  $a_node["node_id"],
215  "grp_pg",
216  $a_first_child_drop_area,
217  true
218  );
219  }
220  if ($a_childs[0]["type"] != "pg") {
221  $this->makeDragTarget(
222  $a_node["node_id"],
223  "grp_st",
224  $a_first_child_drop_area,
225  true
226  );
227  }
228  }
229  }
230 
237  public function getChildIcon($a_item)
238  {
239  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
240 
241  $img = "icon_" . $a_item["type"] . ".svg";
242 
243  if ($a_item["type"] == "pg") {
244  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
245  $lm_set = new ilSetting("lm");
246  $active = ilLMPage::_lookupActive(
247  $a_item["node_id"],
248  $this->lm_type,
249  $lm_set->get("time_scheduled_page_activation")
250  );
251 
252  // is page scheduled?
253  $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
254  ilLMPage::_isScheduledActivation($a_item["node_id"], $this->lm_type))
255  ? "_sc"
256  : "";
257 
258  $img = "icon_pg" . $img_sc . ".svg";
259 
260  if (!$active) {
261  $img = "icon_pg_d" . $img_sc . ".svg";
262  } else {
263  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
265  $a_item["node_id"],
266  $this->lm_type
267  );
268  if ($contains_dis) {
269  $img = "icon_pg_del" . $img_sc . ".svg";
270  }
271  }
272  }
273  return ilUtil::getImagePath($img);
274  }
275 
282  public function getChildIconAlt($a_item)
283  {
284  $lng = $this->lng;
285 
286  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
287 
288  if ($a_item["type"] == "pg") {
289  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
290  $active = ilLMPage::_lookupActive($a_item["node_id"], $this->lm_type);
291 
292  if (!$active) {
293  return $lng->txt("cont_page_deactivated");
294  } else {
295  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
297  $a_item["node_id"],
298  $this->lm_type
299  );
300  if ($contains_dis) {
301  return $lng->txt("cont_page_deactivated_elements");
302  }
303  }
304  }
305  return ilUtil::getImagePath("icon_" . $a_item["type"] . ".svg");
306  }
307 
314  public function getChildCommands($a_item)
315  {
316  $lng = $this->lng;
318 
319  $lm_class = "ilobjlearningmodulegui";
320 
321  $commands = array();
322  switch ($a_item["type"]) {
323  case "pg":
324  $ilCtrl->setParameterByClass(
325  "illmpageobjectgui",
326  "obj_id",
327  $a_item["node_id"]
328  );
329  $commands[] = array("text" => $lng->txt("edit"),
330  "link" => $ilCtrl->getLinkTargetByClass(array($lm_class, "illmpageobjectgui"), "edit"));
331  break;
332 
333  case "st":
334  $ilCtrl->setParameterByClass(
335  "ilstructureobjectgui",
336  "obj_id",
337  $a_item["node_id"]
338  );
339  $commands[] = array("text" => $lng->txt("edit"),
340  "link" => $ilCtrl->getLinkTargetByClass(array($lm_class, "ilstructureobjectgui"), "view"));
341  break;
342  }
343 
344  return $commands;
345  }
346 }
__construct($a_lm_type, $a_lang="-")
Constructor.
global $DIC
Definition: saml.php:7
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.
getChildCommands($a_item)
Get item commands.
nodeAllowsChilds($a_node)
Which nodes allow child nodes?
setCheckboxName($a_checkboxname)
Set Checkbox Name.
getMenuItems($a_node, $a_depth, $a_first_child=false, $a_next_sibling=null, $a_childs=null)
Get menu items.
user()
Definition: user.php:4
global $ilCtrl
Definition: ilias.php:18
makeDragContent($a_id, $a_group)
Makes a node a drag content.
This class represents a hierarchical form.
getChildIcon($a_item)
Get icon path for an item.
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.
getMaxDepth()
Get Maximum Depth.
static _lookupActive($a_id, $a_parent_type, $a_check_scheduled_activation=false, $a_lang="-")
lookup activation status
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class represents a hierarchical form.
getChildIconAlt($a_item)
Get icon alt text.
getChildTitle($a_child)
Get child title.
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
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.
$lm_set
Translation information on lm object.