ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
4include_once("./Services/Form/classes/class.ilFormGUI.php");
5
15{
21 function __construct()
22 {
23 global $lng, $tpl;
24
25 $this->maxdepth = -1;
26 $this->multi_commands = array();
27 $this->commands = array();
28 $this->drag_target[] = array();
29 $this->drag_content[] = array();
30 $lng->loadLanguageModule("form");
31 $this->setCheckboxName("cbox");
32 parent::ilFormGUI();
33 $this->help_items = array();
34
35 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
37 $tpl->addJavascript("./Services/Form/js/ServiceFormHierarchyForm.js");
38 }
39
45 function setParentCommand($a_parent_obj, $a_parent_cmd)
46 {
47 $this->parent_obj = $a_parent_obj;
48 $this->parent_cmd = $a_parent_cmd;
49 }
50
56 function getParentObject()
57 {
58 return $this->parent_obj;
59 }
60
67 {
68 return $this->parent_cmd;
69 }
70
76 function setId($a_id)
77 {
78 die("ilHierarchyFormGUI does currently not support multiple forms (multiple IDs). ID is always hform.");
79 }
80
86 function getId()
87 {
88 return "hform";
89 }
90
96 function setTree($a_tree)
97 {
98 $this->tree = $a_tree;
99 }
100
106 function getTree()
107 {
108 return $this->tree;
109 }
110
116 function setCurrentTopNodeId($a_currenttopnodeid)
117 {
118 $this->currenttopnodeid = $a_currenttopnodeid;
119 }
120
127 {
128 return $this->currenttopnodeid;
129 }
130
136 function setTitle($a_title)
137 {
138 $this->title = $a_title;
139 }
140
146 function getTitle()
147 {
148 return $this->title;
149 }
150
156 function setIcon($a_icon)
157 {
158 $this->icon = $a_icon;
159 }
160
166 function getIcon()
167 {
168 return $this->icon;
169 }
170
176 function setCheckboxName($a_checkboxname)
177 {
178 $this->checkboxname = $a_checkboxname;
179 }
180
187 {
188 return $this->checkboxname;
189 }
190
196 function setDragIcon($a_dragicon)
197 {
198 $this->dragicon = $a_dragicon;
199 }
200
206 function getDragIcon()
207 {
208 return $this->dragicon;
209 }
210
216 function setMaxDepth($a_maxdepth)
217 {
218 $this->maxdepth = $a_maxdepth;
219 }
220
226 function getMaxDepth()
227 {
228 return $this->maxdepth;
229 }
230
236 function setExplorerUpdater($a_exp_frame, $a_exp_id, $a_exp_target_script)
237 {
238 $this->exp_frame = $a_exp_frame;
239 $this->exp_id = $a_exp_id;
240 $this->exp_target_script = $a_exp_target_script;
241 }
242
248 function setTriggeredUpdateCommand($a_triggered_update_command)
249 {
250 $this->triggered_update_command = $a_triggered_update_command;
251 }
252
256 function addHelpItem($a_text, $a_image = "")
257 {
258 $this->help_items[] = array("text" => $a_text,
259 "image" => $a_image);
260 }
261
265 function getHelpItems()
266 {
267 return $this->help_items;
268 }
269
276 function makeDragTarget($a_id, $a_group, $a_first_child_drop_area = false, $a_as_subitem = false, $a_diss_text = "")
277 {
278 if ($a_first_child_drop_area == true) // first child drop areas only insert as subitems
279 {
280 $a_as_subitem = true;
281 }
282
283 if ($a_id != "")
284 {
285 if ($a_first_child_drop_area)
286 {
287 $a_id.= "fc";
288 }
289
290 $this->drag_target[] = array("id" => $a_id, "group" => $a_group);
291 $this->diss_menues[$a_id][$a_group][] = array("subitem" => $a_as_subitem, "text" => $a_diss_text);
292 }
293 }
294
301 function makeDragContent($a_id, $a_group)
302 {
303 if ($a_id != "")
304 {
305 $this->drag_content[] = array("id" => $a_id, "group" => $a_group);
306 }
307 }
308
315 function addMultiCommand($a_txt, $a_cmd)
316 {
317 $this->multi_commands[] = array("text" => $a_txt, "cmd" => $a_cmd);
318 }
319
326 function addCommand($a_txt, $a_cmd)
327 {
328 $this->commands[] = array("text" => $a_txt, "cmd" => $a_cmd);
329 }
330
336 function setHighlightedNodes($a_val)
337 {
338 $this->highlighted_nodes = $a_val;
339 }
340
347 {
348 return $this->highlighted_nodes;
349 }
350
356 function setFocusId($a_val)
357 {
358 $this->focus_id = $a_val;
359 }
360
366 function getFocusId()
367 {
368 return $this->focus_id;
369 }
370
376 function setExpandVariable($a_val)
377 {
378 $this->expand_variable = $a_val;
379 }
380
387 {
388 return $this->expand_variable;
389 }
390
396 function setExpanded($a_val)
397 {
398 $this->expanded = $a_val;
399 }
400
406 function getExpanded()
407 {
408 return $this->expanded;
409 }
410
416 function updateExpanded()
417 {
418 $ev = $this->getExpandVariable();
419
420 if ($ev == "")
421 {
422 return;
423 }
424
425 // init empty session
426 if (!is_array($_SESSION[$ev]))
427 {
428 $_SESSION[$ev] = array($this->getTree()->getRootId());
429 }
430
431 if ($_POST["il_hform_expand"] != "")
432 {
433 $node_id = $_POST["il_hform_expand"];
434 }
435 if ($_GET[$ev] != "")
436 {
437 $node_id = $_GET[$ev];
438 }
439
440 // if positive => expand this node
441 if ($node_id > 0 && !in_array($node_id,$_SESSION[$ev]))
442 {
443 array_push($_SESSION[$ev], $node_id);
444 }
445 // if negative => compress this node
446 if ($node_id < 0)
447 {
448 $key = array_keys($_SESSION[$ev],-(int) $node_id);
449 unset($_SESSION[$ev][$key[0]]);
450 }
451 $this->setExpanded($_SESSION[$ev]);
452 }
453
459 function setTypeWhiteList($a_val)
460 {
461 $this->white_list = $a_val;
462 }
463
470 {
471 return $this->white_list;
472 }
473
478 function getChilds($a_node_id = false)
479 {
480 if ($a_node_id == false)
481 {
482 $a_node_id = $this->getCurrentTopNodeId();
483 }
484
485 $tree_childs = $this->getTree()->getChilds($a_node_id);
486 $childs = array();
487 foreach($tree_childs as $tree_child)
488 {
489
490 if (!is_array($this->white_list) || in_array($tree_child["type"], $this->white_list))
491 {
492 $childs[] = array("node_id" => $tree_child["child"],
493 "title" => $tree_child["title"],
494 "type" => $tree_child["type"],
495 "depth" => $tree_child["depth"]
496 );
497 }
498 }
499
500 return $childs;
501 }
502
506 function getContent()
507 {
508 global $lng;
509
510 if ($this->getExpandVariable() != "")
511 {
512 $this->updateExpanded();
513 }
514
515 $ttpl = new ilTemplate("tpl.hierarchy_form.html", true, true, "Services/Form");
516 $ttpl->setVariable("TXT_SAVING", $lng->txt("saving"));
517 $top_node_data = $this->getTree()->getNodeData($this->getCurrentTopNodeId());
518 $top_node = array("node_id" => $top_node_data["child"],
519 "title" => $top_node_data["title"],
520 "type" => $top_node_data["type"]);
521
522 $childs = null;
523 $nodes_html = $this->getLevelHTML($top_node, 0, $childs);
524
525
526 // commands
527 $secs = array("1", "2");
528 foreach ($secs as $sec)
529 {
530 reset($this->commands);
531 reset($this->multi_commands);
532 if (count($this->multi_commands) > 0 || count($this->commands) > 0)
533 {
534 if (count($childs) > 0)
535 {
536 $single = false;
537 foreach($this->commands as $cmd)
538 {
539 $ttpl->setCurrentBlock("cmd".$sec);
540 $ttpl->setVariable("CMD", $cmd["cmd"]);
541 $ttpl->setVariable("CMD_TXT", $cmd["text"]);
542 $ttpl->parseCurrentBlock();
543 $single = true;
544 }
545
546 $multi = false;
547 foreach($this->multi_commands as $cmd)
548 {
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 {
557 $ttpl->setCurrentBlock("multi_cmds".$sec);
558 $ttpl->setVariable("MCMD_ALT", $lng->txt("commands"));
559 if ($sec == "1")
560 {
561 $ttpl->setVariable("MCMD_IMG", ilUtil::getImagePath("arrow_downright.svg"));
562 }
563 else
564 {
565 $ttpl->setVariable("MCMD_IMG", ilUtil::getImagePath("arrow_upright.svg"));
566 }
567 $ttpl->parseCurrentBlock();
568 }
569 }
570
571 if ($single || $multi)
572 {
573 $ttpl->setCurrentBlock("commands".$sec);
574 $ttpl->parseCurrentBlock();
575 }
576 $single = true;
577 }
578 }
579
580 // explorer updater
581 if ($this->exp_frame != "")
582 {
583 $ttpl->setCurrentBlock("updater");
584 $ttpl->setVariable("UPDATER_FRAME", $this->exp_frame);
585 $ttpl->setVariable("EXP_ID_UPDATER", $this->exp_id);
586 $ttpl->setVariable("HREF_UPDATER", $this->exp_target_script);
587 $ttpl->parseCurrentBlock();
588 }
589
590 // drag and drop initialisation
591 foreach($this->drag_target as $drag_target)
592 {
593 $ttpl->setCurrentBlock("dragtarget");
594 $ttpl->setVariable("EL_ID", $drag_target["id"]);
595 $ttpl->setVariable("GROUP", $drag_target["group"]);
596 $ttpl->parseCurrentBlock();
597 }
598 foreach($this->drag_content as $drag_content)
599 {
600 $ttpl->setCurrentBlock("dragcontent");
601 $ttpl->setVariable("EL_ID", $drag_content["id"]);
602 $ttpl->setVariable("GROUP", $drag_content["group"]);
603 $ttpl->parseCurrentBlock();
604 }
605
606 // disambiguation menues and "insert as first child" flags
607 if (is_array($this->diss_menues))
608 {
609 foreach($this->diss_menues as $node_id => $d_menu)
610 {
611 foreach($d_menu as $group => $menu)
612 {
613 if (count($menu) > 1)
614 {
615 foreach($menu as $menu_item)
616 {
617 $ttpl->setCurrentBlock("dmenu_cmd");
618 $ttpl->setVariable("SUBITEM", (int) $menu_item["subitem"]);
619 $ttpl->setVariable("TXT_MENU_CMD", $menu_item["text"]);
620 $ttpl->parseCurrentBlock();
621 }
622
623 $ttpl->setCurrentBlock("disambiguation_menu");
624 $ttpl->setVariable("DNODE_ID", $node_id);
625 $ttpl->setVariable("GRP", $group);
626 $ttpl->parseCurrentBlock();
627 }
628 else if (count($menu) == 1)
629 {
630 // set first child flag
631 $ttpl->setCurrentBlock("as_subitem_flag");
632 $ttpl->setVariable("SI_NODE_ID", $node_id);
633 $ttpl->setVariable("SI_GRP", $group);
634 $ttpl->setVariable("SI_SI", (int) $menu[0]["subitem"]);
635 $ttpl->parseCurrentBlock();
636
637 }
638 }
639 }
640 }
641 $this->diss_menues[$a_id][$a_group][] = array("type" => $a_type, "text" => $a_diss_text);
642
643
644 if ($this->triggered_update_command != "")
645 {
646 $ttpl->setCurrentBlock("tr_update");
647 $ttpl->setVariable("UPDATE_CMD", $this->triggered_update_command);
648 $ttpl->parseCurrentBlock();
649 }
650
651 // disambiguation menues and "insert as first child" flags
652 if (is_array($this->diss_menues))
653 {
654 foreach($this->diss_menues as $node_id => $d_menu)
655 {
656 foreach($d_menu as $group => $menu)
657 {
658 if (count($menu) > 1)
659 {
660 foreach($menu as $menu_item)
661 {
662 $ttpl->setCurrentBlock("dmenu_cmd");
663 $ttpl->setVariable("SUBITEM", (int) $menu_item["subitem"]);
664 $ttpl->setVariable("TXT_MENU_CMD", $menu_item["text"]);
665 $ttpl->parseCurrentBlock();
666 }
667
668 $ttpl->setCurrentBlock("disambiguation_menu");
669 $ttpl->setVariable("DNODE_ID", $node_id);
670 $ttpl->setVariable("GRP", $group);
671 $ttpl->parseCurrentBlock();
672 }
673 else if (count($menu) == 1)
674 {
675 // set first child flag
676 $ttpl->setCurrentBlock("as_subitem_flag");
677 $ttpl->setVariable("SI_NODE_ID", $node_id);
678 $ttpl->setVariable("SI_GRP", $group);
679 $ttpl->setVariable("SI_SI", (int) $menu[0]["subitem"]);
680 $ttpl->parseCurrentBlock();
681
682 }
683 }
684 }
685 }
686 $this->diss_menues[$a_id][$a_group][] = array("type" => $a_type, "text" => $a_diss_text);
687
688 // nodes
689 $ttpl->setVariable("NODES", $nodes_html);
690
691 // title
692//echo "<br>".htmlentities($this->getTitle())." --- ".htmlentities(ilUtil::prepareFormOutput($this->getTitle()));
693 $ttpl->setVariable("TITLE", $this->getTitle());
694
695
696 return $ttpl->get();
697 }
698
704 function getLegend()
705 {
706 global $lng;
707
708 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
709
710 $ttpl = new ilTemplate("tpl.hierarchy_form_legend.html", true, true, "Services/Form");
711 if ($this->getDragIcon() != "")
712 {
713 $ttpl->setCurrentBlock("help_drag");
714 $ttpl->setVariable("IMG_DRAG", $this->getDragIcon());
715 $ttpl->setVariable("DRAG_ARROW",
717 $ttpl->setVariable("TXT_DRAG",
718 $lng->txt("form_hierarchy_drag_drop_help"));
719 $ttpl->setVariable("PLUS", ilGlyphGUI::get(ilGlyphGUI::ADD));
720 $ttpl->parseCurrentBlock();
721 }
722
723 // additional help items
724 foreach ($this->getHelpItems() as $help)
725 {
726 if ($help["image"] != "")
727 {
728 $ttpl->setCurrentBlock("help_img");
729 $ttpl->setVariable("IMG_HELP", $help["image"]);
730 $ttpl->parseCurrentBlock();
731 }
732 $ttpl->setCurrentBlock("help_item");
733 $ttpl->setVariable("TXT_HELP", $help["text"]);
734 $ttpl->parseCurrentBlock();
735 }
736
737 $ttpl->setVariable("TXT_ADD_EL",
738 $lng->txt("form_hierarchy_add_elements"));
739 $ttpl->setVariable("PLUS2", ilGlyphGUI::get(ilGlyphGUI::ADD));
740
741 return $ttpl->get();
742 }
743
744
748 function getLevelHTML($a_par_node, $a_depth, &$a_childs)
749 {
750 global $lng;
751
752 if ($this->getMaxDepth() > -1 && $this->getMaxDepth() < $a_depth)
753 {
754 return "";
755 }
756
757 $childs = $this->getChilds($a_par_node["node_id"]);
758 $a_childs = $childs;
759 $html = "";
760 $last_child = null;
761 $ttpl = new ilTemplate("tpl.hierarchy_form_nodes.html", true, true, "Services/Form");
762
763 // prepended drop area
764 if ($this->nodeAllowsChilds($a_par_node) && (count($childs) > 0 || $a_depth == 0))
765 {
766 $ttpl->setCurrentBlock("drop_area");
767 $ttpl->setVariable("DNODE_ID", $a_par_node["node_id"]."fc"); // fc means "first child"
768 $ttpl->setVariable("IMG_BLANK", ilUtil::getImagePath("spacer.png"));
769 if (count($childs) == 0)
770 {
771 $ttpl->setVariable("NO_CONTENT_CLASS", "ilCOPGNoPageContent");
772 $ttpl->setVariable("NO_CONTENT_TXT", " &nbsp;".$lng->txt("form_hier_click_to_add"));
773 }
774 $ttpl->parseCurrentBlock();
775
776 $this->manageDragAndDrop($a_par_node, $a_depth, true, null, $childs);
777 $menu_items = $this->getMenuItems($a_par_node, $a_depth, true, null, $childs);
778//var_dump($menu_items);
779 if (count($menu_items) > 0)
780 {
781 // determine maximum of multi add numbers
782 $max = 1;
783 foreach($menu_items as $menu_item)
784 {
785 if ($menu_item["multi"] > $max)
786 {
787 $max = $menu_item["multi"];
788 }
789 }
790
791 reset($menu_items);
792 $mcnt = 1;
793 foreach($menu_items as $menu_item)
794 {
795 if ($menu_item["multi"] > 1)
796 {
797 for($i = 1; $i <= $menu_item["multi"]; $i++)
798 {
799 $ttpl->setCurrentBlock("multi_add");
800 $ttpl->setVariable("MA_NUM", $i);
801 $ttpl->setVariable("MENU_CMD", $menu_item["cmd"]);
802 $ttpl->setVariable("FC", "1");
803 $ttpl->setVariable("CMD_NODE", $a_par_node["node_id"]);
804 $ttpl->setVariable("MCNT", $mcnt."fc");
805 $ttpl->parseCurrentBlock();
806 }
807 }
808
809 // buffer td for lower multis
810 if ($max > $menu_item["multi"])
811 {
812 $ttpl->setCurrentBlock("multi_buffer");
813 $ttpl->setVariable("BUF_SPAN", $max - $menu_item["multi"]);
814 $ttpl->parseCurrentBlock();
815 }
816 $ttpl->setCurrentBlock("menu_cmd");
817 $ttpl->setVariable("TXT_MENU_CMD", $menu_item["text"]);
818 $ttpl->setVariable("MENU_CMD", $menu_item["cmd"]);
819 $ttpl->setVariable("CMD_NODE", $a_par_node["node_id"]);
820 $ttpl->setVariable("FC", "1");
821 $ttpl->setVariable("MCNT", $mcnt."fc");
822 $ttpl->parseCurrentBlock();
823 $mcnt++;
824 }
825 $ttpl->setCurrentBlock("drop_area_menu");
826 $ttpl->setVariable("MNODE_ID", $a_par_node["node_id"]."fc");
827 $ttpl->parseCurrentBlock();
828
829 $ttpl->setCurrentBlock("element");
830 $ttpl->parseCurrentBlock();
831 }
832 }
833
834 // insert childs
835 if (count($childs) > 0)
836 {
837 for($i = 0; $i < count($childs); $i++)
838 {
839 $next_sibling = ($i < (count($childs) - 1))
840 ? $next_sibling = $childs[$i+1]
841 : null;
842
843 $this->renderChild($ttpl, $childs[$i], $a_depth, $next_sibling);
844 $last_child = $child;
845 }
846 }
847
848 $html = $ttpl->get();
849 unset($ttpl);
850
851 return $html;
852 }
853
857 function renderChild($a_tpl, $a_child, $a_depth, $next_sibling = null)
858 {
859 global $ilCtrl;
860
861 // image
862 $a_tpl->setCurrentBlock("img");
863 $a_tpl->setVariable("IMGPATH", $this->getChildIcon($a_child));
864 $a_tpl->setVariable("IMGALT", $this->getChildIconAlt($a_child));
865 $a_tpl->setVariable("IMG_NODE", $a_child["node_id"]);
866 $a_tpl->setVariable("NODE_ID", $a_child["node_id"]);
867 $a_tpl->setVariable("TYPE", $a_child["type"]);
868 $a_tpl->parseCurrentBlock();
869
870 // checkbox
871 $a_tpl->setCurrentBlock("cbox");
872 $a_tpl->setVariable("CNODE_ID", $a_child["node_id"]);
873 $a_tpl->setVariable("CBOX_NAME", $this->getCheckboxName());
874 $a_tpl->parseCurrentBlock();
875
876 // node info
877 if (($info = $this->getChildInfo($a_child)) != "")
878 {
879 $a_tpl->setCurrentBlock("node_info");
880 $a_tpl->setVariable("NODE_INFO", $info);
881 $a_tpl->parseCurrentBlock();
882 }
883
884 // commands of child node
885 $child_commands = $this->getChildCommands($a_child);
886 if (is_array($child_commands))
887 {
888 foreach($child_commands as $command)
889 {
890 $a_tpl->setCurrentBlock("node_cmd");
891 $a_tpl->setVariable("HREF_NODE_CMD", $command["link"]);
892 $a_tpl->setVariable("TXT_NODE_CMD", $command["text"]);
893 $a_tpl->parseCurrentBlock();
894 }
895 }
896
897 // title
898 $a_tpl->setCurrentBlock("text");
899 $hl = $this->getHighlightedNodes();
900 if (is_array($hl) && in_array($a_child["node_id"], $hl))
901 {
902 $a_tpl->setVariable("CLASS", ' class="ilHFormHighlighted" ');
903 }
904 $a_tpl->setVariable("VAL_TITLE", ilUtil::prepareFormOutput($this->getChildTitle($a_child)));
905 $a_tpl->setVariable("TNODE_ID", $a_child["node_id"]);
906 $a_tpl->parseCurrentBlock();
907 $grandchilds = null;
908 $grandchilds_html = $this->getLevelHTML($a_child, $a_depth + 1, $grandchilds);
909
910 // focus
911 if ($this->getFocusId() == $a_child["node_id"])
912 {
913 $a_tpl->setCurrentBlock("focus");
914 $a_tpl->setVariable("FNODE_ID", $a_child["node_id"]);
915 $a_tpl->parseCurrentBlock();
916 }
917
918 // expander
919 if ($this->getExpandVariable() != "")
920 {
921 $a_tpl->setCurrentBlock("expand_icon");
922 if (!is_null($grandchilds) && count($grandchilds) > 0)
923 {
924 if (!in_array($a_child["node_id"],$this->getExpanded()))
925 {
926 $ilCtrl->setParameter($this->getParentObject(), $this->getExpandVariable(), $a_child["node_id"]);
927 $a_tpl->setVariable("IMG_EXPAND", ilUtil::getImagePath("browser/plus.png"));
928 $a_tpl->setVariable("HREF_NAME", "n".$a_child["node_id"]);
929 $a_tpl->setVariable("HREF_EXPAND",
930 $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCommand(), "n".$a_child["node_id"]));
931 $grandchilds_html = "";
932 }
933 else
934 {
935 $ilCtrl->setParameter($this->getParentObject(), $this->getExpandVariable(), -$a_child["node_id"]);
936 $a_tpl->setVariable("IMG_EXPAND", ilUtil::getImagePath("browser/minus.png"));
937 $a_tpl->setVariable("HREF_NAME", "n".$a_child["node_id"]);
938 $a_tpl->setVariable("HREF_EXPAND",
939 $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCommand(), "n".$a_child["node_id"]));
940 }
941 $ilCtrl->setParameter($this->getParentObject(), $this->getExpandVariable(), "");
942 }
943 else
944 {
945 $a_tpl->setVariable("IMG_EXPAND", ilUtil::getImagePath("spacer.png"));
946 }
947 $a_tpl->parseCurrentBlock();
948 }
949
950 // childs
951 $a_tpl->setCurrentBlock("list_item");
952 $a_tpl->setVariable("CHILDS", $grandchilds_html);
953 $a_tpl->parseCurrentBlock();
954
955 $a_tpl->setCurrentBlock("element");
956 $a_tpl->parseCurrentBlock();
957
958 // drop area after child
959 $a_tpl->setCurrentBlock("drop_area");
960 $a_tpl->setVariable("DNODE_ID", $a_child["node_id"]);
961 $a_tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("spacer.png"));
962 $a_tpl->parseCurrentBlock();
963
964 // manage drag and drop areas
965 $this->manageDragAndDrop($a_child, $a_depth, false, $next_sibling, $grandchilds);
966
967 // drop area menu
968 $menu_items = $this->getMenuItems($a_child, $a_depth, false, $next_sibling, $grandchilds);
969 if (count($menu_items) > 0)
970 {
971 // determine maximum of multi add numbers
972 $max = 1;
973 foreach($menu_items as $menu_item)
974 {
975 if ($menu_item["multi"] > $max)
976 {
977 $max = $menu_item["multi"];
978 }
979 }
980
981 reset($menu_items);
982 $mcnt = 1;
983 foreach($menu_items as $menu_item)
984 {
985 if ($menu_item["multi"] > 1 )
986 {
987 for($i = 1; $i <= $menu_item["multi"]; $i++)
988 {
989 $a_tpl->setCurrentBlock("multi_add");
990 $a_tpl->setVariable("MA_NUM", $i);
991 $a_tpl->setVariable("MENU_CMD", $menu_item["cmd"]);
992 if ($menu_item["as_subitem"])
993 {
994 $a_tpl->setVariable("FC", "1");
995 $a_tpl->setVariable("MCNT", $mcnt."fc");
996 }
997 else
998 {
999 $a_tpl->setVariable("FC", "0");
1000 $a_tpl->setVariable("MCNT", $mcnt);
1001 }
1002 $a_tpl->setVariable("CMD_NODE", $a_child["node_id"]);
1003 $a_tpl->parseCurrentBlock();
1004 }
1005 }
1006
1007 // buffer td for lower multis
1008 if ($max > $menu_item["multi"])
1009 {
1010 $a_tpl->setCurrentBlock("multi_buffer");
1011 $a_tpl->setVariable("BUF_SPAN", $max - $menu_item["multi"]);
1012 $a_tpl->parseCurrentBlock();
1013 }
1014
1015 $a_tpl->setCurrentBlock("menu_cmd");
1016 $a_tpl->setVariable("TXT_MENU_CMD", $menu_item["text"]);
1017 $a_tpl->setVariable("MENU_CMD", $menu_item["cmd"]);
1018 if ($menu_item["as_subitem"])
1019 {
1020 $a_tpl->setVariable("FC", "1");
1021 $a_tpl->setVariable("MCNT", $mcnt."fc");
1022 }
1023 else
1024 {
1025 $a_tpl->setVariable("FC", "0");
1026 $a_tpl->setVariable("MCNT", $mcnt);
1027 }
1028 $a_tpl->setVariable("CMD_NODE", $a_child["node_id"]);
1029 $a_tpl->parseCurrentBlock();
1030 $mcnt++;
1031 }
1032 $a_tpl->setCurrentBlock("drop_area_menu");
1033 $a_tpl->setVariable("MNODE_ID", $a_child["node_id"]);
1034 $a_tpl->parseCurrentBlock();
1035 }
1036
1037 $a_tpl->setCurrentBlock("element");
1038 $a_tpl->parseCurrentBlock();
1039 }
1040
1047 function getChildIcon($a_item)
1048 {
1049 return ilUtil::getImagePath("icon_".$a_item["type"].".svg");
1050 }
1051
1058 function getChildIconAlt($a_item)
1059 {
1060 global $lng;
1061
1062 return $lng->txt($a_item["type"]);
1063 }
1064
1071 function getChildCommands($a_item)
1072 {
1073 return false;
1074 }
1075
1082 function getChildTitle($a_child)
1083 {
1084 return $a_child["title"];
1085 }
1086
1093 function getChildInfo($a_child)
1094 {
1095 return "";
1096 }
1097
1110 function getMenuItems($a_node, $a_depth, $a_first_child = false, $a_next_sibling = null, $a_childs = null)
1111 {
1112 return array();
1113 }
1114
1119 function nodeAllowsChilds($a_node)
1120 {
1121 return true;
1122 }
1123
1130 function manageDragAndDrop($a_node, $a_depth, $a_first_child = false, $a_next_sibling = null, $a_childs = null)
1131 {
1132 //$this->makeDragTarget($a_node["id"], $a_group);
1133 //$this->makeDragTarget($a_node["id"], $a_group);
1134 }
1135
1139 static function getPostMulti()
1140 {
1141 return (int) ($_POST["il_hform_multi"] > 1
1142 ? $_POST["il_hform_multi"]
1143 : 1);
1144 }
1145
1149 static function getPostNodeId()
1150 {
1151 return $_POST["il_hform_node"];
1152 }
1153
1157 static function getPostFirstChild()
1158 {
1159 return (((int) $_POST["il_hform_fc"]) == 1);
1160 }
1161
1168 function getHTML()
1169 {
1170 return parent::getHTML().$this->getLegend();
1171 }
1172
1176 static function getPostFields()
1177 {
1178 return array (
1179 "il_hform_node" => $_POST["il_hform_node"],
1180 "il_hform_fc" => $_POST["il_hform_fc"],
1181 "il_hform_as_subitem" => $_POST["il_hform_as_subitem"],
1182 "il_hform_multi" => $_POST["il_hform_multi"],
1183 "il_hform_source_id" => $_POST["il_hform_source_id"],
1184 "il_hform_target_id" => $_POST["il_hform_target_id"]
1185 );
1186 }
1187
1188}
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
$_SESSION["AccountId"]
This class represents a form user interface.
static get($a_glyph, $a_text="")
Get glyph html.
This class represents a hierarchical form.
getCurrentTopNodeId()
Get Current Top Node ID.
getHighlightedNodes()
Get highlighted nodes.
getMaxDepth()
Get Maximum Depth.
static getPostNodeId()
Get node ID of _POST input.
getChildInfo($a_child)
Get child info.
setHighlightedNodes($a_val)
Set highlighted nodes.
addHelpItem($a_text, $a_image="")
Get all help items.
setCheckboxName($a_checkboxname)
Set Checkbox Name.
setTree($a_tree)
Set Tree Object.
getCheckboxName()
Get Checkbox Name.
nodeAllowsChilds($a_node)
Checks, whether current nodes allows childs at all.
getChildIcon($a_item)
Get icon path for an item.
getExpandVariable()
Get expand variable.
setMaxDepth($a_maxdepth)
Set Maximum Depth.
getExpanded()
Get expanded array.
getDragIcon()
Get Drag Icon Path.
getLevelHTML($a_par_node, $a_depth, &$a_childs)
Get Form HTML.
addCommand($a_txt, $a_cmd)
Add a command.
setFocusId($a_val)
Set focus if.
getChildIconAlt($a_item)
Get icon alt text for an item.
setDragIcon($a_dragicon)
Set Drag Icon Path.
getChildCommands($a_item)
Get item commands.
setTriggeredUpdateCommand($a_triggered_update_command)
Set Explorer Updater.
getTypeWhiteList()
Get type whitelist.
setCurrentTopNodeId($a_currenttopnodeid)
Set Current Top Node ID.
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)
static getPostFields()
Get all post fields.
getChilds($a_node_id=false)
Get all childs of current node.
renderChild($a_tpl, $a_child, $a_depth, $next_sibling=null)
Render a single child (including grandchilds)
setTitle($a_title)
Set Title.
getParentObject()
Get Parent object.
makeDragContent($a_id, $a_group)
Makes a node a drag content.
getContent()
Get Form Content.
setParentCommand($a_parent_obj, $a_parent_cmd)
Set parent gui object/cmd.
getChildTitle($a_child)
Get child title.
setExpandVariable($a_val)
Set expand variable.
setTypeWhiteList($a_val)
Set type whitelist.
setExplorerUpdater($a_exp_frame, $a_exp_id, $a_exp_target_script)
Set Explorer Updater.
manageDragAndDrop($a_node, $a_depth, $a_first_child=false, $a_next_sibling=null, $a_childs=null)
Makes nodes drag and drop content and targets.
getHelpItems()
Get all help items.
getParentCommand()
Get parent command.
updateExpanded()
Update expand information in session.
static getPostFirstChild()
Should node be inserted as first child of target node (true) or as successor (false)
static getPostMulti()
Get multi number of _POST input.
setExpanded($a_val)
Set expanded Array.
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.
special template class to simplify handling of ITX/PEAR
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
static initDragDrop()
Init YUI Drag and Drop.
$_POST['username']
Definition: cron.php:12
$html
Definition: example_001.php:87
$info
Definition: example_052.php:80
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35