ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 $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(999);
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  {
62  $this->tpl->setCurrentBlock('footer_export_e');
63  $this->tpl->setVariable('TXT_EXPORT_E_ALL',$this->lng->txt('select_all'));
64  $this->tpl->parseCurrentBlock();
65  $this->tpl->setCurrentBlock('footer_export');
66  $this->tpl->setVariable('TXT_EXPORT_ALL',$this->lng->txt('select_all'));
67  $this->tpl->parseCurrentBlock();
68  $this->tpl->setCurrentBlock('footer_omit');
69  $this->tpl->setVariable('TXT_OMIT_ALL',$this->lng->txt('select_all'));
70  $this->tpl->parseCurrentBlock();
71  return true;
72  }
73 
74  for($i = 0; $i < $s['depth']; $i++)
75  {
76  $this->tpl->touchBlock('padding');
77  $this->tpl->touchBlock('end_padding');
78  }
79  $this->tpl->setVariable('TREE_IMG',ilUtil::getImagePath('icon_'.$s['type'].'_s.png'));
80  $this->tpl->setVariable('TREE_ALT_IMG',$this->lng->txt('obj_'.$s['type']));
81  $this->tpl->setVariable('TREE_TITLE',$s['title']);
82 
83 
84  if($s['last_export'])
85  {
86  $this->tpl->setVariable('VAL_LAST_EXPORT',ilDatePresentation::formatDate(new ilDateTime($s['last_export'],IL_CAL_UNIX)));
87  }
88  else
89  {
90  $this->tpl->setVariable('VAL_LAST_EXPORT',$this->lng->txt('no_date'));
91  }
92 
93  if($s['source'])
94  {
95  return true;
96  }
97 
98  // Export existing
99  if($s['perm_export'] and $s['last_export'])
100  {
101  $this->tpl->setCurrentBlock('radio_export_e');
102  $this->tpl->setVariable('TXT_EXPORT_E',$this->lng->txt('export_existing'));
103  $this->tpl->setVariable('NAME_EXPORT_E','cp_options['.$s['ref_id'].'][type]');
104  $this->tpl->setVariable('VALUE_EXPORT_E',ilExportOptions::EXPORT_EXISTING);
105  $this->tpl->setVariable('ID_EXPORT_E',$s['depth'].'_'.$s['type'].'_'.$s['ref_id'].'_export_e');
106  $this->tpl->setVariable('EXPORT_E_CHECKED','checked="checked"');
107  $this->tpl->parseCurrentBlock();
108  }
109  elseif(!$s['perm_export'])
110  {
111  $this->tpl->setCurrentBlock('missing_export_perm');
112  $this->tpl->setVariable('TXT_MISSING_EXPORT_PERM',$this->lng->txt('missing_perm'));
113  $this->tpl->parseCurrentBlock();
114  }
115 
116 
117  // Create new
118  if($s['perm_export'] and $s['export'])
119  {
120  $this->tpl->setCurrentBlock('radio_export');
121  $this->tpl->setVariable('TXT_EXPORT',$this->lng->txt('export'));
122  $this->tpl->setVariable('NAME_EXPORT','cp_options['.$s['ref_id'].'][type]');
123  $this->tpl->setVariable('VALUE_EXPORT',ilExportOptions::EXPORT_BUILD);
124  $this->tpl->setVariable('ID_EXPORT',$s['depth'].'_'.$s['type'].'_'.$s['ref_id'].'_export');
125  if(!$copy or !$perm_copy)
126  {
127  $this->tpl->setVariable('EXPORT_CHECKED','checked="checked"');
128  }
129  $this->tpl->parseCurrentBlock();
130  }
131  elseif($s['export'])
132  {
133  $this->tpl->setCurrentBlock('missing_export_perm');
134  $this->tpl->setVariable('TXT_MISSING_EXPORT_PERM',$this->lng->txt('missing_perm'));
135  $this->tpl->parseCurrentBlock();
136  }
137 
138  // Omit
139  $this->tpl->setCurrentBlock('omit_radio');
140  $this->tpl->setVariable('TXT_OMIT',$this->lng->txt('omit'));
141  $this->tpl->setVariable('NAME_OMIT','cp_options['.$s['ref_id'].'][type]');
142  $this->tpl->setVariable('VALUE_OMIT',ilExportOptions::EXPORT_OMIT);
143  $this->tpl->setVariable('ID_OMIT',$s['depth'].'_'.$s['type'].'_'.$s['ref_id'].'_omit');
144  if((!$s['copy'] or !$s['perm_copy']) and (!$s['link']))
145  {
146  $this->tpl->setVariable('OMIT_CHECKED','checked="checked"');
147  }
148  $this->tpl->parseCurrentBlock();
149 
150 
151  }
152 
158  public function parseContainer($a_source)
159  {
160  global $tree,$objDefinition, $ilAccess;
161 
162  $first = true;
163  foreach($tree->getSubTree($root = $tree->getNodeData($a_source)) as $node)
164  {
165  if($node['type'] == 'rolf')
166  {
167  continue;
168  }
169  if(!$objDefinition->allowExport($node['type']))
170  {
171  #continue;
172  }
173 
174  $r = array();
175 
176  if($last = ilExportFileInfo::lookupLastExport($node['obj_id'], 'xml'))
177  {
178  $r['last_export'] = $last->getCreationDate()->get(IL_CAL_UNIX);
179  }
180  else
181  {
182  $r['last_export'] = 0;
183  }
184 
185  $r['last'] = false;
186  $r['source']= $first;
187  $r['ref_id']= $node['child'];
188  $r['depth'] = $node['depth'] - $root['depth'];
189  $r['type'] = $node['type'];
190  $r['title'] = $node['title'];
191  $r['export'] = $objDefinition->allowExport($node['type']);
192  $r['perm_export'] = $ilAccess->checkAccess('write','',$node['child']);
193 
194  $rows[] = $r;
195 
196  $first = false;
197  }
198 
199  $rows[] = array('last' => true);
200  $this->setData((array) $rows);
201  }
202 
203 }
204 ?>