ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilTrashTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Table/classes/class.ilTable2GUI.php");
5require_once('./Services/Repository/classes/class.ilObjectPlugin.php');
6
15{
16 protected const TABLE_BASE_ID = 'adm_trash_table';
17
18 private $logger = null;
19
23 protected $access;
24
28 protected $obj_definition;
29
30
34 private $ref_id = 0;
35
36
40 private $current_filter = [];
41
42
49 public function __construct($a_parent_obj, $a_parent_cmd, int $ref_id)
50 {
51 global $DIC;
52
53 $this->access = $DIC->access();
54 $this->obj_definition = $DIC["objDefinition"];
55 $this->ref_id = $ref_id;
56
57 $this->logger = $DIC->logger()->rep();
58
59 $this->setId(self::TABLE_BASE_ID);
60 parent::__construct($a_parent_obj, $a_parent_cmd);
61
62 $this->lng->loadLanguageModule('rep');
63 }
64
68 public function init()
69 {
70 $this->setTitle(
71 $this->lng->txt('rep_trash_table_title') . ' "' .
72 \ilObject::_lookupTitle(\ilObject::_lookupObjId($this->ref_id)) . '" '
73 );
74
75 $this->addColumn('', '', 1, 1);
76 $this->addColumn($this->lng->txt('type'), 'type');
77 $this->addColumn($this->lng->txt('title'), 'title');
78 $this->addColumn($this->lng->txt('rep_trash_table_col_deleted_by'), 'deleted_by');
79 $this->addColumn($this->lng->txt('rep_trash_table_col_deleted_on'), 'deleted');
80 $this->addColumn($this->lng->txt('rep_trash_table_col_num_subs'), '');
81
82 $this->setDefaultOrderField('title');
83 $this->setDefaultOrderDirection('asc');
84
85 $this->setExternalSorting(true);
86 $this->setExternalSegmentation(true);
87
88 $this->setEnableHeader(true);
89 $this->enable('sort');
90 $this->setEnableTitle(true);
91 $this->setEnableNumInfo(true);
92 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
93
94 $this->setRowTemplate('tpl.trash_list_row.html', 'Services/Repository');
95 $this->setSelectAllCheckbox('trash_id');
96
97 $this->addMultiCommand('undelete', $this->lng->txt('btn_undelete_origin_location'));
98 $this->addMultiCommand('restoreToNewLocation', $this->lng->txt('btn_undelete_new_location'));
99 $this->addMultiCommand('confirmRemoveFromSystem', $this->lng->txt('btn_remove_system'));
100
101 $this->initFilter();
102 }
103
107 public function initFilter()
108 {
109 $this->setDefaultFilterVisiblity(true);
110
111 $type = new \ilMultiSelectInputGUI(
112 $this->lng->txt('type'),
113 'type'
114 );
115
117 'type',
119 false,
120 $this->lng->txt('type')
121 );
122 $type->setOptions($this->prepareTypeFilterTypes());
123 $this->current_filter['type'] = $type->getValue();
124
126 'title',
128 false,
129 $this->lng->txt('title')
130 );
131 $this->current_filter['title'] = $title->getValue();
132
133 $deleted_by = $this->addFilterItemByMetaType(
134 'deleted_by',
136 false,
137 $this->lng->txt('rep_trash_table_col_deleted_by')
138 );
139 $this->current_filter['deleted_by'] = $deleted_by->getValue();
140
141 $deleted = $this->addFilterItemByMetaType(
142 'deleted',
144 false,
145 $this->lng->txt('rep_trash_table_col_deleted_on')
146 );
147 $this->current_filter['deleted'] = $deleted->getValue();
148 }
149
153 public function parse()
154 {
156
157 $max_trash_entries = 0;
158
159 $trash_tree_reader = new \ilTreeTrashQueries();
160 $items = $trash_tree_reader->getTrashNodeForContainer(
161 $this->ref_id,
162 $this->current_filter,
163 $max_trash_entries,
164 $this->getOrderField(),
165 $this->getOrderDirection(),
166 (int) $this->getLimit(),
167 (int) $this->getOffset()
168 );
169
170 $this->setMaxCount($max_trash_entries);
171
172 $rows = [];
173 foreach ($items as $item) {
174 $row['id'] = $item->getRefId();
175 $row['obj_id'] = $item->getObjId();
176 $row['type'] = $item->getType();
177 $row['title'] = $item->getTitle();
178 $row['description'] = $item->getDescription();
179 $row['deleted_by_id'] = $item->getDeletedBy();
180 $row['deleted_by'] = $this->lng->txt('rep_trash_deleted_by_unknown');
181 if ($login = \ilObjUser::_lookupLogin($row['deleted_by_id'])) {
182 $row['deleted_by'] = $login;
183 }
184 $row['deleted'] = $item->getDeleted();
185 $row['num_subs'] = $trash_tree_reader->getNumberOfTrashedNodesForTrashedContainer($item->getRefId());
186
187 $rows[] = $row;
188 }
189
190
191 $this->setData($rows);
192 }
193
197 protected function fillRow($row)
198 {
199 $this->tpl->setVariable('ID', $row['id']);
200 $this->tpl->setVariable('VAL_TITLE', $row['title']);
201 if (strlen(trim($row['description']))) {
202 $this->tpl->setCurrentBlock('with_desc');
203 $this->tpl->setVariable('VAL_DESC', $row['description']);
204 $this->tpl->parseCurrentBlock();
205 }
206
207 $this->tpl->setCurrentBlock('with_path');
208 $path = new ilPathGUI();
209 $path->enableTextOnly(false);
210 $this->tpl->setVariable('PATH', $path->getPath($this->ref_id, $row['id']));
211 $this->tpl->parseCurrentBlock();
212
214 $row['obj_id'],
215 'small',
216 $row['type']
217 );
218 if (strlen($img)) {
219 $alt = ($this->obj_definition->isPlugin($row['type']))
220 ? $this->lng->txt('icon') . ' ' . \ilObjectPlugin::lookupTxtById($row['type'], 'obj_' . $row['type'])
221 : $this->lng->txt('icon') . ' ' . $this->lng->txt('obj_' . $row['type'])
222 ;
223 $this->tpl->setVariable('IMG_PATH', $img);
224 $this->tpl->setVariable('IMG_ALT', $alt);
225 }
226
227 $this->tpl->setVariable('VAL_DELETED_BY', $row['deleted_by']);
228
229 $dt = new \ilDateTime($row['deleted'], IL_CAL_DATETIME);
230 $this->tpl->setVariable('VAL_DELETED_ON', \ilDatePresentation::formatDate($dt));
231 $this->tpl->setVariable('VAL_SUBS', (string) (int) $row['num_subs']);
232 }
233
237 protected function prepareTypeFilterTypes()
238 {
239 $trash = new \ilTreeTrashQueries();
240 $subs = $trash->getTrashedNodeTypesForContainer($this->ref_id);
241
242
243 $options = [];
244 foreach ($subs as $type) {
245 if ($type == 'rolf') {
246 continue;
247 }
248 if ($type == 'root') {
249 continue;
250 }
251
252 if (!$this->obj_definition->isRBACObject($type)) {
253 continue;
254 }
255 $options[$type] = $this->lng->txt('objs_' . $type);
256 }
257 asort($options, SORT_LOCALE_STRING);
258 array_unshift($options, $this->lng->txt('select_one'));
259 return $options;
260 }
261}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static _lookupLogin($a_user_id)
lookup login
static lookupTxtById($plugin_id, $lang_var)
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
Creates a path for a start and endnode.
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable Header.
setExternalSorting($a_val)
Set external sorting.
setDefaultFilterVisiblity($a_status)
Set default filter visiblity.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
setData($a_data)
set table data @access public
setEnableTitle($a_enabletitle)
Set Enable Title.
setEnableNumInfo($a_val)
Set enable num info.
getLimit()
Get limit.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=null)
Add filter by standard type.
getOffset()
Get offset.
setExternalSegmentation($a_val)
Set external segmentation.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
getOrderDirection()
Get order direction.
setMaxCount($a_max_count)
set max.
enable($a_module_name)
enables particular modules of table
TableGUI class for.
fillRow($row)
Standard Version of Fill Row.Most likely to be overwritten by derived class.
__construct($a_parent_obj, $a_parent_cmd, int $ref_id)
ilTrashTableGUI constructor.
$login
Definition: cron.php:13
global $DIC
Definition: goto.php:24
$img
Definition: imgupload.php:57
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
$rows
Definition: xhr_table.php:10