3declare(strict_types=1);
67 $this->
lng = $DIC->language();
68 $this->
ctrl = $DIC->ctrl();
70 $this->main_tpl =
$DIC->ui()->mainTemplate();
73 $this->multi_commands = array();
74 $this->commands = array();
75 $this->drag_target[] = array();
76 $this->drag_content[] = array();
79 $this->help_items = array();
82 $this->main_tpl->addJavascript(
"./Services/Form/js/ServiceFormHierarchyForm.js");
85 $this->
http = $DIC->http();
93 $this->parent_obj = $a_parent_obj;
94 $this->parent_cmd = $a_parent_cmd;
99 return $this->parent_obj;
104 return $this->parent_cmd;
110 public function setId(
string $a_id): void
112 throw new ilException(
"ilHierarchyFormGUI does currently not support multiple forms (multiple IDs). ID is always hform.");
122 $this->tree = $a_tree;
132 $this->currenttopnodeid = $a_currenttopnodeid;
137 return $this->currenttopnodeid;
142 $this->title = $a_title;
152 $this->icon = $a_icon;
162 $this->checkboxname = $a_checkboxname;
167 return $this->checkboxname;
172 $this->dragicon = $a_dragicon;
177 return $this->dragicon;
182 $this->maxdepth = $a_maxdepth;
187 return $this->maxdepth;
193 string $a_exp_target_script
195 $this->exp_frame = $a_exp_frame;
196 $this->exp_id = $a_exp_id;
197 $this->exp_target_script = $a_exp_target_script;
201 string $a_triggered_update_command
203 $this->triggered_update_command = $a_triggered_update_command;
210 $this->help_items[] = array(
"text" => $a_text,
211 "image" => $a_image);
216 return $this->help_items;
223 bool $a_first_child_drop_area =
false,
224 bool $a_as_subitem =
false,
225 string $a_diss_text =
""
227 if ($a_first_child_drop_area ==
true) {
228 $a_as_subitem =
true;
232 if ($a_first_child_drop_area) {
236 $this->drag_target[] = array(
"id" => $a_id,
"group" => $a_group);
237 $this->diss_menues[$a_id][$a_group][] = array(
"subitem" => $a_as_subitem,
"text" => $a_diss_text);
247 $this->drag_content[] = array(
"id" => $a_id,
"group" => $a_group);
256 $this->multi_commands[] = array(
"text" => $a_txt,
"cmd" => $a_cmd);
263 $this->commands[] = array(
"text" => $a_txt,
"cmd" => $a_cmd);
269 $this->highlighted_nodes = $a_val;
274 return $this->highlighted_nodes;
279 $this->focus_id = $a_val;
284 return $this->focus_id;
289 $this->expand_variable = $a_val;
294 return $this->expand_variable;
299 $this->expanded = $a_val;
304 return $this->expanded;
309 return self::_str(
$key);
316 $w =
$DIC->http()->wrapper();
317 $t =
$DIC->refinery()->kindlyTo()->string();
319 if (!$w->post()->has(
$key) && !$w->query()->has(
$key)) {
323 $val = (string) ($w->post()->retrieve(
$key, $t) ??
"");
326 $val = (string) ($w->query()->retrieve(
$key, $t) ??
"");
334 $ev = $this->getExpandVariable();
345 if ($this->
str(
"il_hform_expand") !=
"") {
346 $node_id = $this->
str(
"il_hform_expand");
348 if ($this->
str($ev) !=
"") {
349 $node_id = $this->
str($ev);
362 unset($nodes[$ev][
$key[0]]);
370 $this->white_list = $a_val;
375 return $this->white_list;
382 public function getChilds(?
int $a_node_id =
null): array
384 if ($a_node_id ==
null) {
385 $a_node_id = $this->getCurrentTopNodeId();
388 $tree_childs = $this->getTree()->getChilds($a_node_id);
390 foreach ($tree_childs as $tree_child) {
391 if (!isset($this->white_list) || !is_array($this->white_list) || in_array($tree_child[
"type"], $this->white_list)) {
392 $childs[] = array(
"node_id" => $tree_child[
"child"],
393 "title" => $tree_child[
"title"],
394 "type" => $tree_child[
"type"],
395 "depth" => $tree_child[
"depth"]
409 if ($this->getExpandVariable() !=
"") {
410 $this->updateExpanded();
413 $ttpl =
new ilTemplate(
"tpl.hierarchy_form.html",
true,
true,
"Services/Form");
414 $ttpl->setVariable(
"TXT_SAVING",
$lng->txt(
"saving"));
415 $top_node_data = $this->getTree()->getNodeData($this->getCurrentTopNodeId());
416 $top_node = array(
"node_id" => $top_node_data[
"child"] ?? 0,
417 "title" => $top_node_data[
"title"] ??
"",
418 "type" => $top_node_data[
"type"] ??
"");
421 $nodes_html = $this->getLevelHTML($top_node, 0, $childs);
425 $secs = array(
"1",
"2");
426 foreach ($secs as $sec) {
427 reset($this->commands);
428 reset($this->multi_commands);
429 if (count($this->multi_commands) > 0 || count($this->commands) > 0) {
430 if (count($childs) > 0) {
432 foreach ($this->commands as $cmd) {
433 $ttpl->setCurrentBlock(
"cmd" . $sec);
434 $ttpl->setVariable(
"CMD", $cmd[
"cmd"]);
435 $ttpl->setVariable(
"CMD_TXT", $cmd[
"text"]);
436 $ttpl->parseCurrentBlock();
441 foreach ($this->multi_commands as $cmd) {
442 $ttpl->setCurrentBlock(
"multi_cmd" . $sec);
443 $ttpl->setVariable(
"MULTI_CMD", $cmd[
"cmd"]);
444 $ttpl->setVariable(
"MULTI_CMD_TXT", $cmd[
"text"]);
445 $ttpl->parseCurrentBlock();
449 $ttpl->setCurrentBlock(
"multi_cmds" . $sec);
450 $ttpl->setVariable(
"MCMD_ALT",
$lng->txt(
"commands"));
456 $ttpl->parseCurrentBlock();
460 if ($single || $multi) {
461 $ttpl->setCurrentBlock(
"commands" . $sec);
462 $ttpl->parseCurrentBlock();
479 foreach ($this->drag_target as $drag_target) {
480 $this->main_tpl->addOnLoadCode(
'd = new ilDragTarget("droparea_" + "'.($drag_target[
"id"] ??
"").
481 '", "'.($drag_target[
"group"] ??
"").
'");');
483 foreach ($this->drag_content as $drag_content) {
484 $this->main_tpl->addOnLoadCode(
'd = new ilDragContent("il_img_" + "'.($drag_content[
"id"] ??
"").
485 '", "'.($drag_content[
"group"] ??
"").
'");');
489 if (is_array($this->diss_menues)) {
490 foreach ($this->diss_menues as $node_id => $d_menu) {
491 foreach ($d_menu as $group => $menu) {
492 if (count($menu) > 1) {
493 foreach ($menu as $menu_item) {
494 $ttpl->setCurrentBlock(
"dmenu_cmd");
495 $ttpl->setVariable(
"SUBITEM", (
int) $menu_item[
"subitem"]);
496 $ttpl->setVariable(
"TXT_MENU_CMD", $menu_item[
"text"]);
497 $ttpl->parseCurrentBlock();
500 $ttpl->setCurrentBlock(
"disambiguation_menu");
501 $ttpl->setVariable(
"DNODE_ID", $node_id);
502 $ttpl->setVariable(
"GRP", $group);
503 $ttpl->parseCurrentBlock();
504 } elseif (count($menu) == 1) {
506 $this->main_tpl->addOnLoadCode(
'as_subitem["'.$node_id.
'" + "_" + "'.$group.
'"] = "'.(
int) $menu[0][
"subitem"].
'";');
514 if ($this->triggered_update_command !=
"") {
515 $ttpl->setCurrentBlock(
"tr_update");
516 $ttpl->setVariable(
"UPDATE_CMD", $this->triggered_update_command);
517 $ttpl->parseCurrentBlock();
521 if (is_array($this->diss_menues)) {
522 foreach ($this->diss_menues as $node_id => $d_menu) {
523 foreach ($d_menu as $group => $menu) {
524 if (count($menu) > 1) {
525 foreach ($menu as $menu_item) {
526 $ttpl->setCurrentBlock(
"dmenu_cmd");
527 $ttpl->setVariable(
"SUBITEM", (
int) $menu_item[
"subitem"]);
528 $ttpl->setVariable(
"TXT_MENU_CMD", $menu_item[
"text"]);
529 $ttpl->parseCurrentBlock();
532 $ttpl->setCurrentBlock(
"disambiguation_menu");
533 $ttpl->setVariable(
"DNODE_ID", $node_id);
534 $ttpl->setVariable(
"GRP", $group);
535 $ttpl->parseCurrentBlock();
536 } elseif (count($menu) == 1) {
538 $this->main_tpl->addOnLoadCode(
'as_subitem["'.$node_id.
'" + "_" + "'.$group.
'"] = "'.(
int) $menu[0][
"subitem"].
'";');
546 $ttpl->setVariable(
"NODES", $nodes_html);
550 $ttpl->setVariable(
"TITLE", $this->getTitle());
560 $ttpl =
new ilTemplate(
"tpl.hierarchy_form_legend.html",
true,
true,
"Services/Form");
561 if ($this->getDragIcon() !=
"") {
562 $ttpl->setCurrentBlock(
"help_drag");
563 $ttpl->setVariable(
"IMG_DRAG", $this->getDragIcon());
570 $lng->txt(
"form_hierarchy_drag_drop_help")
573 $ttpl->parseCurrentBlock();
577 foreach ($this->getHelpItems() as $help) {
578 if ($help[
"image"] !=
"") {
579 $ttpl->setCurrentBlock(
"help_img");
580 $ttpl->setVariable(
"IMG_HELP", $help[
"image"]);
581 $ttpl->parseCurrentBlock();
583 $ttpl->setCurrentBlock(
"help_item");
584 $ttpl->setVariable(
"TXT_HELP", $help[
"text"]);
585 $ttpl->parseCurrentBlock();
590 $lng->txt(
"form_hierarchy_add_elements")
604 if ($this->getMaxDepth() > -1 && $this->getMaxDepth() < $a_depth) {
608 $childs = $this->getChilds((
int) $a_par_node[
"node_id"]);
610 $ttpl =
new ilTemplate(
"tpl.hierarchy_form_nodes.html",
true,
true,
"Services/Form");
613 if ($this->nodeAllowsChilds($a_par_node) && (count($childs) > 0 || $a_depth == 0)) {
614 $ttpl->setCurrentBlock(
"drop_area");
615 $ttpl->setVariable(
"DNODE_ID", $a_par_node[
"node_id"] .
"fc");
617 if (count($childs) == 0) {
618 $ttpl->setVariable(
"NO_CONTENT_CLASS",
"ilCOPGNoPageContent");
619 $ttpl->setVariable(
"NO_CONTENT_TXT",
" " .
$lng->txt(
"form_hier_click_to_add"));
621 $ttpl->parseCurrentBlock();
623 $this->manageDragAndDrop($a_par_node, $a_depth,
true,
null, $childs);
624 $menu_items = $this->getMenuItems($a_par_node, $a_depth,
true,
null, $childs);
626 if (count($menu_items) > 0) {
629 foreach ($menu_items as $menu_item) {
630 if ($menu_item[
"multi"] > $max) {
631 $max = $menu_item[
"multi"];
637 foreach ($menu_items as $menu_item) {
638 if ($menu_item[
"multi"] > 1) {
639 for (
$i = 1;
$i <= $menu_item[
"multi"];
$i++) {
640 $ttpl->setCurrentBlock(
"multi_add");
641 $ttpl->setVariable(
"MA_NUM",
$i);
642 $ttpl->setVariable(
"MENU_CMD", $menu_item[
"cmd"]);
643 $ttpl->setVariable(
"FC",
"1");
644 $ttpl->setVariable(
"CMD_NODE", $a_par_node[
"node_id"]);
645 $ttpl->setVariable(
"MCNT", $mcnt .
"fc");
646 $ttpl->parseCurrentBlock();
651 if ($max > $menu_item[
"multi"]) {
652 $ttpl->setCurrentBlock(
"multi_buffer");
653 $ttpl->setVariable(
"BUF_SPAN", $max - $menu_item[
"multi"]);
654 $ttpl->parseCurrentBlock();
656 $ttpl->setCurrentBlock(
"menu_cmd");
657 $ttpl->setVariable(
"TXT_MENU_CMD", $menu_item[
"text"]);
658 $ttpl->setVariable(
"MENU_CMD", $menu_item[
"cmd"]);
659 $ttpl->setVariable(
"CMD_NODE", $a_par_node[
"node_id"]);
660 $ttpl->setVariable(
"FC",
"1");
661 $ttpl->setVariable(
"MCNT", $mcnt .
"fc");
662 $ttpl->parseCurrentBlock();
665 $ttpl->setCurrentBlock(
"drop_area_menu");
666 $ttpl->setVariable(
"MNODE_ID", $a_par_node[
"node_id"] .
"fc");
667 $ttpl->parseCurrentBlock();
669 $ttpl->setCurrentBlock(
"element");
670 $ttpl->parseCurrentBlock();
675 if (count($childs) > 0) {
676 for (
$i = 0, $iMax = count($childs);
$i < $iMax;
$i++) {
677 $next_sibling = (
$i < (count($childs) - 1))
681 $this->renderChild($ttpl, $childs[
$i], $a_depth, $next_sibling);
685 $html = $ttpl->get();
698 ?array $next_sibling =
null
700 $ilCtrl = $this->ctrl;
704 $a_tpl->
setVariable(
"IMGPATH", $this->getChildIcon($a_child));
705 $a_tpl->
setVariable(
"IMGALT", $this->getChildIconAlt($a_child));
706 $a_tpl->
setVariable(
"IMG_NODE", $a_child[
"node_id"]);
707 $a_tpl->
setVariable(
"NODE_ID", $a_child[
"node_id"]);
713 $a_tpl->
setVariable(
"CNODE_ID", $a_child[
"node_id"]);
714 $a_tpl->
setVariable(
"CBOX_NAME", $this->getCheckboxName());
718 if (($info = $this->getChildInfo($a_child)) !=
"") {
725 $child_commands = $this->getChildCommands($a_child);
726 if (is_array($child_commands)) {
727 foreach ($child_commands as $command) {
729 $a_tpl->
setVariable(
"HREF_NODE_CMD", $command[
"link"]);
730 $a_tpl->
setVariable(
"TXT_NODE_CMD", $command[
"text"]);
737 $hl = $this->getHighlightedNodes();
738 if (is_array($hl) && in_array($a_child[
"node_id"], $hl)) {
739 $a_tpl->
setVariable(
"CLASS",
' class="ilHFormHighlighted" ');
742 $a_tpl->
setVariable(
"TNODE_ID", $a_child[
"node_id"]);
745 $grandchilds_html = $this->getLevelHTML($a_child, $a_depth + 1, $grandchilds);
748 if ($this->getFocusId() == $a_child[
"node_id"]) {
749 $this->main_tpl->addOnLoadCode(
'document.getElementById("inp'.$a_child[
"node_id"].
'").focus();');
753 if ($this->getExpandVariable() !=
"") {
755 if (!is_null($grandchilds) && count($grandchilds) > 0) {
756 if (!in_array($a_child[
"node_id"], $this->getExpanded())) {
757 $ilCtrl->setParameter($this->getParentObject(), $this->getExpandVariable(), $a_child[
"node_id"]);
759 $a_tpl->
setVariable(
"HREF_NAME",
"n" . $a_child[
"node_id"]);
762 $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCommand(),
"n" . $a_child[
"node_id"])
764 $grandchilds_html =
"";
766 $ilCtrl->setParameter($this->getParentObject(), $this->getExpandVariable(), -$a_child[
"node_id"]);
768 $a_tpl->
setVariable(
"HREF_NAME",
"n" . $a_child[
"node_id"]);
771 $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCommand(),
"n" . $a_child[
"node_id"])
774 $ilCtrl->setParameter($this->getParentObject(), $this->getExpandVariable(),
"");
791 $a_tpl->
setVariable(
"DNODE_ID", $a_child[
"node_id"]);
796 $this->manageDragAndDrop($a_child, $a_depth,
false, $next_sibling, $grandchilds);
799 $menu_items = $this->getMenuItems($a_child, $a_depth,
false, $next_sibling, $grandchilds);
800 if (count($menu_items) > 0) {
803 foreach ($menu_items as $menu_item) {
804 if ($menu_item[
"multi"] > $max) {
805 $max = $menu_item[
"multi"];
811 foreach ($menu_items as $menu_item) {
812 if ($menu_item[
"multi"] > 1) {
813 for (
$i = 1;
$i <= $menu_item[
"multi"];
$i++) {
816 $a_tpl->
setVariable(
"MENU_CMD", $menu_item[
"cmd"]);
817 if ($menu_item[
"as_subitem"] ??
false) {
824 $a_tpl->
setVariable(
"CMD_NODE", $a_child[
"node_id"]);
830 if ($max > $menu_item[
"multi"]) {
832 $a_tpl->
setVariable(
"BUF_SPAN", $max - $menu_item[
"multi"]);
837 $a_tpl->
setVariable(
"TXT_MENU_CMD", $menu_item[
"text"]);
838 $a_tpl->
setVariable(
"MENU_CMD", $menu_item[
"cmd"]);
839 if ($menu_item[
"as_subitem"] ??
false) {
846 $a_tpl->
setVariable(
"CMD_NODE", $a_child[
"node_id"]);
851 $a_tpl->
setVariable(
"MNODE_ID", $a_child[
"node_id"]);
868 return $lng->txt($a_item[
"type"]);
878 return $a_child[
"title"];
899 bool $a_first_child =
false,
900 ?array $a_next_sibling =
null,
901 ?array $a_childs =
null
923 bool $a_first_child =
false,
924 ?array $a_next_sibling =
null,
925 ?array $a_childs =
null
936 return max(1, (
int) self::_str(
"il_hform_multi"));
944 return self::_str(
"il_hform_node");
952 return ((
int) self::_str(
"il_hform_fc") == 1);
957 return parent::getHTML() . $this->getLegend();
963 "il_hform_node" => self::_str(
"il_hform_node"),
964 "il_hform_fc" => self::_str(
"il_hform_fc"),
965 "il_hform_as_subitem" => self::_str(
"il_hform_as_subitem"),
966 "il_hform_multi" => self::_str(
"il_hform_multi"),
967 "il_hform_source_id" => self::_str(
"il_hform_source_id"),
968 "il_hform_target_id" => self::_str(
"il_hform_target_id")
static return function(ContainerConfigurator $containerConfigurator)
setVariable($variable, $value='')
Sets a variable value.
Class ilCtrl provides processing control methods.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static get(string $a_glyph, string $a_text="")
loadLanguageModule(string $a_module)
Load language module.
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static initDragDrop(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Drag and Drop used in Modules/Survey, Services/Calendar, Services/COPage,...
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...