ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAdminSubItemsTableGUI.php
Go to the documentation of this file.
1<?php
2
20
27{
31 protected ilTree $tree;
32 protected bool $editable = false;
33 protected int $ref_id;
35
36 public function __construct(
37 ilObjectGUI $a_parent_obj,
38 string $a_parent_cmd,
39 int $a_ref_id,
40 bool $editable = false
41 ) {
43 global $DIC;
44
45 $this->editable = $editable;
46 $this->ctrl = $DIC->ctrl();
47 $this->lng = $DIC->language();
48 $this->access = $DIC->access();
49 $this->rbacsystem = $DIC->rbac()->system();
50 $this->obj_definition = $DIC["objDefinition"];
51 $this->tree = $DIC->repositoryTree();
52 $ilCtrl = $DIC->ctrl();
53 $lng = $DIC->language();
54 $this->clipboard = $DIC
55 ->repository()
56 ->internal()
57 ->domain()
58 ->clipboard();
59
60 $this->ref_id = $a_ref_id;
61
62 $this->setId('recf_' . $a_ref_id);
63 parent::__construct($a_parent_obj, $a_parent_cmd);
64 $this->setSelectAllCheckbox("id[]");
65
66 $this->addColumn("", "", "1", true);
67 $this->addColumn($this->lng->txt("type"), "", "1");
68 $this->addColumn($this->lng->txt("title"), "title");
69 $this->addColumn($this->lng->txt("last_change"), "last_update", "25%");
70
71 $this->setEnableHeader(true);
72 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
73 $this->setRowTemplate("tpl.admin_sub_items_row.html", "components/ILIAS/Repository");
74 //$this->disable("footer");
75 $this->setEnableTitle(true);
76 $this->setDefaultOrderField("title");
77 $this->setDefaultOrderDirection("asc");
78
79 // TODO: Needs other solution
80 if (ilObject::_lookupType($a_ref_id, true) === 'chac') {
81 $this->getItems();
82 return;
83 }
84
85 if (ilObject::_lookupType($a_ref_id, true) !== "recf") {
86 if ($this->clipboard->hasEntries()) {
87 if ($this->isEditable()) {
88 $this->addCommandButton("paste", $lng->txt("paste"));
89 $this->addCommandButton("clear", $lng->txt("clear"));
90 }
91 } elseif ($this->isEditable()) {
92 $this->addMultiCommand("cut", $lng->txt("cut"));
93 $this->addMultiCommand("delete", $lng->txt("delete"));
94 $this->addMultiCommand("link", $lng->txt("link"));
95 }
96 } elseif ($this->clipboard->hasEntries()) {
97 if ($this->isEditable()) {
98 $this->addCommandButton("clear", $lng->txt("clear"));
99 }
100 } elseif ($this->isEditable()) {
101 $this->addMultiCommand("cut", $lng->txt("cut"));
102 $this->addMultiCommand("removeFromSystem", $lng->txt("btn_remove_system"));
103 }
104 $this->getItems();
105 }
106
107 public function isEditable(): bool
108 {
109 return $this->editable;
110 }
111
112 public function getItems(): void
113 {
115 $objDefinition = $this->obj_definition;
117
118 $items = [];
119 $childs = $tree->getChilds($this->ref_id);
120 foreach ($childs as $key => $val) {
121 // visible
122 if (!$rbacsystem->checkAccess("visible", $val["ref_id"])) {
123 continue;
124 }
125
126 // hide object types in devmode
127 if ($objDefinition->getDevMode($val["type"])) {
128 continue;
129 }
130
131 // don't show administration in root node list
132 if ($val["type"] === "adm") {
133 continue;
134 }
135 if (!$this->parent_obj->isVisible($val["ref_id"], $val["type"])) {
136 continue;
137 }
138 $items[] = $val;
139 }
140 $this->setData($items);
141 }
142
143 protected function fillRow(array $a_set): void
144 {
146 $objDefinition = $this->obj_definition;
147 $ilCtrl = $this->ctrl;
148
149 // surpress checkbox for particular object types AND the system role
150 if (!$objDefinition->hasCheckbox($a_set["type"]) ||
151 (int) $a_set["obj_id"] === SYSTEM_ROLE_ID ||
152 (int) $a_set["obj_id"] === SYSTEM_USER_ID ||
153 (int) $a_set["obj_id"] === ANONYMOUS_ROLE_ID) {
154 $this->tpl->touchBlock("no_checkbox");
155 } else {
156 $this->tpl->setCurrentBlock("checkbox");
157 $this->tpl->setVariable("ID", $a_set["ref_id"]);
158 $this->tpl->parseCurrentBlock();
159 }
160
161 //build link
162 $class_name = $objDefinition->getClassName($a_set["type"]);
163 $class = strtolower("ilObj" . $class_name . "GUI");
164 $ilCtrl->setParameterByClass($class, "ref_id", $a_set["ref_id"]);
165 $this->tpl->setVariable("HREF_TITLE", $ilCtrl->getLinkTargetByClass($class, "view"));
166 $ilCtrl->setParameterByClass($class, "ref_id", $this->ref_id);
167
168 // TODO: broken! fix me
169 $title = $a_set["title"];
170 if ($this->clipboard->hasEntries() && in_array($a_set["ref_id"], $this->clipboard->getRefIds())) {
171 switch ($this->clipboard->getCmd()) {
172 case "cut":
173 $title = "<del>" . $title . "</del>";
174 break;
175
176 case "copy":
177 $title = "<font color=\"green\">+</font> " . $title;
178 break;
179
180 case "link":
181 $title = "<font color=\"black\"><</font> " . $title;
182 break;
183 }
184 }
185 $this->tpl->setVariable("VAL_TITLE", $title);
186 $this->tpl->setVariable("VAL_DESC", ilStr::shortenTextExtended($a_set["desc"], ilObject::DESC_LENGTH, true));
187 $this->tpl->setVariable("VAL_LAST_CHANGE", ilDatePresentation::formatDate(new ilDateTime($a_set["last_update"], IL_CAL_DATETIME)));
188 $alt = ($objDefinition->isPlugin($a_set["type"]))
189 ? $lng->txt("icon") . " " . ilObjectPlugin::lookupTxtById($a_set["type"], "obj_" . $a_set["type"])
190 : $lng->txt("icon") . " " . $lng->txt("obj_" . $a_set["type"]);
191 $this->tpl->setVariable(
192 "IMG_TYPE",
193 ilUtil::img(ilObject::_getIcon((int) $a_set["obj_id"], "small"), $alt, "", "", "", "", "ilIcon")
194 );
195 }
196}
Manages items in repository clipboard.
const IL_CAL_DATETIME
TableGUI class for sub items listed in repository administration.
fillRow(array $a_set)
Standard Version of Fill Row.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
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...
parses the objects.xml it handles the xml-description of all ilias objects
Class ilObjectGUI Basic methods of all Output classes.
static lookupTxtById(string $plugin_id, string $lang_var)
static _lookupType(int $id, bool $reference=false)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
const DESC_LENGTH
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(?object $a_parent_obj, string $a_parent_cmd="", string $a_template_context="")
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)
setDefaultOrderField(string $a_defaultorderfield)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
ilLanguage $lng
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
getChilds(int $a_node_id, string $a_order="", string $a_direction="ASC")
get child nodes of given node
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
const SYSTEM_ROLE_ID
Definition: constants.php:29
const ANONYMOUS_ROLE_ID
Definition: constants.php:28
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
Definition: constants.php:26
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26