ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTrashTableGUI.php
Go to the documentation of this file.
1<?php
24{
25 protected const TABLE_BASE_ID = 'adm_trash_table';
26
29 private int $ref_id = 0;
30 private array $current_filter = [];
31
32 public function __construct(
33 object $a_parent_obj,
34 string $a_parent_cmd,
35 int $ref_id
36 ) {
37 global $DIC;
38
39 $this->access = $DIC->access();
40 $this->obj_definition = $DIC["objDefinition"];
41 $this->ref_id = $ref_id;
42
43 $this->setId(self::TABLE_BASE_ID);
44 parent::__construct($a_parent_obj, $a_parent_cmd);
45
46 $this->lng->loadLanguageModule('rep');
47 }
48
52 public function init(): void
53 {
54 $this->setTitle(
55 $this->lng->txt('rep_trash_table_title') . ' "' .
57 );
58
59 $this->addColumn('', '', '1', true);
60 $this->addColumn($this->lng->txt('type'), 'type');
61 $this->addColumn($this->lng->txt('title'), 'title');
62 $this->addColumn($this->lng->txt('rep_trash_table_col_deleted_by'), 'deleted_by');
63 $this->addColumn($this->lng->txt('rep_trash_table_col_deleted_on'), 'deleted');
64 $this->addColumn($this->lng->txt('rep_trash_table_col_num_subs'), '');
65
66 $this->setDefaultOrderField('title');
67 $this->setDefaultOrderDirection('asc');
68
69 $this->setExternalSorting(true);
70 $this->setExternalSegmentation(true);
71
72 $this->setEnableHeader(true);
73 $this->enable('sort');
74 $this->setEnableTitle(true);
75 $this->setEnableNumInfo(true);
76 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
77
78 $this->setRowTemplate(
79 'tpl.trash_list_row.html',
80 'components/ILIAS/Repository/Trash'
81 );
82 $this->setSelectAllCheckbox('trash_id');
83
84 $this->addMultiCommand('undelete', $this->lng->txt('btn_undelete_origin_location'));
85 $this->addMultiCommand('restoreToNewLocation', $this->lng->txt('btn_undelete_new_location'));
86 $this->addMultiCommand('confirmRemoveFromSystem', $this->lng->txt('btn_remove_system'));
87
88 $this->initFilter();
89 }
90
91 public function initFilter(): void
92 {
93 $this->setDefaultFilterVisiblity(true);
94 $type = $this->addFilterItemByMetaType(
95 'type',
97 false,
98 $this->lng->txt('type')
99 );
100 $type->setOptions($this->prepareTypeFilterTypes());
101 if ($type->getValue() != '') {
102 $this->current_filter['type'] = $type->getValue();
103 }
104
106 'title',
108 false,
109 $this->lng->txt('title')
110 );
111 if ($title->getValue() != '') {
112 $this->current_filter['title'] = $title->getValue();
113 }
114 $deleted_by = $this->addFilterItemByMetaType(
115 'deleted_by',
117 false,
118 $this->lng->txt('rep_trash_table_col_deleted_by')
119 );
120 $this->current_filter['deleted_by'] = $deleted_by->getValue();
121
122 $deleted = $this->addFilterItemByMetaType(
123 'deleted',
125 false,
126 $this->lng->txt('rep_trash_table_col_deleted_on')
127 );
128 $this->current_filter['deleted'] = $deleted->getValue();
129 }
130
131 public function parse(): void
132 {
134
135 $max_trash_entries = 0;
136
137 $trash_tree_reader = new ilTreeTrashQueries();
138 $items = $trash_tree_reader->getTrashNodeForContainer(
139 $this->ref_id,
140 $this->current_filter,
141 $max_trash_entries,
142 $this->getOrderField(),
143 $this->getOrderDirection(),
144 $this->getLimit(),
145 $this->getOffset()
146 );
147
148 $this->setMaxCount($max_trash_entries);
149
150 $rows = [];
151 foreach ($items as $item) {
152 $row['id'] = $item->getRefId();
153 $row['obj_id'] = $item->getObjId();
154 $row['type'] = $item->getType();
155 $row['title'] = ilUtil::stripSlashes($item->getTitle());
156 $row['description'] = ilUtil::stripSlashes($item->getDescription());
157 $row['deleted_by_id'] = $item->getDeletedBy();
158 $row['deleted_by'] = $this->lng->txt('rep_trash_deleted_by_unknown');
159 if ($login = ilObjUser::_lookupLogin($row['deleted_by_id'])) {
160 $row['deleted_by'] = $login;
161 }
162 $row['deleted'] = $item->getDeleted();
163 $row['num_subs'] = $trash_tree_reader->getNumberOfTrashedNodesForTrashedContainer($item->getRefId());
164
165 $rows[] = $row;
166 }
167
168
169 $this->setData($rows);
170 }
171
172 protected function fillRow(array $a_set): void
173 {
174 $this->tpl->setVariable('ID', $a_set['id']);
175 $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
176 if (trim($a_set['description']) !== '') {
177 $this->tpl->setCurrentBlock('with_desc');
178 $this->tpl->setVariable('VAL_DESC', $a_set['description']);
179 $this->tpl->parseCurrentBlock();
180 }
181
182 $this->tpl->setCurrentBlock('with_path');
183 $path = new ilPathGUI();
184 $path->enableTextOnly(false);
185 $this->tpl->setVariable('PATH', $path->getPath($this->ref_id, $a_set['id']));
186 $this->tpl->parseCurrentBlock();
187
188 $img = ilObject::_getIcon(
189 (int) $a_set['obj_id'],
190 'small',
191 $a_set['type']
192 );
193 if ($img !== '') {
194 $alt = ($this->obj_definition->isPlugin($a_set['type']))
195 ? $this->lng->txt('icon') . ' ' . ilObjectPlugin::lookupTxtById($a_set['type'], 'obj_' . $a_set['type'])
196 : $this->lng->txt('icon') . ' ' . $this->lng->txt('obj_' . $a_set['type'])
197 ;
198 $this->tpl->setVariable('IMG_PATH', $img);
199 $this->tpl->setVariable('IMG_ALT', $alt);
200 }
201
202 $this->tpl->setVariable('VAL_DELETED_BY', $a_set['deleted_by']);
203
204 $dt = new ilDateTime($a_set['deleted'], IL_CAL_DATETIME);
205 $this->tpl->setVariable('VAL_DELETED_ON', ilDatePresentation::formatDate($dt));
206 $this->tpl->setVariable('VAL_SUBS', (string) (int) $a_set['num_subs']);
207 }
208
209 protected function prepareTypeFilterTypes(): array
210 {
211 $trash = new ilTreeTrashQueries();
212 $subs = $trash->getTrashedNodeTypesForContainer($this->ref_id);
213
214
215 $options = [];
216 foreach ($subs as $type) {
217 if ($type === 'rolf') {
218 continue;
219 }
220 if ($type === 'root') {
221 continue;
222 }
223
224 if (!$this->obj_definition->isRBACObject($type)) {
225 continue;
226 }
227 if ($this->obj_definition->isPlugin($type)) {
228 $this->lng->loadLanguageModule('rep_robj_' . $type);
229 $options[$type] = $this->lng->txt('rep_robj_' . $type . '_objs_' . $type);
230 } else {
231 $options[$type] = $this->lng->txt('objs_' . $type);
232 }
233 }
234 asort($options, SORT_LOCALE_STRING);
235 array_unshift($options, $this->lng->txt('select_one'));
236 return $options;
237 }
238}
const IL_CAL_DATETIME
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
static _lookupLogin(int $a_user_id)
parses the objects.xml it handles the xml-description of all ilias objects
static lookupTxtById(string $plugin_id, string $lang_var)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
determineOffsetAndOrder(bool $a_omit_offset=false)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setEnableNumInfo(bool $a_val)
setExternalSegmentation(bool $a_val)
setEnableTitle(bool $a_enabletitle)
addMultiCommand(string $a_cmd, string $a_text)
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
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)
setExternalSorting(bool $a_val)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setDefaultFilterVisiblity(bool $a_status)
setData(array $a_data)
Set table data.
enable(string $a_module_name)
setMaxCount(int $a_max_count)
set max.
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, int $ref_id)
ilAccessHandler $access
fillRow(array $a_set)
Standard Version of Fill Row.
ilObjectDefinition $obj_definition
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
$path
Definition: ltiservices.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26