4 include_once(
"./Services/Form/classes/class.ilFormGUI.php");
26 $this->multi_commands =
array();
27 $this->commands =
array();
28 $this->drag_target[] =
array();
29 $this->drag_content[] =
array();
30 $lng->loadLanguageModule(
"form");
32 $this->help_items =
array();
34 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
36 $tpl->addJavascript(
"./Services/Form/js/ServiceFormHierarchyForm.js");
46 $this->parent_obj = $a_parent_obj;
47 $this->parent_cmd = $a_parent_cmd;
57 return $this->parent_obj;
67 return $this->parent_cmd;
77 die(
"ilHierarchyFormGUI does currently not support multiple forms (multiple IDs). ID is always hform.");
97 $this->tree = $a_tree;
117 $this->currenttopnodeid = $a_currenttopnodeid;
127 return $this->currenttopnodeid;
137 $this->title = $a_title;
157 $this->icon = $a_icon;
177 $this->checkboxname = $a_checkboxname;
187 return $this->checkboxname;
197 $this->dragicon = $a_dragicon;
207 return $this->dragicon;
217 $this->maxdepth = $a_maxdepth;
227 return $this->maxdepth;
237 $this->exp_frame = $a_exp_frame;
238 $this->exp_id = $a_exp_id;
239 $this->exp_target_script = $a_exp_target_script;
249 $this->triggered_update_command = $a_triggered_update_command;
257 $this->help_items[] =
array(
"text" => $a_text,
258 "image" => $a_image);
266 return $this->help_items;
275 function makeDragTarget($a_id, $a_group, $a_first_child_drop_area =
false, $a_as_subitem =
false, $a_diss_text =
"")
277 if ($a_first_child_drop_area ==
true)
279 $a_as_subitem =
true;
284 if ($a_first_child_drop_area)
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);
304 $this->drag_content[] =
array(
"id" => $a_id,
"group" => $a_group);
316 $this->multi_commands[] =
array(
"text" => $a_txt,
"cmd" => $a_cmd);
327 $this->commands[] =
array(
"text" => $a_txt,
"cmd" => $a_cmd);
337 $this->highlighted_nodes = $a_val;
347 return $this->highlighted_nodes;
357 $this->focus_id = $a_val;
367 return $this->focus_id;
377 $this->expand_variable = $a_val;
387 return $this->expand_variable;
397 $this->expanded = $a_val;
407 return $this->expanded;
430 if (
$_POST[
"il_hform_expand"] !=
"")
432 $node_id =
$_POST[
"il_hform_expand"];
434 if (
$_GET[$ev] !=
"")
436 $node_id =
$_GET[$ev];
440 if ($node_id > 0 && !in_array($node_id,
$_SESSION[$ev]))
447 $key = array_keys(
$_SESSION[$ev],-(
int) $node_id);
460 $this->white_list = $a_val;
470 return $this->white_list;
479 if ($a_node_id ==
false)
484 $tree_childs = $this->
getTree()->getChilds($a_node_id);
486 foreach($tree_childs as $tree_child)
489 if (!is_array($this->white_list) || in_array($tree_child[
"type"], $this->white_list))
491 $childs[] =
array(
"node_id" => $tree_child[
"child"],
492 "title" => $tree_child[
"title"],
493 "type" => $tree_child[
"type"],
494 "depth" => $tree_child[
"depth"]
514 $ttpl =
new ilTemplate(
"tpl.hierarchy_form.html",
true,
true,
"Services/Form");
515 $ttpl->setVariable(
"TXT_SAVING", $lng->txt(
"saving"));
517 $top_node =
array(
"node_id" => $top_node_data[
"child"],
518 "title" => $top_node_data[
"title"],
519 "type" => $top_node_data[
"type"]);
522 $nodes_html = $this->
getLevelHTML($top_node, 0, $childs);
526 $secs =
array(
"1",
"2");
527 foreach ($secs as $sec)
529 reset($this->commands);
530 reset($this->multi_commands);
531 if (count($this->multi_commands) > 0 || count($this->commands) > 0)
533 if (count($childs) > 0)
536 foreach($this->commands as
$cmd)
538 $ttpl->setCurrentBlock(
"cmd".$sec);
539 $ttpl->setVariable(
"CMD", $cmd[
"cmd"]);
540 $ttpl->setVariable(
"CMD_TXT", $cmd[
"text"]);
541 $ttpl->parseCurrentBlock();
546 foreach($this->multi_commands as $cmd)
548 $ttpl->setCurrentBlock(
"multi_cmd".$sec);
549 $ttpl->setVariable(
"MULTI_CMD", $cmd[
"cmd"]);
550 $ttpl->setVariable(
"MULTI_CMD_TXT", $cmd[
"text"]);
551 $ttpl->parseCurrentBlock();
556 $ttpl->setCurrentBlock(
"multi_cmds".$sec);
557 $ttpl->setVariable(
"MCMD_ALT", $lng->txt(
"commands"));
566 $ttpl->parseCurrentBlock();
570 if ($single || $multi)
572 $ttpl->setCurrentBlock(
"commands".$sec);
573 $ttpl->parseCurrentBlock();
580 if ($this->exp_frame !=
"")
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();
590 foreach($this->drag_target as $drag_target)
592 $ttpl->setCurrentBlock(
"dragtarget");
593 $ttpl->setVariable(
"EL_ID", $drag_target[
"id"]);
594 $ttpl->setVariable(
"GROUP", $drag_target[
"group"]);
595 $ttpl->parseCurrentBlock();
597 foreach($this->drag_content as $drag_content)
599 $ttpl->setCurrentBlock(
"dragcontent");
600 $ttpl->setVariable(
"EL_ID", $drag_content[
"id"]);
601 $ttpl->setVariable(
"GROUP", $drag_content[
"group"]);
602 $ttpl->parseCurrentBlock();
606 if (is_array($this->diss_menues))
608 foreach($this->diss_menues as $node_id => $d_menu)
610 foreach($d_menu as $group => $menu)
612 if (count($menu) > 1)
614 foreach($menu as $menu_item)
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();
622 $ttpl->setCurrentBlock(
"disambiguation_menu");
623 $ttpl->setVariable(
"DNODE_ID", $node_id);
624 $ttpl->setVariable(
"GRP", $group);
625 $ttpl->parseCurrentBlock();
627 else if (count($menu) == 1)
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();
640 $this->diss_menues[$a_id][$a_group][] =
array(
"type" =>
$a_type,
"text" => $a_diss_text);
643 if ($this->triggered_update_command !=
"")
645 $ttpl->setCurrentBlock(
"tr_update");
646 $ttpl->setVariable(
"UPDATE_CMD", $this->triggered_update_command);
647 $ttpl->parseCurrentBlock();
651 if (is_array($this->diss_menues))
653 foreach($this->diss_menues as $node_id => $d_menu)
655 foreach($d_menu as $group => $menu)
657 if (count($menu) > 1)
659 foreach($menu as $menu_item)
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();
667 $ttpl->setCurrentBlock(
"disambiguation_menu");
668 $ttpl->setVariable(
"DNODE_ID", $node_id);
669 $ttpl->setVariable(
"GRP", $group);
670 $ttpl->parseCurrentBlock();
672 else if (count($menu) == 1)
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();
685 $this->diss_menues[$a_id][$a_group][] =
array(
"type" =>
$a_type,
"text" => $a_diss_text);
688 $ttpl->setVariable(
"NODES", $nodes_html);
692 $ttpl->setVariable(
"TITLE", $this->
getTitle());
707 include_once(
"./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
709 $ttpl =
new ilTemplate(
"tpl.hierarchy_form_legend.html",
true,
true,
"Services/Form");
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"));
719 $ttpl->parseCurrentBlock();
725 if ($help[
"image"] !=
"")
727 $ttpl->setCurrentBlock(
"help_img");
728 $ttpl->setVariable(
"IMG_HELP", $help[
"image"]);
729 $ttpl->parseCurrentBlock();
731 $ttpl->setCurrentBlock(
"help_item");
732 $ttpl->setVariable(
"TXT_HELP", $help[
"text"]);
733 $ttpl->parseCurrentBlock();
736 $ttpl->setVariable(
"TXT_ADD_EL",
737 $lng->txt(
"form_hierarchy_add_elements"));
756 $childs = $this->
getChilds($a_par_node[
"node_id"]);
760 $ttpl =
new ilTemplate(
"tpl.hierarchy_form_nodes.html",
true,
true,
"Services/Form");
763 if ($this->
nodeAllowsChilds($a_par_node) && (count($childs) > 0 || $a_depth == 0))
765 $ttpl->setCurrentBlock(
"drop_area");
766 $ttpl->setVariable(
"DNODE_ID", $a_par_node[
"node_id"].
"fc");
768 if (count($childs) == 0)
770 $ttpl->setVariable(
"NO_CONTENT_CLASS",
"ilCOPGNoPageContent");
771 $ttpl->setVariable(
"NO_CONTENT_TXT",
" ".$lng->txt(
"form_hier_click_to_add"));
773 $ttpl->parseCurrentBlock();
776 $menu_items = $this->
getMenuItems($a_par_node, $a_depth,
true, null, $childs);
778 if (count($menu_items) > 0)
782 foreach($menu_items as $menu_item)
784 if ($menu_item[
"multi"] > $max)
786 $max = $menu_item[
"multi"];
792 foreach($menu_items as $menu_item)
794 if ($menu_item[
"multi"] > 1)
796 for($i = 1; $i <= $menu_item[
"multi"]; $i++)
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();
809 if ($max > $menu_item[
"multi"])
811 $ttpl->setCurrentBlock(
"multi_buffer");
812 $ttpl->setVariable(
"BUF_SPAN", $max - $menu_item[
"multi"]);
813 $ttpl->parseCurrentBlock();
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();
824 $ttpl->setCurrentBlock(
"drop_area_menu");
825 $ttpl->setVariable(
"MNODE_ID", $a_par_node[
"node_id"].
"fc");
826 $ttpl->parseCurrentBlock();
828 $ttpl->setCurrentBlock(
"element");
829 $ttpl->parseCurrentBlock();
834 if (count($childs) > 0)
836 for($i = 0; $i < count($childs); $i++)
838 $next_sibling = ($i < (count($childs) - 1))
839 ? $next_sibling = $childs[$i+1]
842 $this->
renderChild($ttpl, $childs[$i], $a_depth, $next_sibling);
843 $last_child = $child;
847 $html = $ttpl->get();
856 function renderChild($a_tpl, $a_child, $a_depth, $next_sibling = null)
861 $a_tpl->setCurrentBlock(
"img");
862 $a_tpl->setVariable(
"IMGPATH", $this->
getChildIcon($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();
870 $a_tpl->setCurrentBlock(
"cbox");
871 $a_tpl->setVariable(
"CNODE_ID", $a_child[
"node_id"]);
873 $a_tpl->parseCurrentBlock();
878 $a_tpl->setCurrentBlock(
"node_info");
879 $a_tpl->setVariable(
"NODE_INFO",
$info);
880 $a_tpl->parseCurrentBlock();
885 if (is_array($child_commands))
887 foreach($child_commands as $command)
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();
897 $a_tpl->setCurrentBlock(
"text");
899 if (is_array($hl) && in_array($a_child[
"node_id"], $hl))
901 $a_tpl->setVariable(
"CLASS",
' class="ilHFormHighlighted" ');
904 $a_tpl->setVariable(
"TNODE_ID", $a_child[
"node_id"]);
905 $a_tpl->parseCurrentBlock();
907 $grandchilds_html = $this->
getLevelHTML($a_child, $a_depth + 1, $grandchilds);
910 if ($this->
getFocusId() == $a_child[
"node_id"])
912 $a_tpl->setCurrentBlock(
"focus");
913 $a_tpl->setVariable(
"FNODE_ID", $a_child[
"node_id"]);
914 $a_tpl->parseCurrentBlock();
920 $a_tpl->setCurrentBlock(
"expand_icon");
921 if (!is_null($grandchilds) && count($grandchilds) > 0)
923 if (!in_array($a_child[
"node_id"],$this->
getExpanded()))
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 =
"";
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"]));
946 $a_tpl->parseCurrentBlock();
950 $a_tpl->setCurrentBlock(
"list_item");
951 $a_tpl->setVariable(
"CHILDS", $grandchilds_html);
952 $a_tpl->parseCurrentBlock();
954 $a_tpl->setCurrentBlock(
"element");
955 $a_tpl->parseCurrentBlock();
958 $a_tpl->setCurrentBlock(
"drop_area");
959 $a_tpl->setVariable(
"DNODE_ID", $a_child[
"node_id"]);
961 $a_tpl->parseCurrentBlock();
964 $this->
manageDragAndDrop($a_child, $a_depth,
false, $next_sibling, $grandchilds);
967 $menu_items = $this->
getMenuItems($a_child, $a_depth,
false, $next_sibling, $grandchilds);
968 if (count($menu_items) > 0)
972 foreach($menu_items as $menu_item)
974 if ($menu_item[
"multi"] > $max)
976 $max = $menu_item[
"multi"];
982 foreach($menu_items as $menu_item)
984 if ($menu_item[
"multi"] > 1 )
986 for($i = 1; $i <= $menu_item[
"multi"]; $i++)
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"])
993 $a_tpl->setVariable(
"FC",
"1");
994 $a_tpl->setVariable(
"MCNT", $mcnt.
"fc");
998 $a_tpl->setVariable(
"FC",
"0");
999 $a_tpl->setVariable(
"MCNT", $mcnt);
1001 $a_tpl->setVariable(
"CMD_NODE", $a_child[
"node_id"]);
1002 $a_tpl->parseCurrentBlock();
1007 if ($max > $menu_item[
"multi"])
1009 $a_tpl->setCurrentBlock(
"multi_buffer");
1010 $a_tpl->setVariable(
"BUF_SPAN", $max - $menu_item[
"multi"]);
1011 $a_tpl->parseCurrentBlock();
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"])
1019 $a_tpl->setVariable(
"FC",
"1");
1020 $a_tpl->setVariable(
"MCNT", $mcnt.
"fc");
1024 $a_tpl->setVariable(
"FC",
"0");
1025 $a_tpl->setVariable(
"MCNT", $mcnt);
1027 $a_tpl->setVariable(
"CMD_NODE", $a_child[
"node_id"]);
1028 $a_tpl->parseCurrentBlock();
1031 $a_tpl->setCurrentBlock(
"drop_area_menu");
1032 $a_tpl->setVariable(
"MNODE_ID", $a_child[
"node_id"]);
1033 $a_tpl->parseCurrentBlock();
1036 $a_tpl->setCurrentBlock(
"element");
1037 $a_tpl->parseCurrentBlock();
1061 return $lng->txt($a_item[
"type"]);
1083 return $a_child[
"title"];
1109 function getMenuItems($a_node, $a_depth, $a_first_child =
false, $a_next_sibling = null, $a_childs = null)
1129 function manageDragAndDrop($a_node, $a_depth, $a_first_child =
false, $a_next_sibling = null, $a_childs = null)
1140 return (
int) (
$_POST[
"il_hform_multi"] > 1
1141 ?
$_POST[
"il_hform_multi"]
1150 return $_POST[
"il_hform_node"];
1158 return (((
int)
$_POST[
"il_hform_fc"]) == 1);
1169 return parent::getHTML().$this->getLegend();
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"]
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
static get($a_glyph, $a_text="")
Get glyph html.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
Create styles array
The data for the language used.
static initDragDrop()
Init YUI Drag and Drop.