4 define(
"IL_FM_POSITIVE", 1);
5 define(
"IL_FM_NEGATIVE", 2);
168 global
$ilias, $objDefinition;
170 if (!isset($a_target) or !is_string($a_target))
172 $this->ilias->raiseError(get_class($this).
"::Constructor(): No target given!",$this->ilias->error_obj->WARNING);
176 $devtypes = $objDefinition->getDevModeAll();
178 if (count($devtypes > 0))
183 foreach ($devtypes as
$type)
190 $this->output = array();
191 $this->expanded = array();
192 $this->target = $a_target;
193 $this->target_get =
'ref_id';
194 $this->frame_target =
"content";
195 $this->order_column =
"title";
196 $this->tree =
new ilTree(ROOT_FOLDER_ID);
197 $this->expand_target = $_SERVER[
"PATH_INFO"];
198 $this->rbac_check =
true;
199 $this->output_icons =
true;
200 $this->expand_variable =
"expand";
202 $this->post_sort=
true;
204 $this->highlighted =
"";
205 $this->show_minus =
true;
218 $this->counter = $a_number;
228 $this->title = $a_val;
238 $this->textwidth = $a_length;
247 return $this->textwidth;
269 #$this->tree = new ilTree(ROOT_FOLDER_ID,$a_root_id);
270 $this->root_id = $a_root_id;
282 return $this->root_id == null ?
283 $this->tree->getRootId() :
294 $this->order_column = $a_column;
304 if ($a_direction ==
"desc")
306 $this->order_direction = $a_direction;
310 $this->order_direction =
"asc";
321 if (!isset($a_target_get) or !is_string($a_target_get))
323 $this->ilias->raiseError(get_class($this).
"::setTargetGet(): No target given!",$this->ilias->error_obj->WARNING);
326 $this->target_get = $a_target_get;
336 if (!isset($a_params_get) or !is_array($a_params_get))
338 $this->ilias->raiseError(get_class($this).
"::setTargetGet(): No target given!",$this->ilias->error_obj->WARNING);
341 foreach ($a_params_get as $key => $val)
343 $str .=
"&".$key.
"=".$val;
346 $this->params_get = $str;
358 $this->expand_target = $a_exp_target;
368 $this->up_frame = $a_up_frame;
369 $this->up_script = $a_up_script;
370 $this->up_params = $a_params;
379 $this->highlighted = $a_id;
389 $this->rbac_check = $a_check;
399 $this->expand_variable = $a_var_name;
409 $this->output_icons = $a_icons;
423 $this->is_clickable[$a_type] =
"";
427 $this->is_clickable[$a_type] =
"n";
435 if (!$this->rbac_check)
440 $ilBench->start(
"Explorer",
"setOutput_isVisible");
441 $visible = $rbacsystem->checkAccess(
'visible',$a_ref_id);
442 $ilBench->stop(
"Explorer",
"setOutput_isVisible");
454 $this->tree_lead = $a_val;
464 return $this->tree_lead;
480 if ($this->is_clickable[$a_type] ==
"n")
496 $this->post_sort = $a_sort;
506 $this->filter_mode = $a_mode;
527 $this->use_standard_frame = $a_val;
548 function setOutput($a_parent_id, $a_depth = 1,$a_obj_id = 0, $a_highlighted_subtree =
false)
550 global $rbacadmin, $rbacsystem,
$ilBench;
552 #echo 'ParentId: '.$a_parent_id.' depth: '.$a_depth.' obj_id: '.$a_obj_id;
554 if (!isset($a_parent_id))
556 $this->ilias->raiseError(get_class($this).
"::setOutput(): No node_id given!",$this->ilias->error_obj->WARNING);
559 if ($this->
showChilds($a_parent_id,$a_obj_id))
561 $objects = $this->tree->getChilds($a_parent_id, $this->order_column);
575 if ($this->
forceExpanded($a_parent_id) && !in_array($a_parent_id, $this->expanded))
577 $this->expanded[] = $a_parent_id;
580 if (count($objects) > 0)
583 $tab = ++$a_depth - 2;
584 if ($this->post_sort)
586 $objects = $this->
sortNodes($objects,$a_obj_id);
589 foreach ($objects as $key => $object)
598 if ($this->filtered ==
false or $this->
checkFilter($object[
"type"]) ==
false)
600 if ($this->
isVisible($object[
'child'],$object[
'type']))
602 $ilBench->start(
"Explorer",
"setOutput_setFormatOptions");
603 #echo 'CHILD getIndex() '.$object['child'].' parent: '.$this->getRoot();
604 if ($object[
"child"] != $this->
getRoot())
606 $parent_index = $this->
getIndex($object);
608 $this->format_options[
"$this->counter"][
"parent"] = $object[
"parent"];
609 $this->format_options[
"$this->counter"][
"child"] = $object[
"child"];
610 $this->format_options[
"$this->counter"][
"title"] = $object[
"title"];
611 $this->format_options[
"$this->counter"][
"type"] = $object[
"type"];
612 $this->format_options[
"$this->counter"][
"obj_id"] = $object[
"obj_id"];
613 $this->format_options[
"$this->counter"][
"desc"] =
"obj_".$object[
"type"];
614 $this->format_options[
"$this->counter"][
"depth"] =
$tab;
615 $this->format_options[
"$this->counter"][
"container"] =
false;
616 $this->format_options[
"$this->counter"][
"visible"] =
true;
617 $this->format_options[
"$this->counter"][
"highlighted_subtree"] = $a_highlighted_subtree;
620 for ($i = 0; $i <
$tab; ++$i)
622 $this->format_options[
"$this->counter"][
"tab"][] =
'blank';
626 if ($parent_index == 0)
628 if (!$this->expand_all and !in_array($object[
"parent"], $this->expanded))
630 $this->expanded[] = $object[
"parent"];
635 if ($object[
"child"] != $this->
getRoot() and ((!$this->expand_all and !in_array($object[
"parent"],$this->expanded))
636 or !$this->format_options[
"$parent_index"][
"visible"]))
643 if ($this->format_options[
"$this->counter"][
"visible"])
648 $this->format_options[
"$this->counter"][
"visible"] =
false;
653 if ($object[
"child"] != $this->
getRoot())
655 $this->format_options[
"$parent_index"][
"container"] =
true;
657 if ($this->expand_all or in_array($object[
"parent"],$this->expanded))
662 $this->format_options[
"$parent_index"][
"tab"][($tab-2)] =
'forceexp';
666 $this->format_options[
"$parent_index"][
"tab"][($tab-2)] =
'minus';
671 $this->format_options[
"$parent_index"][
"tab"][($tab-2)] =
'plus';
677 $ilBench->stop(
"Explorer",
"setOutput_setFormatOptions");
680 if ($this->expand_all or in_array($object[
"parent"],$this->expanded) or ($object[
"parent"] == 0)
683 $highlighted_subtree = ($a_highlighted_subtree ||
684 ($object[
"child"] == $this->highlighted))
689 $this->
setOutput($object[
"child"],$a_depth,$object[
'obj_id'], $highlighted_subtree);
730 $ilBench->start(
"Explorer",
"getOutput");
732 $this->format_options[0][
"tab"] = array();
734 $depth = $this->tree->getMaximumDepth();
736 for ($i=0;$i<$depth;++$i)
741 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
743 $tpl->addJavaScript(
"./Services/Explorer/js/ilexplorercallback.js");
745 $tpl->addBlockFile(
"EXPLORER_TOP",
"exp_top",
"tpl.explorer_top.html");
748 $tpl->setBodyClass(
"il_Explorer");
750 $tpl_tree =
new ilTemplate(
"tpl.tree.html",
true,
true);
753 if ((
$_GET[
"ict"] ||
$_POST[
"collapseAll"] !=
"" ||
$_POST[
"expandAll"] !=
"") && $this->up_frame !=
"")
755 $tpl_tree->setCurrentBlock(
"updater");
756 $tpl_tree->setVariable(
"UPDATE_FRAME", $this->up_frame);
757 $tpl_tree->setVariable(
"UPDATE_SCRIPT", $this->up_script);
758 if (is_array($this->up_params))
761 foreach ($this->up_params as $p)
763 $up_str.= $lim.
"'".$p.
"'";
766 $tpl_tree->setVariable(
"UPDATE_PARAMS", $up_str);
768 $tpl_tree->parseCurrentBlock();
772 foreach ($this->format_options as $key => $options)
775 if (!$options[
"visible"])
786 $cur_depth = $options[
"depth"];
788 if ($options[
"visible"] and $key != 0)
790 $this->
formatObject($tpl_tree, $options[
"child"],$options,$options[
'obj_id']);
794 $this->
formatHeader($tpl_tree, $options[
"child"],$options);
801 $ilBench->stop(
"Explorer",
"getOutput");
803 $tpl_tree->setVariable(
"TREE_LEAD",
"");
804 if ($this->tree_lead !=
"")
806 $tpl_tree->setCurrentBlock(
"tree_lead");
807 $tpl_tree->setVariable(
"TREE_LEAD", $this->tree_lead);
808 $tpl_tree->parseCurrentBlock();
811 $html = $tpl_tree->get();
815 $mtpl =
new ilTemplate(
"tpl.main.html",
true,
true);
817 $mtpl->setVariable(
"BODY_CLASS",
"il_Explorer");
818 $mtpl->addBlockFile(
"CONTENT",
"content",
"tpl.explorer.html");
821 $mtpl->setVariable(
"TXT_EXPLORER_HEADER", $this->
getTitle());
824 $mtpl->setCurrentBlock(
"content");
825 $mtpl->setVariable(
"EXPLORER", $html);
826 $mtpl->setVariable(
"EXP_REFRESH", $lng->txt(
"refresh"));
827 $mtpl->parseCurrentBlock();
828 $html = $mtpl->get();
841 if ($a_item_depth < $a_cur_depth)
844 for ($i = 0; $i < ($a_cur_depth - $a_item_depth); $i++)
846 $a_tpl_tree->touchBlock(
"end_list_item");
847 $a_tpl_tree->touchBlock(
"element");
849 $a_tpl_tree->touchBlock(
"end_list");
850 $a_tpl_tree->touchBlock(
"element");
853 else if ($a_item_depth == $a_cur_depth)
856 $a_tpl_tree->touchBlock(
"end_list_item");
857 $a_tpl_tree->touchBlock(
"element");
867 if ($a_item_depth > $a_cur_depth)
870 if ($a_item_depth > 1)
872 $a_tpl_tree->touchBlock(
"start_list");
876 $a_tpl_tree->touchBlock(
"start_list_no_indent");
878 $a_tpl_tree->touchBlock(
"element");
880 $a_tpl_tree->touchBlock(
"start_list_item");
881 $a_tpl_tree->touchBlock(
"element");
886 $a_tpl_tree->touchBlock(
"start_list_item");
887 $a_tpl_tree->touchBlock(
"element");
914 if (!isset($a_node_id) or !is_array($a_option))
916 $this->ilias->raiseError(get_class($this).
"::formatObject(): Missing parameter or wrong datatype! ".
917 "node_id: ".$a_node_id.
" options:".var_dump($a_option),$this->ilias->error_obj->WARNING);
921 foreach ((array) $a_option[
"tab"] as $picture)
923 if ($picture ==
'plus')
925 $tpl->setCurrentBlock(
"exp_desc");
926 $tpl->setVariable(
"EXP_DESC", $lng->txt(
"collapsed"));
927 $tpl->parseCurrentBlock();
929 $tpl->setCurrentBlock(
"expander");
930 $tpl->setVariable(
"LINK_NAME", $a_node_id);
931 $tpl->setVariable(
"LINK_TARGET_EXPANDER",
$target);
932 $tpl->setVariable(
"IMGPATH", $this->
getImage(
"browser/plus.gif"));
933 $tpl->parseCurrentBlock();
937 if ($picture ==
'forceexp')
939 $tpl->setCurrentBlock(
"exp_desc");
940 $tpl->setVariable(
"EXP_DESC", $lng->txt(
"expanded"));
941 $tpl->parseCurrentBlock();
943 $tpl->setCurrentBlock(
"expander");
944 $tpl->setVariable(
"LINK_NAME", $a_node_id);
945 $tpl->setVariable(
"LINK_TARGET_EXPANDER",
$target);
946 $tpl->setVariable(
"IMGPATH", $this->
getImage(
"browser/forceexp.gif"));
947 $tpl->parseCurrentBlock();
951 if ($picture ==
'minus' && $this->show_minus)
953 $tpl->setCurrentBlock(
"exp_desc");
954 $tpl->setVariable(
"EXP_DESC", $lng->txt(
"expanded"));
955 $tpl->parseCurrentBlock();
957 $tpl->setCurrentBlock(
"expander");
958 $tpl->setVariable(
"LINK_NAME", $a_node_id);
959 $tpl->setVariable(
"LINK_TARGET_EXPANDER",
$target);
960 $tpl->setVariable(
"IMGPATH", $this->
getImage(
"browser/minus.gif"));
961 $tpl->parseCurrentBlock();
979 $tpl->setCurrentBlock(
"blank");
980 $tpl->setVariable(
"BLANK_PATH", $this->
getImage(
"browser/blank.gif"));
981 $tpl->parseCurrentBlock();
984 if ($this->output_icons)
986 $tpl->setCurrentBlock(
"icon");
987 $tpl->setVariable(
"ICON_IMAGE" , $this->
getImage(
"icon_".$a_option[
"type"].
"_s.gif", $a_option[
"type"], $a_obj_id));
989 $tpl->setVariable(
"TARGET_ID" ,
"iconid_".$a_node_id);
990 $this->iconList[] =
"iconid_".$a_node_id;
991 $tpl->setVariable(
"TXT_ALT_IMG",
992 $this->
getImageAlt($lng->txt(
"icon").
" ".$lng->txt($a_option[
"desc"]), $a_option[
"type"], $a_obj_id));
993 $tpl->parseCurrentBlock();
996 if(strlen($sel = $this->
buildSelect($a_node_id,$a_option[
'type'])))
998 $tpl->setCurrentBlock(
'select');
999 $tpl->setVariable(
'OBJ_SEL',$sel);
1000 $tpl->parseCurrentBlock();
1003 if ($this->
isClickable($a_option[
"type"], $a_node_id,$a_obj_id))
1005 $tpl->setCurrentBlock(
"link");
1013 if ($style_class !=
"")
1015 $tpl->setVariable(
"A_CLASS",
' class="'.$style_class.
'" ' );
1018 if (($onclick = $this->
buildOnClick($a_node_id, $a_option[
"type"], $a_option[
"title"])) !=
"")
1020 $tpl->setVariable(
"ONCLICK",
"onClick=\"$onclick\"");
1025 $this->
buildTitle($a_option[
"title"], $a_node_id, $a_option[
"type"]),
1026 $this->textwidth,
true));
1028 $this->
buildDescription($a_option[
"description"], $a_node_id, $a_option[
"type"]), $this->textwidth,
true));
1029 $frame_target = $this->
buildFrameTarget($a_option[
"type"], $a_node_id, $a_option[
"obj_id"]);
1030 if ($frame_target !=
"")
1032 $tpl->setVariable(
"TARGET",
" target=\"".$frame_target.
"\"");
1034 $tpl->parseCurrentBlock();
1038 $tpl->setCurrentBlock(
"text");
1040 $this->
buildTitle($a_option[
"title"], $a_node_id, $a_option[
"type"]), $this->textwidth,
true));
1042 $this->
buildDescription($a_option[
"desc"], $a_node_id, $a_option[
"type"]), $this->textwidth,
true));
1043 $tpl->parseCurrentBlock();
1046 $tpl->setCurrentBlock(
"list_item");
1047 $tpl->parseCurrentBlock();
1048 $tpl->touchBlock(
"element");
1054 function getImage($a_name, $a_type =
"", $a_obj_id =
"")
1064 return $a_default_text;
1072 if ($a_id == $this->highlighted)
1074 return "il_HighlightedNode";
1084 $target = (strpos($this->target,
"?") ===
false)
1086 : $this->target.
"&";
1087 return $target.$this->target_get.
"=".$a_node_id.$this->params_get;
1128 return $this->frame_target;
1141 if (!isset($a_type) or !is_string($a_type) or !isset($a_node_id))
1143 $this->ilias->raiseError(get_class($this).
"::createTarget(): Missing parameter or wrong datatype! ".
1144 "type: ".$a_type.
" node_id:".$a_node_id,$this->ilias->error_obj->WARNING);
1150 $a_node_id = $a_type ==
'+' ? $a_node_id : -(int) $a_node_id;
1152 $sep = (is_int(strpos($this->expand_target,
"?")))
1157 $ict_str = ($a_highlighted_subtree || $this->highlighted ==
"")
1160 return $this->expand_target.$sep.$this->expand_variable.
"=".$a_node_id.$this->params_get.$ict_str.
"#".abs($a_node_id);
1171 $this->frame_target = $a_target;
1181 for ($i = 0; $i < count($this->format_options); ++$i)
1183 if ($this->format_options[$i][
"depth"] == $a_depth+1
1184 and !$this->format_options[$i][
"container"]
1185 and $this->format_options[$i][
"depth"] != 1)
1187 $this->format_options[$i][
"tab"][
"$a_depth"] =
"quer";
1190 if ($this->format_options[$i][
"depth"] == $a_depth+2)
1192 if ($this->
is_in_array($i+1,$this->format_options[$i][
"depth"]))
1194 $this->format_options[$i][
"tab"][
"$a_depth"] =
"winkel";
1198 $this->format_options[$i][
"tab"][
"$a_depth"] =
"ecke";
1202 if ($this->format_options[$i][
"depth"] > $a_depth+2)
1206 $this->format_options[$i][
"tab"][
"$a_depth"] =
"hoch";
1221 for ($i=$a_start;$i<count($this->format_options);++$i)
1223 if ($this->format_options[$i][
"depth"] < $a_depth)
1228 if ($this->format_options[$i][
"depth"] == $a_depth)
1244 if(!is_array($this->format_options))
1249 foreach ($this->format_options as $key => $value)
1251 if (($value[
"child"] == $a_data[
"parent"]))
1259 #$this->ilias->raiseError(get_class($this)."::getIndex(): Error in tree. No index found!",$this->ilias->error_obj->FATAL);
1272 if (is_array($this->filter))
1275 foreach ($this->filter as $item)
1277 if ($item == $a_item)
1287 $this->filter = array();
1289 if ($is_present == 0)
1291 $this->filter[] = $a_item;
1306 if (is_array($this->filter))
1311 foreach ($this->filter as $item)
1313 if ($item != $a_item)
1323 $this->filter = $tmp;
1349 if(!is_array(
$_SESSION[$this->expand_variable]))
1354 if ($a_node_id > 0 && !in_array($a_node_id,
$_SESSION[$this->expand_variable]))
1356 array_push(
$_SESSION[$this->expand_variable],$a_node_id);
1361 $key = array_keys(
$_SESSION[$this->expand_variable],-(
int) $a_node_id);
1362 unset(
$_SESSION[$this->expand_variable][$key[0]]);
1375 $this->expand_all = (bool) $a_mode;
1376 $this->show_minus = $a_show_minus;
1387 $this->filtered = $a_bool;
1399 if (is_array($this->filter))
1401 if (in_array($a_item, $this->filter))
1433 foreach ($a_nodes as $key => $node)
1435 if ($node[
"type"] ==
"adm")
1444 isset($match) ? array_splice($a_nodes,$match,1) :
"";
1446 $a_nodes =
ilUtil::sortArray($a_nodes,$this->order_column,$this->order_direction);
1449 isset ($match) ? array_push($a_nodes,$adm_node) :
"";