ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilExportGUI Class Reference

Export User Interface Class. More...

+ Inheritance diagram for ilExportGUI:
+ Collaboration diagram for ilExportGUI:

Public Member Functions

 __construct ($a_parent_gui, $a_main_obj=null)
 Constuctor. More...
 
 addFormat ($a_key, $a_txt="", $a_call_obj=null, $a_call_func="")
 Add formats. More...
 
 getFormats ()
 Get formats. More...
 
 addCustomColumn ($a_txt, $a_obj, $a_func)
 Add custom column. More...
 
 addCustomMultiCommand ($a_txt, $a_obj, $a_func)
 Add custom multi command. More...
 
 getCustomMultiCommands ()
 Get custom multi commands. More...
 
 getCustomColumns ()
 Get custom columns. More...
 
 executeCommand ()
 Execute command. More...
 
 listExportFiles ()
 List export files. More...
 
 createExportFile ()
 Create export file. More...
 
 confirmDeletion ()
 Confirm file deletion. More...
 
 delete ()
 Delete files. More...
 
 download ()
 Download file. More...
 
 handleCustomMultiCommand ()
 Handle custom multi command. More...
 

Protected Member Functions

 getParentGUI ()
 get parent gui More...
 
 showItemSelection ()
 Show container item selection table. More...
 
 saveItemSelection ()
 Save selection of subitems. More...
 

Protected Attributes

 $formats = array()
 
 $custom_columns = array()
 
 $custom_multi_commands = array()
 

Private Attributes

 $parent_gui = null
 

Detailed Description

Export User Interface Class.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

ilExportGUI:

Definition at line 14 of file class.ilExportGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilExportGUI::__construct (   $a_parent_gui,
  $a_main_obj = null 
)

Constuctor.

Parameters

Definition at line 28 of file class.ilExportGUI.php.

References $lng, and $tpl.

29  {
30  global $lng,$tpl;
31 
32  $this->parent_gui = $a_parent_gui;
33  if ($a_main_obj == null)
34  {
35  $this->obj = $a_parent_gui->object;
36  }
37  else
38  {
39  $this->obj = $a_main_obj;
40  }
41  $lng->loadLanguageModule("exp");
42  $this->tpl = $tpl;
43  }
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
global $lng
Definition: privfeed.php:40

Member Function Documentation

◆ addCustomColumn()

ilExportGUI::addCustomColumn (   $a_txt,
  $a_obj,
  $a_func 
)

Add custom column.

Parameters

Definition at line 87 of file class.ilExportGUI.php.

88  {
89  $this->custom_columns[] = array("txt" => $a_txt,
90  "obj" => $a_obj,
91  "func" => $a_func);
92  }

◆ addCustomMultiCommand()

ilExportGUI::addCustomMultiCommand (   $a_txt,
  $a_obj,
  $a_func 
)

Add custom multi command.

Parameters

Definition at line 100 of file class.ilExportGUI.php.

101  {
102  $this->custom_multi_commands[] = array("txt" => $a_txt,
103  "obj" => $a_obj,
104  "func" => $a_func);
105  }

◆ addFormat()

ilExportGUI::addFormat (   $a_key,
  $a_txt = "",
  $a_call_obj = null,
  $a_call_func = "" 
)

Add formats.

Parameters
arrayformats

Definition at line 59 of file class.ilExportGUI.php.

References $lng.

60  {
61  global $lng;
62 
63  if ($a_txt == "")
64  {
65  $a_txt = $lng->txt("exp_".$a_key);
66  }
67  $this->formats[] = array("key" => $a_key, "txt" => $a_txt,
68  "call_obj" => $a_call_obj, "call_func" => $a_call_func);
69  }
global $lng
Definition: privfeed.php:40

◆ confirmDeletion()

ilExportGUI::confirmDeletion ( )

Confirm file deletion.

Definition at line 262 of file class.ilExportGUI.php.

References $_POST, $filename, $ilCtrl, $lng, $tpl, and ilUtil\sendInfo().

