ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilSkillGSToolProvider.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
26 
33 {
34  public const SHOW_SKILL_TREE = 'show_skill_tree';
35  public const SHOW_TEMPLATE_TREE = 'show_template_tree';
36  public const SKILL_TREE_ID = 'skill_tree_id';
37 
38 
43  {
44  return $this->context_collection->main()->desktop();
45  }
46 
47 
51  public function getToolsForContextStack(CalledContexts $called_contexts): array
52  {
53  $lang = $this->dic->language();
54 
55  $lang->loadLanguageModule("skill");
56 
57  $title = $lang->txt("skmg_skills");
58 
59  $tools = [];
60 
61  $icon = $this->dic->ui()->factory()->symbol()->icon()->custom(\ilUtil::getImagePath("standard/icon_skmg.svg"), $title);
62 
63  $additional_data = $called_contexts->current()->getAdditionalData();
64  if ($additional_data->is(self::SHOW_SKILL_TREE, true)) {
65  $tree_id = $additional_data->get(self::SKILL_TREE_ID);
66  $tools[] = $this->factory->tool($this->identification_provider->contextAwareIdentifier("tree"))
67  ->withTitle($title)
68  ->withSymbol($icon)
69  ->withContentWrapper(function () use ($tree_id): Legacy {
70  return $this->dic->ui()->factory()->legacy($this->getSkillTree($tree_id));
71  });
72  }
73 
74  $title = $lang->txt("skmg_skill_templates");
75  $icon = $this->dic->ui()->factory()->symbol()->icon()->custom(\ilUtil::getImagePath("standard/icon_skmg.svg"), $title);
76 
77  if ($additional_data->is(self::SHOW_TEMPLATE_TREE, true)) {
78  $tree_id = $additional_data->get(self::SKILL_TREE_ID);
79  $tools[] = $this->factory->tool($this->identification_provider->contextAwareIdentifier("tree"))
80  ->withTitle("Templates")
81  ->withSymbol($icon)
82  ->withContentWrapper(function () use ($tree_id): Legacy {
83  return $this->dic->ui()->factory()->legacy($this->getTemplateTree($tree_id));
84  });
85  }
86  return $tools;
87  }
88 
89  private function getSkillTree(int $tree_id): string
90  {
91  $exp = new ilSkillTreeExplorerGUI(["ilAdministrationGUI", "ilObjSkillManagementGUI",
92  "ilSkillTreeAdminGUI", "ilObjSkillTreeGUI"], "showTree", $tree_id);
93 
94  return $exp->getHTML();
95  }
96 
97  private function getTemplateTree(int $tree_id): string
98  {
99  $exp = new ilSkillTemplateTreeExplorerGUI(["ilAdministrationGUI", "ilObjSkillManagementGUI",
100  "ilSkillTreeAdminGUI", "ilObjSkillTreeGUI"], "showTree", $tree_id);
101 
102  return $exp->getHTML();
103  }
104 }
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
Explorer class that works on tree objects (Services/Tree)
Workspace GS tool provider.
getToolsForContextStack(CalledContexts $called_contexts)
$lang
Definition: xapiexit.php:26
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Explorer class that works on tree objects (Services/Tree)