ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilNewItemGroupTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
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", "Services/Repository/Administration");
71  $this->setLimit(10000);
72 
73  $this->setExternalSorting(true);
74  $this->getGroups();
75  }
76 
77  public function getGroups(): void
78  {
79  $lng = $this->lng;
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 
93  foreach (ilObjRepositorySettings::getNewItemGroups() as $item) {
94  $data[] = [
95  "id" => $item["id"],
96  "pos" => $item["pos"],
97  "title" => $item["title"],
98  "type" => $item["type"],
99  "subitems" => is_array($subitems[$item["id"]] ?? null) ? count($subitems[$item["id"]]) : 0
100  ];
101  }
102 
103  $data = ilArrayUtil::sortArray($data, "pos", "asc", true);
104 
105  $this->setData($data);
106  }
107 
108  protected function fillRow(array $a_set): void
109  {
110  $lng = $this->lng;
111  $ilCtrl = $this->ctrl;
112 
113  if ($this->has_write) {
114  $this->tpl->setVariable("VAR_MULTI", "grp_ids[]");
115  $this->tpl->setVariable("VAL_MULTI", $a_set["id"]);
116  }
117 
118  $this->tpl->setVariable("VAR_POS", "grp_order[" . $a_set["id"] . "]");
119  $this->tpl->setVariable("VAL_POS", $a_set["pos"]);
120  $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
121 
122  if ((int) $a_set["type"] === ilObjRepositorySettings::NEW_ITEM_GROUP_TYPE_GROUP) {
123  $this->tpl->setVariable("VAL_ITEMS", $a_set["subitems"]);
124 
125  if ($this->has_write) {
126  $ilCtrl->setParameter($this->parent_obj, "grp_id", $a_set["id"]);
127  $url = $ilCtrl->getLinkTarget($this->parent_obj, "editNewItemGroup");
128  $ilCtrl->setParameter($this->parent_obj, "grp_id", "");
129 
130  $this->tpl->setVariable("URL_EDIT", $url);
131  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
132  }
133  }
134  }
135 }
setData(array $a_data)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
setFormAction(string $a_form_action, bool $a_multipart=false)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
ilLanguage $lng
setId(string $a_val)
global $DIC
Definition: feed.php:28
setExternalSorting(bool $a_val)
__construct(ilObjRepositorySettingsGUI $a_parent_obj, string $a_parent_cmd="", bool $a_has_write=false)
__construct(VocabulariesInterface $vocabularies)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
$url
Definition: ltiregstart.php:35
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setLimit(int $a_limit=0, int $a_default_limit=0)
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)
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
addMultiCommand(string $a_cmd, string $a_text)
setEnableHeader(bool $a_enableheader)
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
ilGlobalTemplateInterface $main_tpl