ILIAS  release_7 Revision v7.30-3-g800a261c036
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("orgu_explorer", ilObjOrgUnitGUI::class, "showTree", new ilTree(1));
72 $tree->setTypeWhiteList($this->getTreeWhiteList());
73 $tree->setRootId(ilObjOrgUnit::getRootOrgRefId());
74 $tree->setPathOpen($_GET['item_ref_id'] ?? $_GET['ref_id'] ?? '');
75 $tree->setOrderField('title');
76
77 return $tree;
78 }
79
80 private function getTreeWhiteList() : array
81 {
82 $whiteList = array('orgu');
83 $pls = ilOrgUnitExtension::getActivePluginIdsForTree();
84
85 return array_merge($whiteList, $pls);
86 }
87}
$_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...
global $DIC
Definition: goto.php:24
Interface for mapping data-structures to the Tree.
This describes a Tree Control.
Definition: Tree.php:14
withSymbol(Symbol $symbol)
@inheritDoc
$lng