ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
OrgUnitToolProvider.php
Go to the documentation of this file.
1 <?php
2 
3 namespace ILIAS\OrgUnit\Provider;
4 
10 use ilObjOrgUnit;
11 use ilObjOrgUnitGUI;
14 use 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"]
$lng
getToolsForContextStack(CalledContexts $called_contexts)
global $DIC
Definition: goto.php:24
static getRootOrgRefId()
This describes a Tree Control.
Definition: Tree.php:13
Interface for mapping data-structures to the Tree.