4include_once(
"./Services/Form/classes/class.ilFormGUI.php");
 
   40        $this->lng = 
$DIC->language();
 
   41        $this->tpl = 
$DIC[
"tpl"];
 
   42        $this->ctrl = 
$DIC->ctrl();
 
   47        $this->multi_commands = array();
 
   48        $this->commands = array();
 
   49        $this->drag_target[] = array();
 
   50        $this->drag_content[] = array();
 
   51        $lng->loadLanguageModule(
"form");
 
   53        $this->help_items = array();
 
   55        include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
 
   57        $tpl->addJavascript(
"./Services/Form/js/ServiceFormHierarchyForm.js");
 
   67        $this->parent_obj = $a_parent_obj;
 
   68        $this->parent_cmd = $a_parent_cmd;
 
   78        return $this->parent_obj;
 
   88        return $this->parent_cmd;
 
   98        die(
"ilHierarchyFormGUI does currently not support multiple forms (multiple IDs). ID is always hform.");
 
  118        $this->tree = $a_tree;
 
  138        $this->currenttopnodeid = $a_currenttopnodeid;
 
  148        return $this->currenttopnodeid;
 
  158        $this->title = $a_title;
 
  178        $this->icon = $a_icon;
 
  198        $this->checkboxname = $a_checkboxname;
 
  208        return $this->checkboxname;
 
  218        $this->dragicon = $a_dragicon;
 
  228        return $this->dragicon;
 
  238        $this->maxdepth = $a_maxdepth;
 
  248        return $this->maxdepth;
 
  258        $this->exp_frame = $a_exp_frame;
 
  259        $this->exp_id = $a_exp_id;
 
  260        $this->exp_target_script = $a_exp_target_script;
 
  270        $this->triggered_update_command = $a_triggered_update_command;
 
  278        $this->help_items[] = array(
"text" => $a_text,
 
  279            "image" => $a_image);
 
  287        return $this->help_items;
 
  296    public function makeDragTarget($a_id, $a_group, $a_first_child_drop_area = 
false, $a_as_subitem = 
false, $a_diss_text = 
"")
 
  298        if ($a_first_child_drop_area == 
true) {         
 
  299            $a_as_subitem = 
true;
 
  303            if ($a_first_child_drop_area) {
 
  307            $this->drag_target[] = array(
"id" => $a_id, 
"group" => $a_group);
 
  308            $this->diss_menues[$a_id][$a_group][] = array(
"subitem" => $a_as_subitem, 
"text" => $a_diss_text);
 
  321            $this->drag_content[] = array(
"id" => $a_id, 
"group" => $a_group);
 
  333        $this->multi_commands[] = array(
"text" => $a_txt, 
"cmd" => $a_cmd);
 
  344        $this->commands[] = array(
"text" => $a_txt, 
"cmd" => $a_cmd);
 
  354        $this->highlighted_nodes = $a_val;
 
  364        return $this->highlighted_nodes;
 
  374        $this->focus_id = $a_val;
 
  384        return $this->focus_id;
 
  394        $this->expand_variable = $a_val;
 
  404        return $this->expand_variable;
 
  414        $this->expanded = $a_val;
 
  424        return $this->expanded;
 
  445        if (
$_POST[
"il_hform_expand"] != 
"") {
 
  446            $node_id = 
$_POST[
"il_hform_expand"];
 
  448        if (
$_GET[$ev] != 
"") {
 
  449            $node_id = 
$_GET[$ev];
 
  453        if ($node_id > 0 && !in_array($node_id, 
$_SESSION[$ev])) {
 
  471        $this->white_list = $a_val;
 
  481        return $this->white_list;
 
  490        if ($a_node_id == 
false) {
 
  494        $tree_childs = $this->
getTree()->getChilds($a_node_id);
 
  496        foreach ($tree_childs as $tree_child) {
 
  497            if (!is_array($this->white_list) || in_array($tree_child[
"type"], $this->white_list)) {
 
  498                $childs[] = array(
"node_id" => $tree_child[
"child"],
 
  499                    "title" => $tree_child[
"title"],
 
  500                    "type" => $tree_child[
"type"],
 
  501                    "depth" => $tree_child[
"depth"]
 
  520        $ttpl = 
new ilTemplate(
"tpl.hierarchy_form.html", 
true, 
true, 
"Services/Form");
 
  521        $ttpl->setVariable(
"TXT_SAVING", 
$lng->txt(
"saving"));
 
  523        $top_node = array(
"node_id" => $top_node_data[
"child"],
 
  524                "title" => $top_node_data[
"title"],
 
  525                "type" => $top_node_data[
"type"]);
 
  528        $nodes_html = $this->
getLevelHTML($top_node, 0, $childs);
 
  532        $secs = array(
"1", 
"2");
 
  533        foreach ($secs as $sec) {
 
  534            reset($this->commands);
 
  535            reset($this->multi_commands);
 
  536            if (count($this->multi_commands) > 0 || count($this->commands) > 0) {
 
  537                if (count($childs) > 0) {
 
  539                    foreach ($this->commands as $cmd) {
 
  540                        $ttpl->setCurrentBlock(
"cmd" . $sec);
 
  541                        $ttpl->setVariable(
"CMD", $cmd[
"cmd"]);
 
  542                        $ttpl->setVariable(
"CMD_TXT", $cmd[
"text"]);
 
  543                        $ttpl->parseCurrentBlock();
 
  548                    foreach ($this->multi_commands as $cmd) {
 
  549                        $ttpl->setCurrentBlock(
"multi_cmd" . $sec);
 
  550                        $ttpl->setVariable(
"MULTI_CMD", $cmd[
"cmd"]);
 
  551                        $ttpl->setVariable(
"MULTI_CMD_TXT", $cmd[
"text"]);
 
  552                        $ttpl->parseCurrentBlock();
 
  556                        $ttpl->setCurrentBlock(
"multi_cmds" . $sec);
 
  557                        $ttpl->setVariable(
"MCMD_ALT", 
$lng->txt(
"commands"));
 
  563                        $ttpl->parseCurrentBlock();
 
  567                if ($single || $multi) {
 
  568                    $ttpl->setCurrentBlock(
"commands" . $sec);
 
  569                    $ttpl->parseCurrentBlock();
 
  576        if ($this->exp_frame != 
"") {
 
  577            $ttpl->setCurrentBlock(
"updater");
 
  578            $ttpl->setVariable(
"UPDATER_FRAME", $this->exp_frame);
 
  579            $ttpl->setVariable(
"EXP_ID_UPDATER", $this->exp_id);
 
  580            $ttpl->setVariable(
"HREF_UPDATER", $this->exp_target_script);
 
  581            $ttpl->parseCurrentBlock();
 
  585        foreach ($this->drag_target as $drag_target) {
 
  586            $ttpl->setCurrentBlock(
"dragtarget");
 
  587            $ttpl->setVariable(
"EL_ID", $drag_target[
"id"]);
 
  588            $ttpl->setVariable(
"GROUP", $drag_target[
"group"]);
 
  589            $ttpl->parseCurrentBlock();
 
  591        foreach ($this->drag_content as $drag_content) {
 
  592            $ttpl->setCurrentBlock(
"dragcontent");
 
  593            $ttpl->setVariable(
"EL_ID", $drag_content[
"id"]);
 
  594            $ttpl->setVariable(
"GROUP", $drag_content[
"group"]);
 
  595            $ttpl->parseCurrentBlock();
 
  599        if (is_array($this->diss_menues)) {
 
  600            foreach ($this->diss_menues as $node_id => $d_menu) {
 
  601                foreach ($d_menu as $group => $menu) {
 
  602                    if (count($menu) > 1) {
 
  603                        foreach ($menu as $menu_item) {
 
  604                            $ttpl->setCurrentBlock(
"dmenu_cmd");
 
  605                            $ttpl->setVariable(
"SUBITEM", (
int) $menu_item[
"subitem"]);
 
  606                            $ttpl->setVariable(
"TXT_MENU_CMD", $menu_item[
"text"]);
 
  607                            $ttpl->parseCurrentBlock();
 
  610                        $ttpl->setCurrentBlock(
"disambiguation_menu");
 
  611                        $ttpl->setVariable(
"DNODE_ID", $node_id);
 
  612                        $ttpl->setVariable(
"GRP", $group);
 
  613                        $ttpl->parseCurrentBlock();
 
  614                    } elseif (count($menu) == 1) {
 
  616                        $ttpl->setCurrentBlock(
"as_subitem_flag");
 
  617                        $ttpl->setVariable(
"SI_NODE_ID", $node_id);
 
  618                        $ttpl->setVariable(
"SI_GRP", $group);
 
  619                        $ttpl->setVariable(
"SI_SI", (
int) $menu[0][
"subitem"]);
 
  620                        $ttpl->parseCurrentBlock();
 
  625        $this->diss_menues[$a_id][$a_group][] = array(
"type" => 
$a_type, 
"text" => $a_diss_text);
 
  628        if ($this->triggered_update_command != 
"") {
 
  629            $ttpl->setCurrentBlock(
"tr_update");
 
  630            $ttpl->setVariable(
"UPDATE_CMD", $this->triggered_update_command);
 
  631            $ttpl->parseCurrentBlock();
 
  635        if (is_array($this->diss_menues)) {
 
  636            foreach ($this->diss_menues as $node_id => $d_menu) {
 
  637                foreach ($d_menu as $group => $menu) {
 
  638                    if (count($menu) > 1) {
 
  639                        foreach ($menu as $menu_item) {
 
  640                            $ttpl->setCurrentBlock(
"dmenu_cmd");
 
  641                            $ttpl->setVariable(
"SUBITEM", (
int) $menu_item[
"subitem"]);
 
  642                            $ttpl->setVariable(
"TXT_MENU_CMD", $menu_item[
"text"]);
 
  643                            $ttpl->parseCurrentBlock();
 
  646                        $ttpl->setCurrentBlock(
"disambiguation_menu");
 
  647                        $ttpl->setVariable(
"DNODE_ID", $node_id);
 
  648                        $ttpl->setVariable(
"GRP", $group);
 
  649                        $ttpl->parseCurrentBlock();
 
  650                    } elseif (count($menu) == 1) {
 
  652                        $ttpl->setCurrentBlock(
"as_subitem_flag");
 
  653                        $ttpl->setVariable(
"SI_NODE_ID", $node_id);
 
  654                        $ttpl->setVariable(
"SI_GRP", $group);
 
  655                        $ttpl->setVariable(
"SI_SI", (
int) $menu[0][
"subitem"]);
 
  656                        $ttpl->parseCurrentBlock();
 
  661        $this->diss_menues[$a_id][$a_group][] = array(
"type" => 
$a_type, 
"text" => $a_diss_text);
 
  664        $ttpl->setVariable(
"NODES", $nodes_html);
 
  668        $ttpl->setVariable(
"TITLE", $this->
getTitle());
 
  683        include_once(
"./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
 
  685        $ttpl = 
new ilTemplate(
"tpl.hierarchy_form_legend.html", 
true, 
true, 
"Services/Form");
 
  687            $ttpl->setCurrentBlock(
"help_drag");
 
  688            $ttpl->setVariable(
"IMG_DRAG", $this->
getDragIcon());
 
  695                $lng->txt(
"form_hierarchy_drag_drop_help")
 
  698            $ttpl->parseCurrentBlock();
 
  703            if ($help[
"image"] != 
"") {
 
  704                $ttpl->setCurrentBlock(
"help_img");
 
  705                $ttpl->setVariable(
"IMG_HELP", $help[
"image"]);
 
  706                $ttpl->parseCurrentBlock();
 
  708            $ttpl->setCurrentBlock(
"help_item");
 
  709            $ttpl->setVariable(
"TXT_HELP", $help[
"text"]);
 
  710            $ttpl->parseCurrentBlock();
 
  715            $lng->txt(
"form_hierarchy_add_elements")
 
  734        $childs = $this->
getChilds($a_par_node[
"node_id"]);
 
  738        $ttpl = 
new ilTemplate(
"tpl.hierarchy_form_nodes.html", 
true, 
true, 
"Services/Form");
 
  741        if ($this->
nodeAllowsChilds($a_par_node) && (count($childs) > 0 || $a_depth == 0)) {
 
  742            $ttpl->setCurrentBlock(
"drop_area");
 
  743            $ttpl->setVariable(
"DNODE_ID", $a_par_node[
"node_id"] . 
"fc");              
 
  745            if (count($childs) == 0) {
 
  746                $ttpl->setVariable(
"NO_CONTENT_CLASS", 
"ilCOPGNoPageContent");
 
  747                $ttpl->setVariable(
"NO_CONTENT_TXT", 
"  " . 
$lng->txt(
"form_hier_click_to_add"));
 
  749            $ttpl->parseCurrentBlock();
 
  752            $menu_items = $this->
getMenuItems($a_par_node, $a_depth, 
true, 
null, $childs);
 
  754            if (count($menu_items) > 0) {
 
  757                foreach ($menu_items as $menu_item) {
 
  758                    if ($menu_item[
"multi"] > $max) {
 
  759                        $max = $menu_item[
"multi"];
 
  765                foreach ($menu_items as $menu_item) {
 
  766                    if ($menu_item[
"multi"] > 1) {
 
  767                        for (
$i = 1; 
$i <= $menu_item[
"multi"]; 
$i++) {
 
  768                            $ttpl->setCurrentBlock(
"multi_add");
 
  769                            $ttpl->setVariable(
"MA_NUM", 
$i);
 
  770                            $ttpl->setVariable(
"MENU_CMD", $menu_item[
"cmd"]);
 
  771                            $ttpl->setVariable(
"FC", 
"1");
 
  772                            $ttpl->setVariable(
"CMD_NODE", $a_par_node[
"node_id"]);
 
  773                            $ttpl->setVariable(
"MCNT", $mcnt . 
"fc");
 
  774                            $ttpl->parseCurrentBlock();
 
  779                    if ($max > $menu_item[
"multi"]) {
 
  780                        $ttpl->setCurrentBlock(
"multi_buffer");
 
  781                        $ttpl->setVariable(
"BUF_SPAN", $max - $menu_item[
"multi"]);
 
  782                        $ttpl->parseCurrentBlock();
 
  784                    $ttpl->setCurrentBlock(
"menu_cmd");
 
  785                    $ttpl->setVariable(
"TXT_MENU_CMD", $menu_item[
"text"]);
 
  786                    $ttpl->setVariable(
"MENU_CMD", $menu_item[
"cmd"]);
 
  787                    $ttpl->setVariable(
"CMD_NODE", $a_par_node[
"node_id"]);
 
  788                    $ttpl->setVariable(
"FC", 
"1");
 
  789                    $ttpl->setVariable(
"MCNT", $mcnt . 
"fc");
 
  790                    $ttpl->parseCurrentBlock();
 
  793                $ttpl->setCurrentBlock(
"drop_area_menu");
 
  794                $ttpl->setVariable(
"MNODE_ID", $a_par_node[
"node_id"] . 
"fc");
 
  795                $ttpl->parseCurrentBlock();
 
  797                $ttpl->setCurrentBlock(
"element");
 
  798                $ttpl->parseCurrentBlock();
 
  803        if (count($childs) > 0) {
 
  804            for (
$i = 0; 
$i < count($childs); 
$i++) {
 
  805                $next_sibling = (
$i < (count($childs) - 1))
 
  806                    ? $next_sibling = $childs[
$i+1]
 
  809                $this->
renderChild($ttpl, $childs[
$i], $a_depth, $next_sibling);
 
  810                $last_child = $child;
 
  814        $html = $ttpl->get();
 
  823    public function renderChild($a_tpl, $a_child, $a_depth, $next_sibling = 
null)
 
  828        $a_tpl->setCurrentBlock(
"img");
 
  829        $a_tpl->setVariable(
"IMGPATH", $this->
getChildIcon($a_child));
 
  831        $a_tpl->setVariable(
"IMG_NODE", $a_child[
"node_id"]);
 
  832        $a_tpl->setVariable(
"NODE_ID", $a_child[
"node_id"]);
 
  833        $a_tpl->setVariable(
"TYPE", $a_child[
"type"]);
 
  834        $a_tpl->parseCurrentBlock();
 
  837        $a_tpl->setCurrentBlock(
"cbox");
 
  838        $a_tpl->setVariable(
"CNODE_ID", $a_child[
"node_id"]);
 
  840        $a_tpl->parseCurrentBlock();
 
  844            $a_tpl->setCurrentBlock(
"node_info");
 
  845            $a_tpl->setVariable(
"NODE_INFO", 
$info);
 
  846            $a_tpl->parseCurrentBlock();
 
  851        if (is_array($child_commands)) {
 
  852            foreach ($child_commands as $command) {
 
  853                $a_tpl->setCurrentBlock(
"node_cmd");
 
  854                $a_tpl->setVariable(
"HREF_NODE_CMD", $command[
"link"]);
 
  855                $a_tpl->setVariable(
"TXT_NODE_CMD", $command[
"text"]);
 
  856                $a_tpl->parseCurrentBlock();
 
  861        $a_tpl->setCurrentBlock(
"text");
 
  863        if (is_array($hl) && in_array($a_child[
"node_id"], $hl)) {
 
  864            $a_tpl->setVariable(
"CLASS", 
' class="ilHFormHighlighted" ');
 
  867        $a_tpl->setVariable(
"TNODE_ID", $a_child[
"node_id"]);
 
  868        $a_tpl->parseCurrentBlock();
 
  870        $grandchilds_html = $this->
getLevelHTML($a_child, $a_depth + 1, $grandchilds);
 
  873        if ($this->
getFocusId() == $a_child[
"node_id"]) {
 
  874            $a_tpl->setCurrentBlock(
"focus");
 
  875            $a_tpl->setVariable(
"FNODE_ID", $a_child[
"node_id"]);
 
  876            $a_tpl->parseCurrentBlock();
 
  881            $a_tpl->setCurrentBlock(
"expand_icon");
 
  882            if (!is_null($grandchilds) && count($grandchilds) > 0) {
 
  883                if (!in_array($a_child[
"node_id"], $this->
getExpanded())) {
 
  886                    $a_tpl->setVariable(
"HREF_NAME", 
"n" . $a_child[
"node_id"]);
 
  889                        $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCommand(), 
"n" . $a_child[
"node_id"])
 
  891                    $grandchilds_html = 
"";
 
  895                    $a_tpl->setVariable(
"HREF_NAME", 
"n" . $a_child[
"node_id"]);
 
  898                        $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCommand(), 
"n" . $a_child[
"node_id"])
 
  905            $a_tpl->parseCurrentBlock();
 
  909        $a_tpl->setCurrentBlock(
"list_item");
 
  910        $a_tpl->setVariable(
"CHILDS", $grandchilds_html);
 
  911        $a_tpl->parseCurrentBlock();
 
  913        $a_tpl->setCurrentBlock(
"element");
 
  914        $a_tpl->parseCurrentBlock();
 
  917        $a_tpl->setCurrentBlock(
"drop_area");
 
  918        $a_tpl->setVariable(
"DNODE_ID", $a_child[
"node_id"]);
 
  920        $a_tpl->parseCurrentBlock();
 
  923        $this->
manageDragAndDrop($a_child, $a_depth, 
false, $next_sibling, $grandchilds);
 
  926        $menu_items = $this->
getMenuItems($a_child, $a_depth, 
false, $next_sibling, $grandchilds);
 
  927        if (count($menu_items) > 0) {
 
  930            foreach ($menu_items as $menu_item) {
 
  931                if ($menu_item[
"multi"] > $max) {
 
  932                    $max = $menu_item[
"multi"];
 
  938            foreach ($menu_items as $menu_item) {
 
  939                if ($menu_item[
"multi"] > 1) {
 
  940                    for (
$i = 1; 
$i <= $menu_item[
"multi"]; 
$i++) {
 
  941                        $a_tpl->setCurrentBlock(
"multi_add");
 
  942                        $a_tpl->setVariable(
"MA_NUM", 
$i);
 
  943                        $a_tpl->setVariable(
"MENU_CMD", $menu_item[
"cmd"]);
 
  944                        if ($menu_item[
"as_subitem"]) {
 
  945                            $a_tpl->setVariable(
"FC", 
"1");
 
  946                            $a_tpl->setVariable(
"MCNT", $mcnt . 
"fc");
 
  948                            $a_tpl->setVariable(
"FC", 
"0");
 
  949                            $a_tpl->setVariable(
"MCNT", $mcnt);
 
  951                        $a_tpl->setVariable(
"CMD_NODE", $a_child[
"node_id"]);
 
  952                        $a_tpl->parseCurrentBlock();
 
  957                if ($max > $menu_item[
"multi"]) {
 
  958                    $a_tpl->setCurrentBlock(
"multi_buffer");
 
  959                    $a_tpl->setVariable(
"BUF_SPAN", $max - $menu_item[
"multi"]);
 
  960                    $a_tpl->parseCurrentBlock();
 
  963                $a_tpl->setCurrentBlock(
"menu_cmd");
 
  964                $a_tpl->setVariable(
"TXT_MENU_CMD", $menu_item[
"text"]);
 
  965                $a_tpl->setVariable(
"MENU_CMD", $menu_item[
"cmd"]);
 
  966                if ($menu_item[
"as_subitem"]) {
 
  967                    $a_tpl->setVariable(
"FC", 
"1");
 
  968                    $a_tpl->setVariable(
"MCNT", $mcnt . 
"fc");
 
  970                    $a_tpl->setVariable(
"FC", 
"0");
 
  971                    $a_tpl->setVariable(
"MCNT", $mcnt);
 
  973                $a_tpl->setVariable(
"CMD_NODE", $a_child[
"node_id"]);
 
  974                $a_tpl->parseCurrentBlock();
 
  977            $a_tpl->setCurrentBlock(
"drop_area_menu");
 
  978            $a_tpl->setVariable(
"MNODE_ID", $a_child[
"node_id"]);
 
  979            $a_tpl->parseCurrentBlock();
 
  982        $a_tpl->setCurrentBlock(
"element");
 
  983        $a_tpl->parseCurrentBlock();
 
 1007        return $lng->txt($a_item[
"type"]);
 
 1029        return $a_child[
"title"];
 
 1055    public function getMenuItems($a_node, $a_depth, $a_first_child = 
false, $a_next_sibling = 
null, $a_childs = 
null)
 
 1075    public function manageDragAndDrop($a_node, $a_depth, $a_first_child = 
false, $a_next_sibling = 
null, $a_childs = 
null)
 
 1086        return (
int) (
$_POST[
"il_hform_multi"] > 1
 
 1087            ? 
$_POST[
"il_hform_multi"]
 
 1096        return $_POST[
"il_hform_node"];
 
 1104        return (((
int) 
$_POST[
"il_hform_fc"]) == 1);
 
 1115        return parent::getHTML() . $this->
getLegend();
 
 1124            "il_hform_node" => 
$_POST[
"il_hform_node"],
 
 1125            "il_hform_fc" => 
$_POST[
"il_hform_fc"],
 
 1126            "il_hform_as_subitem" => 
$_POST[
"il_hform_as_subitem"],
 
 1127            "il_hform_multi" => 
$_POST[
"il_hform_multi"],
 
 1128            "il_hform_source_id" => 
$_POST[
"il_hform_source_id"],
 
 1129            "il_hform_target_id" => 
$_POST[
"il_hform_target_id"]
 
An exception for terminatinating execution or to throw for unit testing.
static get($a_glyph, $a_text="")
Get glyph html.
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.