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