ILIAS  release_8 Revision v8.23
class.ilSkillGSToolProvider.php
Go to the documentation of this file.
1 <?php
2 
24 
31 {
32  public const SHOW_SKILL_TREE = 'show_skill_tree';
33  public const SHOW_TEMPLATE_TREE = 'show_template_tree';
34  public const SKILL_TREE_ID = 'skill_tree_id';
35 
36 
41  {
42  return $this->context_collection->main()->desktop();
43  }
44 
45 
49  public function getToolsForContextStack(CalledContexts $called_contexts): array
50  {
51  $lang = $this->dic->language();
52 
53  $lang->loadLanguageModule("skill");
54 
55  $title = $lang->txt("skmg_skills");
56 
57  $tools = [];
58 
59  $icon = $this->dic->ui()->factory()->symbol()->icon()->custom(\ilUtil::getImagePath("icon_skmg.svg"), $title);
60 
61  $additional_data = $called_contexts->current()->getAdditionalData();
62  if ($additional_data->is(self::SHOW_SKILL_TREE, true)) {
63  $tree_id = $additional_data->get(self::SKILL_TREE_ID);
64  $tools[] = $this->factory->tool($this->identification_provider->contextAwareIdentifier("tree"))
65  ->withTitle($title)
66  ->withSymbol($icon)
67  ->withContentWrapper(function () use ($tree_id): Legacy {
68  return $this->dic->ui()->factory()->legacy($this->getSkillTree($tree_id));
69  });
70  }
71 
72  $title = $lang->txt("skmg_skill_templates");
73  $icon = $this->dic->ui()->factory()->symbol()->icon()->custom(\ilUtil::getImagePath("icon_skmg.svg"), $title);
74 
75  if ($additional_data->is(self::SHOW_TEMPLATE_TREE, true)) {
76  $tree_id = $additional_data->get(self::SKILL_TREE_ID);
77  $tools[] = $this->factory->tool($this->identification_provider->contextAwareIdentifier("tree"))
78  ->withTitle("Templates")
79  ->withSymbol($icon)
80  ->withContentWrapper(function () use ($tree_id): Legacy {
81  return $this->dic->ui()->factory()->legacy($this->getTemplateTree($tree_id));
82  });
83  }
84  return $tools;
85  }
86 
87  private function getSkillTree(int $tree_id): string
88  {
89  $exp = new ilSkillTreeExplorerGUI(["ilAdministrationGUI", "ilObjSkillManagementGUI",
90  "ilSkillTreeAdminGUI", "ilObjSkillTreeGUI"], "showTree", $tree_id);
91 
92  return $exp->getHTML();
93  }
94 
95  private function getTemplateTree(int $tree_id): string
96  {
97  $exp = new ilSkillTemplateTreeExplorerGUI(["ilAdministrationGUI", "ilObjSkillManagementGUI",
98  "ilSkillTreeAdminGUI", "ilObjSkillTreeGUI"], "showTree", $tree_id);
99 
100  return $exp->getHTML();
101  }
102 }
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)