ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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

 buildExportTableGUI ()
 
 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  }
global $tpl
Definition: ilias.php:8
global $lng
Definition: privfeed.php:17

Member Function Documentation

◆ addCustomColumn()

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

Add custom column.

Parameters

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

References array.

98  {
99  $this->custom_columns[] = array("txt" => $a_txt,
100  "obj" => $a_obj,
101  "func" => $a_func);
102  }
Create styles array
The data for the language used.

◆ addCustomMultiCommand()

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

Add custom multi command.

Parameters

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

References array.

111  {
112  $this->custom_multi_commands[] = array("txt" => $a_txt,
113  "obj" => $a_obj,
114  "func" => $a_func);
115  }
Create styles array
The data for the language used.

◆ addFormat()

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

Add formats.

Parameters
arrayformats

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

References $lng, array, and formats.

70  {
71  global $lng;
72 
73  if ($a_txt == "")
74  {
75  $a_txt = $lng->txt("exp_".$a_key);
76  }
77  $this->formats[] = array("key" => $a_key, "txt" => $a_txt,
78  "call_obj" => $a_call_obj, "call_func" => $a_call_func);
79  }
Create styles array
The data for the language used.
Set cell number formats
global $lng
Definition: privfeed.php:17

◆ buildExportTableGUI()

ilExportGUI::buildExportTableGUI ( )
protected
Returns
ilExportTableGUI

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

Referenced by listExportFiles().

49  {
50  include_once("./Services/Export/classes/class.ilExportTableGUI.php");
51  $table = new ilExportTableGUI($this, "listExportFiles", $this->obj);
52  return $table;
53  }
+ Here is the caller graph for this function:

◆ confirmDeletion()

ilExportGUI::confirmDeletion ( )

Confirm file deletion.

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

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

281  {
282  global $ilCtrl, $tpl, $lng;
283 
284  if (!is_array($_POST["file"]) || count($_POST["file"]) == 0)
285  {
286  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
287  $ilCtrl->redirect($this, "listExportFiles");
288  }
289  else
290  {
291  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
292  $cgui = new ilConfirmationGUI();
293  $cgui->setFormAction($ilCtrl->getFormAction($this));
294  $cgui->setHeaderText($lng->txt("exp_really_delete"));
295  $cgui->setCancel($lng->txt("cancel"), "listExportFiles");
296  $cgui->setConfirm($lng->txt("delete"), "delete");
297 
298  foreach ($_POST["file"] as $i)
299  {
300  if(strpos($i, ':') !== false)
301  {
302  $iarr = explode(":", $i);
303  $filename = $iarr[1];
304  }
305  else
306  {
307  $filename = $i;
308  }
309  $cgui->addItem("file[]", $i, $filename);
310  }
311 
312  $tpl->setContent($cgui->getHTML());
313  }
314  }
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $lng
Definition: privfeed.php:17
$_POST["username"]
Confirmation screen class.
+ Here is the call graph for this function:

◆ createExportFile()

ilExportGUI::createExportFile ( )

Create export file.

Parameters

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

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

Referenced by executeCommand().

