ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
OrgUnitToolProvider.php
Go to the documentation of this file.
1<?php
2
4
10use ilObjOrgUnit;
14use ilTree;
15
21{
22 public const SHOW_ORGU_TREE = 'show_orgu_tree';
23
28 {
29 return $this->context_collection->main()->administration();
30 }
31
35 public function getToolsForContextStack(CalledContexts $called_contexts) : array
36 {
37 $tools = [];
38
39 if ($called_contexts->current()->getAdditionalData()->is(self::SHOW_ORGU_TREE, true)) {
40 $iff = function (string $id) {
41 return $this->identification_provider->contextAwareIdentifier($id);
42 };
43
44 $t = function (string $key) : string {
45 return $this->dic->language()->txt($key);
46 };
47
48 $tools[] = $this->factory->treeTool($iff('tree_new'))
49 ->withTitle($t('tree'))
50 ->withSymbol($this->dic->ui()->factory()->symbol()->icon()->standard('orgu', 'Orgu'))
51 ->withTree($this->getTree());
52 }
53
54 return $tools;
55 }
56
57 private function getTree() : Tree
58 {
59 global $DIC;
60 $lng = $DIC->language();
61 $tree = $this->getTreeRecursion();
62
63 $parent_node_id = $DIC->repositoryTree()->getParentId(ilObjOrgUnit::getRootOrgRefId());
64
65 return $this->dic->ui()->factory()->tree()->expandable($lng->txt("org_units"), $tree)
66 ->withData($tree->getChildsOfNode($parent_node_id));
67 }
68
69 private function getTreeRecursion() : TreeRecursion
70 {
71 $tree = new ilOrgUnitExplorerGUI(
72 "orgu_explorer",
73 ilObjOrgUnitGUI::class,
74 "showTree",
75 new ilTree(1),
76 $this->dic["ilAccess"]
77 );
78 $tree->setTypeWhiteList($this->getTreeWhiteList());
79 $tree->setRootId(ilObjOrgUnit::getRootOrgRefId());
80 $tree->setPathOpen($_GET['item_ref_id'] ?? $_GET['ref_id'] ?? '');
81
82 return $tree;
83 }
84
85 private function getTreeWhiteList() : array
86 {
87 $whiteList = array('orgu');
88 $pls = ilOrgUnitExtension::getActivePluginIdsForTree();
89
90 return array_merge($whiteList, $pls);
91 }
92}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
getToolsForContextStack(CalledContexts $called_contexts)
@inheritDoc
Class ilObjOrgUnit GUI class.
Class ilObjOrgUnit.
static getRootOrgRefId()
Class ilOrgUnitExplorerGUI.
Class ilOrgUnitExtension.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Interface for mapping data-structures to the Tree.
This describes a Tree Control.
Definition: Tree.php:14
withSymbol(Symbol $symbol)
@inheritDoc
$lng
$DIC
Definition: xapitoken.php:46