ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
21  protected $obj_definition;
22 
26  protected $error;
27 
31  protected $rbacsystem;
32 
36  protected $tpl;
37 
41  protected $lng;
42 
43  public $id;
44 
50  public $output;
51 
58 
64  public $tree;
65 
71  public $target;
72 
78  public $target_get;
79 
85  public $params_get;
86 
92  public $expanded;
93 
99  public $order_column;
100 
106  public $order_direction = "asc";
107 
114 
120  public $rbac_check;
121 
122 
129 
136 
143 
149  public $post_sort;
150 
156  public $filtered = false;
157 
163  public $filter_mode;
164 
170  public $expand_all = false;
171 
177  public $root_id = null;
178 
179  public $use_standard_frame = false;
180 
186  public function __construct($a_target)
187  {
188  global $DIC;
189 
190  $this->obj_definition = $DIC["objDefinition"];
191  $this->error = $DIC["ilErr"];
192  $this->rbacsystem = $DIC->rbac()->system();
193  $this->tpl = $DIC["tpl"];
194  $this->lng = $DIC->language();
195  $objDefinition = $DIC["objDefinition"];
196  $ilErr = $DIC["ilErr"];
197 
198  if (!isset($a_target) or !is_string($a_target)) {
199  $ilErr->raiseError(get_class($this) . "::Constructor(): No target given!", $ilErr->WARNING);
200  }
201 
202  // autofilter object types in devmode
203  $devtypes = $objDefinition->getDevModeAll();
204 
205  if (count($devtypes) > 0) {
206  // activate filter if objects found in devmode
207  $this->setFiltered(true);
208 
209  foreach ($devtypes as $type) {
210  $this->addFilter($type);
211  }
212  }
213 
214  $this->ilias = $DIC["ilias"];
215  $this->output = array();
216  $this->expanded = array();
217  $this->target = $a_target;
218  $this->target_get = 'ref_id';
219  $this->frame_target = "content";
220  $this->order_column = "title";
221  $this->tree = new ilTree(ROOT_FOLDER_ID);
222  $this->tree->initLangCode();
223  $this->expand_target = $_SERVER["PATH_INFO"];
224  $this->rbac_check = true;
225  $this->output_icons = true;
226  $this->expand_variable = "expand";
227  $this->setTitleLength(50);
228  $this->post_sort=true;
230  $this->highlighted = "";
231  $this->show_minus = true;
232  $this->counter = 0;
233  $this->asnch_expanding = false;
234  }
235 
241  public function setId($a_val)
242  {
243  $this->id = $a_val;
244  }
245 
251  public function getId()
252  {
253  return $this->id;
254  }
255 
261  public function setAsynchExpanding($a_val)
262  {
263  $this->asnch_expanding = $a_val;
264  }
265 
271  public function getAsynchExpanding()
272  {
273  return $this->asnch_expanding;
274  }
275 
283  public function initItemCounter($a_number)
284  {
285  $this->counter = $a_number;
286  }
287 
293  public function setTitle($a_val)
294  {
295  $this->title = $a_val;
296  }
297 
303  public function setTitleLength($a_length)
304  {
305  $this->textwidth = $a_length;
306  }
307 
312  public function getTitleLength()
313  {
314  return $this->textwidth;
315  }
316 
322  public function getTitle()
323  {
324  return $this->title;
325  }
326 
334  public function setRoot($a_root_id)
335  {
336  #$this->tree = new ilTree(ROOT_FOLDER_ID,$a_root_id);
337  $this->root_id = $a_root_id;
338  }
339 
347  public function getRoot()
348  {
349  return $this->root_id == null ?
350  $this->tree->getRootId() :
352  }
353 
359  public function setOrderColumn($a_column)
360  {
361  $this->order_column = $a_column;
362  }
363 
369  public function setOrderDirection($a_direction)
370  {
371  if ($a_direction == "desc") {
372  $this->order_direction = $a_direction;
373  } else {
374  $this->order_direction = "asc";
375  }
376  }
377 
383  public function setTargetGet($a_target_get)
384  {
386 
387  if (!isset($a_target_get) or !is_string($a_target_get)) {
388  $ilErr->raiseError(get_class($this) . "::setTargetGet(): No target given!", $ilErr->WARNING);
389  }
390 
391  $this->target_get = $a_target_get;
392  }
393 
399  public function setParamsGet($a_params_get)
400  {
402 
403  if (!isset($a_params_get) or !is_array($a_params_get)) {
404  $ilErr->raiseError(get_class($this) . "::setTargetGet(): No target given!", $ilErr->WARNING);
405  }
406  $str = "";
407  foreach ($a_params_get as $key => $val) {
408  $str .= "&" . $key . "=" . $val;
409  }
410 
411  $this->params_get = $str;
412  }
413 
414 
421  public function setExpandTarget($a_exp_target)
422  {
423  $this->expand_target = $a_exp_target;
424  }
425 
431  public function setFrameUpdater($a_up_frame, $a_up_script, $a_params = "")
432  {
433  $this->up_frame = $a_up_frame;
434  $this->up_script = $a_up_script;
435  $this->up_params = $a_params;
436  }
437 
438 
442  public function highlightNode($a_id)
443  {
444  $this->highlighted = $a_id;
445  }
446 
452  public function checkPermissions($a_check)
453  {
454  $this->rbac_check = $a_check;
455  }
456 
462  public function setSessionExpandVariable($a_var_name = "expand")
463  {
464  $this->expand_variable = $a_var_name;
465  }
466 
472  public function outputIcons($a_icons)
473  {
474  $this->output_icons = $a_icons;
475  }
476 
477 
484  public function setClickable($a_type, $a_clickable)
485  {
486  if ($a_clickable) {
487  $this->is_clickable[$a_type] = "";
488  } else {
489  $this->is_clickable[$a_type] = "n";
490  }
491  }
492 
493  public function isVisible($a_ref_id, $a_type)
494  {
496 
497  if (!$this->rbac_check) {
498  return true;
499  }
500 
501  $visible = $rbacsystem->checkAccess('visible', $a_ref_id);
502 
503  return $visible;
504  }
505 
511  public function setTreeLead($a_val)
512  {
513  $this->tree_lead = $a_val;
514  }
515 
521  public function getTreeLead()
522  {
523  return $this->tree_lead;
524  }
525 
533  public function isClickable($a_type, $a_ref_id = 0)
534  {
535  // in this standard implementation
536  // only the type determines, wether an object should be clickable or not
537  // but this method can be overwritten and make $exp->setFilterMode(IL_FM_NEGATIVE);use of the ref id
538  // (this happens e.g. in class ilRepositoryExplorerGUI)
539  if ($this->is_clickable[$a_type] == "n") {
540  return false;
541  } else {
542  return true;
543  }
544  }
545 
550  public function setPostSort($a_sort)
551  {
552  $this->post_sort = $a_sort;
553  }
554 
560  public function setFilterMode($a_mode = IL_FM_NEGATIVE)
561  {
562  $this->filter_mode = $a_mode;
563  }
564 
570  public function getFilterMode()
571  {
572  return $this->filter_mode;
573  }
574 
581  public function setUseStandardFrame($a_val)
582  {
583  $this->use_standard_frame = $a_val;
584  }
585 
591  public function getUseStandardFrame()
592  {
594  }
595 
602  public function getChildsOfNode($a_parent_id)
603  {
604  return $this->tree->getChilds($a_parent_id, $this->order_column);
605  }
606 
607 
616  public function setOutput($a_parent_id, $a_depth = 1, $a_obj_id = 0, $a_highlighted_subtree = false)
617  {
619 
620  if (!isset($a_parent_id)) {
621  $ilErr->raiseError(get_class($this) . "::setOutput(): No node_id given!", $ilErr->WARNING);
622  }
623 
624  if ($this->showChilds($a_parent_id, $a_obj_id)) {
625  $objects = $this->getChildsOfNode($a_parent_id);
626  } else {
627  $objects = array();
628  }
629 
630  $objects = $this->modifyChilds($a_parent_id, $objects);
631 
632  // force expansion (of single nodes)
633  if ($this->forceExpanded($a_parent_id) && !in_array($a_parent_id, $this->expanded)) {
634  $this->expanded[] = $a_parent_id;
635  }
636 
637  if (count($objects) > 0) {
638  // Maybe call a lexical sort function for the child objects
639  $tab = ++$a_depth - 2;
640  if ($this->post_sort) {
641  $objects = $this->sortNodes($objects, $a_obj_id);
642  }
643  $skip_rest = false;
644  foreach ($objects as $key => $object) {
645  // skip childs, if parent is not expanded
646  if (!$this->forceExpanded($object["child"]) && $skip_rest) {
647  continue;
648  }
649  //echo "<br>-".$object["child"]."-".$this->forceExpanded($object["child"])."-";
650  //ask for FILTER
651  if ($this->filtered == false or $this->checkFilter($object["type"]) == false) {
652  if ($this->isVisible($object['child'], $object['type'])) {
653  #echo 'CHILD getIndex() '.$object['child'].' parent: '.$this->getRoot();
654  if ($object["child"] != $this->getRoot()) {
655  $parent_index = $this->getIndex($object);
656  }
657  $this->format_options["$this->counter"]["parent"] = $object["parent"];
658  $this->format_options["$this->counter"]["child"] = $object["child"];
659  $this->format_options["$this->counter"]["title"] = $object["title"];
660  $this->format_options["$this->counter"]["type"] = $object["type"];
661  $this->format_options["$this->counter"]["obj_id"] = $object["obj_id"];
662  $this->format_options["$this->counter"]["desc"] = "obj_" . $object["type"];
663  $this->format_options["$this->counter"]["depth"] = $tab;
664  $this->format_options["$this->counter"]["container"] = false;
665  $this->format_options["$this->counter"]["visible"] = true;
666  $this->format_options["$this->counter"]["highlighted_subtree"] = $a_highlighted_subtree;
667 
668  // Create prefix array
669  for ($i = 0; $i < $tab; ++$i) {
670  $this->format_options["$this->counter"]["tab"][] = 'blank';
671  }
672 
673  // fix explorer (sometimes explorer disappears)
674  if ($parent_index == 0) {
675  if (!$this->expand_all and !in_array($object["parent"], $this->expanded)) {
676  $this->expanded[] = $object["parent"];
677  }
678  }
679 
680  // only if parent is expanded and visible, object is visible
681  if ($object["child"] != $this->getRoot() and ((!$this->expand_all and !in_array($object["parent"], $this->expanded))
682  or !$this->format_options["$parent_index"]["visible"])) {
683  if (!$this->forceExpanded($object["child"])) {
684  // if parent is not expanded, and one child is
685  // visible we don't need more information and
686  // can skip the rest of the childs
687  if ($this->format_options["$this->counter"]["visible"]) {
688  //echo "-setSkipping";
689  $skip_rest = true;
690  }
691  $this->format_options["$this->counter"]["visible"] = false;
692  }
693  }
694 
695  // if object exists parent is container
696  if ($object["child"] != $this->getRoot()) {
697  $this->format_options["$parent_index"]["container"] = true;
698 
699  if ($this->expand_all or in_array($object["parent"], $this->expanded)) {
700  //echo "<br>-".$object["child"]."-".$this->forceExpanded($object["child"])."-";
701  if ($this->forceExpanded($object["parent"])) {
702  $this->format_options["$parent_index"]["tab"][($tab-2)] = 'forceexp';
703  } else {
704  $this->format_options["$parent_index"]["tab"][($tab-2)] = 'minus';
705  }
706  } else {
707  $this->format_options["$parent_index"]["tab"][($tab-2)] = 'plus';
708  }
709  }
710  //echo "-"."$parent_index"."-";
711  //var_dump($this->format_options["$parent_index"]);
712  ++$this->counter;
713 
714  // stop recursion if 2. level beyond expanded nodes is reached
715  if ($this->expand_all or in_array($object["parent"], $this->expanded) or ($object["parent"] == 0)
716  or $this->forceExpanded($object["child"])) {
717  $highlighted_subtree = ($a_highlighted_subtree ||
718  ($object["child"] == $this->highlighted))
719  ? true
720  : false;
721 
722  // recursive
723  $this->setOutput($object["child"], $a_depth, $object['obj_id'], $highlighted_subtree);
724  }
725  } //if
726  } //if FILTER
727  } //foreach
728  } //if
729  } //function
730 
731  public function modifyChilds($a_parent_id, $a_objects)
732  {
733  return $a_objects;
734  }
735 
741  public function showChilds($a_parent_id)
742  {
743  return true;
744  }
745 
749  public function forceExpanded($a_obj_id)
750  {
751  return false;
752  }
753 
760  public function getMaximumTreeDepth()
761  {
762  $this->tree->getMaximumDepth();
763  }
764 
765 
772  public function getOutput()
773  {
774  $tpl = $this->tpl;
775  $lng = $this->lng;
776 
777  $this->format_options[0]["tab"] = array();
778 
779  $depth = $this->getMaximumTreeDepth();
780 
781  for ($i=0;$i<$depth;++$i) {
782  $this->createLines($i);
783  }
784 
785  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
787  $tpl->addJavaScript("./Services/UIComponent/Explorer/js/ilExplorer.js");
788 
789  //echo "hh";
790  // set global body class
791  // $tpl->setBodyClass("il_Explorer");
792 
793  $tpl_tree = new ilTemplate("tpl.tree.html", true, true, "Services/UIComponent/Explorer");
794 
795  // updater
796  if (($_GET["ict"] || $_POST["collapseAll"] != "" || $_POST["expandAll"] != "") && $this->up_frame != "") {
797  $tpl_tree->setCurrentBlock("updater");
798  $tpl_tree->setVariable("UPDATE_FRAME", $this->up_frame);
799  $tpl_tree->setVariable("UPDATE_SCRIPT", $this->up_script);
800  if (is_array($this->up_params)) {
801  $up_str = $lim = "";
802  foreach ($this->up_params as $p) {
803  $up_str.= $lim . "'" . $p . "'";
804  $lim = ",";
805  }
806  $tpl_tree->setVariable("UPDATE_PARAMS", $up_str);
807  }
808  $tpl_tree->parseCurrentBlock();
809  }
810 
811  $cur_depth = -1;
812  foreach ($this->format_options as $key => $options) {
813  //echo "-".$options["depth"]."-";
814  if (!$options["visible"]) {
815  continue;
816  }
817 
818  // end tags
819  $this->handleListEndTags($tpl_tree, $cur_depth, $options["depth"]);
820 
821  // start tags
822  $this->handleListStartTags($tpl_tree, $cur_depth, $options["depth"]);
823 
824  $cur_depth = $options["depth"];
825 
826  if ($options["visible"] and $key != 0) {
827  $this->formatObject($tpl_tree, $options["child"], $options, $options['obj_id']);
828  }
829  if ($key == 0) {
830  $this->formatHeader($tpl_tree, $options["child"], $options);
831  }
832  }
833 
834  $this->handleListEndTags($tpl_tree, $cur_depth, -1);
835 
836  $tpl_tree->setVariable("TREE_LEAD", "");
837  if ($this->tree_lead != "") {
838  $tpl_tree->setCurrentBlock("tree_lead");
839  $tpl_tree->setVariable("TREE_LEAD", $this->tree_lead);
840  $tpl_tree->parseCurrentBlock();
841  }
842  if ($this->getId() != "") {
843  $tpl_tree->setVariable("TREE_ID", 'id="' . $this->getId() . '_tree"');
844  }
845 
846  $html = $tpl_tree->get();
847 
848  if ($this->getUseStandardFrame()) {
849  $mtpl = new ilTemplate("tpl.main.html", true, true);
850  $mtpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
851  $mtpl->setVariable("BODY_CLASS", "il_Explorer");
852  $mtpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
853  if ($this->getTitle() != "") {
854  $mtpl->setVariable("TXT_EXPLORER_HEADER", $this->getTitle());
855  }
856  if ($this->getId() != "") {
857  $mtpl->setVariable("ID", 'id="' . $this->getId() . '"');
858  }
859  $mtpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.png", false));
860  $mtpl->setCurrentBlock("content");
861  $mtpl->setVariable("EXPLORER", $html);
862  $mtpl->setVariable("EXP_REFRESH", $lng->txt("refresh"));
863  $mtpl->parseCurrentBlock();
864  $html = $mtpl->get();
865  }
866 
867  return $html;
868  }
869 
870 
871 
875  public function handleListEndTags(&$a_tpl_tree, $a_cur_depth, $a_item_depth)
876  {
877  if ($a_item_depth < $a_cur_depth) {
878  // </li></ul> for ending lists
879  for ($i = 0; $i < ($a_cur_depth - $a_item_depth); $i++) {
880  $a_tpl_tree->touchBlock("end_list_item");
881  $a_tpl_tree->touchBlock("element");
882 
883  $a_tpl_tree->touchBlock("end_list");
884  $a_tpl_tree->touchBlock("element");
885  }
886  } elseif ($a_item_depth == $a_cur_depth) {
887  // </li> for ending list items
888  $a_tpl_tree->touchBlock("end_list_item");
889  $a_tpl_tree->touchBlock("element");
890  }
891  }
892 
896  public function handleListStartTags(&$a_tpl_tree, $a_cur_depth, $a_item_depth)
897  {
898  // start tags
899  if ($a_item_depth > $a_cur_depth) {
900  // <ul><li> for new lists
901  if ($a_item_depth > 1) {
902  $a_tpl_tree->touchBlock("start_list");
903  } else {
904  $a_tpl_tree->touchBlock("start_list_no_indent");
905  }
906  $a_tpl_tree->touchBlock("element");
907 
908  $a_tpl_tree->touchBlock("start_list_item");
909  $a_tpl_tree->touchBlock("element");
910  } else {
911  // <li> items
912  $a_tpl_tree->touchBlock("start_list_item");
913  $a_tpl_tree->touchBlock("element");
914  }
915  }
916 
925  public function formatHeader($tpl, $a_obj_id, $a_option)
926  {
927  }
928 
937  public function formatObject($tpl, $a_node_id, $a_option, $a_obj_id = 0)
938  {
939  $lng = $this->lng;
941 
942  if (!isset($a_node_id) or !is_array($a_option)) {
943  $ilErr->raiseError(get_class($this) . "::formatObject(): Missing parameter or wrong datatype! " .
944  "node_id: " . $a_node_id . " options:" . var_dump($a_option), $ilErr->WARNING);
945  }
946 
947  $pic = false;
948  foreach ((array) $a_option["tab"] as $picture) {
949  if ($picture == 'plus') {
950  $tpl->setCurrentBlock("expander");
951  $tpl->setVariable("EXP_DESC", $lng->txt("collapsed"));
952  $tpl->setVariable("LINK_NAME", $a_node_id);
953  if (!$this->getAsynchExpanding()) {
954  $target = $this->createTarget('+', $a_node_id, $a_option["highlighted_subtree"]);
955  $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
956  } else {
957  $target = $this->createTarget('+', $a_node_id, $a_option["highlighted_subtree"], false);
958  $tpl->setVariable("ONCLICK_TARGET_EXPANDER", " onclick=\"return il.Explorer.refresh('tree_div', '" . $target . "');\"");
959  $tpl->setVariable("LINK_TARGET_EXPANDER", "#");
960  }
961  $tpl->setVariable("IMGPATH", $this->getImage("browser/plus.png"));
962  $tpl->parseCurrentBlock();
963  $pic = true;
964  }
965 
966  if ($picture == 'forceexp') {
967  $tpl->setCurrentBlock("expander");
968  $tpl->setVariable("EXP_DESC", $lng->txt("expanded"));
969  $target = $this->createTarget('+', $a_node_id);
970  $tpl->setVariable("LINK_NAME", $a_node_id);
971  $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
972  $tpl->setVariable("IMGPATH", $this->getImage("browser/forceexp.png"));
973  $tpl->parseCurrentBlock();
974  $pic = true;
975  }
976 
977  if ($picture == 'minus' && $this->show_minus) {
978  $tpl->setCurrentBlock("expander");
979  $tpl->setVariable("EXP_DESC", $lng->txt("expanded"));
980  $tpl->setVariable("LINK_NAME", $a_node_id);
981  if (!$this->getAsynchExpanding()) {
982  $target = $this->createTarget('-', $a_node_id, $a_option["highlighted_subtree"]);
983  $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
984  } else {
985  $target = $this->createTarget('-', $a_node_id, $a_option["highlighted_subtree"], false);
986  $tpl->setVariable("ONCLICK_TARGET_EXPANDER", " onclick=\"return il.Explorer.refresh('tree_div', '" . $target . "');\"");
987  $tpl->setVariable("LINK_TARGET_EXPANDER", "#");
988  }
989  $tpl->setVariable("IMGPATH", $this->getImage("browser/minus.png"));
990  $tpl->parseCurrentBlock();
991  $pic = true;
992  }
993  }
994 
995  if (!$pic) {
996  $tpl->setCurrentBlock("blank");
997  $tpl->setVariable("BLANK_PATH", $this->getImage("browser/blank.png"));
998  $tpl->parseCurrentBlock();
999  }
1000 
1001  if ($this->output_icons) {
1002  $tpl->setCurrentBlock("icon");
1003  $tpl->setVariable("ICON_IMAGE", $this->getImage("icon_" . $a_option["type"] . ".svg", $a_option["type"], $a_obj_id));
1004 
1005  $tpl->setVariable("TARGET_ID", "iconid_" . $a_node_id);
1006  $this->iconList[] = "iconid_" . $a_node_id;
1007  $tpl->setVariable(
1008  "TXT_ALT_IMG",
1009  $this->getImageAlt($lng->txt("icon") . " " . $lng->txt($a_option["desc"]), $a_option["type"], $a_obj_id)
1010  );
1011  $tpl->parseCurrentBlock();
1012  }
1013 
1014  if (strlen($sel = $this->buildSelect($a_node_id, $a_option['type']))) {
1015  $tpl->setCurrentBlock('select');
1016  $tpl->setVariable('OBJ_SEL', $sel);
1017  $tpl->parseCurrentBlock();
1018  }
1019 
1020  if ($this->isClickable($a_option["type"], $a_node_id, $a_obj_id)) { // output link
1021  $tpl->setCurrentBlock("link");
1022  //$target = (strpos($this->target, "?") === false) ?
1023  // $this->target."?" : $this->target."&";
1024  //$tpl->setVariable("LINK_TARGET", $target.$this->target_get."=".$a_node_id.$this->params_get);
1025  $tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($a_node_id, $a_option["type"]));
1026 
1027  $style_class = $this->getNodeStyleClass($a_node_id, $a_option["type"]);
1028 
1029  if ($style_class != "") {
1030  $tpl->setVariable("A_CLASS", ' class="' . $style_class . '" ');
1031  }
1032 
1033  if (($onclick = $this->buildOnClick($a_node_id, $a_option["type"], $a_option["title"])) != "") {
1034  $tpl->setVariable("ONCLICK", "onClick=\"$onclick\"");
1035  }
1036 
1037  //$tpl->setVariable("LINK_NAME", $a_node_id);
1038  $tpl->setVariable("TITLE", ilUtil::shortenText(
1039  $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]),
1040  $this->textwidth,
1041  true
1042  ));
1043  $tpl->setVariable("DESC", ilUtil::shortenText(
1044  $this->buildDescription($a_option["description"], $a_node_id, $a_option["type"]),
1045  $this->textwidth,
1046  true
1047  ));
1048  $frame_target = $this->buildFrameTarget($a_option["type"], $a_node_id, $a_option["obj_id"]);
1049  if ($frame_target != "") {
1050  $tpl->setVariable("TARGET", " target=\"" . $frame_target . "\"");
1051  }
1052  $tpl->parseCurrentBlock();
1053  } else { // output text only
1054  $tpl->setCurrentBlock("text");
1055  $tpl->setVariable("OBJ_TITLE", ilUtil::shortenText(
1056  $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]),
1057  $this->textwidth,
1058  true
1059  ));
1060  $tpl->setVariable("OBJ_DESC", ilUtil::shortenText(
1061  $this->buildDescription($a_option["desc"], $a_node_id, $a_option["type"]),
1062  $this->textwidth,
1063  true
1064  ));
1065  $tpl->parseCurrentBlock();
1066  }
1067 
1068  $tpl->setCurrentBlock("list_item");
1069  $tpl->parseCurrentBlock();
1070  $tpl->touchBlock("element");
1071  }
1072 
1076  public function getImage($a_name, $a_type = "", $a_obj_id = "")
1077  {
1078  return ilUtil::getImagePath($a_name);
1079  }
1080 
1084  public function getImageAlt($a_default_text, $a_type = "", $a_obj_id = "")
1085  {
1086  return $a_default_text;
1087  }
1088 
1092  public function getNodeStyleClass($a_id, $a_type)
1093  {
1094  if ($a_id == $this->highlighted) {
1095  return "il_HighlightedNode";
1096  }
1097  return "";
1098  }
1099 
1103  public function buildLinkTarget($a_node_id, $a_type)
1104  {
1105  $target = (strpos($this->target, "?") === false)
1106  ? $this->target . "?"
1107  : $this->target . "&";
1108  return $target . $this->target_get . "=" . $a_node_id . $this->params_get;
1109  }
1110 
1114  public function buildOnClick($a_node_id, $a_type, $a_title)
1115  {
1116  return "";
1117  }
1118 
1122  public function buildTitle($a_title, $a_id, $a_type)
1123  {
1124  return $a_title;
1125  }
1126 
1130  public function buildDescription($a_desc, $a_id, $a_type)
1131  {
1132  return "";
1133  }
1134 
1138  public function buildSelect($a_node_id, $a_type)
1139  {
1140  return "";
1141  }
1142 
1143 
1147  public function buildFrameTarget($a_type, $a_child = 0, $a_obj_id = 0)
1148  {
1149  return $this->frame_target;
1150  }
1151 
1152 
1160  public function createTarget($a_type, $a_node_id, $a_highlighted_subtree = false, $a_append_anch = true)
1161  {
1162  $ilErr = $this->error;
1163 
1164  if (!isset($a_type) or !is_string($a_type) or !isset($a_node_id)) {
1165  $ilErr->raiseError(get_class($this) . "::createTarget(): Missing parameter or wrong datatype! " .
1166  "type: " . $a_type . " node_id:" . $a_node_id, $ilErr->WARNING);
1167  }
1168 
1169  // SET expand parameter:
1170  // positive if object is expanded
1171  // negative if object is compressed
1172  $a_node_id = $a_type == '+' ? $a_node_id : -(int) $a_node_id;
1173 
1174  $sep = (is_int(strpos($this->expand_target, "?")))
1175  ? "&"
1176  : "?";
1177 
1178  // in current tree flag
1179  $ict_str = ($a_highlighted_subtree || $this->highlighted == "")
1180  ? "&ict=1"
1181  : "";
1182  if ($this->getAsynchExpanding()) {
1183  $ict_str.= "&cmdMode=asynch";
1184  }
1185  if ($a_append_anch) {
1186  return $this->expand_target . $sep . $this->expand_variable . "=" . $a_node_id . $this->params_get . $ict_str . "#" . abs($a_node_id);
1187  } else {
1188  return $this->expand_target . $sep . $this->expand_variable . "=" . $a_node_id . $this->params_get . $ict_str;
1189  }
1190  }
1191 
1198  public function setFrameTarget($a_target)
1199  {
1200  $this->frame_target = $a_target;
1201  }
1202 
1208  public function createLines($a_depth)
1209  {
1210  for ($i = 0; $i < count($this->format_options); ++$i) {
1211  if ($this->format_options[$i]["depth"] == $a_depth+1
1212  and !$this->format_options[$i]["container"]
1213  and $this->format_options[$i]["depth"] != 1) {
1214  $this->format_options[$i]["tab"]["$a_depth"] = "quer";
1215  }
1216 
1217  if ($this->format_options[$i]["depth"] == $a_depth+2) {
1218  if ($this->is_in_array($i+1, $this->format_options[$i]["depth"])) {
1219  $this->format_options[$i]["tab"]["$a_depth"] = "winkel";
1220  } else {
1221  $this->format_options[$i]["tab"]["$a_depth"] = "ecke";
1222  }
1223  }
1224 
1225  if ($this->format_options[$i]["depth"] > $a_depth+2) {
1226  if ($this->is_in_array($i+1, $a_depth+2)) {
1227  $this->format_options[$i]["tab"]["$a_depth"] = "hoch";
1228  }
1229  }
1230  }
1231  }
1232 
1240  public function is_in_array($a_start, $a_depth)
1241  {
1242  for ($i=$a_start;$i<count($this->format_options);++$i) {
1243  if ($this->format_options[$i]["depth"] < $a_depth) {
1244  break;
1245  }
1246 
1247  if ($this->format_options[$i]["depth"] == $a_depth) {
1248  return true;
1249  }
1250  }
1251  return false;
1252  }
1253 
1260  public function getIndex($a_data)
1261  {
1262  if (!is_array($this->format_options)) {
1263  return -1;
1264  }
1265 
1266  foreach ($this->format_options as $key => $value) {
1267  if (($value["child"] == $a_data["parent"])) {
1268  return $key;
1269  }
1270  }
1271 
1272  return -1;
1273  }
1274 
1281  public function addFilter($a_item)
1282  {
1283  $ispresent = 0;
1284 
1285  if (is_array($this->filter)) {
1286  //run through filter
1287  foreach ($this->filter as $item) {
1288  if ($item == $a_item) {
1289  $is_present = 1;
1290 
1291  return false;
1292  }
1293  }
1294  } else {
1295  $this->filter = array();
1296  }
1297  if ($is_present == 0) {
1298  $this->filter[] = $a_item;
1299  }
1300 
1301  return true;
1302  }
1303 
1310  public function delFilter($a_item)
1311  {
1312  //check if a filter exists
1313  if (is_array($this->filter)) {
1314  //build copy of the existing filter without the given item
1315  $tmp = array();
1316 
1317  foreach ($this->filter as $item) {
1318  if ($item != $a_item) {
1319  $tmp[] = $item;
1320  } else {
1321  $deleted = 1;
1322  }
1323  }
1324 
1325  $this->filter = $tmp;
1326  } else {
1327  return false;
1328  }
1329 
1330  if ($deleted == 1) {
1331  return true;
1332  } else {
1333  return false;
1334  }
1335  }
1336 
1343  public function setExpand($a_node_id)
1344  {
1345  // IF ISN'T SET CREATE SESSION VARIABLE
1346  if (!is_array($_SESSION[$this->expand_variable])) {
1348  }
1349  // IF $_GET["expand"] is positive => expand this node
1350  if ($a_node_id > 0 && !in_array($a_node_id, $_SESSION[$this->expand_variable])) {
1351  array_push($_SESSION[$this->expand_variable], $a_node_id);
1352  }
1353  // IF $_GET["expand"] is negative => compress this node
1354  if ($a_node_id < 0) {
1355  $key = array_keys($_SESSION[$this->expand_variable], -(int) $a_node_id);
1356  unset($_SESSION[$this->expand_variable][$key[0]]);
1357  }
1358  $this->expanded = $_SESSION[$this->expand_variable];
1359  }
1360 
1367  public function forceExpandAll($a_mode, $a_show_minus = true)
1368  {
1369  $this->expand_all = (bool) $a_mode;
1370  $this->show_minus = $a_show_minus;
1371  }
1372 
1379  public function setFiltered($a_bool)
1380  {
1381  $this->filtered = $a_bool;
1382  return true;
1383  }
1384 
1391  public function checkFilter($a_item)
1392  {
1393  if (is_array($this->filter)) {
1394  if (in_array($a_item, $this->filter)) {
1395  $ret = true;
1396  } else {
1397  $ret = false;
1398  }
1399  } else {
1400  $ret = false;
1401  }
1402 
1403  if ($this->getFilterMode() == IL_FM_NEGATIVE) {
1404  return $ret;
1405  } else {
1406  return !$ret;
1407  }
1408  }
1409 
1416  public function sortNodes($a_nodes, $a_parent_obj_id)
1417  {
1418  foreach ($a_nodes as $key => $node) {
1419  if ($node["type"] == "adm") {
1420  $match = $key;
1421  $adm_node = $node;
1422  break;
1423  }
1424  }
1425 
1426  // cut off adm node
1427  isset($match) ? array_splice($a_nodes, $match, 1) : "";
1428 
1429  $a_nodes = ilUtil::sortArray($a_nodes, $this->order_column, $this->order_direction);
1430 
1431  // append adm node to end of list
1432  isset($match) ? array_push($a_nodes, $adm_node) : "";
1433 
1434  return $a_nodes;
1435  }
1436 } // END class.ilExplorer
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
formatObject($tpl, $a_node_id, $a_option, $a_obj_id=0)
Creates output recursive method private.
global $ilErr
Definition: raiseError.php:16
forceExpandAll($a_mode, $a_show_minus=true)
force expandAll.
setPostSort($a_sort)
process post sorting
formatHeader($tpl, $a_obj_id, $a_option)
Creates output for header (is empty here but can be overwritten in derived classes) ...
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
buildFrameTarget($a_type, $a_child=0, $a_obj_id=0)
get frame target (may be overwritten by derived classes)
setFilterMode($a_mode=IL_FM_NEGATIVE)
set filter mode
highlightNode($a_id)
set highlighted node
getNodeStyleClass($a_id, $a_type)
get style class for node
getTitleLength()
Get max title length.
$_SESSION["AccountId"]
buildLinkTarget($a_node_id, $a_type)
get link target (may be overwritten by derived classes)
__construct($a_target)
Constructor public.
setId($a_val)
Set id.
setTargetGet($a_target_get)
set the varname in Get-string public
$type
isVisible($a_ref_id, $a_type)
global $DIC
Definition: saml.php:7
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
static initConnection(ilTemplate $a_main_tpl=null)
Init YUI Connection module.
getUseStandardFrame()
Get use standard explorer frame.
setTitleLength($a_length)
Set max title length.
is_in_array($a_start, $a_depth)
DESCRIPTION MISSING private.
buildSelect($a_node_id, $a_type)
standard implementation for adding an option select box between image and title
setFrameUpdater($a_up_frame, $a_up_script, $a_params="")
Set Explorer Updater.
modifyChilds($a_parent_id, $a_objects)
setExpandTarget($a_exp_target)
target script for expand icons
getChildsOfNode($a_parent_id)
Get childs of node.
getId()
Get id.
checkPermissions($a_check)
check permissions via rbac
setAsynchExpanding($a_val)
Set asynch expanding.
handleListEndTags(&$a_tpl_tree, $a_cur_depth, $a_item_depth)
handle list end tags ( and )
getIndex($a_data)
get index of format_options array from specific ref_id,parent_id private
setOrderColumn($a_column)
set the order column public
setFiltered($a_bool)
active/deactivate the filter public
getAsynchExpanding()
Get asynch expanding.
setClickable($a_type, $a_clickable)
(de-)activates links for a certain object type
setOutput($a_parent_id, $a_depth=1, $a_obj_id=0, $a_highlighted_subtree=false)
Creates output for explorer view in admin menue recursive method public.
createTarget($a_type, $a_node_id, $a_highlighted_subtree=false, $a_append_anch=true)
Creates Get Parameter private.
setUseStandardFrame($a_val)
Set use standard frame.
$counter
buildOnClick($a_node_id, $a_type, $a_title)
get onclick event handling (may be overwritten by derived classes)
$a_type
Definition: workflow.php:92
forceExpanded($a_obj_id)
force expansion of node
sortNodes($a_nodes, $a_parent_obj_id)
sort nodes and put adm object to the end of sorted array private
getRoot()
get root id
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
getTreeLead()
Get tree leading content.
special template class to simplify handling of ITX/PEAR
showChilds($a_parent_id)
determines wether the childs of an object should be shown or not note: this standard implementation a...
redirection script todo: (a better solution should control the processing via a xml file) ...
setFrameTarget($a_target)
set target frame or not frame?
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Create styles array
The data for the language used.
setRoot($a_root_id)
Set root node.
Class ilExplorer class for explorer view in admin frame.
initItemCounter($a_number)
Init item counter.
buildTitle($a_title, $a_id, $a_type)
standard implementation for title, may be overwritten by derived classes
getFilterMode()
get filter mode
checkFilter($a_item)
check if item is in filter private
getImage($a_name, $a_type="", $a_obj_id="")
get image path (may be overwritten by derived classes)
getMaximumTreeDepth()
Get maximum tree depth.
handleListStartTags(&$a_tpl_tree, $a_cur_depth, $a_item_depth)
handle list start tags (
setParamsGet($a_params_get)
set additional params to be passed in Get-string public
isClickable($a_type, $a_ref_id=0)
check if links for certain object type are activated
setTreeLead($a_val)
Set tree leading content.
$ret
Definition: parser.php:6
setOrderDirection($a_direction)
set the order direction public
$i
Definition: disco.tpl.php:19
getTitle()
Get title.
setSessionExpandVariable($a_var_name="expand")
set name of expand session variable
addFilter($a_item)
adds item to the filter public
getImageAlt($a_default_text, $a_type="", $a_obj_id="")
get image alt text
delFilter($a_item)
removes item from the filter public
const IL_FM_NEGATIVE
$key
Definition: croninfo.php:18
outputIcons($a_icons)
output icons
buildDescription($a_desc, $a_id, $a_type)
standard implementation for description, may be overwritten by derived classes
setTitle($a_val)
Set title.
$_POST["username"]
$html
Definition: example_001.php:87
createLines($a_depth)
Creates lines for explorer view private.
setExpand($a_node_id)
set the expand option this value is stored in a SESSION variable to save it different view (lo view...
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
getOutput()
Creates output recursive method public.