ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.CharacteristicTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Style\Content;
22
23use ILIAS\Style;
26use ilTable2GUI;
28
35{
39 protected string $super_type;
40 protected bool $hideable;
41 protected int $order_cnt = 0;
42 protected bool $expandable = false;
44 protected array $core_styles = [];
45
46 public function __construct(
48 object $a_parent_obj,
49 string $a_parent_cmd,
50 string $a_super_type,
51 ilObjStyleSheet $a_style,
54 ) {
55 $this->gui_service = $gui_service;
56 $this->manager = $manager;
57 $this->access_manager = $access_manager;
58 $this->super_type = $a_super_type;
59 $this->style = $a_style;
60
61 $ctrl = $this->gui_service->ctrl();
62
63 parent::__construct($a_parent_obj, $a_parent_cmd);
64 $this->setExternalSorting(true);
65 $this->core_styles = ilObjStyleSheet::_getCoreStyles();
66 $this->getItems();
67 $this->setTitle($this->lng->txt("sty_" . $a_super_type . "_char"));
68 $this->setLimit(9999);
69
70 // check, whether any of the types is expandable
71 $this->expandable = false;
72 $this->hideable = false;
73 $all_super_types = ilObjStyleSheet::_getStyleSuperTypes();
74 $types = $all_super_types[$this->super_type];
75 foreach ($types as $t) {
77 $this->expandable = true;
78 }
80 $this->hideable = true;
81 }
82 }
83
84 $this->addColumn("", "", "1"); // checkbox
85 if ($this->expandable) {
86 $this->addColumn($this->lng->txt("sty_order"));
87 }
88 $this->addColumn($this->lng->txt("sty_class_name"));
89 $this->addColumn($this->lng->txt("title"));
90 $this->addColumn($this->lng->txt("sty_type"));
91 $this->addColumn($this->lng->txt("sty_example"));
92 if ($this->hideable) {
93 $this->addColumn($this->lng->txt("sty_hide")); // hide checkbox
94 }
95 $this->addColumn($this->lng->txt("sty_outdated"));
96 $this->addColumn($this->lng->txt("actions"));
97 $this->setEnableHeader(true);
98 $this->setFormAction($ctrl->getFormAction($a_parent_obj));
99 $this->setRowTemplate("tpl.style_row.html", "components/ILIAS/Style/Content/Characteristic");
100 $this->disable("footer");
101
102 if ($this->access_manager->checkWrite()) {
103 // action commands
104 if ($this->hideable || $this->expandable) {
105 $txt = $this->lng->txt("sty_save_hide_status");
106 if ($this->hideable && $this->expandable) {
107 $txt = $this->lng->txt("sty_save_hide_order_status");
108 } elseif (!$this->hideable) {
109 $txt = $this->lng->txt("sty_save_order_status");
110 }
111
112 $this->addCommandButton("saveStatus", $txt);
113 }
114
115 $this->addMultiCommand("copyCharacteristics", $this->lng->txt("copy"));
116 $this->addMultiCommand("setOutdated", $this->lng->txt("sty_set_outdated"));
117 $this->addMultiCommand("removeOutdated", $this->lng->txt("sty_remove_outdated"));
118
119 // action commands
120 if ($this->expandable) {
121 $this->addMultiCommand("deleteCharacteristicConfirmation", $this->lng->txt("delete"));
122 }
123 }
124
125 $this->setEnableTitle(true);
126 }
127
128 protected function getItems(): void
129 {
130 $data = [];
131 foreach ($this->manager->getBySuperType($this->super_type) as $char) {
132 $data[] = [
133 "obj" => $char
134 ];
135 }
136 $this->setData($data);
137 }
138
139 protected function fillRow(array $a_set): void
140 {
142 $ilCtrl = $this->gui_service->ctrl();
143 $ui = $this->gui_service->ui();
144
145 $char = $a_set["obj"];
146
147 if ($this->expandable) {
148 $this->order_cnt = $this->order_cnt + 10;
149 $this->tpl->setCurrentBlock("order");
150 $this->tpl->setVariable("OCHAR", $char->getType() . "." .
151 ilObjStyleSheet::_determineTag($char->getType()) .
152 "." . $char->getCharacteristic());
153 $this->tpl->setVariable("ORDER", $this->order_cnt);
154 $this->tpl->parseCurrentBlock();
155 }
156
157
158 $this->tpl->setCurrentBlock("checkbox");
159 $this->tpl->setVariable("CHAR", $char->getType() . "." .
160 ilObjStyleSheet::_determineTag($char->getType()) .
161 "." . $char->getCharacteristic());
162 $this->tpl->parseCurrentBlock();
163
164 if ($this->hideable) {
165 if (!ilObjStyleSheet::_isHideable($char->getType()) ||
166 (!empty($this->core_styles[$char->getType() . "." .
167 ilObjStyleSheet::_determineTag($char->getType()) .
168 "." . $char->getCharacteristic()]))) {
169 $this->tpl->touchBlock("no_hide_checkbox");
170 } else {
171 $this->tpl->setCurrentBlock("hide_checkbox");
172 $this->tpl->setVariable("CHAR", $char->getType() . "." .
173 ilObjStyleSheet::_determineTag($char->getType()) .
174 "." . $char->getCharacteristic());
175 if ($this->style->getHideStatus($char->getType(), $char->getCharacteristic())) {
176 $this->tpl->setVariable("CHECKED", "checked='checked'");
177 }
178 $this->tpl->parseCurrentBlock();
179 }
180 }
181
182 // example
183 $this->tpl->setVariable(
184 "EXAMPLE",
185 ilObjStyleSheetGUI::getStyleExampleHTML($char->getType(), $char->getCharacteristic())
186 );
187 $tag_str = ilObjStyleSheet::_determineTag($char->getType()) . "." . $char->getCharacteristic();
188 $this->tpl->setVariable("TXT_TAG", $char->getCharacteristic());
189 $this->tpl->setVariable("TXT_TYPE", $lng->txt("sty_type_" . $char->getType()));
190
191 $this->tpl->setVariable("TITLE", $this->manager->getPresentationTitle(
192 $char->getType(),
193 $char->getCharacteristic(),
194 false
195 ));
196
197 if ($this->access_manager->checkWrite()) {
198 $ilCtrl->setParameter($this->parent_obj, "tag", $tag_str);
199 $ilCtrl->setParameter($this->parent_obj, "style_type", $char->getType());
200 $ilCtrl->setParameter($this->parent_obj, "char", $char->getCharacteristic());
201
202 $links = [];
203 $links[] = $ui->factory()->link()->standard(
204 $this->lng->txt("edit"),
205 $ilCtrl->getLinkTargetByClass("ilStyleCharacteristicGUI", "editTagStyle")
206 );
207
208 if (!ilObjStyleSheet::isCoreStyle($char->getType(), $char->getCharacteristic())) {
209 if ($char->isOutdated()) {
210 $this->tpl->setVariable("OUTDATED", $lng->txt("yes"));
211 $links[] = $ui->factory()->link()->standard(
212 $this->lng->txt("sty_remove_outdated"),
213 $ilCtrl->getLinkTargetByClass("ilStyleCharacteristicGUI", "removeOutdated")
214 );
215 } else {
216 $this->tpl->setVariable("OUTDATED", $lng->txt("no"));
217 $links[] = $ui->factory()->link()->standard(
218 $this->lng->txt("sty_set_outdated"),
219 $ilCtrl->getLinkTargetByClass("ilStyleCharacteristicGUI", "setOutdated")
220 );
221 }
222 }
223
224 $dd = $ui->factory()->dropdown()->standard($links);
225
226 $this->tpl->setVariable(
227 "ACTIONS",
228 $ui->renderer()->render($dd)
229 );
230 }
231 }
232}
Manages access to content style editing.
Main business logic for characteristics.
fillRow(array $a_set)
Standard Version of Fill Row.
__construct(InternalGUIService $gui_service, object $a_parent_obj, string $a_parent_cmd, string $a_super_type, ilObjStyleSheet $a_style, Style\Content\CharacteristicManager $manager, Access\StyleAccessManager $access_manager)
getFormAction(object $a_gui_obj, ?string $a_fallback_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
Class ilObjStyleSheetGUI.
static getStyleExampleHTML(string $a_type, string $a_class)
Get style example HTML.
Class ilObjStyleSheet.
static isCoreStyle(string $a_type, string $a_class)
static _determineTag(string $a_type)
static _isHideable(string $a_type)
static _isExpandable(string $a_type)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setEnableTitle(bool $a_enabletitle)
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)
setExternalSorting(bool $a_val)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
ILIAS DI UIServices $ui
setData(array $a_data)
Set table data.
ilLanguage $lng
disable(string $a_module_name)
$txt
Definition: error.php:31
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc