ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.UsagesUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Skill\Usage;
22
24use ILIAS\UI;
25
30{
31 protected \ilLanguage $lng;
32 protected UI\Factory $ui_fac;
33 protected UI\Renderer $ui_ren;
36 protected \ilSkillTreeRepository $tree_repo;
37 protected int $skill_id = 0;
38 protected int $tref_id = 0;
39 protected array $usage = [];
40 protected string $mode = "";
41
42 public function __construct(
43 string $cskill_id,
44 array $usage,
45 string $mode = ""
46 ) {
47 global $DIC;
48
49 $this->lng = $DIC->language();
50 $this->ui_fac = $DIC->ui()->factory();
51 $this->ui_ren = $DIC->ui()->renderer();
52 $this->tree_manager = $DIC->skills()->internal()->manager()->getTreeManager();
53 $this->usage_manager = $DIC->skills()->internal()->manager()->getUsageManager();
54 $this->tree_repo = $DIC->skills()->internal()->repo()->getTreeRepo();
55
56 $id_parts = explode(":", $cskill_id);
57 $this->skill_id = (int) $id_parts[0];
58 $this->tref_id = (int) $id_parts[1];
59 $this->usage = $usage;
60 $this->mode = $mode;
61 }
62
63 public function render(): string
64 {
65 $tree = $this->tree_repo->getTreeForNodeId($this->skill_id);
66 if ($this->mode === "tree") {
67 $tree_obj = $this->tree_manager->getTree($tree->getTreeId());
68 $title = $tree_obj->getTitle() . " > " . \ilSkillTreeNode::_lookupTitle($this->skill_id, $this->tref_id);
69 } else {
70 $title = \ilSkillTreeNode::_lookupTitle($this->skill_id, $this->tref_id);
71 }
72
73 //$description = $tree->getSkillTreePathAsString($skill_id, $tref_id);
74
75 $listing = $this->getUsagesListing();
76
77 $panel = $this->ui_fac->panel()->standard($title, $listing);
78
79 return $this->ui_ren->render($panel);
80 }
81
82 protected function getUsagesListing(): UI\Component\Listing\CharacteristicValue\Text
83 {
84 $types = [];
85 foreach ($this->usage as $type => $type_usages) {
86 $types[$this->usage_manager->getTypeInfoString($type)] = count($type_usages) . " " .
87 $this->usage_manager->getObjTypeString($type);
88 }
89
90 $listing = $this->ui_fac->listing()->characteristicValue()->text($types);
91
92 return $listing;
93 }
94}
ilSkillTreeRepository $tree_repo
Tree SkillTreeManager $tree_manager
SkillUsageManager $usage_manager
__construct(string $cskill_id, array $usage, string $mode="")
Definition: UI.php:24
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26