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