ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
4 include_once './Services/Table/classes/class.ilTable2GUI.php';
5 include_once './Services/Export/classes/class.ilExportOptions.php';
6 include_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  parent::__construct($a_parent_class, $a_parent_cmd);
36 
37  $this->lng = $lng;
38  $this->lng->loadLanguageModule('export');
39  $this->ctrl = $ilCtrl;
40 
41  $this->setTitle($this->lng->txt('export_select_resources'));
42 
43 
44  $this->addColumn($this->lng->txt('title'), '');
45  $this->addColumn($this->lng->txt('export_last_export'), '');
46  $this->addColumn($this->lng->txt('export_last_export_file'), '');
47  $this->addColumn($this->lng->txt('export_create_new_file'), '');
48  $this->addColumn($this->lng->txt('export_omit_resource'), '');
49 
50  $this->setEnableHeader(true);
51  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
52  $this->setRowTemplate("tpl.export_item_selection_row.html", "Services/Export");
53  $this->setEnableTitle(true);
54  $this->setEnableNumInfo(true);
55  $this->setLimit(10000);
56 
57  $this->setFormName('cmd');
58 
59  $this->addCommandButton('saveItemSelection', $this->lng->txt('export_save_selection'));
60  $this->addCommandButton($a_parent_cmd, $this->lng->txt('cancel'));
61  }
62 
63  public function fillRow($s)
64  {
65  if ($s['last']) {
66  $this->tpl->setCurrentBlock('footer_export_e');
67  $this->tpl->setVariable('TXT_EXPORT_E_ALL', $this->lng->txt('select_all'));
68  $this->tpl->parseCurrentBlock();
69  $this->tpl->setCurrentBlock('footer_export');
70  $this->tpl->setVariable('TXT_EXPORT_ALL', $this->lng->txt('select_all'));
71  $this->tpl->parseCurrentBlock();
72  $this->tpl->setCurrentBlock('footer_omit');
73  $this->tpl->setVariable('TXT_OMIT_ALL', $this->lng->txt('select_all'));
74  $this->tpl->parseCurrentBlock();
75  return true;
76  }
77 
78  for ($i = 0; $i < $s['depth']; $i++) {
79  $this->tpl->touchBlock('padding');
80  $this->tpl->touchBlock('end_padding');
81  }
82  $this->tpl->setVariable('TREE_IMG', ilObject::_getIcon(ilObject::_lookupObjId($s['ref_id']), "tiny", $s['type']));
83  $this->tpl->setVariable('TREE_ALT_IMG', $this->lng->txt('obj_' . $s['type']));
84  $this->tpl->setVariable('TREE_TITLE', $s['title']);
85 
86 
87  if ($s['last_export']) {
88  $this->tpl->setVariable('VAL_LAST_EXPORT', ilDatePresentation::formatDate(new ilDateTime($s['last_export'], IL_CAL_UNIX)));
89  } else {
90  $this->tpl->setVariable('VAL_LAST_EXPORT', $this->lng->txt('no_file'));
91  }
92 
93  if ($s['source']) {
94  return true;
95  }
96 
97  // Export existing
98  if ($s['perm_export'] and $s['last_export']) {
99  $this->tpl->setCurrentBlock('radio_export_e');
100  $this->tpl->setVariable('TXT_EXPORT_E', $this->lng->txt('export_existing'));
101  $this->tpl->setVariable('NAME_EXPORT_E', 'cp_options[' . $s['ref_id'] . '][type]');
102  $this->tpl->setVariable('VALUE_EXPORT_E', ilExportOptions::EXPORT_EXISTING);
103  $this->tpl->setVariable('ID_EXPORT_E', $s['depth'] . '_' . $s['type'] . '_' . $s['ref_id'] . '_export_e');
104  $this->tpl->setVariable('EXPORT_E_CHECKED', 'checked="checked"');
105  $this->tpl->parseCurrentBlock();
106  } elseif (!$s['perm_export']) {
107  $this->tpl->setCurrentBlock('missing_export_perm');
108  $this->tpl->setVariable('TXT_MISSING_EXPORT_PERM', $this->lng->txt('missing_perm'));
109  $this->tpl->parseCurrentBlock();
110  }
111 
112 
113  // Create new
114  if ($s['perm_export'] and $s['export']) {
115  $this->tpl->setCurrentBlock('radio_export');
116  $this->tpl->setVariable('TXT_EXPORT', $this->lng->txt('export'));
117  $this->tpl->setVariable('NAME_EXPORT', 'cp_options[' . $s['ref_id'] . '][type]');
118  $this->tpl->setVariable('VALUE_EXPORT', ilExportOptions::EXPORT_BUILD);
119  $this->tpl->setVariable('ID_EXPORT', $s['depth'] . '_' . $s['type'] . '_' . $s['ref_id'] . '_export');
120  if (!$copy or !$perm_copy) {
121  $this->tpl->setVariable('EXPORT_CHECKED', 'checked="checked"');
122  }
123  $this->tpl->parseCurrentBlock();
124  } elseif ($s['export']) {
125  $this->tpl->setCurrentBlock('missing_export_perm');
126  $this->tpl->setVariable('TXT_MISSING_EXPORT_PERM', $this->lng->txt('missing_perm'));
127  $this->tpl->parseCurrentBlock();
128  }
129 
130  // Omit
131  $this->tpl->setCurrentBlock('omit_radio');
132  $this->tpl->setVariable('TXT_OMIT', $this->lng->txt('omit'));
133  $this->tpl->setVariable('NAME_OMIT', 'cp_options[' . $s['ref_id'] . '][type]');
134  $this->tpl->setVariable('VALUE_OMIT', ilExportOptions::EXPORT_OMIT);
135  $this->tpl->setVariable('ID_OMIT', $s['depth'] . '_' . $s['type'] . '_' . $s['ref_id'] . '_omit');
136  if ((!$s['copy'] or !$s['perm_copy']) and (!$s['link'])) {
137  $this->tpl->setVariable('OMIT_CHECKED', 'checked="checked"');
138  }
139  $this->tpl->parseCurrentBlock();
140  }
141 
147  public function parseContainer($a_source)
148  {
149  global $DIC;
150 
151  $tree = $DIC['tree'];
152  $objDefinition = $DIC['objDefinition'];
153  $ilAccess = $DIC['ilAccess'];
154 
155  $first = true;
156  foreach ($tree->getSubTree($root = $tree->getNodeData($a_source)) as $node) {
157  if ($node['type'] == 'rolf') {
158  continue;
159  }
160  if (!$objDefinition->allowExport($node['type'])) {
161  #continue;
162  }
163  include_once("./Modules/File/classes/class.ilObjFileAccess.php");
164  if ($node['type'] == "file" &&
165  ilObjFileAccess::_isFileHidden($node['title'])) {
166  continue;
167  }
168  $r = array();
169 
170  if ($last = ilExportFileInfo::lookupLastExport($node['obj_id'], 'xml')) {
171  $r['last_export'] = $last->getCreationDate()->get(IL_CAL_UNIX);
172  } else {
173  $r['last_export'] = 0;
174  }
175 
176  $r['last'] = false;
177  $r['source'] = $first;
178  $r['ref_id'] = $node['child'];
179  $r['depth'] = $node['depth'] - $root['depth'];
180  $r['type'] = $node['type'];
181  $r['title'] = $node['title'];
182  $r['export'] = $objDefinition->allowExport($node['type']);
183  $r['perm_export'] = $ilAccess->checkAccess('write', '', $node['child']);
184 
185  $rows[] = $r;
186 
187  $first = false;
188  }
189 
190  $rows[] = array('last' => true);
191  $this->setData((array) $rows);
192  }
193 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
global $DIC
Definition: saml.php:7
setEnableNumInfo($a_val)
Set enable num info.
static _isFileHidden($a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user. ...
$s
Definition: pwgen.php:45
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
__construct($a_parent_class, $a_parent_cmd)
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
$r
Definition: example_031.php:79
Class ilTable2GUI.
static _lookupObjId($a_id)
static lookupLastExport($a_obj_id, $a_type, $a_version='')
Lookup last export.
Date and time handling
$ilUser
Definition: imgupload.php:18
$root
Definition: sabredav.php:45
setRowTemplate($a_template, $a_template_dir="")
Set row template.
$rows
Definition: xhr_table.php:10
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setFormName($a_formname="")
Set Form name.
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.
$i
Definition: disco.tpl.php:19
setEnableHeader($a_enableheader)
Set Enable Header.
setEnableTitle($a_enabletitle)
Set Enable Title.
setLimit($a_limit=0, $a_default_limit=0)