ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilTrashTableGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 protected const TABLE_BASE_ID = 'adm_trash_table';
27
30 private int $ref_id = 0;
31 private array $current_filter = [];
32
33 public function __construct(
34 object $a_parent_obj,
35 string $a_parent_cmd,
36 int $ref_id
37 ) {
38 global $DIC;
39
40 $this->access = $DIC->access();
41 $this->obj_definition = $DIC["objDefinition"];
42 $this->ref_id = $ref_id;
43
44 $this->setId(self::TABLE_BASE_ID);
45 parent::__construct($a_parent_obj, $a_parent_cmd);
46
47 $this->lng->loadLanguageModule('rep');
48 }
49
53 public function init(): void
54 {
55 $this->setTitle(
56 $this->lng->txt('rep_trash_table_title') . ' "' .
58 );
59
60 $this->addColumn('', '', '1', true);
61 $this->addColumn($this->lng->txt('type'), 'type');
62 $this->addColumn($this->lng->txt('title'), 'title');
63 $this->addColumn($this->lng->txt('rep_trash_table_col_deleted_by'), 'deleted_by');
64 $this->addColumn($this->lng->txt('rep_trash_table_col_deleted_on'), 'deleted');
65 $this->addColumn($this->lng->txt('rep_trash_table_col_num_subs'), '');
66
67 $this->setDefaultOrderField('title');
68 $this->setDefaultOrderDirection('asc');
69
70 $this->setExternalSorting(true);
71 $this->setExternalSegmentation(true);
72
73 $this->setEnableHeader(true);
74 $this->enable('sort');
75 $this->setEnableTitle(true);
76 $this->setEnableNumInfo(true);
77 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
78
79 $this->setRowTemplate(
80 'tpl.trash_list_row.html',
81 'components/ILIAS/Repository/Trash'
82 );
83 $this->setSelectAllCheckbox('trash_id');
84
85 $this->addMultiCommand('undelete', $this->lng->txt('btn_undelete_origin_location'));
86 $this->addMultiCommand('restoreToNewLocation', $this->lng->txt('btn_undelete_new_location'));
87 $this->addMultiCommand('confirmRemoveFromSystem', $this->lng->txt('btn_remove_system'));
88
89 $this->initFilter();
90 }
91
92 public function initFilter(): void
93 {
94 $this->setDefaultFilterVisiblity(true);
95 $type = $this->addFilterItemByMetaType(
96 'type',
98 false,
99 $this->lng->txt('type')
100 );
101 $type->setOptions($this->prepareTypeFilterTypes());
102 if ($type->getValue() != '') {
103 $this->current_filter['type'] = $type->getValue();
104 }
105
107 'title',
109 false,
110 $this->lng->txt('title')
111 );
112 if ($title->getValue() != '') {
113 $this->current_filter['title'] = $title->getValue();
114 }
115 $deleted_by = $this->addFilterItemByMetaType(
116 'deleted_by',
118 false,
119 $this->lng->txt('rep_trash_table_col_deleted_by')
120 );
121 $this->current_filter['deleted_by'] = $deleted_by->getValue();
122
123 $deleted = $this->addFilterItemByMetaType(
124 'deleted',
126 false,
127 $this->lng->txt('rep_trash_table_col_deleted_on')
128 );
129 $this->current_filter['deleted'] = $deleted->getValue();
130 }
131
132 public function parse(): void
133 {
135
136 $max_trash_entries = 0;
137
138 $trash_tree_reader = new ilTreeTrashQueries();
139 $items = $trash_tree_reader->getTrashNodeForContainer(
140 $this->ref_id,
141 $this->current_filter,
142 $max_trash_entries,
143 $this->getOrderField(),
144 $this->getOrderDirection(),
145 $this->getLimit(),
146 $this->getOffset()
147 );
148
149 $this->setMaxCount($max_trash_entries);
150
151 $rows = [];
152 foreach ($items as $item) {
153 $row['id'] = $item->getRefId();
154 $row['obj_id'] = $item->getObjId();
155 $row['type'] = $item->getType();
156 $row['title'] = ilUtil::stripSlashes($item->getTitle());
157 $row['description'] = ilUtil::stripSlashes($item->getDescription());
158 $row['deleted_by_id'] = $item->getDeletedBy();
159 $row['deleted_by'] = $this->lng->txt('rep_trash_deleted_by_unknown');
160 if ($login = ilObjUser::_lookupLogin($row['deleted_by_id'])) {
161 $row['deleted_by'] = $login;
162 }
163 $row['deleted'] = $item->getDeleted();
164 $row['num_subs'] = $trash_tree_reader->getNumberOfTrashedNodesForTrashedContainer($item->getRefId());
165
166 $rows[] = $row;
167 }
168
169
170 $this->setData($rows);
171 }
172
173 protected function fillRow(array $a_set): void
174 {
175 $this->tpl->setVariable('ID', $a_set['id']);
176 $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
177 if (trim($a_set['description']) !== '') {
178 $this->tpl->setCurrentBlock('with_desc');
179 $this->tpl->setVariable('VAL_DESC', $a_set['description']);
180 $this->tpl->parseCurrentBlock();
181 }
182
183 $this->tpl->setCurrentBlock('with_path');
184 $path = new ilPathGUI();
185 $path->enableTextOnly(false);
186 $this->tpl->setVariable('PATH', $path->getPath($this->ref_id, $a_set['id']));
187 $this->tpl->parseCurrentBlock();
188
189 $img = ilObject::_getIcon(
190 (int) $a_set['obj_id'],
191 'small',
192 $a_set['type']
193 );
194 if ($img !== '') {
195 $alt = ($this->obj_definition->isPlugin($a_set['type']))
196 ? $this->lng->txt('icon') . ' ' . ilObjectPlugin::lookupTxtById($a_set['type'], 'obj_' . $a_set['type'])
197 : $this->lng->txt('icon') . ' ' . $this->lng->txt('obj_' . $a_set['type'])
198 ;
199 $this->tpl->setVariable('IMG_PATH', $img);
200 $this->tpl->setVariable('IMG_ALT', $alt);
201 }
202
203 $this->tpl->setVariable('VAL_DELETED_BY', $a_set['deleted_by']);
204
205 $dt = new ilDateTime($a_set['deleted'], IL_CAL_DATETIME);
206 $this->tpl->setVariable('VAL_DELETED_ON', ilDatePresentation::formatDate($dt));
207 $this->tpl->setVariable('VAL_SUBS', (string) (int) $a_set['num_subs']);
208 }
209
210 protected function prepareTypeFilterTypes(): array
211 {
212 $trash = new ilTreeTrashQueries();
213 $subs = $trash->getTrashedNodeTypesForContainer($this->ref_id);
214
215
216 $options = [];
217 foreach ($subs as $type) {
218 if ($type === 'rolf') {
219 continue;
220 }
221 if ($type === 'root') {
222 continue;
223 }
224
225 if (!$this->obj_definition->isRBACObject($type)) {
226 continue;
227 }
228 if ($this->obj_definition->isPlugin($type)) {
229 $this->lng->loadLanguageModule('rep_robj_' . $type);
230 $options[$type] = $this->lng->txt('rep_robj_' . $type . '_objs_' . $type);
231 } else {
232 $options[$type] = $this->lng->txt('objs_' . $type);
233 }
234 }
235 asort($options, SORT_LOCALE_STRING);
236 array_unshift($options, $this->lng->txt('select_one'));
237 return $options;
238 }
239}
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