ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilExplorer.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 define("IL_FM_POSITIVE", 1);
5 define("IL_FM_NEGATIVE", 2);
6 
17 {
23  var $ilias;
24 
30  var $output;
31 
38 
44  var $tree;
45 
51  var $target;
52 
59 
66 
72  var $expanded;
73 
80 
86  var $order_direction = "asc";
87 
94 
101 
102 
109 
116 
123 
130 
136  var $filtered = false;
137 
144 
150  var $expand_all = false;
151 
157  var $root_id = null;
158 
159  var $use_standard_frame = false;
160 
166  function ilExplorer($a_target)
167  {
168  global $ilias, $objDefinition;
169 
170  if (!isset($a_target) or !is_string($a_target))
171  {
172  $this->ilias->raiseError(get_class($this)."::Constructor(): No target given!",$this->ilias->error_obj->WARNING);
173  }
174 
175  // autofilter object types in devmode
176  $devtypes = $objDefinition->getDevModeAll();
177 
178  if (count($devtypes > 0))
179  {
180  // activate filter if objects found in devmode
181  $this->setFiltered(true);
182 
183  foreach ($devtypes as $type)
184  {
185  $this->addFilter($type);
186  }
187  }
188 
189  $this->ilias =& $ilias;
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";
201  $this->setTitleLength(50);
202  $this->post_sort=true;
204  $this->highlighted = "";
205  $this->show_minus = true;
206  $this->counter = 0;
207  }
208 
216  public function initItemCounter($a_number)
217  {
218  $this->counter = $a_number;
219  }
220 
226  function setTitle($a_val)
227  {
228  $this->title = $a_val;
229  }
230 
236  public function setTitleLength($a_length)
237  {
238  $this->textwidth = $a_length;
239  }
240 
245  public function getTitleLength()
246  {
247  return $this->textwidth;
248  }
249 
255  function getTitle()
256  {
257  return $this->title;
258  }
259 
267  public function setRoot($a_root_id)
268  {
269  #$this->tree = new ilTree(ROOT_FOLDER_ID,$a_root_id);
270  $this->root_id = $a_root_id;
271  }
272 
280  public function getRoot()
281  {
282  return $this->root_id == null ?
283  $this->tree->getRootId() :
285  }
286 
292  function setOrderColumn($a_column)
293  {
294  $this->order_column = $a_column;
295  }
296 
302  function setOrderDirection($a_direction)
303  {
304  if ($a_direction == "desc")
305  {
306  $this->order_direction = $a_direction;
307  }
308  else
309  {
310  $this->order_direction = "asc";
311  }
312  }
313 
319  function setTargetGet($a_target_get)
320  {
321  if (!isset($a_target_get) or !is_string($a_target_get))
322  {
323  $this->ilias->raiseError(get_class($this)."::setTargetGet(): No target given!",$this->ilias->error_obj->WARNING);
324  }
325 
326  $this->target_get = $a_target_get;
327  }
328 
334  function setParamsGet($a_params_get)
335  {
336  if (!isset($a_params_get) or !is_array($a_params_get))
337  {
338  $this->ilias->raiseError(get_class($this)."::setTargetGet(): No target given!",$this->ilias->error_obj->WARNING);
339  }
340 
341  foreach ($a_params_get as $key => $val)
342  {
343  $str .= "&".$key."=".$val;
344  }
345 
346  $this->params_get = $str;
347  }
348 
349 
356  function setExpandTarget($a_exp_target)
357  {
358  $this->expand_target = $a_exp_target;
359  }
360 
366  function setFrameUpdater($a_up_frame, $a_up_script, $a_params = "")
367  {
368  $this->up_frame = $a_up_frame;
369  $this->up_script = $a_up_script;
370  $this->up_params = $a_params;
371  }
372 
373 
377  function highlightNode($a_id)
378  {
379  $this->highlighted = $a_id;
380  }
381 
387  function checkPermissions($a_check)
388  {
389  $this->rbac_check = $a_check;
390  }
391 
397  function setSessionExpandVariable($a_var_name = "expand")
398  {
399  $this->expand_variable = $a_var_name;
400  }
401 
407  function outputIcons($a_icons)
408  {
409  $this->output_icons = $a_icons;
410  }
411 
412 
419  function setClickable($a_type, $a_clickable)
420  {
421  if($a_clickable)
422  {
423  $this->is_clickable[$a_type] = "";
424  }
425  else
426  {
427  $this->is_clickable[$a_type] = "n";
428  }
429  }
430 
431  function isVisible($a_ref_id,$a_type)
432  {
433  global $rbacsystem, $ilBench;
434 
435  if (!$this->rbac_check)
436  {
437  return true;
438  }
439 
440  $ilBench->start("Explorer", "setOutput_isVisible");
441  $visible = $rbacsystem->checkAccess('visible',$a_ref_id);
442  $ilBench->stop("Explorer", "setOutput_isVisible");
443 
444  return $visible;
445  }
446 
452  public function setTreeLead($a_val)
453  {
454  $this->tree_lead = $a_val;
455  }
456 
462  public function getTreeLead()
463  {
464  return $this->tree_lead;
465  }
466 
474  function isClickable($a_type, $a_ref_id = 0)
475  {
476  // in this standard implementation
477  // only the type determines, wether an object should be clickable or not
478  // but this method can be overwritten and make $exp->setFilterMode(IL_FM_NEGATIVE);use of the ref id
479  // (this happens e.g. in class ilRepositoryExplorerGUI)
480  if ($this->is_clickable[$a_type] == "n")
481  {
482  return false;
483  }
484  else
485  {
486  return true;
487  }
488  }
489 
494  function setPostSort($a_sort)
495  {
496  $this->post_sort = $a_sort;
497  }
498 
504  function setFilterMode($a_mode = IL_FM_NEGATIVE)
505  {
506  $this->filter_mode = $a_mode;
507  }
508 
514  function getFilterMode()
515  {
516  return $this->filter_mode;
517  }
518 
525  function setUseStandardFrame($a_val)
526  {
527  $this->use_standard_frame = $a_val;
528  }
529 
536  {
538  }
539 
548  function setOutput($a_parent_id, $a_depth = 1,$a_obj_id = 0, $a_highlighted_subtree = false)
549  {
550  global $rbacadmin, $rbacsystem, $ilBench;
551 
552 #echo 'ParentId: '.$a_parent_id.' depth: '.$a_depth.' obj_id: '.$a_obj_id;
553 
554  if (!isset($a_parent_id))
555  {
556  $this->ilias->raiseError(get_class($this)."::setOutput(): No node_id given!",$this->ilias->error_obj->WARNING);
557  }
558 
559  if ($this->showChilds($a_parent_id,$a_obj_id))
560  {
561  $objects = $this->tree->getChilds($a_parent_id, $this->order_column);
562  }
563  else
564  {
565  $objects = array();
566  }
567 
568  $objects = $this->modifyChilds($a_parent_id, $objects);
569 
570  // force expansion (of single nodes)
571 // if ($this->forceExpanded($a_obj_id) && !in_array($a_obj_id, $this->expanded))
572 // {
573 // $this->expanded[] = $a_obj_id;
574 // }
575 if ($this->forceExpanded($a_parent_id) && !in_array($a_parent_id, $this->expanded))
576 {
577  $this->expanded[] = $a_parent_id;
578 }
579 
580  if (count($objects) > 0)
581  {
582  // Maybe call a lexical sort function for the child objects
583  $tab = ++$a_depth - 2;
584  if ($this->post_sort)
585  {
586  $objects = $this->sortNodes($objects,$a_obj_id);
587  }
588  $skip_rest = false;
589  foreach ($objects as $key => $object)
590  {
591  // skip childs, if parent is not expanded
592  if (!$this->forceExpanded($object["child"]) && $skip_rest)
593  {
594  continue;
595  }
596 //echo "<br>-".$object["child"]."-".$this->forceExpanded($object["child"])."-";
597  //ask for FILTER
598  if ($this->filtered == false or $this->checkFilter($object["type"]) == false)
599  {
600  if ($this->isVisible($object['child'],$object['type']))
601  {
602  $ilBench->start("Explorer", "setOutput_setFormatOptions");
603  #echo 'CHILD getIndex() '.$object['child'].' parent: '.$this->getRoot();
604  if ($object["child"] != $this->getRoot())
605  {
606  $parent_index = $this->getIndex($object);
607  }
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;
618 
619  // Create prefix array
620  for ($i = 0; $i < $tab; ++$i)
621  {
622  $this->format_options["$this->counter"]["tab"][] = 'blank';
623  }
624 
625  // fix explorer (sometimes explorer disappears)
626  if ($parent_index == 0)
627  {
628  if (!$this->expand_all and !in_array($object["parent"], $this->expanded))
629  {
630  $this->expanded[] = $object["parent"];
631  }
632  }
633 
634  // only if parent is expanded and visible, object is visible
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"]))
637  {
638  if (!$this->forceExpanded($object["child"]))
639  {
640  // if parent is not expanded, and one child is
641  // visible we don't need more information and
642  // can skip the rest of the childs
643  if ($this->format_options["$this->counter"]["visible"])
644  {
645 //echo "-setSkipping";
646  $skip_rest = true;
647  }
648  $this->format_options["$this->counter"]["visible"] = false;
649  }
650  }
651 
652  // if object exists parent is container
653  if ($object["child"] != $this->getRoot())
654  {
655  $this->format_options["$parent_index"]["container"] = true;
656 
657  if ($this->expand_all or in_array($object["parent"],$this->expanded))
658  {
659  //echo "<br>-".$object["child"]."-".$this->forceExpanded($object["child"])."-";
660  if ($this->forceExpanded($object["parent"]))
661  {
662  $this->format_options["$parent_index"]["tab"][($tab-2)] = 'forceexp';
663  }
664  else
665  {
666  $this->format_options["$parent_index"]["tab"][($tab-2)] = 'minus';
667  }
668  }
669  else
670  {
671  $this->format_options["$parent_index"]["tab"][($tab-2)] = 'plus';
672  }
673  }
674  //echo "-"."$parent_index"."-";
675  //var_dump($this->format_options["$parent_index"]);
676  ++$this->counter;
677  $ilBench->stop("Explorer", "setOutput_setFormatOptions");
678 
679  // stop recursion if 2. level beyond expanded nodes is reached
680  if ($this->expand_all or in_array($object["parent"],$this->expanded) or ($object["parent"] == 0)
681  or $this->forceExpanded($object["child"]))
682  {
683  $highlighted_subtree = ($a_highlighted_subtree ||
684  ($object["child"] == $this->highlighted))
685  ? true
686  : false;
687 
688  // recursive
689  $this->setOutput($object["child"],$a_depth,$object['obj_id'], $highlighted_subtree);
690  }
691  } //if
692  } //if FILTER
693  } //foreach
694  } //if
695  } //function
696 
697  function modifyChilds($a_parent_id, $a_objects)
698  {
699  return $a_objects;
700  }
701 
707  function showChilds($a_parent_id)
708  {
709  return true;
710  }
711 
715  function forceExpanded($a_obj_id)
716  {
717  return false;
718  }
719 
726  function getOutput()
727  {
728  global $ilBench, $tpl, $lng;
729 
730  $ilBench->start("Explorer", "getOutput");
731 
732  $this->format_options[0]["tab"] = array();
733 
734  $depth = $this->tree->getMaximumDepth();
735 
736  for ($i=0;$i<$depth;++$i)
737  {
738  $this->createLines($i);
739  }
740 
741  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
743  $tpl->addJavaScript("./Services/Explorer/js/ilexplorercallback.js");
744 
745  $tpl->addBlockFile("EXPLORER_TOP", "exp_top", "tpl.explorer_top.html");
746 //echo "hh";
747  // set global body class
748  $tpl->setBodyClass("il_Explorer");
749 
750  $tpl_tree = new ilTemplate("tpl.tree.html", true, true);
751 
752  // updater
753  if (($_GET["ict"] || $_POST["collapseAll"] != "" || $_POST["expandAll"] != "") && $this->up_frame != "")
754  {
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))
759  {
760  $up_str = $lim = "";
761  foreach ($this->up_params as $p)
762  {
763  $up_str.= $lim."'".$p."'";
764  $lim = ",";
765  }
766  $tpl_tree->setVariable("UPDATE_PARAMS", $up_str);
767  }
768  $tpl_tree->parseCurrentBlock();
769  }
770 
771  $cur_depth = -1;
772  foreach ($this->format_options as $key => $options)
773  {
774 //echo "-".$options["depth"]."-";
775  if (!$options["visible"])
776  {
777  continue;
778  }
779 
780  // end tags
781  $this->handleListEndTags($tpl_tree, $cur_depth, $options["depth"]);
782 
783  // start tags
784  $this->handleListStartTags($tpl_tree, $cur_depth, $options["depth"]);
785 
786  $cur_depth = $options["depth"];
787 
788  if ($options["visible"] and $key != 0)
789  {
790  $this->formatObject($tpl_tree, $options["child"],$options,$options['obj_id']);
791  }
792  if ($key == 0)
793  {
794  $this->formatHeader($tpl_tree, $options["child"],$options);
795  }
796 
797  }
798 //if ($GLOBALS["ilUser"]->getLogin() == "alex") var_dump($this->format_options);
799  $this->handleListEndTags($tpl_tree, $cur_depth, -1);
800 
801  $ilBench->stop("Explorer", "getOutput");
802 
803  $tpl_tree->setVariable("TREE_LEAD", "");
804  if ($this->tree_lead != "")
805  {
806  $tpl_tree->setCurrentBlock("tree_lead");
807  $tpl_tree->setVariable("TREE_LEAD", $this->tree_lead);
808  $tpl_tree->parseCurrentBlock();
809  }
810 
811  $html = $tpl_tree->get();
812 
813  if ($this->getUseStandardFrame())
814  {
815  $mtpl = new ilTemplate("tpl.main.html", true, true);
816  $mtpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
817  $mtpl->setVariable("BODY_CLASS", "il_Explorer");
818  $mtpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
819  if ($this->getTitle() != "")
820  {
821  $mtpl->setVariable("TXT_EXPLORER_HEADER", $this->getTitle());
822  }
823  $mtpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
824  $mtpl->setCurrentBlock("content");
825  $mtpl->setVariable("EXPLORER", $html);
826  $mtpl->setVariable("EXP_REFRESH", $lng->txt("refresh"));
827  $mtpl->parseCurrentBlock();
828  $html = $mtpl->get();
829  }
830 
831  return $html;
832  }
833 
834 
835 
839  function handleListEndTags(&$a_tpl_tree, $a_cur_depth, $a_item_depth)
840  {
841  if ($a_item_depth < $a_cur_depth)
842  {
843  // </li></ul> for ending lists
844  for ($i = 0; $i < ($a_cur_depth - $a_item_depth); $i++)
845  {
846  $a_tpl_tree->touchBlock("end_list_item");
847  $a_tpl_tree->touchBlock("element");
848 
849  $a_tpl_tree->touchBlock("end_list");
850  $a_tpl_tree->touchBlock("element");
851  }
852  }
853  else if ($a_item_depth == $a_cur_depth)
854  {
855  // </li> for ending list items
856  $a_tpl_tree->touchBlock("end_list_item");
857  $a_tpl_tree->touchBlock("element");
858  }
859  }
860 
864  function handleListStartTags(&$a_tpl_tree, $a_cur_depth, $a_item_depth)
865  {
866  // start tags
867  if ($a_item_depth > $a_cur_depth)
868  {
869  // <ul><li> for new lists
870  if ($a_item_depth > 1)
871  {
872  $a_tpl_tree->touchBlock("start_list");
873  }
874  else
875  {
876  $a_tpl_tree->touchBlock("start_list_no_indent");
877  }
878  $a_tpl_tree->touchBlock("element");
879 
880  $a_tpl_tree->touchBlock("start_list_item");
881  $a_tpl_tree->touchBlock("element");
882  }
883  else
884  {
885  // <li> items
886  $a_tpl_tree->touchBlock("start_list_item");
887  $a_tpl_tree->touchBlock("element");
888  }
889  }
890 
899  function formatHeader(&$tpl,$a_obj_id,$a_option)
900  {
901  }
902 
911  function formatObject(&$tpl, $a_node_id,$a_option,$a_obj_id = 0)
912  {
913  global $lng;
914  if (!isset($a_node_id) or !is_array($a_option))
915  {
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);
918  }
919 
920  $pic = false;
921  foreach ((array) $a_option["tab"] as $picture)
922  {
923  if ($picture == 'plus')
924  {
925  $tpl->setCurrentBlock("exp_desc");
926  $tpl->setVariable("EXP_DESC", $lng->txt("collapsed"));
927  $tpl->parseCurrentBlock();
928  $target = $this->createTarget('+',$a_node_id, $a_option["highlighted_subtree"]);
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();
934  $pic = true;
935  }
936 
937  if ($picture == 'forceexp')
938  {
939  $tpl->setCurrentBlock("exp_desc");
940  $tpl->setVariable("EXP_DESC", $lng->txt("expanded"));
941  $tpl->parseCurrentBlock();
942  $target = $this->createTarget('+',$a_node_id);
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();
948  $pic = true;
949  }
950 
951  if ($picture == 'minus' && $this->show_minus)
952  {
953  $tpl->setCurrentBlock("exp_desc");
954  $tpl->setVariable("EXP_DESC", $lng->txt("expanded"));
955  $tpl->parseCurrentBlock();
956  $target = $this->createTarget('-',$a_node_id, $a_option["highlighted_subtree"]);
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();
962  $pic = true;
963  }
964 
965  /*
966  if ($picture == 'blank' or $picture == 'winkel'
967  or $picture == 'hoch' or $picture == 'quer' or $picture == 'ecke')
968  {
969  $picture = "blank";
970  $tpl->setCurrentBlock("lines");
971  $tpl->setVariable("IMGPATH_LINES", $this->getImage("browser/".$picture.".gif"));
972  $tpl->parseCurrentBlock();
973  }
974  */
975  }
976 
977  if (!$pic)
978  {
979  $tpl->setCurrentBlock("blank");
980  $tpl->setVariable("BLANK_PATH", $this->getImage("browser/blank.gif"));
981  $tpl->parseCurrentBlock();
982  }
983 
984  if ($this->output_icons)
985  {
986  $tpl->setCurrentBlock("icon");
987  $tpl->setVariable("ICON_IMAGE" , $this->getImage("icon_".$a_option["type"]."_s.gif", $a_option["type"], $a_obj_id));
988 
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();
994  }
995 
996  if(strlen($sel = $this->buildSelect($a_node_id,$a_option['type'])))
997  {
998  $tpl->setCurrentBlock('select');
999  $tpl->setVariable('OBJ_SEL',$sel);
1000  $tpl->parseCurrentBlock();
1001  }
1002 
1003  if ($this->isClickable($a_option["type"], $a_node_id,$a_obj_id)) // output link
1004  {
1005  $tpl->setCurrentBlock("link");
1006  //$target = (strpos($this->target, "?") === false) ?
1007  // $this->target."?" : $this->target."&";
1008  //$tpl->setVariable("LINK_TARGET", $target.$this->target_get."=".$a_node_id.$this->params_get);
1009  $tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($a_node_id, $a_option["type"]));
1010 
1011  $style_class = $this->getNodeStyleClass($a_node_id, $a_option["type"]);
1012 
1013  if ($style_class != "")
1014  {
1015  $tpl->setVariable("A_CLASS", ' class="'.$style_class.'" ' );
1016  }
1017 
1018  if (($onclick = $this->buildOnClick($a_node_id, $a_option["type"], $a_option["title"])) != "")
1019  {
1020  $tpl->setVariable("ONCLICK", "onClick=\"$onclick\"");
1021  }
1022 
1023  //$tpl->setVariable("LINK_NAME", $a_node_id);
1024  $tpl->setVariable("TITLE", ilUtil::shortenText(
1025  $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]),
1026  $this->textwidth, true));
1027  $tpl->setVariable("DESC", ilUtil::shortenText(
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 != "")
1031  {
1032  $tpl->setVariable("TARGET", " target=\"".$frame_target."\"");
1033  }
1034  $tpl->parseCurrentBlock();
1035  }
1036  else // output text only
1037  {
1038  $tpl->setCurrentBlock("text");
1039  $tpl->setVariable("OBJ_TITLE", ilUtil::shortenText(
1040  $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]), $this->textwidth, true));
1041  $tpl->setVariable("OBJ_DESC", ilUtil::shortenText(
1042  $this->buildDescription($a_option["desc"], $a_node_id, $a_option["type"]), $this->textwidth, true));
1043  $tpl->parseCurrentBlock();
1044  }
1045 
1046  $tpl->setCurrentBlock("list_item");
1047  $tpl->parseCurrentBlock();
1048  $tpl->touchBlock("element");
1049  }
1050 
1054  function getImage($a_name, $a_type = "", $a_obj_id = "")
1055  {
1056  return ilUtil::getImagePath($a_name);
1057  }
1058 
1062  function getImageAlt($a_default_text, $a_type = "", $a_obj_id = "")
1063  {
1064  return $a_default_text;
1065  }
1066 
1070  function getNodeStyleClass($a_id, $a_type)
1071  {
1072  if ($a_id == $this->highlighted)
1073  {
1074  return "il_HighlightedNode";
1075  }
1076  return "";
1077  }
1078 
1082  function buildLinkTarget($a_node_id, $a_type)
1083  {
1084  $target = (strpos($this->target, "?") === false)
1085  ? $this->target."?"
1086  : $this->target."&";
1087  return $target.$this->target_get."=".$a_node_id.$this->params_get;
1088  }
1089 
1093  function buildOnClick($a_node_id, $a_type, $a_title)
1094  {
1095  return "";
1096  }
1097 
1101  function buildTitle($a_title, $a_id, $a_type)
1102  {
1103  return $a_title;
1104  }
1105 
1109  function buildDescription($a_desc, $a_id, $a_type)
1110  {
1111  return "";
1112  }
1113 
1117  function buildSelect($a_node_id,$a_type)
1118  {
1119  return "";
1120  }
1121 
1122 
1126  function buildFrameTarget($a_type, $a_child = 0, $a_obj_id = 0)
1127  {
1128  return $this->frame_target;
1129  }
1130 
1131 
1139  function createTarget($a_type,$a_node_id,$a_highlighted_subtree = false)
1140  {
1141  if (!isset($a_type) or !is_string($a_type) or !isset($a_node_id))
1142  {
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);
1145  }
1146 
1147  // SET expand parameter:
1148  // positive if object is expanded
1149  // negative if object is compressed
1150  $a_node_id = $a_type == '+' ? $a_node_id : -(int) $a_node_id;
1151 
1152  $sep = (is_int(strpos($this->expand_target, "?")))
1153  ? "&"
1154  : "?";
1155 
1156  // in current tree flag
1157  $ict_str = ($a_highlighted_subtree || $this->highlighted == "")
1158  ? "&ict=1"
1159  : "";
1160  return $this->expand_target.$sep.$this->expand_variable."=".$a_node_id.$this->params_get.$ict_str."#".abs($a_node_id);
1161  }
1162 
1169  function setFrameTarget($a_target)
1170  {
1171  $this->frame_target = $a_target;
1172  }
1173 
1179  function createLines($a_depth)
1180  {
1181  for ($i = 0; $i < count($this->format_options); ++$i)
1182  {
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)
1186  {
1187  $this->format_options[$i]["tab"]["$a_depth"] = "quer";
1188  }
1189 
1190  if ($this->format_options[$i]["depth"] == $a_depth+2)
1191  {
1192  if ($this->is_in_array($i+1,$this->format_options[$i]["depth"]))
1193  {
1194  $this->format_options[$i]["tab"]["$a_depth"] = "winkel";
1195  }
1196  else
1197  {
1198  $this->format_options[$i]["tab"]["$a_depth"] = "ecke";
1199  }
1200  }
1201 
1202  if ($this->format_options[$i]["depth"] > $a_depth+2)
1203  {
1204  if ($this->is_in_array($i+1,$a_depth+2))
1205  {
1206  $this->format_options[$i]["tab"]["$a_depth"] = "hoch";
1207  }
1208  }
1209  }
1210  }
1211 
1219  function is_in_array($a_start,$a_depth)
1220  {
1221  for ($i=$a_start;$i<count($this->format_options);++$i)
1222  {
1223  if ($this->format_options[$i]["depth"] < $a_depth)
1224  {
1225  break;
1226  }
1227 
1228  if ($this->format_options[$i]["depth"] == $a_depth)
1229  {
1230  return true;
1231  }
1232  }
1233  return false;
1234  }
1235 
1242  function getIndex($a_data)
1243  {
1244  if(!is_array($this->format_options))
1245  {
1246  return -1;
1247  }
1248 
1249  foreach ($this->format_options as $key => $value)
1250  {
1251  if (($value["child"] == $a_data["parent"]))
1252  {
1253  return $key;
1254  }
1255  }
1256 
1257  return -1;
1258  // exit on error
1259  #$this->ilias->raiseError(get_class($this)."::getIndex(): Error in tree. No index found!",$this->ilias->error_obj->FATAL);
1260  }
1261 
1268  function addFilter($a_item)
1269  {
1270  $ispresent = 0;
1271 
1272  if (is_array($this->filter))
1273  {
1274  //run through filter
1275  foreach ($this->filter as $item)
1276  {
1277  if ($item == $a_item)
1278  {
1279  $is_present = 1;
1280 
1281  return false;
1282  }
1283  }
1284  }
1285  else
1286  {
1287  $this->filter = array();
1288  }
1289  if ($is_present == 0)
1290  {
1291  $this->filter[] = $a_item;
1292  }
1293 
1294  return true;
1295  }
1296 
1303  function delFilter($a_item)
1304  {
1305  //check if a filter exists
1306  if (is_array($this->filter))
1307  {
1308  //build copy of the existing filter without the given item
1309  $tmp = array();
1310 
1311  foreach ($this->filter as $item)
1312  {
1313  if ($item != $a_item)
1314  {
1315  $tmp[] = $item;
1316  }
1317  else
1318  {
1319  $deleted = 1;
1320  }
1321  }
1322 
1323  $this->filter = $tmp;
1324  }
1325  else
1326  {
1327  return false;
1328  }
1329 
1330  if ($deleted == 1)
1331  {
1332  return true;
1333  }
1334  else
1335  {
1336  return false;
1337  }
1338  }
1339 
1346  function setExpand($a_node_id)
1347  {
1348  // IF ISN'T SET CREATE SESSION VARIABLE
1349  if(!is_array($_SESSION[$this->expand_variable]))
1350  {
1351  $_SESSION[$this->expand_variable] = array($this->getRoot());
1352  }
1353  // IF $_GET["expand"] is positive => expand this node
1354  if ($a_node_id > 0 && !in_array($a_node_id,$_SESSION[$this->expand_variable]))
1355  {
1356  array_push($_SESSION[$this->expand_variable],$a_node_id);
1357  }
1358  // IF $_GET["expand"] is negative => compress this node
1359  if ($a_node_id < 0)
1360  {
1361  $key = array_keys($_SESSION[$this->expand_variable],-(int) $a_node_id);
1362  unset($_SESSION[$this->expand_variable][$key[0]]);
1363  }
1364  $this->expanded = $_SESSION[$this->expand_variable];
1365  }
1366 
1373  function forceExpandAll($a_mode, $a_show_minus = true)
1374  {
1375  $this->expand_all = (bool) $a_mode;
1376  $this->show_minus = $a_show_minus;
1377  }
1378 
1385  function setFiltered($a_bool)
1386  {
1387  $this->filtered = $a_bool;
1388  return true;
1389  }
1390 
1397  function checkFilter($a_item)
1398  {
1399  if (is_array($this->filter))
1400  {
1401  if (in_array($a_item, $this->filter))
1402  {
1403  $ret = true;
1404  }
1405  else
1406  {
1407  $ret = false;
1408  }
1409  }
1410  else
1411  {
1412  $ret = false;
1413  }
1414 
1415  if ($this->getFilterMode() == IL_FM_NEGATIVE )
1416  {
1417  return $ret;
1418  }
1419  else
1420  {
1421  return !$ret;
1422  }
1423  }
1424 
1431  function sortNodes($a_nodes,$a_parent_obj_id)
1432  {
1433  foreach ($a_nodes as $key => $node)
1434  {
1435  if ($node["type"] == "adm")
1436  {
1437  $match = $key;
1438  $adm_node = $node;
1439  break;
1440  }
1441  }
1442 
1443  // cut off adm node
1444  isset($match) ? array_splice($a_nodes,$match,1) : "";
1445 
1446  $a_nodes = ilUtil::sortArray($a_nodes,$this->order_column,$this->order_direction);
1447 
1448  // append adm node to end of list
1449  isset ($match) ? array_push($a_nodes,$adm_node) : "";
1450 
1451  return $a_nodes;
1452  }
1453 } // END class.ilExplorer
1454 ?>