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