263  {
264  global $ilCtrl, $tpl, $lng;
265 
266  if (!is_array($_POST["file"]) || count($_POST["file"]) == 0)
267  {
268  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
269  $ilCtrl->redirect($this, "listExportFiles");
270  }
271  else
272  {
273  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
274  $cgui = new ilConfirmationGUI();
275  $cgui->setFormAction($ilCtrl->getFormAction($this));
276  $cgui->setHeaderText($lng->txt("exp_really_delete"));
277  $cgui->setCancel($lng->txt("cancel"), "listExportFiles");
278  $cgui->setConfirm($lng->txt("delete"), "delete");
279 
280  foreach ($_POST["file"] as $i)
281  {
282  if(strpos($i, ':') !== false)
283  {
284  $iarr = explode(":", $i);
285  $filename = $iarr[1];
286  }
287  else
288  {
289  $filename = $i;
290  }
291  $cgui->addItem("file[]", $i, $filename);
292  }
293 
294  $tpl->setContent($cgui->getHTML());
295  }
296  }
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
$filename
Definition: buildRTE.php:89
global $lng
Definition: privfeed.php:40
Confirmation screen class.
+ Here is the call graph for this function:

◆ createExportFile()

ilExportGUI::createExportFile ( )

Create export file.

Parameters

Definition at line 222 of file class.ilExportGUI.php.

References $_POST, $ilCtrl, $lng, getFormats(), getParentGUI(), ilUtil\sendSuccess(), showItemSelection(), and ilUtil\stripSlashes().

Referenced by executeCommand().

