ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilNewItemGroupTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 protected bool $has_write;
30
31 public function __construct(
32 ilObjRepositorySettingsGUI $a_parent_obj,
33 string $a_parent_cmd = "",
34 bool $a_has_write = false
35 ) {
36 global $DIC;
37 $this->main_tpl = $DIC->ui()->mainTemplate();
38
39 $this->ctrl = $DIC->ctrl();
40 $this->lng = $DIC->language();
41 $ilCtrl = $DIC->ctrl();
42 $lng = $DIC->language();
43
44 $this->has_write = $a_has_write;
45
46 parent::__construct($a_parent_obj, $a_parent_cmd);
47
48 $this->setId("repnwitgrptbl");
49
50 $this->setTitle($lng->txt("rep_new_item_groups"));
51
52 if ($this->has_write) {
53 $this->addColumn("", "", '1');
54 }
55 $this->addColumn($lng->txt("cmps_add_new_rank"), "");
56 $this->addColumn($lng->txt("title"), "");
57 $this->addColumn($lng->txt("rep_new_item_group_nr_subitems"), "");
58
59 if ($this->has_write) {
60 $this->addColumn($lng->txt("action"), "");
61 }
62
63 if ($this->has_write) {
64 $this->addCommandButton("saveNewItemGroupOrder", $lng->txt("cmps_save_options"));
65 $this->addMultiCommand("confirmDeleteNewItemGroup", $lng->txt("delete"));
66 }
67
68 $this->setEnableHeader(true);
69 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
70 $this->setRowTemplate("tpl.table_row_new_item_group.html", "components/ILIAS/Repository/Administration");
71 $this->setLimit(10000);
72
73 $this->setExternalSorting(true);
74 $this->getGroups();
75 }
76
77 public function getGroups(): void
78 {
80
81 $data = [];
82
84
85 if ($subitems[0] ?? false) {
86 $this->main_tpl->setOnScreenMessage('info', sprintf(
87 $lng->txt("rep_new_item_group_unassigned_subitems"),
88 is_array($subitems[0]) ? count($subitems[0]) : 0
89 ));
90 unset($subitems[0]);
91 }
92
94 $data[] = [
95 "id" => $item["id"],
96 "pos" => $item["pos"],
97 "title" => $item["title"],
98 "subitems" => is_array($subitems[$item["id"]] ?? null) ? count($subitems[$item["id"]]) : 0
99 ];
100 }
101
102 $data = ilArrayUtil::sortArray($data, "pos", "asc", true);
103
104 $this->setData($data);
105 }
106
107 protected function fillRow(array $a_set): void
108 {
110 $ilCtrl = $this->ctrl;
111
112 if ($this->has_write) {
113 $this->tpl->setVariable("VAR_MULTI", "grp_ids[]");
114 $this->tpl->setVariable("VAL_MULTI", $a_set["id"]);
115 }
116
117 $this->tpl->setVariable("VAR_POS", "grp_order[" . $a_set["id"] . "]");
118 $this->tpl->setVariable("VAL_POS", $a_set["pos"]);
119 $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
120 $this->tpl->setVariable("VAL_ITEMS", $a_set["subitems"]);
121
122 if ($this->has_write) {
123 $ilCtrl->setParameter($this->parent_obj, "grp_id", $a_set["id"]);
124 $url = $ilCtrl->getLinkTarget($this->parent_obj, "editNewItemGroup");
125 $ilCtrl->setParameter($this->parent_obj, "grp_id", "");
126
127 $this->tpl->setVariable("URL_EDIT", $url);
128 $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
129 }
130 }
131}
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
@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...
TableGUI class for new item groups.
fillRow(array $a_set)
Standard Version of Fill Row.
__construct(ilObjRepositorySettingsGUI $a_parent_obj, string $a_parent_cmd="", bool $a_has_write=false)
ilGlobalTemplateInterface $main_tpl
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="")
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.
setId(string $a_val)
setData(array $a_data)
Set table data.
ilLanguage $lng
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68