22use Psr\Http\Message\RequestInterface;
38 private readonly HttpServices
$http;
56 $a_export_callback =
null,
57 ?
string $a_export_subobj_title =
null
61 $this->tpl =
$DIC[
"tpl"];
62 $this->
http = $DIC->http();
63 $this->
ctrl = $DIC->ctrl();
64 $this->
lng = $DIC->language();
65 $this->
toolbar = $DIC->toolbar();
67 $this->request =
$DIC->http()->request();
68 $this->ui_factory =
$DIC->ui()->factory();
69 $this->ui_renderer =
$DIC->ui()->renderer();
73 $this->parent_id = $a_parent_id;
74 $this->export_callback = $a_export_callback;
75 $this->export_subobj_title = $a_export_subobj_title;
79 $params = $this->request->getQueryParams();
80 $body = $this->request->getParsedBody();
81 $this->requested_cat_id = (
int) ($body[
"cat_id"] ?? (
$params[
"cat_id"] ?? 0));
83 if ($this->requested_cat_id) {
85 if ($cat->getParentId() === $this->parent_id) {
86 $this->cat_id = $cat->getId();
99 $cmd = $ilCtrl->getCmd(
'listCategories');
101 switch ($next_class) {
110 $cmd = $this->
http->wrapper()->query()->retrieve(
111 'rating_category_ordering_table_action',
114 $this->refinery->kindlyTo()->string(),
115 $this->refinery->always(
'')
132 $ilToolbar->addButton(
133 $lng->
txt(
"rating_add_category"),
134 $ilCtrl->getLinkTarget($this,
"add")
137 $ilToolbar->addSeparator();
139 $ilToolbar->addButton(
141 $ilCtrl->getLinkTarget($this,
"export")
144 $tpl->
setContent($this->ui_renderer->render($this->getRatingCategoryOrderingTable()->getComponent()));
155 $this->
http->request()
166 $form->setTarget(
"_top");
167 $form->setFormAction($ilCtrl->getFormAction($this,
"save"));
168 $form->setTitle(
$lng->
txt(
"rating_category_" . ($a_id ?
"edit" :
"create")));
172 $ti->setMaxLength(128);
174 $ti->setRequired(
true);
185 $form->addCommandButton(
"save",
$lng->
txt(
"rating_category_add"));
188 $ti->setValue($cat->getTitle());
189 $ta->setValue($cat->getDescription());
191 $form->addCommandButton(
"update",
$lng->
txt(
"rating_category_update"));
193 $form->addCommandButton(
"listCategories",
$lng->
txt(
"cancel"));
209 protected function save(): void
215 if ($form->checkInput()) {
217 $cat->setParentId($this->parent_id);
218 $cat->setTitle($form->getInput(
"title"));
219 $cat->setDescription($form->getInput(
"desc"));
222 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
"rating_category_created"));
223 $ilCtrl->redirect($this,
"listCategories");
226 $form->setValuesByPost();
235 $cat_id = $this->
http->wrapper()->query()->has(
'rating_category_ordering_rating_ids') ?
236 $this->
http->wrapper()->query()->retrieve(
237 'rating_category_ordering_rating_ids',
238 $this->
refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
242 $ilCtrl->setParameter($this,
'cat_id',
$cat_id);
257 if ($form->checkInput()) {
259 $cat->setTitle($form->getInput(
"title"));
260 $cat->setDescription($form->getInput(
"desc"));
263 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
"rating_category_updated"));
264 $ilCtrl->redirect($this,
"listCategories");
267 $form->setValuesByPost();
277 $data = $table->getComponent()->getData();
282 if ($cat->getParentId() === $this->parent_id) {
284 $cat->setPosition($cnt);
289 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
'settings_saved'),
true);
290 $ilCtrl->redirect($this,
'listCategories');
299 $cat_id = $this->
http->wrapper()->query()->has(
'rating_category_ordering_rating_ids') ?
300 $this->
http->wrapper()->query()->retrieve(
301 'rating_category_ordering_rating_ids',
302 $this->
refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
313 $cgui->setHeaderText(
$lng->
txt(
'rating_category_delete_sure') .
'<br/>' .
314 $lng->
txt(
'info_delete_warning_no_trash'));
316 $cgui->setFormAction($ilCtrl->getFormAction($this));
317 $cgui->setCancel(
$lng->
txt(
'cancel'),
'listCategories');
318 $cgui->setConfirm(
$lng->
txt(
'confirm'),
'delete');
321 $cgui->addItem(
'cat_id',
$cat_id, $cat->getTitle());
326 protected function delete():
void
333 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
"rating_category_deleted"),
true);
342 $cat->setPosition($cnt);
346 $ilCtrl->redirect($this,
"listCategories");
354 $excel->addSheet(
$lng->
txt(
"rating_categories"));
359 $active[$item[
"id"]] = $item[
"title"];
364 $excel->setCell($row, 0, $this->export_subobj_title .
" (" .
$lng->
txt(
"id") .
")");
365 $excel->setCell($row, 1, $this->export_subobj_title);
366 $excel->setCell($row, 2,
$lng->
txt(
"rating_export_category") .
" (" .
$lng->
txt(
"id") .
")");
367 $excel->setCell($row, 3,
$lng->
txt(
"rating_export_category"));
368 $excel->setCell($row, 4,
$lng->
txt(
"rating_export_date"));
369 $excel->setCell($row, 5,
$lng->
txt(
"rating_export_rating"));
370 $excel->setBold(
"A1:F1");
375 if (!$item[
"sub_obj_id"]) {
381 $sub_obj_title = $item[
"sub_obj_type"];
382 if ($this->export_callback) {
383 $sub_obj_title = call_user_func($this->export_callback, $item[
"sub_obj_id"], $item[
"sub_obj_type"]);
386 $excel->setCell($row, 0, (
int) $item[
"sub_obj_id"]);
387 $excel->setCell($row, 1, $sub_obj_title);
388 $excel->setCell($row, 2, (
int) $item[
"category_id"]);
389 $excel->setCell($row, 3, $active[$item[
"category_id"]] ??
"");
391 $excel->setCell($row, 5, $item[
"rating"] ??
"");
399 return [
'handleTableActions'];
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Builds a Color from either hex- or rgb values.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
getNextClass($a_gui_class=null)
@inheritDoc
@classDescription Date and time handling
loadLanguageModule(string $a_module)
Load language module.
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...
static _lookupType(int $id, bool $reference=false)
static _lookupTitle(int $obj_id)
Class ilRatingCategoryGUI.
getSafePostCommands()
This method must return a list of safe POST commands.
add(?ilPropertyFormGUI $a_form=null)
string $export_subobj_title
readonly HttpServices $http
getRatingCategoryOrderingTable()
RequestInterface $request
readonly UIRenderer $ui_renderer
getUnsafeGetCommands()
This method must return a list of unsafe GET commands.
readonly UIFactory $ui_factory
__construct(int $a_parent_id, $a_export_callback=null, ?string $a_export_subobj_title=null)
ilRatingCategoryGUI constructor.
initCategoryForm(?int $a_id=null)
ilGlobalTemplateInterface $tpl
readonly Refinery $refinery
edit(?ilPropertyFormGUI $a_form=null)
executeCommand()
execute command
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getAllForObject(int $a_parent_obj_id)
static getExportData(int $a_obj_id, string $a_obj_type, ?array $a_category_ids=null)
Get export data.
This class represents a text area property in a property form.
This class represents a text property in a property form.
setContent(string $a_html)
Sets content for standard template.
An entity that renders components to a string output.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
static http()
Fetches the global http state from ILIAS.