241  {
242  global $ilCtrl, $lng;
243 
244  if ($ilCtrl->getCmd() == "createExportFile")
245  {
246  $format = ilUtil::stripSlashes($_POST["format"]);
247  }
248  else
249  {
250  $format = substr($ilCtrl->getCmd(), 7);
251  }
252  foreach ($this->getFormats() as $f)
253  {
254  if ($f["key"] == $format)
255  {
256  if (is_object($f["call_obj"]))
257  {
258  $f["call_obj"]->{$f["call_func"]}();
259  }
260  elseif($this->getParentGUI() instanceof ilContainerGUI)
261  {
262  return $this->showItemSelection();
263  }
264  else if ($format == "xml") // standard procedure
265  {
266  include_once("./Services/Export/classes/class.ilExport.php");
267  $exp = new ilExport();
268  $exp->exportObject($this->obj->getType(),$this->obj->getId());
269  }
270  }
271  }
272 
273  ilUtil::sendSuccess($lng->txt("exp_file_created"), true);
274  $ilCtrl->redirect($this, "listExportFiles");
275  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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:17
Class ilContainerGUI.
$_POST["username"]
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 319 of file class.ilExportGUI.php.

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

320  {
321  global $ilCtrl;
322 
323  foreach($_POST["file"] as $file)
324  {
325  $file = explode(":", $file);
326 
327  $file[1] = basename($file[1]);
328 
329  include_once("./Services/Export/classes/class.ilExport.php");
330  $export_dir = ilExport::_getExportDirectory($this->obj->getId(),
331  str_replace("..", "", $file[0]), $this->obj->getType());
332 
333  $exp_file = $export_dir."/".str_replace("..", "", $file[1]);
334  $exp_dir = $export_dir."/".substr($file[1], 0, strlen($file[1]) - 4);
335  if (@is_file($exp_file))
336  {
337  unlink($exp_file);
338  }
339  if (@is_dir($exp_dir))
340  {
341  ilUtil::delDir($exp_dir);
342  }
343 
344  // delete entry in database
345  include_once './Services/Export/classes/class.ilExportFileInfo.php';
346  $info = new ilExportFileInfo($this->obj->getId(),$file[0],$file[1]);
347  $info->delete();
348  }
349  $ilCtrl->redirect($this, "listExportFiles");
350  }
global $ilCtrl
Definition: ilias.php:18
$info
Definition: example_052.php:80
Stores information of creation date and versions of export files
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
$_POST["username"]
+ Here is the call graph for this function:

◆ download()

ilExportGUI::download ( )

Download file.

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

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

Referenced by ilTestExportGUI\listExportFiles().

356  {
357  global $ilCtrl, $lng;
358 
359  if(!isset($_GET["file"]) ||
360  is_array($_GET["file"]))
361  {
362  $ilCtrl->redirect($this, "listExportFiles");
363  }
364 
365  $file = explode(":", trim($_GET["file"]));
366  include_once("./Services/Export/classes/class.ilExport.php");
367  $export_dir = ilExport::_getExportDirectory($this->obj->getId(),
368  str_replace("..", "", $file[0]), $this->obj->getType());
369 
370  $file[1] = basename($file[1]);
371 
372  ilUtil::deliverFile($export_dir."/".$file[1],
373  $file[1]);
374  }
$_GET["client_id"]
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.
global $lng
Definition: privfeed.php:17
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ 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 142 of file class.ilExportGUI.php.

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

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

◆ getCustomColumns()

ilExportGUI::getCustomColumns ( )

Get custom columns.

Parameters

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

References $custom_columns.

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

132  {
133  return $this->custom_columns;
134  }
+ Here is the caller graph for this function:

◆ getCustomMultiCommands()

ilExportGUI::getCustomMultiCommands ( )

Get custom multi commands.

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

References $custom_multi_commands.

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

121  {
123  }
+ Here is the caller graph for this function:

◆ getFormats()

ilExportGUI::getFormats ( )

Get formats.

Returns
array formats

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

References $formats.

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

87  {
88  return $this->formats;
89  }
+ Here is the caller graph for this function:

◆ getParentGUI()

ilExportGUI::getParentGUI ( )
protected

get parent gui

Returns

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

References $parent_gui.

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

60  {
61  return $this->parent_gui;
62  }
+ Here is the caller graph for this function:

◆ handleCustomMultiCommand()

ilExportGUI::handleCustomMultiCommand ( )

Handle custom multi command.

Parameters

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

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

Referenced by executeCommand().

383  {
384  global $ilCtrl;
385 
386  $cmd = substr($ilCtrl->getCmd(), 6);
387  foreach ($this->getCustomMultiCommands() as $c)
388  {
389  if ($c["func"] == $cmd)
390  {
391  $c["obj"]->{$c["func"]}($_POST["file"]);
392  }
393  }
394  }
$cmd
Definition: sahs_server.php:35
global $ilCtrl
Definition: ilias.php:18
getCustomMultiCommands()
Get custom multi commands.
$_POST["username"]
+ 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 186 of file class.ilExportGUI.php.

References $ilCtrl, $lng, $options, $si, $tpl, buildExportTableGUI(), getCustomColumns(), getCustomMultiCommands(), getFormats(), and ilSubmitButton\getInstance().

187  {
188  global $tpl, $ilToolbar, $ilCtrl, $lng;
189 
190  include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
191  $button = ilSubmitButton::getInstance();
192 
193  // creation buttons
194  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
195  if (count($this->getFormats()) > 1)
196  {
197  // type selection
198  foreach ($this->getFormats() as $f)
199  {
200  $options[$f["key"]] = $f["txt"];
201  }
202  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
203  $si = new ilSelectInputGUI($lng->txt("type"), "format");
204  $si->setOptions($options);
205  $ilToolbar->addInputItem($si, true);
206 
207  $button->setCaption("exp_create_file");
208  $button->setCommand("createExportFile");
209  }
210  else
211  {
212  $format = $this->getFormats();
213  $format = $format[0];
214 
215  $button->setCaption($lng->txt("exp_create_file")." (".$format["txt"].")", false);
216  $button->setCommand("create_".$format["key"]);
217  }
218 
219  $ilToolbar->addButtonInstance($button);
220 
221  $table = $this->buildExportTableGUI();
222  $table->setSelectAllCheckbox("file");
223  foreach ($this->getCustomColumns() as $c)
224  {
225  $table->addCustomColumn($c["txt"], $c["obj"], $c["func"]);
226  }
227  foreach ($this->getCustomMultiCommands() as $c)
228  {
229  $table->addCustomMultiCommand($c["txt"], "multi_".$c["func"]);
230  }
231  $tpl->setContent($table->getHTML());
232  }
This class represents a selection list property in a property form.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
getCustomColumns()
Get custom columns.
if(!is_array($argv)) $options
getFormats()
Get formats.
getCustomMultiCommands()
Get custom multi commands.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ saveItemSelection()

ilExportGUI::saveItemSelection ( )
protected

Save selection of subitems.

Returns

Definition at line 417 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().

418  {
419  global $tree,$objDefinition, $ilAccess, $ilCtrl,$lng;
420 
421  include_once './Services/Export/classes/class.ilExportOptions.php';
423  $eo->addOption(ilExportOptions::KEY_ROOT,0,0,$this->obj->getId());
424 
425  $items_selected = false;
426  foreach($tree->getSubTree($root = $tree->getNodeData($this->getParentGUI()->object->getRefId())) as $node)
427  {
428  if($node['type'] == 'rolf')
429  {
430  continue;
431  }
432  if($node['ref_id'] == $this->getParentGUI()->object->getRefId())
433  {
434  $eo->addOption(
436  $node['ref_id'],
437  $node['obj_id'],
439  );
440  continue;
441  }
442  // no export available or no access
443  if(!$objDefinition->allowExport($node['type']) or !$ilAccess->checkAccess('write','',$node['ref_id']))
444  {
445 
446  $eo->addOption(
448  $node['ref_id'],
449  $node['obj_id'],
451  );
452  continue;
453  }
454 
455  $mode = isset($_POST['cp_options'][$node['ref_id']]['type']) ?
456  $_POST['cp_options'][$node['ref_id']]['type'] :
458  $eo->addOption(
460  $node['ref_id'],
461  $node['obj_id'],
462  $mode
463  );
464  if($mode != ilExportOptions::EXPORT_OMIT)
465  {
466  $items_selected = true;
467  }
468  }
469 
470  include_once("./Services/Export/classes/class.ilExport.php");
471  if($items_selected)
472  {
473  // TODO: move this to background soap
474  $eo->read();
475  $exp = new ilExport();
476  foreach($eo->getSubitemsForCreation($this->obj->getRefId()) as $ref_id)
477  {
478  $obj_id = ilObject::_lookupObjId($ref_id);
479  $type = ilObject::_lookupType($obj_id);
480  $exp->exportObject($type,$obj_id);
481  }
482  // Fixme: there is a naming conflict between the container settings xml and the container subitem xml.
483  sleep(1);
484  // Export container
485  include_once './Services/Export/classes/class.ilExportContainer.php';
486  $cexp = new ilExportContainer($eo);
487  $cexp->exportObject($this->obj->getType(),$this->obj->getId());
488  }
489  else
490  {
491  $exp = new ilExport();
492  $exp->exportObject($this->obj->getType(),$this->obj->getId());
493  }
494 
495  // Delete export options
496  $eo->delete();
497 
498  ilUtil::sendSuccess($lng->txt('export_created'),true);
499  $ilCtrl->redirect($this, "listExportFiles");
500  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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:17
static allocateExportId()
Allocate a new export id.
$_POST["username"]
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 400 of file class.ilExportGUI.php.

References $tpl, getParentGUI(), and object.

Referenced by createExportFile().

401  {
402  global $tpl;
403 
404  $tpl->addJavaScript('./Services/CopyWizard/js/ilContainer.js');
405  $tpl->setVariable('BODY_ATTRIBUTES','onload="ilDisableChilds(\'cmd\');"');
406 
407  include_once './Services/Export/classes/class.ilExportSelectionTableGUI.php';
408  $table = new ilExportSelectionTableGUI($this,'listExportFiles');
409  $table->parseContainer($this->getParentGUI()->object->getRefId());
410  $this->tpl->setContent($table->getHTML());
411  }
global $tpl
Definition: ilias.php:8
Create new PHPExcel object
obj_idprivate
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: