4 define(
"IL_FM_POSITIVE", 1);
5 define(
"IL_FM_NEGATIVE", 2);
170 global
$ilias, $objDefinition;
172 if (!isset($a_target) or !is_string($a_target))
174 $this->ilias->raiseError(get_class($this).
"::Constructor(): No target given!",$this->ilias->error_obj->WARNING);
178 $devtypes = $objDefinition->getDevModeAll();
180 if (count($devtypes > 0))
185 foreach ($devtypes as $type)
192 $this->output = array();
193 $this->expanded = array();
194 $this->target = $a_target;
195 $this->target_get =
'ref_id';
196 $this->frame_target =
"content";
197 $this->order_column =
"title";
198 $this->tree =
new ilTree(ROOT_FOLDER_ID);
199 $this->tree->initLangCode();
200 $this->expand_target = $_SERVER[
"PATH_INFO"];
201 $this->rbac_check =
true;
202 $this->output_icons =
true;
203 $this->expand_variable =
"expand";
205 $this->post_sort=
true;
207 $this->highlighted =
"";
208 $this->show_minus =
true;
210 $this->asnch_expanding =
false;
240 $this->asnch_expanding = $a_val;
250 return $this->asnch_expanding;
262 $this->counter = $a_number;
272 $this->title = $a_val;
282 $this->textwidth = $a_length;
291 return $this->textwidth;
313 #$this->tree = new ilTree(ROOT_FOLDER_ID,$a_root_id);
314 $this->root_id = $a_root_id;
326 return $this->root_id == null ?
327 $this->tree->getRootId() :
338 $this->order_column = $a_column;
348 if ($a_direction ==
"desc")
350 $this->order_direction = $a_direction;
354 $this->order_direction =
"asc";
365 if (!isset($a_target_get) or !is_string($a_target_get))
367 $this->ilias->raiseError(get_class($this).
"::setTargetGet(): No target given!",$this->ilias->error_obj->WARNING);
370 $this->target_get = $a_target_get;
380 if (!isset($a_params_get) or !is_array($a_params_get))
382 $this->ilias->raiseError(get_class($this).
"::setTargetGet(): No target given!",$this->ilias->error_obj->WARNING);
385 foreach ($a_params_get as $key => $val)
387 $str .=
"&".$key.
"=".$val;
390 $this->params_get = $str;
402 $this->expand_target = $a_exp_target;
412 $this->up_frame = $a_up_frame;
413 $this->up_script = $a_up_script;
414 $this->up_params = $a_params;
423 $this->highlighted = $a_id;
433 $this->rbac_check = $a_check;
443 $this->expand_variable = $a_var_name;
453 $this->output_icons = $a_icons;
467 $this->is_clickable[$a_type] =
"";
471 $this->is_clickable[$a_type] =
"n";
479 if (!$this->rbac_check)
484 $ilBench->start(
"Explorer",
"setOutput_isVisible");
485 $visible = $rbacsystem->checkAccess(
'visible',$a_ref_id);
486 $ilBench->stop(
"Explorer",
"setOutput_isVisible");
498 $this->tree_lead = $a_val;
508 return $this->tree_lead;
524 if ($this->is_clickable[$a_type] ==
"n")
540 $this->post_sort = $a_sort;
550 $this->filter_mode = $a_mode;
571 $this->use_standard_frame = $a_val;
592 return $this->tree->getChilds($a_parent_id, $this->order_column);
604 function setOutput($a_parent_id, $a_depth = 1,$a_obj_id = 0, $a_highlighted_subtree =
false)
606 global $rbacadmin, $rbacsystem,
$ilBench;
608 #echo 'ParentId: '.$a_parent_id.' depth: '.$a_depth.' obj_id: '.$a_obj_id;
610 if (!isset($a_parent_id))
612 $this->ilias->raiseError(get_class($this).
"::setOutput(): No node_id given!",$this->ilias->error_obj->WARNING);
615 if ($this->
showChilds($a_parent_id,$a_obj_id))
627 if ($this->
forceExpanded($a_parent_id) && !in_array($a_parent_id, $this->expanded))
629 $this->expanded[] = $a_parent_id;
632 if (count($objects) > 0)
635 $tab = ++$a_depth - 2;
636 if ($this->post_sort)
638 $objects = $this->
sortNodes($objects,$a_obj_id);
641 foreach ($objects as $key => $object)
650 if ($this->filtered ==
false or $this->
checkFilter($object[
"type"]) ==
false)
652 if ($this->
isVisible($object[
'child'],$object[
'type']))
654 $ilBench->start(
"Explorer",
"setOutput_setFormatOptions");
655 #echo 'CHILD getIndex() '.$object['child'].' parent: '.$this->getRoot();
656 if ($object[
"child"] != $this->
getRoot())
658 $parent_index = $this->
getIndex($object);
660 $this->format_options[
"$this->counter"][
"parent"] = $object[
"parent"];
661 $this->format_options[
"$this->counter"][
"child"] = $object[
"child"];
662 $this->format_options[
"$this->counter"][
"title"] = $object[
"title"];
663 $this->format_options[
"$this->counter"][
"type"] = $object[
"type"];
664 $this->format_options[
"$this->counter"][
"obj_id"] = $object[
"obj_id"];
665 $this->format_options[
"$this->counter"][
"desc"] =
"obj_".$object[
"type"];
666 $this->format_options[
"$this->counter"][
"depth"] =
$tab;
667 $this->format_options[
"$this->counter"][
"container"] =
false;
668 $this->format_options[
"$this->counter"][
"visible"] =
true;
669 $this->format_options[
"$this->counter"][
"highlighted_subtree"] = $a_highlighted_subtree;
672 for ($i = 0; $i <
$tab; ++$i)
674 $this->format_options[
"$this->counter"][
"tab"][] =
'blank';
678 if ($parent_index == 0)
680 if (!$this->expand_all and !in_array($object[
"parent"], $this->expanded))
682 $this->expanded[] = $object[
"parent"];
687 if ($object[
"child"] != $this->
getRoot() and ((!$this->expand_all and !in_array($object[
"parent"],$this->expanded))
688 or !$this->format_options[
"$parent_index"][
"visible"]))
695 if ($this->format_options[
"$this->counter"][
"visible"])
700 $this->format_options[
"$this->counter"][
"visible"] =
false;
705 if ($object[
"child"] != $this->
getRoot())
707 $this->format_options[
"$parent_index"][
"container"] =
true;
709 if ($this->expand_all or in_array($object[
"parent"],$this->expanded))
714 $this->format_options[
"$parent_index"][
"tab"][($tab-2)] =
'forceexp';
718 $this->format_options[
"$parent_index"][
"tab"][($tab-2)] =
'minus';
723 $this->format_options[
"$parent_index"][
"tab"][($tab-2)] =
'plus';
729 $ilBench->stop(
"Explorer",
"setOutput_setFormatOptions");
732 if ($this->expand_all or in_array($object[
"parent"],$this->expanded) or ($object[
"parent"] == 0)
735 $highlighted_subtree = ($a_highlighted_subtree ||
736 ($object[
"child"] == $this->highlighted))
741 $this->
setOutput($object[
"child"],$a_depth,$object[
'obj_id'], $highlighted_subtree);
780 $this->tree->getMaximumDepth();
794 $ilBench->start(
"Explorer",
"getOutput");
796 $this->format_options[0][
"tab"] = array();
800 for ($i=0;$i<$depth;++$i)
805 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
807 $tpl->addJavaScript(
"./Services/UIComponent/Explorer/js/ilExplorer.js");
809 $tpl->addBlockFile(
"EXPLORER_TOP",
"exp_top",
"tpl.explorer_top.html");
812 $tpl->setBodyClass(
"il_Explorer");
814 $tpl_tree =
new ilTemplate(
"tpl.tree.html",
true,
true,
"Services/UIComponent/Explorer");
817 if ((
$_GET[
"ict"] ||
$_POST[
"collapseAll"] !=
"" ||
$_POST[
"expandAll"] !=
"") && $this->up_frame !=
"")
819 $tpl_tree->setCurrentBlock(
"updater");
820 $tpl_tree->setVariable(
"UPDATE_FRAME", $this->up_frame);
821 $tpl_tree->setVariable(
"UPDATE_SCRIPT", $this->up_script);
822 if (is_array($this->up_params))
825 foreach ($this->up_params as $p)
827 $up_str.= $lim.
"'".$p.
"'";
830 $tpl_tree->setVariable(
"UPDATE_PARAMS", $up_str);
832 $tpl_tree->parseCurrentBlock();
836 foreach ($this->format_options as $key => $options)
839 if (!$options[
"visible"])
850 $cur_depth = $options[
"depth"];
852 if ($options[
"visible"] and $key != 0)
854 $this->
formatObject($tpl_tree, $options[
"child"],$options,$options[
'obj_id']);
858 $this->
formatHeader($tpl_tree, $options[
"child"],$options);
865 $ilBench->stop(
"Explorer",
"getOutput");
867 $tpl_tree->setVariable(
"TREE_LEAD",
"");
868 if ($this->tree_lead !=
"")
870 $tpl_tree->setCurrentBlock(
"tree_lead");
871 $tpl_tree->setVariable(
"TREE_LEAD", $this->tree_lead);
872 $tpl_tree->parseCurrentBlock();
874 if ($this->
getId() !=
"")
876 $tpl_tree->setVariable(
"TREE_ID",
'id="'.$this->
getId().
'_tree"');
879 $html = $tpl_tree->get();
883 $mtpl =
new ilTemplate(
"tpl.main.html",
true,
true);
885 $mtpl->setVariable(
"BODY_CLASS",
"il_Explorer");
886 $mtpl->addBlockFile(
"CONTENT",
"content",
"tpl.explorer.html");
889 $mtpl->setVariable(
"TXT_EXPLORER_HEADER", $this->
getTitle());
891 if ($this->
getId() !=
"")
893 $mtpl->setVariable(
"ID",
'id="'.$this->
getId().
'"');
896 $mtpl->setCurrentBlock(
"content");
897 $mtpl->setVariable(
"EXPLORER", $html);
898 $mtpl->setVariable(
"EXP_REFRESH", $lng->txt(
"refresh"));
899 $mtpl->parseCurrentBlock();
900 $html = $mtpl->get();
913 if ($a_item_depth < $a_cur_depth)
916 for ($i = 0; $i < ($a_cur_depth - $a_item_depth); $i++)
918 $a_tpl_tree->touchBlock(
"end_list_item");
919 $a_tpl_tree->touchBlock(
"element");
921 $a_tpl_tree->touchBlock(
"end_list");
922 $a_tpl_tree->touchBlock(
"element");
925 else if ($a_item_depth == $a_cur_depth)
928 $a_tpl_tree->touchBlock(
"end_list_item");
929 $a_tpl_tree->touchBlock(
"element");
939 if ($a_item_depth > $a_cur_depth)
942 if ($a_item_depth > 1)
944 $a_tpl_tree->touchBlock(
"start_list");
948 $a_tpl_tree->touchBlock(
"start_list_no_indent");
950 $a_tpl_tree->touchBlock(
"element");
952 $a_tpl_tree->touchBlock(
"start_list_item");
953 $a_tpl_tree->touchBlock(
"element");
958 $a_tpl_tree->touchBlock(
"start_list_item");
959 $a_tpl_tree->touchBlock(
"element");
986 if (!isset($a_node_id) or !is_array($a_option))
988 $this->ilias->raiseError(get_class($this).
"::formatObject(): Missing parameter or wrong datatype! ".
989 "node_id: ".$a_node_id.
" options:".var_dump($a_option),$this->ilias->error_obj->WARNING);
993 foreach ((array) $a_option[
"tab"] as $picture)
995 if ($picture ==
'plus')
997 $tpl->setCurrentBlock(
"exp_desc");
998 $tpl->setVariable(
"EXP_DESC", $lng->txt(
"collapsed"));
999 $tpl->parseCurrentBlock();
1000 $tpl->setCurrentBlock(
"expander");
1001 $tpl->setVariable(
"LINK_NAME", $a_node_id);
1005 $tpl->setVariable(
"LINK_TARGET_EXPANDER",
$target);
1010 $tpl->setVariable(
"ONCLICK_TARGET_EXPANDER",
" onclick=\"return il.Explorer.refresh('tree_div', '".
$target.
"');\"");
1011 $tpl->setVariable(
"LINK_TARGET_EXPANDER",
"#");
1013 $tpl->setVariable(
"IMGPATH", $this->
getImage(
"browser/plus.png"));
1014 $tpl->parseCurrentBlock();
1018 if ($picture ==
'forceexp')
1020 $tpl->setCurrentBlock(
"exp_desc");
1021 $tpl->setVariable(
"EXP_DESC", $lng->txt(
"expanded"));
1022 $tpl->parseCurrentBlock();
1024 $tpl->setCurrentBlock(
"expander");
1025 $tpl->setVariable(
"LINK_NAME", $a_node_id);
1026 $tpl->setVariable(
"LINK_TARGET_EXPANDER",
$target);
1027 $tpl->setVariable(
"IMGPATH", $this->
getImage(
"browser/forceexp.png"));
1028 $tpl->parseCurrentBlock();
1032 if ($picture ==
'minus' && $this->show_minus)
1034 $tpl->setCurrentBlock(
"exp_desc");
1035 $tpl->setVariable(
"EXP_DESC", $lng->txt(
"expanded"));
1036 $tpl->parseCurrentBlock();
1037 $tpl->setCurrentBlock(
"expander");
1038 $tpl->setVariable(
"LINK_NAME", $a_node_id);
1042 $tpl->setVariable(
"LINK_TARGET_EXPANDER",
$target);
1047 $tpl->setVariable(
"ONCLICK_TARGET_EXPANDER",
" onclick=\"return il.Explorer.refresh('tree_div', '".
$target.
"');\"");
1048 $tpl->setVariable(
"LINK_TARGET_EXPANDER",
"#");
1050 $tpl->setVariable(
"IMGPATH", $this->
getImage(
"browser/minus.png"));
1051 $tpl->parseCurrentBlock();
1069 $tpl->setCurrentBlock(
"blank");
1070 $tpl->setVariable(
"BLANK_PATH", $this->
getImage(
"browser/blank.png"));
1071 $tpl->parseCurrentBlock();
1074 if ($this->output_icons)
1076 $tpl->setCurrentBlock(
"icon");
1077 $tpl->setVariable(
"ICON_IMAGE" , $this->
getImage(
"icon_".$a_option[
"type"].
"_s.png", $a_option[
"type"], $a_obj_id));
1079 $tpl->setVariable(
"TARGET_ID" ,
"iconid_".$a_node_id);
1080 $this->iconList[] =
"iconid_".$a_node_id;
1081 $tpl->setVariable(
"TXT_ALT_IMG",
1082 $this->
getImageAlt($lng->txt(
"icon").
" ".$lng->txt($a_option[
"desc"]), $a_option[
"type"], $a_obj_id));
1083 $tpl->parseCurrentBlock();
1086 if(strlen($sel = $this->
buildSelect($a_node_id,$a_option[
'type'])))
1088 $tpl->setCurrentBlock(
'select');
1089 $tpl->setVariable(
'OBJ_SEL',$sel);
1090 $tpl->parseCurrentBlock();
1093 if ($this->
isClickable($a_option[
"type"], $a_node_id,$a_obj_id))
1095 $tpl->setCurrentBlock(
"link");
1103 if ($style_class !=
"")
1105 $tpl->setVariable(
"A_CLASS",
' class="'.$style_class.
'" ' );
1108 if (($onclick = $this->
buildOnClick($a_node_id, $a_option[
"type"], $a_option[
"title"])) !=
"")
1110 $tpl->setVariable(
"ONCLICK",
"onClick=\"$onclick\"");
1115 $this->
buildTitle($a_option[
"title"], $a_node_id, $a_option[
"type"]),
1116 $this->textwidth,
true));
1118 $this->
buildDescription($a_option[
"description"], $a_node_id, $a_option[
"type"]), $this->textwidth,
true));
1119 $frame_target = $this->
buildFrameTarget($a_option[
"type"], $a_node_id, $a_option[
"obj_id"]);
1120 if ($frame_target !=
"")
1122 $tpl->setVariable(
"TARGET",
" target=\"".$frame_target.
"\"");
1124 $tpl->parseCurrentBlock();
1128 $tpl->setCurrentBlock(
"text");
1130 $this->
buildTitle($a_option[
"title"], $a_node_id, $a_option[
"type"]), $this->textwidth,
true));
1132 $this->
buildDescription($a_option[
"desc"], $a_node_id, $a_option[
"type"]), $this->textwidth,
true));
1133 $tpl->parseCurrentBlock();
1136 $tpl->setCurrentBlock(
"list_item");
1137 $tpl->parseCurrentBlock();
1138 $tpl->touchBlock(
"element");
1144 function getImage($a_name, $a_type =
"", $a_obj_id =
"")
1154 return $a_default_text;
1162 if ($a_id == $this->highlighted)
1164 return "il_HighlightedNode";
1174 $target = (strpos($this->target,
"?") ===
false)
1176 : $this->target.
"&";
1177 return $target.$this->target_get.
"=".$a_node_id.$this->params_get;
1218 return $this->frame_target;
1229 function createTarget($a_type,$a_node_id,$a_highlighted_subtree =
false, $a_append_anch =
true)
1231 if (!isset($a_type) or !is_string($a_type) or !isset($a_node_id))
1233 $this->ilias->raiseError(get_class($this).
"::createTarget(): Missing parameter or wrong datatype! ".
1234 "type: ".$a_type.
" node_id:".$a_node_id,$this->ilias->error_obj->WARNING);
1240 $a_node_id = $a_type ==
'+' ? $a_node_id : -(int) $a_node_id;
1242 $sep = (is_int(strpos($this->expand_target,
"?")))
1247 $ict_str = ($a_highlighted_subtree || $this->highlighted ==
"")
1252 $ict_str.=
"&cmdMode=asynch";
1256 return $this->expand_target.$sep.$this->expand_variable.
"=".$a_node_id.$this->params_get.$ict_str.
"#".abs($a_node_id);
1260 return $this->expand_target.$sep.$this->expand_variable.
"=".$a_node_id.$this->params_get.$ict_str;
1272 $this->frame_target = $a_target;
1282 for ($i = 0; $i < count($this->format_options); ++$i)
1284 if ($this->format_options[$i][
"depth"] == $a_depth+1
1285 and !$this->format_options[$i][
"container"]
1286 and $this->format_options[$i][
"depth"] != 1)
1288 $this->format_options[$i][
"tab"][
"$a_depth"] =
"quer";
1291 if ($this->format_options[$i][
"depth"] == $a_depth+2)
1293 if ($this->
is_in_array($i+1,$this->format_options[$i][
"depth"]))
1295 $this->format_options[$i][
"tab"][
"$a_depth"] =
"winkel";
1299 $this->format_options[$i][
"tab"][
"$a_depth"] =
"ecke";
1303 if ($this->format_options[$i][
"depth"] > $a_depth+2)
1307 $this->format_options[$i][
"tab"][
"$a_depth"] =
"hoch";
1322 for ($i=$a_start;$i<count($this->format_options);++$i)
1324 if ($this->format_options[$i][
"depth"] < $a_depth)
1329 if ($this->format_options[$i][
"depth"] == $a_depth)
1345 if(!is_array($this->format_options))
1350 foreach ($this->format_options as $key => $value)
1352 if (($value[
"child"] == $a_data[
"parent"]))
1360 #$this->ilias->raiseError(get_class($this)."::getIndex(): Error in tree. No index found!",$this->ilias->error_obj->FATAL);
1373 if (is_array($this->filter))
1376 foreach ($this->filter as $item)
1378 if ($item == $a_item)
1388 $this->filter = array();
1390 if ($is_present == 0)
1392 $this->filter[] = $a_item;
1407 if (is_array($this->filter))
1412 foreach ($this->filter as $item)
1414 if ($item != $a_item)
1424 $this->filter = $tmp;
1450 if(!is_array(
$_SESSION[$this->expand_variable]))
1455 if ($a_node_id > 0 && !in_array($a_node_id,
$_SESSION[$this->expand_variable]))
1457 array_push(
$_SESSION[$this->expand_variable],$a_node_id);
1462 $key = array_keys(
$_SESSION[$this->expand_variable],-(
int) $a_node_id);
1463 unset(
$_SESSION[$this->expand_variable][$key[0]]);
1476 $this->expand_all = (bool) $a_mode;
1477 $this->show_minus = $a_show_minus;
1488 $this->filtered = $a_bool;
1500 if (is_array($this->filter))
1502 if (in_array($a_item, $this->filter))
1534 foreach ($a_nodes as $key => $node)
1536 if ($node[
"type"] ==
"adm")
1545 isset($match) ? array_splice($a_nodes,$match,1) :
"";
1547 $a_nodes =
ilUtil::sortArray($a_nodes,$this->order_column,$this->order_direction);
1550 isset ($match) ? array_push($a_nodes,$adm_node) :
"";