ILIAS  release_8 Revision v8.24
class.ilExportSelectionTableGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
26{
27 protected array $post_data;
28
31 protected ilTree $tree;
32
33 public function __construct(object $a_parent_class, string $a_parent_cmd)
34 {
35 global $DIC;
36
37 //TODO PHP8-Review: please check the usage of $_POST
39 $this->post_data = ($DIC->http()->request()->getParsedBody() ?? []);
40
41 $this->tree = $DIC->repositoryTree();
42 $this->objDefinition = $DIC['objDefinition'];
43 $this->access = $DIC->access();
44
45 parent::__construct($a_parent_class, $a_parent_cmd);
46
47 $this->lng->loadLanguageModule('export');
48 $this->setTitle($this->lng->txt('export_select_resources'));
49 $this->addColumn($this->lng->txt('title'), '');
50 $this->addColumn($this->lng->txt('export_last_export'), '');
51 $this->addColumn($this->lng->txt('export_last_export_file'), '');
52 $this->addColumn($this->lng->txt('export_create_new_file'), '');
53 $this->addColumn($this->lng->txt('export_omit_resource'), '');
54
55 $this->setEnableHeader(true);
56 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
57 $this->setRowTemplate("tpl.export_item_selection_row.html", "Services/Export");
58 $this->setEnableTitle(true);
59 $this->setEnableNumInfo(true);
60 $this->setLimit(10000);
61
62 $this->setFormName('cmd');
63
64 $this->addCommandButton('saveItemSelection', $this->lng->txt('export_save_selection'));
65 $this->addCommandButton($a_parent_cmd, $this->lng->txt('cancel'));
66 }
67
68 protected function fillRow(array $a_set): void
69 {
70 $a_set['copy'] = $a_set['copy'] ?? false;
71 $a_set['perm_copy'] = $a_set['perm_copy'] ?? false;
72 $a_set['link'] = $a_set['link'] ?? false;
73 $a_set['perm_export'] = $a_set['perm_export'] ?? false;
74
75 // set selected radio button
76 $selected = '';
77 if ((!$a_set['copy'] or !$a_set['perm_copy']) and (!$a_set['link'])) {
78 $selected = "OMIT";
79 }
80 if ($a_set['perm_export'] and $a_set['last_export']) {
81 $selected = "EXPORT_E";
82 }
83 if (is_array($this->post_data["cp_options"] ?? null)) {
84 if (isset($a_set['ref_id']) && isset($this->post_data["cp_options"][$a_set['ref_id']]["type"])) {
85 switch ($this->post_data["cp_options"][$a_set['ref_id']]["type"]) {
86 case "2":
87 $selected = "EXPORT";
88 break;
89 case "1":
90 $selected = "EXPORT_E";
91 break;
92 }
93 }
94 }
95
96 if ($a_set['last']) {
97 $this->tpl->setCurrentBlock('footer_export_e');
98 $this->tpl->setVariable('TXT_EXPORT_E_ALL', $this->lng->txt('select_all'));
99 $this->tpl->parseCurrentBlock();
100 $this->tpl->setCurrentBlock('footer_export');
101 $this->tpl->setVariable('TXT_EXPORT_ALL', $this->lng->txt('select_all'));
102 $this->tpl->parseCurrentBlock();
103 $this->tpl->setCurrentBlock('footer_omit');
104 $this->tpl->setVariable('TXT_OMIT_ALL', $this->lng->txt('select_all'));
105 $this->tpl->parseCurrentBlock();
106 return;
107 }
108
109 for ($i = 0; $i < $a_set['depth']; $i++) {
110 $this->tpl->touchBlock('padding');
111 $this->tpl->touchBlock('end_padding');
112 }
113 $this->tpl->setVariable(
114 'TREE_IMG',
115 ilObject::_getIcon(ilObject::_lookupObjId((int) ($a_set['ref_id'] ?? 0)), "tiny", $a_set['type'])
116 );
117 $this->tpl->setVariable('TREE_ALT_IMG', $this->lng->txt('obj_' . $a_set['type']));
118 $this->tpl->setVariable('TREE_TITLE', $a_set['title']);
119
120 if ($a_set['last_export']) {
121 $this->tpl->setVariable(
122 'VAL_LAST_EXPORT',
123 ilDatePresentation::formatDate(new ilDateTime($a_set['last_export'], IL_CAL_UNIX))
124 );
125 } else {
126 $this->tpl->setVariable('VAL_LAST_EXPORT', $this->lng->txt('no_file'));
127 }
128
129 if ($a_set['source']) {
130 return;
131 }
132
133 // Export existing
134 if ($a_set['perm_export'] and $a_set['last_export']) {
135 $this->tpl->setCurrentBlock('radio_export_e');
136 $this->tpl->setVariable('TXT_EXPORT_E', $this->lng->txt('export_existing'));
137 $this->tpl->setVariable('NAME_EXPORT_E', 'cp_options[' . ($a_set['ref_id'] ?? 0) . '][type]');
138 $this->tpl->setVariable('VALUE_EXPORT_E', ilExportOptions::EXPORT_EXISTING);
139 $this->tpl->setVariable(
140 'ID_EXPORT_E',
141 $a_set['depth'] . '_' . $a_set['type'] . '_' . ($a_set['ref_id'] ?? 0) . '_export_e'
142 );
143 $this->tpl->setVariable('EXPORT_E_CHECKED', 'checked="checked"');
144 $this->tpl->parseCurrentBlock();
145 } elseif (!$a_set['perm_export']) {
146 $this->tpl->setCurrentBlock('missing_export_perm');
147 $this->tpl->setVariable('TXT_MISSING_EXPORT_PERM', $this->lng->txt('missing_perm'));
148 $this->tpl->parseCurrentBlock();
149 }
150
151 // Create new
152 if ($a_set['perm_export'] and $a_set['export']) {
153 $this->tpl->setCurrentBlock('radio_export');
154 $this->tpl->setVariable('TXT_EXPORT', $this->lng->txt('export'));
155 $this->tpl->setVariable('NAME_EXPORT', 'cp_options[' . ($a_set['ref_id'] ?? 0) . '][type]');
156 $this->tpl->setVariable('VALUE_EXPORT', ilExportOptions::EXPORT_BUILD);
157 $this->tpl->setVariable(
158 'ID_EXPORT',
159 $a_set['depth'] . '_' . $a_set['type'] . '_' . ($a_set['ref_id'] ?? 0) . '_export'
160 );
161 if ($selected == "EXPORT") {
162 $this->tpl->setVariable('EXPORT_CHECKED', 'checked="checked"');
163 }
164 $this->tpl->parseCurrentBlock();
165 } elseif ($a_set['export']) {
166 $this->tpl->setCurrentBlock('missing_export_perm');
167 $this->tpl->setVariable('TXT_MISSING_EXPORT_PERM', $this->lng->txt('missing_perm'));
168 $this->tpl->parseCurrentBlock();
169 }
170
171 // Omit
172 $this->tpl->setCurrentBlock('omit_radio');
173 $this->tpl->setVariable('TXT_OMIT', $this->lng->txt('omit'));
174 $this->tpl->setVariable('NAME_OMIT', 'cp_options[' . ($a_set['ref_id'] ?? 0) . '][type]');
175 $this->tpl->setVariable('VALUE_OMIT', ilExportOptions::EXPORT_OMIT);
176 $this->tpl->setVariable('ID_OMIT', $a_set['depth'] . '_' . $a_set['type'] . '_' . ($a_set['ref_id'] ?? 0) . '_omit');
177 if ($selected == "OMIT") {
178 $this->tpl->setVariable($selected . '_CHECKED', 'checked="checked"');
179 }
180 $this->tpl->parseCurrentBlock();
181 }
182
183 public function parseContainer(int $a_source): void
184 {
185 $first = true;
186 $rows = [];
187 foreach ($this->tree->getSubTree($root = $this->tree->getNodeData($a_source)) as $node) {
188 if ($node['type'] == 'rolf') {
189 continue;
190 }
191 if (!$this->objDefinition->allowExport($node['type'])) {
192 #continue;
193 }
194 if ($node['type'] == "file" &&
195 ilObjFileAccess::_isFileHidden($node['title'])) {
196 continue;
197 }
198 $r = array();
199
200 if ($last = ilExportFileInfo::lookupLastExport((int) $node['obj_id'], 'xml')) {
201 $r['last_export'] = $last->getCreationDate()->get(IL_CAL_UNIX);
202 } else {
203 $r['last_export'] = 0;
204 }
205
206 $r['last'] = false;
207 $r['source'] = $first;
208 $r['ref_id'] = $node['child'];
209 $r['depth'] = $node['depth'] - $root['depth'];
210 $r['type'] = $node['type'];
211 $r['title'] = $node['title'];
212 $r['export'] = $this->objDefinition->allowExport($node['type']);
213 $r['perm_export'] = $this->access->checkAccess('write', '', (int) $node['child']);
214
215 $rows[] = $r;
216
217 $first = false;
218 }
219
220 $rows[] = array('last' => true);
221 $this->setData($rows);
222 }
223}
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
static lookupLastExport(int $a_obj_id, string $a_type, string $a_version='')
Lookup last export.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
fillRow(array $a_set)
Standard Version of Fill Row.
static _isFileHidden(string $a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user.
parses the objects.xml it handles the xml-description of all ilias objects
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupObjId(int $ref_id)
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="")
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setEnableNumInfo(bool $a_val)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setEnableTitle(bool $a_enabletitle)
setFormName(string $a_name="")
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)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setData(array $a_data)
Set table data.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$i
Definition: metadata.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$rows
Definition: xhr_table.php:10