ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $lng,$ilCtrl,$ilUser,$objDefinition;
29
30 parent::__construct($a_parent_class, $a_parent_cmd);
31
32 $this->lng = $lng;
33 $this->lng->loadLanguageModule('export');
34 $this->ctrl = $ilCtrl;
35
36 $this->setTitle($this->lng->txt('export_select_resources'));
37
38
39 $this->addColumn($this->lng->txt('title'), '');
40 $this->addColumn($this->lng->txt('export_last_export'), '');
41 $this->addColumn($this->lng->txt('export_last_export_file'), '');
42 $this->addColumn($this->lng->txt('export_create_new_file'), '');
43 $this->addColumn($this->lng->txt('export_omit_resource'), '');
44
45 $this->setEnableHeader(true);
46 $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
47 $this->setRowTemplate("tpl.export_item_selection_row.html", "Services/Export");
48 $this->setEnableTitle(true);
49 $this->setEnableNumInfo(true);
50 $this->setLimit(10000);
51
52 $this->setFormName('cmd');
53
54 $this->addCommandButton('saveItemSelection', $this->lng->txt('export_save_selection'));
55 $this->addCommandButton($a_parent_cmd, $this->lng->txt('cancel'));
56 }
57
58 public function fillRow($s)
59 {
60 if ($s['last']) {
61 $this->tpl->setCurrentBlock('footer_export_e');
62 $this->tpl->setVariable('TXT_EXPORT_E_ALL', $this->lng->txt('select_all'));
63 $this->tpl->parseCurrentBlock();
64 $this->tpl->setCurrentBlock('footer_export');
65 $this->tpl->setVariable('TXT_EXPORT_ALL', $this->lng->txt('select_all'));
66 $this->tpl->parseCurrentBlock();
67 $this->tpl->setCurrentBlock('footer_omit');
68 $this->tpl->setVariable('TXT_OMIT_ALL', $this->lng->txt('select_all'));
69 $this->tpl->parseCurrentBlock();
70 return true;
71 }
72
73 for ($i = 0; $i < $s['depth']; $i++) {
74 $this->tpl->touchBlock('padding');
75 $this->tpl->touchBlock('end_padding');
76 }
77 $this->tpl->setVariable('TREE_IMG', ilObject::_getIcon(ilObject::_lookupObjId($s['ref_id']), "tiny", $s['type']));
78 $this->tpl->setVariable('TREE_ALT_IMG', $this->lng->txt('obj_' . $s['type']));
79 $this->tpl->setVariable('TREE_TITLE', $s['title']);
80
81
82 if ($s['last_export']) {
83 $this->tpl->setVariable('VAL_LAST_EXPORT', ilDatePresentation::formatDate(new ilDateTime($s['last_export'], IL_CAL_UNIX)));
84 } else {
85 $this->tpl->setVariable('VAL_LAST_EXPORT', $this->lng->txt('no_file'));
86 }
87
88 if ($s['source']) {
89 return true;
90 }
91
92 // Export existing
93 if ($s['perm_export'] and $s['last_export']) {
94 $this->tpl->setCurrentBlock('radio_export_e');
95 $this->tpl->setVariable('TXT_EXPORT_E', $this->lng->txt('export_existing'));
96 $this->tpl->setVariable('NAME_EXPORT_E', 'cp_options[' . $s['ref_id'] . '][type]');
97 $this->tpl->setVariable('VALUE_EXPORT_E', ilExportOptions::EXPORT_EXISTING);
98 $this->tpl->setVariable('ID_EXPORT_E', $s['depth'] . '_' . $s['type'] . '_' . $s['ref_id'] . '_export_e');
99 $this->tpl->setVariable('EXPORT_E_CHECKED', 'checked="checked"');
100 $this->tpl->parseCurrentBlock();
101 } elseif (!$s['perm_export']) {
102 $this->tpl->setCurrentBlock('missing_export_perm');
103 $this->tpl->setVariable('TXT_MISSING_EXPORT_PERM', $this->lng->txt('missing_perm'));
104 $this->tpl->parseCurrentBlock();
105 }
106
107
108 // Create new
109 if ($s['perm_export'] and $s['export']) {
110 $this->tpl->setCurrentBlock('radio_export');
111 $this->tpl->setVariable('TXT_EXPORT', $this->lng->txt('export'));
112 $this->tpl->setVariable('NAME_EXPORT', 'cp_options[' . $s['ref_id'] . '][type]');
113 $this->tpl->setVariable('VALUE_EXPORT', ilExportOptions::EXPORT_BUILD);
114 $this->tpl->setVariable('ID_EXPORT', $s['depth'] . '_' . $s['type'] . '_' . $s['ref_id'] . '_export');
115 if (!$copy or !$perm_copy) {
116 $this->tpl->setVariable('EXPORT_CHECKED', 'checked="checked"');
117 }
118 $this->tpl->parseCurrentBlock();
119 } elseif ($s['export']) {
120 $this->tpl->setCurrentBlock('missing_export_perm');
121 $this->tpl->setVariable('TXT_MISSING_EXPORT_PERM', $this->lng->txt('missing_perm'));
122 $this->tpl->parseCurrentBlock();
123 }
124
125 // Omit
126 $this->tpl->setCurrentBlock('omit_radio');
127 $this->tpl->setVariable('TXT_OMIT', $this->lng->txt('omit'));
128 $this->tpl->setVariable('NAME_OMIT', 'cp_options[' . $s['ref_id'] . '][type]');
129 $this->tpl->setVariable('VALUE_OMIT', ilExportOptions::EXPORT_OMIT);
130 $this->tpl->setVariable('ID_OMIT', $s['depth'] . '_' . $s['type'] . '_' . $s['ref_id'] . '_omit');
131 if ((!$s['copy'] or !$s['perm_copy']) and (!$s['link'])) {
132 $this->tpl->setVariable('OMIT_CHECKED', 'checked="checked"');
133 }
134 $this->tpl->parseCurrentBlock();
135 }
136
142 public function parseContainer($a_source)
143 {
144 global $tree,$objDefinition, $ilAccess;
145
146 $first = true;
147 foreach ($tree->getSubTree($root = $tree->getNodeData($a_source)) as $node) {
148 if ($node['type'] == 'rolf') {
149 continue;
150 }
151 if (!$objDefinition->allowExport($node['type'])) {
152 #continue;
153 }
154 include_once("./Modules/File/classes/class.ilObjFileAccess.php");
155 if ($node['type'] == "file" &&
156 ilObjFileAccess::_isFileHidden($node['title'])) {
157 continue;
158 }
159 $r = array();
160
161 if ($last = ilExportFileInfo::lookupLastExport($node['obj_id'], 'xml')) {
162 $r['last_export'] = $last->getCreationDate()->get(IL_CAL_UNIX);
163 } else {
164 $r['last_export'] = 0;
165 }
166
167 $r['last'] = false;
168 $r['source']= $first;
169 $r['ref_id']= $node['child'];
170 $r['depth'] = $node['depth'] - $root['depth'];
171 $r['type'] = $node['type'];
172 $r['title'] = $node['title'];
173 $r['export'] = $objDefinition->allowExport($node['type']);
174 $r['perm_export'] = $ilAccess->checkAccess('write', '', $node['child']);
175
176 $rows[] = $r;
177
178 $first = false;
179 }
180
181 $rows[] = array('last' => true);
182 $this->setData((array) $rows);
183 }
184}
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)
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.
$i
Definition: disco.tpl.php:19
$r
Definition: example_031.php:79
global $ilCtrl
Definition: ilias.php:18
$s
Definition: pwgen.php:45
$ilUser
Definition: imgupload.php:18
$rows
Definition: xhr_table.php:10