ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTaxonomySettingsGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 protected ilTabsGUI $tabs;
28 protected ilCtrl $ctrl;
29 protected ilLanguage $lng;
32 protected string $list_info;
33 protected bool $multiple;
34 protected \ILIAS\Taxonomy\InternalGUIService $gui;
35 protected \ILIAS\Taxonomy\InternalDomainService $domain;
36 protected int $rep_obj_id;
37 protected bool $assigned_item_sorting = false;
39 protected string $assigned_item_comp_id = "";
40 protected int $assigned_item_obj_id = 0;
41 protected string $assigned_item_type = "";
42
43
44 public function __construct(
45 \ILIAS\Taxonomy\InternalDomainService $domain,
46 \ILIAS\Taxonomy\InternalGUIService $gui,
47 int $rep_obj_id,
48 string $list_info = "",
49 bool $multiple = true,
50 ?\ILIAS\Taxonomy\Settings\ModifierGUIInterface $modifier = null
51 ) {
52 $this->domain = $domain;
53 $this->gui = $gui;
54
55 $this->toolboar = $gui->toolbar();
56 $this->ctrl = $gui->ctrl();
57 $this->tpl = $gui->ui()->mainTemplate();
58 $this->tabs = $gui->tabs();
59
60 $this->lng = $domain->lng();
61
62 $this->rep_obj_id = $rep_obj_id;
63 $this->multiple = $multiple;
64 $this->list_info = $list_info;
65 $this->modifier = $modifier;
66
67 }
68
69 public function withAssignedItemSorting(
70 ilTaxAssignedItemInfo $a_item_info_obj,
71 string $a_component_id,
72 int $a_obj_id,
73 string $a_item_type
74 ): self {
75 $new = clone $this;
76 $new->assigned_item_sorting = true;
77 $new->assigned_item_info_obj = $a_item_info_obj;
78 $new->assigned_item_comp_id = $a_component_id;
79 $new->assigned_item_obj_id = $a_obj_id;
80 $new->assigned_item_type = $a_item_type;
81 return $new;
82 }
83
84 public function executeCommand(): void
85 {
86 $ctrl = $this->gui->ctrl();
87
88 $next_class = $ctrl->getNextClass($this);
89 $cmd = $ctrl->getCmd("listTaxonomies");
90
91 $this->tabs->activateSubTab("tax_settings");
92
93 switch ($next_class) {
94
95 case strtolower(ilObjTaxonomyGUI::class):
96 $ctrl->setReturn($this, "");
97 $tax_gui = $this->gui->getObjTaxonomyGUI($this->rep_obj_id);
98 if ($this->assigned_item_sorting) {
99 $tax_gui->activateAssignedItemSorting(
100 $this->assigned_item_info_obj,
101 $this->assigned_item_comp_id,
102 $this->assigned_item_obj_id,
103 $this->assigned_item_type
104 );
105 }
106 $this->ctrl->forwardCommand($tax_gui);
107 break;
108
109 default:
110 if (in_array($cmd, ["listTaxonomies"])) {
111 $this->$cmd();
112 }
113 }
114 }
115
116 protected function listTaxonomies(): void
117 {
118 $f = $this->gui->ui()->factory();
119 $r = $this->gui->ui()->renderer();
120 $um = $this->domain->usage();
121 $tax_ids = $um->getUsageOfObject($this->rep_obj_id, true);
122 if ($this->multiple || count($tax_ids) === 0) {
123 $this->toolboar->addButton(
124 $this->lng->txt("tax_add_taxonomy"),
125 $this->ctrl->getLinkTargetByClass(ilObjTaxonomyGUI::class, "createAssignedTaxonomy")
126 );
127 } else {
128 $this->tpl->setOnScreenMessage('info', $this->lng->txt("tax_max_one_tax"));
129 }
130 $items = [];
131 foreach($tax_ids as $t) {
132 $this->ctrl->setParameterByClass(ilObjTaxonomyGUI::class, "tax_id", $t["tax_id"]);
133 $action = [];
134 $action[] = $f->button()->shy(
135 $this->lng->txt("edit"),
136 $this->ctrl->getLinkTargetByClass(ilObjTaxonomyGUI::class, "listNodes")
137 );
138 $action[] = $f->button()->shy(
139 $this->lng->txt("delete"),
140 $this->ctrl->getLinkTargetByClass(ilObjTaxonomyGUI::class, "confirmDeleteTaxonomy")
141 );
142 $properties = [];
143 if ($this->modifier) {
144 $properties = $this->modifier->getProperties((int) $t["tax_id"]);
145 foreach ($this->modifier->getActions((int) $t["tax_id"]) as $act) {
146 $action[] = $act;
147 }
148 }
149 $dd = $f->dropdown()->standard($action);
150 $item = $f->item()->standard($t["title"])->withActions($dd);
151 if (count($properties) > 0) {
152 $item = $item->withProperties($properties);
153 }
154 $items[] = $item;
155 }
156 $title = ($this->multiple)
157 ? $this->lng->txt("obj_taxf")
158 : $this->lng->txt("obj_tax");
159 $panel = $f->panel()->listing()->standard(
160 $title,
161 [$f->item()->group("", $items) ]
162 );
163 $components = [];
164 if ($this->list_info !== "") {
165 $this->tpl->setOnScreenMessage("info", $this->list_info);
166 }
167 $components[] = $panel;
168 $this->tpl->setContent($r->render($components));
169 }
170
171}
$components
Class ilCtrl provides processing control methods.
getNextClass($a_gui_class=null)
@inheritDoc
getCmd(?string $fallback_command=null)
@inheritDoc
setReturn(object $a_gui_obj, ?string $a_cmd=null)
@inheritDoc
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
@ilCtrl_Calls ilTaxonomySettingsGUI: ilObjTaxonomyGUI
withAssignedItemSorting(ilTaxAssignedItemInfo $a_item_info_obj, string $a_component_id, int $a_obj_id, string $a_item_type)
ILIAS Taxonomy InternalGUIService $gui
ILIAS Taxonomy InternalDomainService $domain
ilGlobalTemplateInterface $tpl
ILIAS Taxonomy Settings ModifierGUIInterface $modifier
__construct(\ILIAS\Taxonomy\InternalDomainService $domain, \ILIAS\Taxonomy\InternalGUIService $gui, int $rep_obj_id, string $list_info="", bool $multiple=true, ?\ILIAS\Taxonomy\Settings\ModifierGUIInterface $modifier=null)
ilTaxAssignedItemInfo $assigned_item_info_obj
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.