223  {
224  global $ilCtrl, $lng;
225 
226  if ($ilCtrl->getCmd() == "createExportFile")
227  {
228  $format = ilUtil::stripSlashes($_POST["format"]);
229  }
230  else
231  {
232  $format = substr($ilCtrl->getCmd(), 7);
233  }
234  foreach ($this->getFormats() as $f)
235  {
236  if ($f["key"] == $format)
237  {
238  if (is_object($f["call_obj"]))
239  {
240  $f["call_obj"]->$f["call_func"]();
241  }
242  elseif($this->getParentGUI() instanceof ilContainerGUI)
243  {
244  return $this->showItemSelection();
245  }
246  else if ($format == "xml") // standard procedure
247  {
248  include_once("./Services/Export/classes/class.ilExport.php");
249  $exp = new ilExport();
250  $exp->exportObject($this->obj->getType(),$this->obj->getId(), "4.4.0");
251  }
252  }
253  }
254 
255  ilUtil::sendSuccess($lng->txt("exp_file_created"), true);
256  $ilCtrl->redirect($this, "listExportFiles");
257  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_POST['username']
Definition: cron.php:12
showItemSelection()
Show container item selection table.
global $ilCtrl
Definition: ilias.php:18
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getFormats()
Get formats.
global $lng
Definition: privfeed.php:40
Class ilContainerGUI.
getParentGUI()
get parent gui
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilExportGUI::delete ( )

Delete files.

Definition at line 301 of file class.ilExportGUI.php.

References $_POST, $file, $ilCtrl, ilExport\_getExportDirectory(), ilUtil\delDir(), and ilExportFileInfo\delete().

302  {
303  global $ilCtrl;
304 
305  foreach($_POST["file"] as $file)
306  {
307  $file = explode(":", $file);
308 
309  $file[1] = basename($file[1]);
310 
311  include_once("./Services/Export/classes/class.ilExport.php");
312  $export_dir = ilExport::_getExportDirectory($this->obj->getId(),
313  str_replace("..", "", $file[0]), $this->obj->getType());
314 
315  $exp_file = $export_dir."/".str_replace("..", "", $file[1]);
316  $exp_dir = $export_dir."/".substr($file[1], 0, strlen($file[1]) - 4);
317  if (@is_file($exp_file))
318  {
319  unlink($exp_file);
320  }
321  if (@is_dir($exp_dir))
322  {
323  ilUtil::delDir($exp_dir);
324  }
325 
326  // delete entry in database
327  include_once './Services/Export/classes/class.ilExportFileInfo.php';
328  $info = new ilExportFileInfo($this->obj->getId(),$file[0],$file[1]);
329  $info->delete();
330  }
331  $ilCtrl->redirect($this, "listExportFiles");
332  }
print $file
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
Stores information of creation date and versions of export files
delete()
Delete one export entry.
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ download()

ilExportGUI::download ( )

Download file.

Definition at line 337 of file class.ilExportGUI.php.

References $_POST, $file, $ilCtrl, $lng, ilExport\_getExportDirectory(), ilUtil\deliverFile(), and ilUtil\sendFailure().

Referenced by ilTestExportGUI\listExportFiles().

338  {
339  global $ilCtrl, $lng;
340 
341  if(!isset($_POST["file"]))
342  {
343  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
344  $ilCtrl->redirect($this, "listExportFiles");
345  }
346 
347  if (count($_POST["file"]) > 1)
348  {
349  ilUtil::sendFailure($lng->txt("exp_select_max_one_item"), true);
350  $ilCtrl->redirect($this, "listExportFiles");
351  }
352 
353  $file = explode(":", $_POST["file"][0]);
354  include_once("./Services/Export/classes/class.ilExport.php");
355  $export_dir = ilExport::_getExportDirectory($this->obj->getId(),
356  str_replace("..", "", $file[0]), $this->obj->getType());
357 
358  $file[1] = basename($file[1]);
359 
360  ilUtil::deliverFile($export_dir."/".$file[1],
361  $file[1]);
362  }
print $file
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:40
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilExportGUI::executeCommand ( )

Execute command.

Parameters

Definition at line 132 of file class.ilExportGUI.php.

References $cmd, $ilCtrl, $ilErr, $lng, createExportFile(), and handleCustomMultiCommand().

133  {
134  global $ilCtrl, $ilAccess, $ilErr, $lng;
135 
136  // this should work (at least) for repository objects
137  if(method_exists($this->obj, 'getRefId') and $this->obj->getRefId())
138  {
139  if(!$ilAccess->checkAccess('write','',$this->obj->getRefId()))
140  {
141  $ilErr->raiseError($lng->txt('permission_denied'),$ilErr->WARNING);
142  }
143  }
144 
145  $cmd = $ilCtrl->getCmd("listExportFiles");
146 
147  switch ($cmd)
148  {
149  case "listExportFiles":
150  $this->$cmd();
151  break;
152 
153  default:
154  if (substr($cmd, 0, 7) == "create_")
155  {
156  $this->createExportFile();
157  }
158  else if (substr($cmd, 0, 6) == "multi_") // custom multi command
159  {
160  $this->handleCustomMultiCommand();
161  }
162  else
163  {
164  $this->$cmd();
165  }
166  break;
167  }
168  }
$cmd
Definition: sahs_server.php:35
handleCustomMultiCommand()
Handle custom multi command.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
createExportFile()
Create export file.
+ Here is the call graph for this function:

◆ getCustomColumns()

ilExportGUI::getCustomColumns ( )

Get custom columns.

Parameters

Definition at line 121 of file class.ilExportGUI.php.

References $custom_columns.

Referenced by ilTestExportGUI\listExportFiles(), and listExportFiles().

122  {
123  return $this->custom_columns;
124  }
+ Here is the caller graph for this function:

◆ getCustomMultiCommands()

ilExportGUI::getCustomMultiCommands ( )

Get custom multi commands.

Definition at line 110 of file class.ilExportGUI.php.

References $custom_multi_commands.

Referenced by handleCustomMultiCommand(), ilTestExportGUI\listExportFiles(), and listExportFiles().

111  {
113  }
+ Here is the caller graph for this function:

◆ getFormats()

ilExportGUI::getFormats ( )

Get formats.

Returns
array formats

Definition at line 76 of file class.ilExportGUI.php.

References $formats.

Referenced by createExportFile(), ilTestExportGUI\listExportFiles(), and listExportFiles().

77  {
78  return $this->formats;
79  }
+ Here is the caller graph for this function:

◆ getParentGUI()

ilExportGUI::getParentGUI ( )
protected

get parent gui

Returns

Definition at line 49 of file class.ilExportGUI.php.

References $parent_gui.

Referenced by createExportFile(), ilTestExportGUI\listExportFiles(), saveItemSelection(), and showItemSelection().

50  {
51  return $this->parent_gui;
52  }
+ Here is the caller graph for this function:

◆ handleCustomMultiCommand()

ilExportGUI::handleCustomMultiCommand ( )

Handle custom multi command.

Parameters

Definition at line 370 of file class.ilExportGUI.php.

References $_POST, $cmd, $ilCtrl, and getCustomMultiCommands().

Referenced by executeCommand().

371  {
372  global $ilCtrl;
373 
374  $cmd = substr($ilCtrl->getCmd(), 6);
375  foreach ($this->getCustomMultiCommands() as $c)
376  {
377  if ($c["func"] == $cmd)
378  {
379  $c["obj"]->$c["func"]($_POST["file"]);
380  }
381  }
382  }
$_POST['username']
Definition: cron.php:12
$cmd
Definition: sahs_server.php:35
global $ilCtrl
Definition: ilias.php:18
getCustomMultiCommands()
Get custom multi commands.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listExportFiles()

ilExportGUI::listExportFiles ( )

List export files.

Parameters

Definition at line 176 of file class.ilExportGUI.php.

References $ilCtrl, $lng, $options, $si, $tpl, getCustomColumns(), getCustomMultiCommands(), and getFormats().

177  {
178  global $tpl, $ilToolbar, $ilCtrl, $lng;
179 
180  // creation buttons
181  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
182  if (count($this->getFormats()) > 1)
183  {
184  // type selection
185  foreach ($this->getFormats() as $f)
186  {
187  $options[$f["key"]] = $f["txt"];
188  }
189  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
190  $si = new ilSelectInputGUI($lng->txt("type"), "format");
191  $si->setOptions($options);
192  $ilToolbar->addInputItem($si, true);
193  $ilToolbar->addFormButton($lng->txt("exp_create_file"), "createExportFile");
194  }
195  else
196  {
197  $format = $this->getFormats();
198  $format = $format[0];
199  $ilToolbar->addFormButton($lng->txt("exp_create_file")." (".$format["txt"].")", "create_".$format["key"]);
200  }
201 
202  include_once("./Services/Export/classes/class.ilExportTableGUI.php");
203  $table = new ilExportTableGUI($this, "listExportFiles", $this->obj);
204  $table->setSelectAllCheckbox("file");
205  foreach ($this->getCustomColumns() as $c)
206  {
207  $table->addCustomColumn($c["txt"], $c["obj"], $c["func"]);
208  }
209  foreach ($this->getCustomMultiCommands() as $c)
210  {
211  $table->addCustomMultiCommand($c["txt"], "multi_".$c["func"]);
212  }
213  $tpl->setContent($table->getHTML());
214  }
This class represents a selection list property in a property form.
global $ilCtrl
Definition: ilias.php:18
getCustomColumns()
Get custom columns.
if(!is_array($argv)) $options
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
getFormats()
Get formats.
getCustomMultiCommands()
Get custom multi commands.
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ saveItemSelection()

ilExportGUI::saveItemSelection ( )
protected

Save selection of subitems.

Returns

Definition at line 405 of file class.ilExportGUI.php.

References $_POST, $ilCtrl, $lng, $ref_id, ilObject\_lookupObjId(), ilObject\_lookupType(), ilExportOptions\allocateExportId(), ilExportOptions\EXPORT_BUILD, ilExportOptions\EXPORT_OMIT, getParentGUI(), ilExportOptions\KEY_ITEM_MODE, ilExportOptions\KEY_ROOT, ilExportOptions\newInstance(), and ilUtil\sendSuccess().

406  {
407  global $tree,$objDefinition, $ilAccess, $ilCtrl,$lng;
408 
409  include_once './Services/Export/classes/class.ilExportOptions.php';
411  $eo->addOption(ilExportOptions::KEY_ROOT,0,0,$this->obj->getId());
412 
413  $items_selected = false;
414  foreach($tree->getSubTree($root = $tree->getNodeData($this->getParentGUI()->object->getRefId())) as $node)
415  {
416  if($node['type'] == 'rolf')
417  {
418  continue;
419  }
420  if($node['ref_id'] == $this->getParentGUI()->object->getRefId())
421  {
422  $eo->addOption(
424  $node['ref_id'],
425  $node['obj_id'],
427  );
428  continue;
429  }
430  // no export available or no access
431  if(!$objDefinition->allowExport($node['type']) or !$ilAccess->checkAccess('write','',$node['ref_id']))
432  {
433 
434  $eo->addOption(
436  $node['ref_id'],
437  $node['obj_id'],
439  );
440  continue;
441  }
442 
443  $mode = isset($_POST['cp_options'][$node['ref_id']]['type']) ?
444  $_POST['cp_options'][$node['ref_id']]['type'] :
446  $eo->addOption(
448  $node['ref_id'],
449  $node['obj_id'],
450  $mode
451  );
452  if($mode != ilExportOptions::EXPORT_OMIT)
453  {
454  $items_selected = true;
455  }
456  }
457 
458  include_once("./Services/Export/classes/class.ilExport.php");
459  if($items_selected)
460  {
461  // TODO: move this to background soap
462  $eo->read();
463  $exp = new ilExport();
464  foreach($eo->getSubitemsForCreation($this->obj->getRefId()) as $ref_id)
465  {
466  $obj_id = ilObject::_lookupObjId($ref_id);
467  $type = ilObject::_lookupType($obj_id);
468  $exp->exportObject($type,$obj_id,'4.1.0');
469  }
470  // Fixme: there is a naming conflict between the container settings xml and the container subitem xml.
471  sleep(1);
472  // Export container
473  include_once './Services/Export/classes/class.ilExportContainer.php';
474  $cexp = new ilExportContainer($eo);
475  $cexp->exportObject($this->obj->getType(),$this->obj->getId(),'4.1.0');
476  }
477  else
478  {
479  $exp = new ilExport();
480  $exp->exportObject($this->obj->getType(),$this->obj->getId(), "4.1.0");
481  }
482 
483  // Delete export options
484  $eo->delete();
485 
486  ilUtil::sendSuccess($lng->txt('export_created'),true);
487  $ilCtrl->redirect($this, "listExportFiles");
488  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
static newInstance($a_export_id)
Create new instance.
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
$ref_id
Definition: sahs_server.php:39
global $lng
Definition: privfeed.php:40
static allocateExportId()
Allocate a new export id.
getParentGUI()
get parent gui
+ Here is the call graph for this function:

◆ showItemSelection()

ilExportGUI::showItemSelection ( )
protected

Show container item selection table.

Returns

Definition at line 388 of file class.ilExportGUI.php.

References $tpl, and getParentGUI().

Referenced by createExportFile().

389  {
390  global $tpl;
391 
392  $tpl->addJavaScript('./Services/CopyWizard/js/ilContainer.js');
393  $tpl->setVariable('BODY_ATTRIBUTES','onload="ilDisableChilds(\'cmd\');"');
394 
395  include_once './Services/Export/classes/class.ilExportSelectionTableGUI.php';
396  $table = new ilExportSelectionTableGUI($this,'listExportFiles');
397  $table->parseContainer($this->getParentGUI()->object->getRefId());
398  $this->tpl->setContent($table->getHTML());
399  }
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
getParentGUI()
get parent gui
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $custom_columns

ilExportGUI::$custom_columns = array()
protected

Definition at line 17 of file class.ilExportGUI.php.

Referenced by getCustomColumns().

◆ $custom_multi_commands

ilExportGUI::$custom_multi_commands = array()
protected

Definition at line 18 of file class.ilExportGUI.php.

Referenced by getCustomMultiCommands().

◆ $formats

ilExportGUI::$formats = array()
protected

Definition at line 16 of file class.ilExportGUI.php.

Referenced by getFormats().

◆ $parent_gui

ilExportGUI::$parent_gui = null
private

Definition at line 20 of file class.ilExportGUI.php.

Referenced by getParentGUI().


The documentation for this class was generated from the following file: