ILIAS  release_4-4 Revision
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  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 
66  function getParentCommand()
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 
186  function getCheckboxName()
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 
386  function getExpandVariable()
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 
469  function getTypeWhiteList()
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  // icon
526  if ($this->getIcon() != "")
527  {
528  $ttpl->setCurrentBlock("icon");
529  $ttpl->setVariable("SRC_ICON", $this->getIcon());
530  $ttpl->parseCurrentBlock();
531  }
532 
533  // commands
534  $secs = array("1", "2");
535  foreach ($secs as $sec)
536  {
537  reset($this->commands);
538  reset($this->multi_commands);
539  if (count($this->multi_commands) > 0 || count($this->commands) > 0)
540  {
541  if (count($childs) > 0)
542  {
543  $single = false;
544  foreach($this->commands as $cmd)
545  {
546  $ttpl->setCurrentBlock("cmd".$sec);
547  $ttpl->setVariable("CMD", $cmd["cmd"]);
548  $ttpl->setVariable("CMD_TXT", $cmd["text"]);
549  $ttpl->parseCurrentBlock();
550  $single = true;
551  }
552 
553  $multi = false;
554  foreach($this->multi_commands as $cmd)
555  {
556  $ttpl->setCurrentBlock("multi_cmd".$sec);
557  $ttpl->setVariable("MULTI_CMD", $cmd["cmd"]);
558  $ttpl->setVariable("MULTI_CMD_TXT", $cmd["text"]);
559  $ttpl->parseCurrentBlock();
560  $multi = true;
561  }
562  if ($multi)
563  {
564  $ttpl->setCurrentBlock("multi_cmds".$sec);
565  $ttpl->setVariable("MCMD_ALT", $lng->txt("commands"));
566  if ($sec == "1")
567  {
568  $ttpl->setVariable("MCMD_IMG", ilUtil::getImagePath("arrow_downright.png"));
569  }
570  else
571  {
572  $ttpl->setVariable("MCMD_IMG", ilUtil::getImagePath("arrow_upright.png"));
573  }
574  $ttpl->parseCurrentBlock();
575  }
576  }
577 
578  if ($single || $multi)
579  {
580  $ttpl->setCurrentBlock("commands".$sec);
581  $ttpl->parseCurrentBlock();
582  }
583  $single = true;
584  }
585  }
586 
587  // explorer updater
588  if ($this->exp_frame != "")
589  {
590  $ttpl->setCurrentBlock("updater");
591  $ttpl->setVariable("UPDATER_FRAME", $this->exp_frame);
592  $ttpl->setVariable("EXP_ID_UPDATER", $this->exp_id);
593  $ttpl->setVariable("HREF_UPDATER", $this->exp_target_script);
594  $ttpl->parseCurrentBlock();
595  }
596 
597  // drag and drop initialisation
598  foreach($this->drag_target as $drag_target)
599  {
600  $ttpl->setCurrentBlock("dragtarget");
601  $ttpl->setVariable("EL_ID", $drag_target["id"]);
602  $ttpl->setVariable("GROUP", $drag_target["group"]);
603  $ttpl->parseCurrentBlock();
604  }
605  foreach($this->drag_content as $drag_content)
606  {
607  $ttpl->setCurrentBlock("dragcontent");
608  $ttpl->setVariable("EL_ID", $drag_content["id"]);
609  $ttpl->setVariable("GROUP", $drag_content["group"]);
610  $ttpl->parseCurrentBlock();
611  }
612 
613  // disambiguation menues and "insert as first child" flags
614  if (is_array($this->diss_menues))
615  {
616  foreach($this->diss_menues as $node_id => $d_menu)
617  {
618  foreach($d_menu as $group => $menu)
619  {
620  if (count($menu) > 1)
621  {
622  foreach($menu as $menu_item)
623  {
624  $ttpl->setCurrentBlock("dmenu_cmd");
625  $ttpl->setVariable("SUBITEM", (int) $menu_item["subitem"]);
626  $ttpl->setVariable("TXT_MENU_CMD", $menu_item["text"]);
627  $ttpl->parseCurrentBlock();
628  }
629 
630  $ttpl->setCurrentBlock("disambiguation_menu");
631  $ttpl->setVariable("DNODE_ID", $node_id);
632  $ttpl->setVariable("GRP", $group);
633  $ttpl->parseCurrentBlock();
634  }
635  else if (count($menu) == 1)
636  {
637  // set first child flag
638  $ttpl->setCurrentBlock("as_subitem_flag");
639  $ttpl->setVariable("SI_NODE_ID", $node_id);
640  $ttpl->setVariable("SI_GRP", $group);
641  $ttpl->setVariable("SI_SI", (int) $menu[0]["subitem"]);
642  $ttpl->parseCurrentBlock();
643 
644  }
645  }
646  }
647  }
648  $this->diss_menues[$a_id][$a_group][] = array("type" => $a_type, "text" => $a_diss_text);
649 
650  // help
651  $ttpl->setCurrentBlock("help_img");
652  $ttpl->setVariable("IMG_HELP", ilUtil::getImagePath("streaked_area.png"));
653  $ttpl->parseCurrentBlock();
654  $ttpl->setCurrentBlock("help_section");
655  $ttpl->setVariable("TXT_HELP",
656  $lng->txt("form_hierarchy_add_elements"));
657  $ttpl->parseCurrentBlock();
658 
659  if ($this->getDragIcon() != "")
660  {
661  $ttpl->setCurrentBlock("help_img");
662  $ttpl->setVariable("IMG_HELP", $this->getDragIcon());
663  $ttpl->parseCurrentBlock();
664  $ttpl->setCurrentBlock("help_img");
665  $ttpl->setVariable("IMG_HELP",
666  ilUtil::getImagePath("drop_streaked_area.png"));
667  $ttpl->parseCurrentBlock();
668  $ttpl->setCurrentBlock("help_section");
669  $ttpl->setVariable("TXT_HELP",
670  $lng->txt("form_hierarchy_drag_drop_help"));
671  $ttpl->parseCurrentBlock();
672  }
673 
674  // additional help items
675  foreach ($this->getHelpItems() as $help)
676  {
677  if ($help["image"] != "")
678  {
679  $ttpl->setCurrentBlock("help_img");
680  $ttpl->setVariable("IMG_HELP", $help["image"]);
681  $ttpl->parseCurrentBlock();
682  }
683  $ttpl->setCurrentBlock("help_section");
684  $ttpl->setVariable("TXT_HELP", $help["text"]);
685  $ttpl->parseCurrentBlock();
686  }
687 
688  if ($this->triggered_update_command != "")
689  {
690  $ttpl->setCurrentBlock("tr_update");
691  $ttpl->setVariable("UPDATE_CMD", $this->triggered_update_command);
692  $ttpl->parseCurrentBlock();
693  }
694 
695  // disambiguation menues and "insert as first child" flags
696  if (is_array($this->diss_menues))
697  {
698  foreach($this->diss_menues as $node_id => $d_menu)
699  {
700  foreach($d_menu as $group => $menu)
701  {
702  if (count($menu) > 1)
703  {
704  foreach($menu as $menu_item)
705  {
706  $ttpl->setCurrentBlock("dmenu_cmd");
707  $ttpl->setVariable("SUBITEM", (int) $menu_item["subitem"]);
708  $ttpl->setVariable("TXT_MENU_CMD", $menu_item["text"]);
709  $ttpl->parseCurrentBlock();
710  }
711 
712  $ttpl->setCurrentBlock("disambiguation_menu");
713  $ttpl->setVariable("DNODE_ID", $node_id);
714  $ttpl->setVariable("GRP", $group);
715  $ttpl->parseCurrentBlock();
716  }
717  else if (count($menu) == 1)
718  {
719  // set first child flag
720  $ttpl->setCurrentBlock("as_subitem_flag");
721  $ttpl->setVariable("SI_NODE_ID", $node_id);
722  $ttpl->setVariable("SI_GRP", $group);
723  $ttpl->setVariable("SI_SI", (int) $menu[0]["subitem"]);
724  $ttpl->parseCurrentBlock();
725 
726  }
727  }
728  }
729  }
730  $this->diss_menues[$a_id][$a_group][] = array("type" => $a_type, "text" => $a_diss_text);
731 
732  // nodes
733  $ttpl->setVariable("NODES", $nodes_html);
734 
735  // title
736 //echo "<br>".htmlentities($this->getTitle())." --- ".htmlentities(ilUtil::prepareFormOutput($this->getTitle()));
737  $ttpl->setVariable("TITLE", $this->getTitle());
738 
739 
740  return $ttpl->get();
741  }
742 
746  function getLevelHTML($a_par_node, $a_depth, &$a_childs)
747  {
748  global $lng;
749 
750  if ($this->getMaxDepth() > -1 && $this->getMaxDepth() < $a_depth)
751  {
752  return "";
753  }
754 
755  $childs = $this->getChilds($a_par_node["node_id"]);
756  $a_childs = $childs;
757  $html = "";
758  $last_child = null;
759  $ttpl = new ilTemplate("tpl.hierarchy_form_nodes.html", true, true, "Services/Form");
760 
761  // prepended drop area
762  if ($this->nodeAllowsChilds($a_par_node) && (count($childs) > 0 || $a_depth == 0))
763  {
764  $ttpl->setCurrentBlock("drop_area");
765  $ttpl->setVariable("DNODE_ID", $a_par_node["node_id"]."fc"); // fc means "first child"
766  $ttpl->setVariable("IMG_BLANK", ilUtil::getImagePath("spacer.png"));
767  $ttpl->parseCurrentBlock();
768 
769  $this->manageDragAndDrop($a_par_node, $a_depth, true, null, $childs);
770  $menu_items = $this->getMenuItems($a_par_node, $a_depth, true, null, $childs);
771 //var_dump($menu_items);
772  if (count($menu_items) > 0)
773  {
774  // determine maximum of multi add numbers
775  $max = 1;
776  foreach($menu_items as $menu_item)
777  {
778  if ($menu_item["multi"] > $max)
779  {
780  $max = $menu_item["multi"];
781  }
782  }
783 
784  reset($menu_items);
785  $mcnt = 1;
786  foreach($menu_items as $menu_item)
787  {
788  if ($menu_item["multi"] > 1)
789  {
790  for($i = 1; $i <= $menu_item["multi"]; $i++)
791  {
792  $ttpl->setCurrentBlock("multi_add");
793  $ttpl->setVariable("MA_NUM", $i);
794  $ttpl->setVariable("MENU_CMD", $menu_item["cmd"]);
795  $ttpl->setVariable("FC", "1");
796  $ttpl->setVariable("CMD_NODE", $a_par_node["node_id"]);
797  $ttpl->setVariable("MCNT", $mcnt."fc");
798  $ttpl->parseCurrentBlock();
799  }
800  }
801 
802  // buffer td for lower multis
803  if ($max > $menu_item["multi"])
804  {
805  $ttpl->setCurrentBlock("multi_buffer");
806  $ttpl->setVariable("BUF_SPAN", $max - $menu_item["multi"]);
807  $ttpl->parseCurrentBlock();
808  }
809  $ttpl->setCurrentBlock("menu_cmd");
810  $ttpl->setVariable("TXT_MENU_CMD", $menu_item["text"]);
811  $ttpl->setVariable("MENU_CMD", $menu_item["cmd"]);
812  $ttpl->setVariable("CMD_NODE", $a_par_node["node_id"]);
813  $ttpl->setVariable("FC", "1");
814  $ttpl->setVariable("MCNT", $mcnt."fc");
815  $ttpl->parseCurrentBlock();
816  $mcnt++;
817  }
818  $ttpl->setCurrentBlock("drop_area_menu");
819  $ttpl->setVariable("MNODE_ID", $a_par_node["node_id"]."fc");
820  $ttpl->parseCurrentBlock();
821 
822  $ttpl->setCurrentBlock("element");
823  $ttpl->parseCurrentBlock();
824  }
825  }
826 
827  // insert childs
828  if (count($childs) > 0)
829  {
830  for($i = 0; $i < count($childs); $i++)
831  {
832  $next_sibling = ($i < (count($childs) - 1))
833  ? $next_sibling = $childs[$i+1]
834  : null;
835 
836  $this->renderChild($ttpl, $childs[$i], $a_depth, $next_sibling);
837  $last_child = $child;
838  }
839  }
840 
841  $html = $ttpl->get();
842  unset($ttpl);
843 
844  return $html;
845  }
846 
850  function renderChild($a_tpl, $a_child, $a_depth, $next_sibling = null)
851  {
852  global $ilCtrl;
853 
854  // image
855  $a_tpl->setCurrentBlock("img");
856  $a_tpl->setVariable("IMGPATH", $this->getChildIcon($a_child));
857  $a_tpl->setVariable("IMGALT", $this->getChildIconAlt($a_child));
858  $a_tpl->setVariable("IMG_NODE", $a_child["node_id"]);
859  $a_tpl->setVariable("NODE_ID", $a_child["node_id"]);
860  $a_tpl->setVariable("TYPE", $a_child["type"]);
861  $a_tpl->parseCurrentBlock();
862 
863  // checkbox
864  $a_tpl->setCurrentBlock("cbox");
865  $a_tpl->setVariable("CNODE_ID", $a_child["node_id"]);
866  $a_tpl->setVariable("CBOX_NAME", $this->getCheckboxName());
867  $a_tpl->parseCurrentBlock();
868 
869  // node info
870  if (($info = $this->getChildInfo($a_child)) != "")
871  {
872  $a_tpl->setCurrentBlock("node_info");
873  $a_tpl->setVariable("NODE_INFO", $info);
874  $a_tpl->parseCurrentBlock();
875  }
876 
877  // commands of child node
878  $child_commands = $this->getChildCommands($a_child);
879  if (is_array($child_commands))
880  {
881  foreach($child_commands as $command)
882  {
883  $a_tpl->setCurrentBlock("node_cmd");
884  $a_tpl->setVariable("HREF_NODE_CMD", $command["link"]);
885  $a_tpl->setVariable("TXT_NODE_CMD", $command["text"]);
886  $a_tpl->parseCurrentBlock();
887  }
888  }
889 
890  // title
891  $a_tpl->setCurrentBlock("text");
892  $hl = $this->getHighlightedNodes();
893  if (is_array($hl) && in_array($a_child["node_id"], $hl))
894  {
895  $a_tpl->setVariable("CLASS", ' class="ilHFormHighlighted" ');
896  }
897  $a_tpl->setVariable("VAL_TITLE", ilUtil::prepareFormOutput($this->getChildTitle($a_child)));
898  $a_tpl->setVariable("TNODE_ID", $a_child["node_id"]);
899  $a_tpl->parseCurrentBlock();
900  $grandchilds = null;
901  $grandchilds_html = $this->getLevelHTML($a_child, $a_depth + 1, $grandchilds);
902 
903  // focus
904  if ($this->getFocusId() == $a_child["node_id"])
905  {
906  $a_tpl->setCurrentBlock("focus");
907  $a_tpl->setVariable("FNODE_ID", $a_child["node_id"]);
908  $a_tpl->parseCurrentBlock();
909  }
910 
911  // expander
912  if ($this->getExpandVariable() != "")
913  {
914  $a_tpl->setCurrentBlock("expand_icon");
915  if (!is_null($grandchilds) && count($grandchilds) > 0)
916  {
917  if (!in_array($a_child["node_id"],$this->getExpanded()))
918  {
919  $ilCtrl->setParameter($this->getParentObject(), $this->getExpandVariable(), $a_child["node_id"]);
920  $a_tpl->setVariable("IMG_EXPAND", ilUtil::getImagePath("browser/plus.png"));
921  $a_tpl->setVariable("HREF_NAME", "n".$a_child["node_id"]);
922  $a_tpl->setVariable("HREF_EXPAND",
923  $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCommand(), "n".$a_child["node_id"]));
924  $grandchilds_html = "";
925  }
926  else
927  {
928  $ilCtrl->setParameter($this->getParentObject(), $this->getExpandVariable(), -$a_child["node_id"]);
929  $a_tpl->setVariable("IMG_EXPAND", ilUtil::getImagePath("browser/minus.png"));
930  $a_tpl->setVariable("HREF_NAME", "n".$a_child["node_id"]);
931  $a_tpl->setVariable("HREF_EXPAND",
932  $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCommand(), "n".$a_child["node_id"]));
933  }
934  $ilCtrl->setParameter($this->getParentObject(), $this->getExpandVariable(), "");
935  }
936  else
937  {
938  $a_tpl->setVariable("IMG_EXPAND", ilUtil::getImagePath("spacer.png"));
939  }
940  $a_tpl->parseCurrentBlock();
941  }
942 
943  // childs
944  $a_tpl->setCurrentBlock("list_item");
945  $a_tpl->setVariable("CHILDS", $grandchilds_html);
946  $a_tpl->parseCurrentBlock();
947 
948  $a_tpl->setCurrentBlock("element");
949  $a_tpl->parseCurrentBlock();
950 
951  // drop area after child
952  $a_tpl->setCurrentBlock("drop_area");
953  $a_tpl->setVariable("DNODE_ID", $a_child["node_id"]);
954  $a_tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("spacer.png"));
955  $a_tpl->parseCurrentBlock();
956 
957  // manage drag and drop areas
958  $this->manageDragAndDrop($a_child, $a_depth, false, $next_sibling, $grandchilds);
959 
960  // drop area menu
961  $menu_items = $this->getMenuItems($a_child, $a_depth, false, $next_sibling, $grandchilds);
962  if (count($menu_items) > 0)
963  {
964  // determine maximum of multi add numbers
965  $max = 1;
966  foreach($menu_items as $menu_item)
967  {
968  if ($menu_item["multi"] > $max)
969  {
970  $max = $menu_item["multi"];
971  }
972  }
973 
974  reset($menu_items);
975  $mcnt = 1;
976  foreach($menu_items as $menu_item)
977  {
978  if ($menu_item["multi"] > 1 )
979  {
980  for($i = 1; $i <= $menu_item["multi"]; $i++)
981  {
982  $a_tpl->setCurrentBlock("multi_add");
983  $a_tpl->setVariable("MA_NUM", $i);
984  $a_tpl->setVariable("MENU_CMD", $menu_item["cmd"]);
985  if ($menu_item["as_subitem"])
986  {
987  $a_tpl->setVariable("FC", "1");
988  $a_tpl->setVariable("MCNT", $mcnt."fc");
989  }
990  else
991  {
992  $a_tpl->setVariable("FC", "0");
993  $a_tpl->setVariable("MCNT", $mcnt);
994  }
995  $a_tpl->setVariable("CMD_NODE", $a_child["node_id"]);
996  $a_tpl->parseCurrentBlock();
997  }
998  }
999 
1000  // buffer td for lower multis
1001  if ($max > $menu_item["multi"])
1002  {
1003  $a_tpl->setCurrentBlock("multi_buffer");
1004  $a_tpl->setVariable("BUF_SPAN", $max - $menu_item["multi"]);
1005  $a_tpl->parseCurrentBlock();
1006  }
1007 
1008  $a_tpl->setCurrentBlock("menu_cmd");
1009  $a_tpl->setVariable("TXT_MENU_CMD", $menu_item["text"]);
1010  $a_tpl->setVariable("MENU_CMD", $menu_item["cmd"]);
1011  if ($menu_item["as_subitem"])
1012  {
1013  $a_tpl->setVariable("FC", "1");
1014  $a_tpl->setVariable("MCNT", $mcnt."fc");
1015  }
1016  else
1017  {
1018  $a_tpl->setVariable("FC", "0");
1019  $a_tpl->setVariable("MCNT", $mcnt);
1020  }
1021  $a_tpl->setVariable("CMD_NODE", $a_child["node_id"]);
1022  $a_tpl->parseCurrentBlock();
1023  $mcnt++;
1024  }
1025  $a_tpl->setCurrentBlock("drop_area_menu");
1026  $a_tpl->setVariable("MNODE_ID", $a_child["node_id"]);
1027  $a_tpl->parseCurrentBlock();
1028  }
1029 
1030  $a_tpl->setCurrentBlock("element");
1031  $a_tpl->parseCurrentBlock();
1032  }
1033 
1040  function getChildIcon($a_item)
1041  {
1042  return ilUtil::getImagePath("icon_".$a_item["type"].".png");
1043  }
1044 
1051  function getChildIconAlt($a_item)
1052  {
1053  global $lng;
1054 
1055  return $lng->txt($a_item["type"]);
1056  }
1057 
1064  function getChildCommands($a_item)
1065  {
1066  return false;
1067  }
1068 
1075  function getChildTitle($a_child)
1076  {
1077  return $a_child["title"];
1078  }
1079 
1086  function getChildInfo($a_child)
1087  {
1088  return "";
1089  }
1090 
1103  function getMenuItems($a_node, $a_depth, $a_first_child = false, $a_next_sibling = null, $a_childs = null)
1104  {
1105  return array();
1106  }
1107 
1112  function nodeAllowsChilds($a_node)
1113  {
1114  return true;
1115  }
1116 
1123  function manageDragAndDrop($a_node, $a_depth, $a_first_child = false, $a_next_sibling = null, $a_childs = null)
1124  {
1125  //$this->makeDragTarget($a_node["id"], $a_group);
1126  //$this->makeDragTarget($a_node["id"], $a_group);
1127  }
1128 
1132  static function getPostMulti()
1133  {
1134  return (int) ($_POST["il_hform_multi"] > 1
1135  ? $_POST["il_hform_multi"]
1136  : 1);
1137  }
1138 
1142  static function getPostNodeId()
1143  {
1144  return $_POST["il_hform_node"];
1145  }
1146 
1150  static function getPostFirstChild()
1151  {
1152  return (((int) $_POST["il_hform_fc"]) == 1);
1153  }
1154 
1155 }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
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.
$_POST['username']
Definition: cron.php:12
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.
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 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.
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.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
addMultiCommand($a_txt, $a_cmd)
Add a multi command (for selection of items)
addHelpItem($a_text, $a_image="")
Get all help items.
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:40
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.
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.