ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilHierarchyFormGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Form/classes/class.ilFormGUI.php");
5 
15 {
19  protected $lng;
20 
24  protected $tpl;
25 
29  protected $ctrl;
30 
36  public function __construct()
37  {
38  global $DIC;
39 
40  $this->lng = $DIC->language();
41  $this->tpl = $DIC["tpl"];
42  $this->ctrl = $DIC->ctrl();
43  $lng = $DIC->language();
44  $tpl = $DIC["tpl"];
45 
46  $this->maxdepth = -1;
47  $this->multi_commands = array();
48  $this->commands = array();
49  $this->drag_target[] = array();
50  $this->drag_content[] = array();
51  $lng->loadLanguageModule("form");
52  $this->setCheckboxName("cbox");
53  $this->help_items = array();
54 
55  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
57  $tpl->addJavascript("./Services/Form/js/ServiceFormHierarchyForm.js");
58  }
59 
65  public function setParentCommand($a_parent_obj, $a_parent_cmd)
66  {
67  $this->parent_obj = $a_parent_obj;
68  $this->parent_cmd = $a_parent_cmd;
69  }
70 
76  public function getParentObject()
77  {
78  return $this->parent_obj;
79  }
80 
86  public function getParentCommand()
87  {
88  return $this->parent_cmd;
89  }
90 
96  public function setId($a_id)
97  {
98  die("ilHierarchyFormGUI does currently not support multiple forms (multiple IDs). ID is always hform.");
99  }
100 
106  public function getId()
107  {
108  return "hform";
109  }
110 
116  public function setTree($a_tree)
117  {
118  $this->tree = $a_tree;
119  }
120 
126  public function getTree()
127  {
128  return $this->tree;
129  }
130 
136  public function setCurrentTopNodeId($a_currenttopnodeid)
137  {
138  $this->currenttopnodeid = $a_currenttopnodeid;
139  }
140 
146  public function getCurrentTopNodeId()
147  {
148  return $this->currenttopnodeid;
149  }
150 
156  public function setTitle($a_title)
157  {
158  $this->title = $a_title;
159  }
160 
166  public function getTitle()
167  {
168  return $this->title;
169  }
170 
176  public function setIcon($a_icon)
177  {
178  $this->icon = $a_icon;
179  }
180 
186  public function getIcon()
187  {
188  return $this->icon;
189  }
190 
196  public function setCheckboxName($a_checkboxname)
197  {
198  $this->checkboxname = $a_checkboxname;
199  }
200 
206  public function getCheckboxName()
207  {
208  return $this->checkboxname;
209  }
210 
216  public function setDragIcon($a_dragicon)
217  {
218  $this->dragicon = $a_dragicon;
219  }
220 
226  public function getDragIcon()
227  {
228  return $this->dragicon;
229  }
230 
236  public function setMaxDepth($a_maxdepth)
237  {
238  $this->maxdepth = $a_maxdepth;
239  }
240 
246  public function getMaxDepth()
247  {
248  return $this->maxdepth;
249  }
250 
256  public function setExplorerUpdater($a_exp_frame, $a_exp_id, $a_exp_target_script)
257  {
258  $this->exp_frame = $a_exp_frame;
259  $this->exp_id = $a_exp_id;
260  $this->exp_target_script = $a_exp_target_script;
261  }
262 
268  public function setTriggeredUpdateCommand($a_triggered_update_command)
269  {
270  $this->triggered_update_command = $a_triggered_update_command;
271  }
272 
276  public function addHelpItem($a_text, $a_image = "")
277  {
278  $this->help_items[] = array("text" => $a_text,
279  "image" => $a_image);
280  }
281 
285  public function getHelpItems()
286  {
287  return $this->help_items;
288  }
289 
296  public function makeDragTarget($a_id, $a_group, $a_first_child_drop_area = false, $a_as_subitem = false, $a_diss_text = "")
297  {
298  if ($a_first_child_drop_area == true) { // first child drop areas only insert as subitems
299  $a_as_subitem = true;
300  }
301 
302  if ($a_id != "") {
303  if ($a_first_child_drop_area) {
304  $a_id.= "fc";
305  }
306 
307  $this->drag_target[] = array("id" => $a_id, "group" => $a_group);
308  $this->diss_menues[$a_id][$a_group][] = array("subitem" => $a_as_subitem, "text" => $a_diss_text);
309  }
310  }
311 
318  public function makeDragContent($a_id, $a_group)
319  {
320  if ($a_id != "") {
321  $this->drag_content[] = array("id" => $a_id, "group" => $a_group);
322  }
323  }
324 
331  public function addMultiCommand($a_txt, $a_cmd)
332  {
333  $this->multi_commands[] = array("text" => $a_txt, "cmd" => $a_cmd);
334  }
335 
342  public function addCommand($a_txt, $a_cmd)
343  {
344  $this->commands[] = array("text" => $a_txt, "cmd" => $a_cmd);
345  }
346 
352  public function setHighlightedNodes($a_val)
353  {
354  $this->highlighted_nodes = $a_val;
355  }
356 
362  public function getHighlightedNodes()
363  {
364  return $this->highlighted_nodes;
365  }
366 
372  public function setFocusId($a_val)
373  {
374  $this->focus_id = $a_val;
375  }
376 
382  public function getFocusId()
383  {
384  return $this->focus_id;
385  }
386 
392  public function setExpandVariable($a_val)
393  {
394  $this->expand_variable = $a_val;
395  }
396 
402  public function getExpandVariable()
403  {
404  return $this->expand_variable;
405  }
406 
412  public function setExpanded($a_val)
413  {
414  $this->expanded = $a_val;
415  }
416 
422  public function getExpanded()
423  {
424  return $this->expanded;
425  }
426 
432  public function updateExpanded()
433  {
434  $ev = $this->getExpandVariable();
435 
436  if ($ev == "") {
437  return;
438  }
439 
440  // init empty session
441  if (!is_array($_SESSION[$ev])) {
442  $_SESSION[$ev] = array($this->getTree()->getRootId());
443  }
444 
445  if ($_POST["il_hform_expand"] != "") {
446  $node_id = $_POST["il_hform_expand"];
447  }
448  if ($_GET[$ev] != "") {
449  $node_id = $_GET[$ev];
450  }
451 
452  // if positive => expand this node
453  if ($node_id > 0 && !in_array($node_id, $_SESSION[$ev])) {
454  array_push($_SESSION[$ev], $node_id);
455  }
456  // if negative => compress this node
457  if ($node_id < 0) {
458  $key = array_keys($_SESSION[$ev], -(int) $node_id);
459  unset($_SESSION[$ev][$key[0]]);
460  }
461  $this->setExpanded($_SESSION[$ev]);
462  }
463 
469  public function setTypeWhiteList($a_val)
470  {
471  $this->white_list = $a_val;
472  }
473 
479  public function getTypeWhiteList()
480  {
481  return $this->white_list;
482  }
483 
488  public function getChilds($a_node_id = false)
489  {
490  if ($a_node_id == false) {
491  $a_node_id = $this->getCurrentTopNodeId();
492  }
493 
494  $tree_childs = $this->getTree()->getChilds($a_node_id);
495  $childs = array();
496  foreach ($tree_childs as $tree_child) {
497  if (!is_array($this->white_list) || in_array($tree_child["type"], $this->white_list)) {
498  $childs[] = array("node_id" => $tree_child["child"],
499  "title" => $tree_child["title"],
500  "type" => $tree_child["type"],
501  "depth" => $tree_child["depth"]
502  );
503  }
504  }
505 
506  return $childs;
507  }
508 
512  public function getContent()
513  {
514  $lng = $this->lng;
515 
516  if ($this->getExpandVariable() != "") {
517  $this->updateExpanded();
518  }
519 
520  $ttpl = new ilTemplate("tpl.hierarchy_form.html", true, true, "Services/Form");
521  $ttpl->setVariable("TXT_SAVING", $lng->txt("saving"));
522  $top_node_data = $this->getTree()->getNodeData($this->getCurrentTopNodeId());
523  $top_node = array("node_id" => $top_node_data["child"],
524  "title" => $top_node_data["title"],
525  "type" => $top_node_data["type"]);
526 
527  $childs = null;
528  $nodes_html = $this->getLevelHTML($top_node, 0, $childs);
529 
530 
531  // commands
532  $secs = array("1", "2");
533  foreach ($secs as $sec) {
534  reset($this->commands);
535  reset($this->multi_commands);
536  if (count($this->multi_commands) > 0 || count($this->commands) > 0) {
537  if (count($childs) > 0) {
538  $single = false;
539  foreach ($this->commands as $cmd) {
540  $ttpl->setCurrentBlock("cmd" . $sec);
541  $ttpl->setVariable("CMD", $cmd["cmd"]);
542  $ttpl->setVariable("CMD_TXT", $cmd["text"]);
543  $ttpl->parseCurrentBlock();
544  $single = true;
545  }
546 
547  $multi = false;
548  foreach ($this->multi_commands as $cmd) {
549  $ttpl->setCurrentBlock("multi_cmd" . $sec);
550  $ttpl->setVariable("MULTI_CMD", $cmd["cmd"]);
551  $ttpl->setVariable("MULTI_CMD_TXT", $cmd["text"]);
552  $ttpl->parseCurrentBlock();
553  $multi = true;
554  }
555  if ($multi) {
556  $ttpl->setCurrentBlock("multi_cmds" . $sec);
557  $ttpl->setVariable("MCMD_ALT", $lng->txt("commands"));
558  if ($sec == "1") {
559  $ttpl->setVariable("MCMD_IMG", ilUtil::getImagePath("arrow_downright.svg"));
560  } else {
561  $ttpl->setVariable("MCMD_IMG", ilUtil::getImagePath("arrow_upright.svg"));
562  }
563  $ttpl->parseCurrentBlock();
564  }
565  }
566 
567  if ($single || $multi) {
568  $ttpl->setCurrentBlock("commands" . $sec);
569  $ttpl->parseCurrentBlock();
570  }
571  $single = true;
572  }
573  }
574 
575  // explorer updater
576  if ($this->exp_frame != "") {
577  $ttpl->setCurrentBlock("updater");
578  $ttpl->setVariable("UPDATER_FRAME", $this->exp_frame);
579  $ttpl->setVariable("EXP_ID_UPDATER", $this->exp_id);
580  $ttpl->setVariable("HREF_UPDATER", $this->exp_target_script);
581  $ttpl->parseCurrentBlock();
582  }
583 
584  // drag and drop initialisation
585  foreach ($this->drag_target as $drag_target) {
586  $ttpl->setCurrentBlock("dragtarget");
587  $ttpl->setVariable("EL_ID", $drag_target["id"]);
588  $ttpl->setVariable("GROUP", $drag_target["group"]);
589  $ttpl->parseCurrentBlock();
590  }
591  foreach ($this->drag_content as $drag_content) {
592  $ttpl->setCurrentBlock("dragcontent");
593  $ttpl->setVariable("EL_ID", $drag_content["id"]);
594  $ttpl->setVariable("GROUP", $drag_content["group"]);
595  $ttpl->parseCurrentBlock();
596  }
597 
598  // disambiguation menues and "insert as first child" flags
599  if (is_array($this->diss_menues)) {
600  foreach ($this->diss_menues as $node_id => $d_menu) {
601  foreach ($d_menu as $group => $menu) {
602  if (count($menu) > 1) {
603  foreach ($menu as $menu_item) {
604  $ttpl->setCurrentBlock("dmenu_cmd");
605  $ttpl->setVariable("SUBITEM", (int) $menu_item["subitem"]);
606  $ttpl->setVariable("TXT_MENU_CMD", $menu_item["text"]);
607  $ttpl->parseCurrentBlock();
608  }
609 
610  $ttpl->setCurrentBlock("disambiguation_menu");
611  $ttpl->setVariable("DNODE_ID", $node_id);
612  $ttpl->setVariable("GRP", $group);
613  $ttpl->parseCurrentBlock();
614  } elseif (count($menu) == 1) {
615  // set first child flag
616  $ttpl->setCurrentBlock("as_subitem_flag");
617  $ttpl->setVariable("SI_NODE_ID", $node_id);
618  $ttpl->setVariable("SI_GRP", $group);
619  $ttpl->setVariable("SI_SI", (int) $menu[0]["subitem"]);
620  $ttpl->parseCurrentBlock();
621  }
622  }
623  }
624  }
625  $this->diss_menues[$a_id][$a_group][] = array("type" => $a_type, "text" => $a_diss_text);
626 
627 
628  if ($this->triggered_update_command != "") {
629  $ttpl->setCurrentBlock("tr_update");
630  $ttpl->setVariable("UPDATE_CMD", $this->triggered_update_command);
631  $ttpl->parseCurrentBlock();
632  }
633 
634  // disambiguation menues and "insert as first child" flags
635  if (is_array($this->diss_menues)) {
636  foreach ($this->diss_menues as $node_id => $d_menu) {
637  foreach ($d_menu as $group => $menu) {
638  if (count($menu) > 1) {
639  foreach ($menu as $menu_item) {
640  $ttpl->setCurrentBlock("dmenu_cmd");
641  $ttpl->setVariable("SUBITEM", (int) $menu_item["subitem"]);
642  $ttpl->setVariable("TXT_MENU_CMD", $menu_item["text"]);
643  $ttpl->parseCurrentBlock();
644  }
645 
646  $ttpl->setCurrentBlock("disambiguation_menu");
647  $ttpl->setVariable("DNODE_ID", $node_id);
648  $ttpl->setVariable("GRP", $group);
649  $ttpl->parseCurrentBlock();
650  } elseif (count($menu) == 1) {
651  // set first child flag
652  $ttpl->setCurrentBlock("as_subitem_flag");
653  $ttpl->setVariable("SI_NODE_ID", $node_id);
654  $ttpl->setVariable("SI_GRP", $group);
655  $ttpl->setVariable("SI_SI", (int) $menu[0]["subitem"]);
656  $ttpl->parseCurrentBlock();
657  }
658  }
659  }
660  }
661  $this->diss_menues[$a_id][$a_group][] = array("type" => $a_type, "text" => $a_diss_text);
662 
663  // nodes
664  $ttpl->setVariable("NODES", $nodes_html);
665 
666  // title
667  //echo "<br>".htmlentities($this->getTitle())." --- ".htmlentities(ilUtil::prepareFormOutput($this->getTitle()));
668  $ttpl->setVariable("TITLE", $this->getTitle());
669 
670 
671  return $ttpl->get();
672  }
673 
679  public function getLegend()
680  {
681  $lng = $this->lng;
682 
683  include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
684 
685  $ttpl = new ilTemplate("tpl.hierarchy_form_legend.html", true, true, "Services/Form");
686  if ($this->getDragIcon() != "") {
687  $ttpl->setCurrentBlock("help_drag");
688  $ttpl->setVariable("IMG_DRAG", $this->getDragIcon());
689  $ttpl->setVariable(
690  "DRAG_ARROW",
692  );
693  $ttpl->setVariable(
694  "TXT_DRAG",
695  $lng->txt("form_hierarchy_drag_drop_help")
696  );
697  $ttpl->setVariable("PLUS", ilGlyphGUI::get(ilGlyphGUI::ADD));
698  $ttpl->parseCurrentBlock();
699  }
700 
701  // additional help items
702  foreach ($this->getHelpItems() as $help) {
703  if ($help["image"] != "") {
704  $ttpl->setCurrentBlock("help_img");
705  $ttpl->setVariable("IMG_HELP", $help["image"]);
706  $ttpl->parseCurrentBlock();
707  }
708  $ttpl->setCurrentBlock("help_item");
709  $ttpl->setVariable("TXT_HELP", $help["text"]);
710  $ttpl->parseCurrentBlock();
711  }
712 
713  $ttpl->setVariable(
714  "TXT_ADD_EL",
715  $lng->txt("form_hierarchy_add_elements")
716  );
717  $ttpl->setVariable("PLUS2", ilGlyphGUI::get(ilGlyphGUI::ADD));
718 
719  return $ttpl->get();
720  }
721 
722 
726  public function getLevelHTML($a_par_node, $a_depth, &$a_childs)
727  {
728  $lng = $this->lng;
729 
730  if ($this->getMaxDepth() > -1 && $this->getMaxDepth() < $a_depth) {
731  return "";
732  }
733 
734  $childs = $this->getChilds($a_par_node["node_id"]);
735  $a_childs = $childs;
736  $html = "";
737  $last_child = null;
738  $ttpl = new ilTemplate("tpl.hierarchy_form_nodes.html", true, true, "Services/Form");
739 
740  // prepended drop area
741  if ($this->nodeAllowsChilds($a_par_node) && (count($childs) > 0 || $a_depth == 0)) {
742  $ttpl->setCurrentBlock("drop_area");
743  $ttpl->setVariable("DNODE_ID", $a_par_node["node_id"] . "fc"); // fc means "first child"
744  $ttpl->setVariable("IMG_BLANK", ilUtil::getImagePath("spacer.png"));
745  if (count($childs) == 0) {
746  $ttpl->setVariable("NO_CONTENT_CLASS", "ilCOPGNoPageContent");
747  $ttpl->setVariable("NO_CONTENT_TXT", " &nbsp;" . $lng->txt("form_hier_click_to_add"));
748  }
749  $ttpl->parseCurrentBlock();
750 
751  $this->manageDragAndDrop($a_par_node, $a_depth, true, null, $childs);
752  $menu_items = $this->getMenuItems($a_par_node, $a_depth, true, null, $childs);
753  //var_dump($menu_items);
754  if (count($menu_items) > 0) {
755  // determine maximum of multi add numbers
756  $max = 1;
757  foreach ($menu_items as $menu_item) {
758  if ($menu_item["multi"] > $max) {
759  $max = $menu_item["multi"];
760  }
761  }
762 
763  reset($menu_items);
764  $mcnt = 1;
765  foreach ($menu_items as $menu_item) {
766  if ($menu_item["multi"] > 1) {
767  for ($i = 1; $i <= $menu_item["multi"]; $i++) {
768  $ttpl->setCurrentBlock("multi_add");
769  $ttpl->setVariable("MA_NUM", $i);
770  $ttpl->setVariable("MENU_CMD", $menu_item["cmd"]);
771  $ttpl->setVariable("FC", "1");
772  $ttpl->setVariable("CMD_NODE", $a_par_node["node_id"]);
773  $ttpl->setVariable("MCNT", $mcnt . "fc");
774  $ttpl->parseCurrentBlock();
775  }
776  }
777 
778  // buffer td for lower multis
779  if ($max > $menu_item["multi"]) {
780  $ttpl->setCurrentBlock("multi_buffer");
781  $ttpl->setVariable("BUF_SPAN", $max - $menu_item["multi"]);
782  $ttpl->parseCurrentBlock();
783  }
784  $ttpl->setCurrentBlock("menu_cmd");
785  $ttpl->setVariable("TXT_MENU_CMD", $menu_item["text"]);
786  $ttpl->setVariable("MENU_CMD", $menu_item["cmd"]);
787  $ttpl->setVariable("CMD_NODE", $a_par_node["node_id"]);
788  $ttpl->setVariable("FC", "1");
789  $ttpl->setVariable("MCNT", $mcnt . "fc");
790  $ttpl->parseCurrentBlock();
791  $mcnt++;
792  }
793  $ttpl->setCurrentBlock("drop_area_menu");
794  $ttpl->setVariable("MNODE_ID", $a_par_node["node_id"] . "fc");
795  $ttpl->parseCurrentBlock();
796 
797  $ttpl->setCurrentBlock("element");
798  $ttpl->parseCurrentBlock();
799  }
800  }
801 
802  // insert childs
803  if (count($childs) > 0) {
804  for ($i = 0; $i < count($childs); $i++) {
805  $next_sibling = ($i < (count($childs) - 1))
806  ? $next_sibling = $childs[$i+1]
807  : null;
808 
809  $this->renderChild($ttpl, $childs[$i], $a_depth, $next_sibling);
810  $last_child = $child;
811  }
812  }
813 
814  $html = $ttpl->get();
815  unset($ttpl);
816 
817  return $html;
818  }
819 
823  public function renderChild($a_tpl, $a_child, $a_depth, $next_sibling = null)
824  {
826 
827  // image
828  $a_tpl->setCurrentBlock("img");
829  $a_tpl->setVariable("IMGPATH", $this->getChildIcon($a_child));
830  $a_tpl->setVariable("IMGALT", $this->getChildIconAlt($a_child));
831  $a_tpl->setVariable("IMG_NODE", $a_child["node_id"]);
832  $a_tpl->setVariable("NODE_ID", $a_child["node_id"]);
833  $a_tpl->setVariable("TYPE", $a_child["type"]);
834  $a_tpl->parseCurrentBlock();
835 
836  // checkbox
837  $a_tpl->setCurrentBlock("cbox");
838  $a_tpl->setVariable("CNODE_ID", $a_child["node_id"]);
839  $a_tpl->setVariable("CBOX_NAME", $this->getCheckboxName());
840  $a_tpl->parseCurrentBlock();
841 
842  // node info
843  if (($info = $this->getChildInfo($a_child)) != "") {
844  $a_tpl->setCurrentBlock("node_info");
845  $a_tpl->setVariable("NODE_INFO", $info);
846  $a_tpl->parseCurrentBlock();
847  }
848 
849  // commands of child node
850  $child_commands = $this->getChildCommands($a_child);
851  if (is_array($child_commands)) {
852  foreach ($child_commands as $command) {
853  $a_tpl->setCurrentBlock("node_cmd");
854  $a_tpl->setVariable("HREF_NODE_CMD", $command["link"]);
855  $a_tpl->setVariable("TXT_NODE_CMD", $command["text"]);
856  $a_tpl->parseCurrentBlock();
857  }
858  }
859 
860  // title
861  $a_tpl->setCurrentBlock("text");
862  $hl = $this->getHighlightedNodes();
863  if (is_array($hl) && in_array($a_child["node_id"], $hl)) {
864  $a_tpl->setVariable("CLASS", ' class="ilHFormHighlighted" ');
865  }
866  $a_tpl->setVariable("VAL_TITLE", ilUtil::prepareFormOutput($this->getChildTitle($a_child)));
867  $a_tpl->setVariable("TNODE_ID", $a_child["node_id"]);
868  $a_tpl->parseCurrentBlock();
869  $grandchilds = null;
870  $grandchilds_html = $this->getLevelHTML($a_child, $a_depth + 1, $grandchilds);
871 
872  // focus
873  if ($this->getFocusId() == $a_child["node_id"]) {
874  $a_tpl->setCurrentBlock("focus");
875  $a_tpl->setVariable("FNODE_ID", $a_child["node_id"]);
876  $a_tpl->parseCurrentBlock();
877  }
878 
879  // expander
880  if ($this->getExpandVariable() != "") {
881  $a_tpl->setCurrentBlock("expand_icon");
882  if (!is_null($grandchilds) && count($grandchilds) > 0) {
883  if (!in_array($a_child["node_id"], $this->getExpanded())) {
884  $ilCtrl->setParameter($this->getParentObject(), $this->getExpandVariable(), $a_child["node_id"]);
885  $a_tpl->setVariable("IMG_EXPAND", ilUtil::getImagePath("browser/plus.png"));
886  $a_tpl->setVariable("HREF_NAME", "n" . $a_child["node_id"]);
887  $a_tpl->setVariable(
888  "HREF_EXPAND",
889  $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCommand(), "n" . $a_child["node_id"])
890  );
891  $grandchilds_html = "";
892  } else {
893  $ilCtrl->setParameter($this->getParentObject(), $this->getExpandVariable(), -$a_child["node_id"]);
894  $a_tpl->setVariable("IMG_EXPAND", ilUtil::getImagePath("browser/minus.png"));
895  $a_tpl->setVariable("HREF_NAME", "n" . $a_child["node_id"]);
896  $a_tpl->setVariable(
897  "HREF_EXPAND",
898  $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCommand(), "n" . $a_child["node_id"])
899  );
900  }
901  $ilCtrl->setParameter($this->getParentObject(), $this->getExpandVariable(), "");
902  } else {
903  $a_tpl->setVariable("IMG_EXPAND", ilUtil::getImagePath("spacer.png"));
904  }
905  $a_tpl->parseCurrentBlock();
906  }
907 
908  // childs
909  $a_tpl->setCurrentBlock("list_item");
910  $a_tpl->setVariable("CHILDS", $grandchilds_html);
911  $a_tpl->parseCurrentBlock();
912 
913  $a_tpl->setCurrentBlock("element");
914  $a_tpl->parseCurrentBlock();
915 
916  // drop area after child
917  $a_tpl->setCurrentBlock("drop_area");
918  $a_tpl->setVariable("DNODE_ID", $a_child["node_id"]);
919  $a_tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("spacer.png"));
920  $a_tpl->parseCurrentBlock();
921 
922  // manage drag and drop areas
923  $this->manageDragAndDrop($a_child, $a_depth, false, $next_sibling, $grandchilds);
924 
925  // drop area menu
926  $menu_items = $this->getMenuItems($a_child, $a_depth, false, $next_sibling, $grandchilds);
927  if (count($menu_items) > 0) {
928  // determine maximum of multi add numbers
929  $max = 1;
930  foreach ($menu_items as $menu_item) {
931  if ($menu_item["multi"] > $max) {
932  $max = $menu_item["multi"];
933  }
934  }
935 
936  reset($menu_items);
937  $mcnt = 1;
938  foreach ($menu_items as $menu_item) {
939  if ($menu_item["multi"] > 1) {
940  for ($i = 1; $i <= $menu_item["multi"]; $i++) {
941  $a_tpl->setCurrentBlock("multi_add");
942  $a_tpl->setVariable("MA_NUM", $i);
943  $a_tpl->setVariable("MENU_CMD", $menu_item["cmd"]);
944  if ($menu_item["as_subitem"]) {
945  $a_tpl->setVariable("FC", "1");
946  $a_tpl->setVariable("MCNT", $mcnt . "fc");
947  } else {
948  $a_tpl->setVariable("FC", "0");
949  $a_tpl->setVariable("MCNT", $mcnt);
950  }
951  $a_tpl->setVariable("CMD_NODE", $a_child["node_id"]);
952  $a_tpl->parseCurrentBlock();
953  }
954  }
955 
956  // buffer td for lower multis
957  if ($max > $menu_item["multi"]) {
958  $a_tpl->setCurrentBlock("multi_buffer");
959  $a_tpl->setVariable("BUF_SPAN", $max - $menu_item["multi"]);
960  $a_tpl->parseCurrentBlock();
961  }
962 
963  $a_tpl->setCurrentBlock("menu_cmd");
964  $a_tpl->setVariable("TXT_MENU_CMD", $menu_item["text"]);
965  $a_tpl->setVariable("MENU_CMD", $menu_item["cmd"]);
966  if ($menu_item["as_subitem"]) {
967  $a_tpl->setVariable("FC", "1");
968  $a_tpl->setVariable("MCNT", $mcnt . "fc");
969  } else {
970  $a_tpl->setVariable("FC", "0");
971  $a_tpl->setVariable("MCNT", $mcnt);
972  }
973  $a_tpl->setVariable("CMD_NODE", $a_child["node_id"]);
974  $a_tpl->parseCurrentBlock();
975  $mcnt++;
976  }
977  $a_tpl->setCurrentBlock("drop_area_menu");
978  $a_tpl->setVariable("MNODE_ID", $a_child["node_id"]);
979  $a_tpl->parseCurrentBlock();
980  }
981 
982  $a_tpl->setCurrentBlock("element");
983  $a_tpl->parseCurrentBlock();
984  }
985 
992  public function getChildIcon($a_item)
993  {
994  return ilUtil::getImagePath("icon_" . $a_item["type"] . ".svg");
995  }
996 
1003  public function getChildIconAlt($a_item)
1004  {
1005  $lng = $this->lng;
1006 
1007  return $lng->txt($a_item["type"]);
1008  }
1009 
1016  public function getChildCommands($a_item)
1017  {
1018  return false;
1019  }
1020 
1027  public function getChildTitle($a_child)
1028  {
1029  return $a_child["title"];
1030  }
1031 
1038  public function getChildInfo($a_child)
1039  {
1040  return "";
1041  }
1042 
1055  public function getMenuItems($a_node, $a_depth, $a_first_child = false, $a_next_sibling = null, $a_childs = null)
1056  {
1057  return array();
1058  }
1059 
1064  public function nodeAllowsChilds($a_node)
1065  {
1066  return true;
1067  }
1068 
1075  public function manageDragAndDrop($a_node, $a_depth, $a_first_child = false, $a_next_sibling = null, $a_childs = null)
1076  {
1077  //$this->makeDragTarget($a_node["id"], $a_group);
1078  //$this->makeDragTarget($a_node["id"], $a_group);
1079  }
1080 
1084  public static function getPostMulti()
1085  {
1086  return (int) ($_POST["il_hform_multi"] > 1
1087  ? $_POST["il_hform_multi"]
1088  : 1);
1089  }
1090 
1094  public static function getPostNodeId()
1095  {
1096  return $_POST["il_hform_node"];
1097  }
1098 
1102  public static function getPostFirstChild()
1103  {
1104  return (((int) $_POST["il_hform_fc"]) == 1);
1105  }
1106 
1113  public function getHTML()
1114  {
1115  return parent::getHTML() . $this->getLegend();
1116  }
1117 
1121  public static function getPostFields()
1122  {
1123  return array(
1124  "il_hform_node" => $_POST["il_hform_node"],
1125  "il_hform_fc" => $_POST["il_hform_fc"],
1126  "il_hform_as_subitem" => $_POST["il_hform_as_subitem"],
1127  "il_hform_multi" => $_POST["il_hform_multi"],
1128  "il_hform_source_id" => $_POST["il_hform_source_id"],
1129  "il_hform_target_id" => $_POST["il_hform_target_id"]
1130  );
1131  }
1132 }
getChildCommands($a_item)
Get item commands.
getCheckboxName()
Get Checkbox Name.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
static getPostMulti()
Get multi number of _POST input.
getExpanded()
Get expanded array.
setTriggeredUpdateCommand($a_triggered_update_command)
Set Explorer Updater.
setTitle($a_title)
Set Title.
$_SESSION["AccountId"]
setExpanded($a_val)
Set expanded Array.
getChildIcon($a_item)
Get icon path for an item.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
addCommand($a_txt, $a_cmd)
Add a command.
static getPostNodeId()
Get node ID of _POST input.
getHighlightedNodes()
Get highlighted nodes.
This class represents a form user interface.
getContent()
Get Form Content.
static get($a_glyph, $a_text="")
Get glyph html.
setCheckboxName($a_checkboxname)
Set Checkbox Name.
getHelpItems()
Get all help items.
getParentCommand()
Get parent command.
setTypeWhiteList($a_val)
Set type whitelist.
global $ilCtrl
Definition: ilias.php:18
makeDragContent($a_id, $a_group)
Makes a node a drag content.
static getPostFields()
Get all post fields.
static getPostFirstChild()
Should node be inserted as first child of target node (true) or as successor (false) ...
getChilds($a_node_id=false)
Get all childs of current node.
$a_type
Definition: workflow.php:92
setHighlightedNodes($a_val)
Set highlighted nodes.
manageDragAndDrop($a_node, $a_depth, $a_first_child=false, $a_next_sibling=null, $a_childs=null)
Makes nodes drag and drop content and targets.
setCurrentTopNodeId($a_currenttopnodeid)
Set Current Top Node ID.
This class represents a hierarchical form.
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.
setExplorerUpdater($a_exp_frame, $a_exp_id, $a_exp_target_script)
Set Explorer Updater.
getMaxDepth()
Get Maximum Depth.
getParentObject()
Get Parent object.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
getDragIcon()
Get Drag Icon Path.
special template class to simplify handling of ITX/PEAR
getChildInfo($a_child)
Get child info.
getTypeWhiteList()
Get type whitelist.
getMenuItems($a_node, $a_depth, $a_first_child=false, $a_next_sibling=null, $a_childs=null)
Get menu items for drop area of node.
addMultiCommand($a_txt, $a_cmd)
Add a multi command (for selection of items)
addHelpItem($a_text, $a_image="")
Get all help items.
Create styles array
The data for the language used.
getChildIconAlt($a_item)
Get icon alt text for an item.
renderChild($a_tpl, $a_child, $a_depth, $next_sibling=null)
Render a single child (including grandchilds)
getCurrentTopNodeId()
Get Current Top Node ID.
updateExpanded()
Update expand information in session.
setExpandVariable($a_val)
Set expand variable.
static initDragDrop()
Init YUI Drag and Drop.
getExpandVariable()
Get expand variable.
$i
Definition: disco.tpl.php:19
setMaxDepth($a_maxdepth)
Set Maximum Depth.
setFocusId($a_val)
Set focus if.
getLevelHTML($a_par_node, $a_depth, &$a_childs)
Get Form HTML.
setTree($a_tree)
Set Tree Object.
$info
Definition: index.php:5
setDragIcon($a_dragicon)
Set Drag Icon Path.
$key
Definition: croninfo.php:18
$_POST["username"]
$html
Definition: example_001.php:87
getChildTitle($a_child)
Get child title.
nodeAllowsChilds($a_node)
Checks, whether current nodes allows childs at all.
setParentCommand($a_parent_obj, $a_parent_cmd)
Set parent gui object/cmd.