ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  $this->obj = $a_parent_gui->object;
35  } else {
36  $this->obj = $a_main_obj;
37  }
38  $lng->loadLanguageModule("exp");
39  $this->tpl = $tpl;
40  }
$tpl
Definition: ilias.php:10
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 93 of file class.ilExportGUI.php.

References array.

94  {
95  $this->custom_columns[] = array("txt" => $a_txt,
96  "obj" => $a_obj,
97  "func" => $a_func);
98  }
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 106 of file class.ilExportGUI.php.

References array.

107  {
108  $this->custom_multi_commands[] = array("txt" => $a_txt,
109  "obj" => $a_obj,
110  "func" => $a_func);
111  }
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 66 of file class.ilExportGUI.php.

References $lng, array, and formats.

67  {
68  global $lng;
69 
70  if ($a_txt == "") {
71  $a_txt = $lng->txt("exp_" . $a_key);
72  }
73  $this->formats[] = array("key" => $a_key, "txt" => $a_txt,
74  "call_obj" => $a_call_obj, "call_func" => $a_call_func);
75  }
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 45 of file class.ilExportGUI.php.

References $table.

Referenced by listExportFiles().

46  {
47  include_once("./Services/Export/classes/class.ilExportTableGUI.php");
48  $table = new ilExportTableGUI($this, "listExportFiles", $this->obj);
49  return $table;
50  }
if(empty($password)) $table
Definition: pwgen.php:24
+ Here is the caller graph for this function:

◆ confirmDeletion()

ilExportGUI::confirmDeletion ( )

Confirm file deletion.

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

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

253  {
254  global $ilCtrl, $tpl, $lng;
255 
256  if (!is_array($_POST["file"]) || count($_POST["file"]) == 0) {
257  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
258  $ilCtrl->redirect($this, "listExportFiles");
259  } else {
260  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
261  $cgui = new ilConfirmationGUI();
262  $cgui->setFormAction($ilCtrl->getFormAction($this));
263  $cgui->setHeaderText($lng->txt("exp_really_delete"));
264  $cgui->setCancel($lng->txt("cancel"), "listExportFiles");
265  $cgui->setConfirm($lng->txt("delete"), "delete");
266 
267  foreach ($_POST["file"] as $i) {
268  if (strpos($i, ':') !== false) {
269  $iarr = explode(":", $i);
270  $filename = $iarr[1];
271  } else {
272  $filename = $i;
273  }
274  $cgui->addItem("file[]", $i, $filename);
275  }
276 
277  $tpl->setContent($cgui->getHTML());
278  }
279  }
$tpl
Definition: ilias.php:10
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $lng
Definition: privfeed.php:17
$i
Definition: disco.tpl.php:19
$_POST["username"]
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, $format, $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  $format = ilUtil::stripSlashes($_POST["format"]);
228  } else {
229  $format = substr($ilCtrl->getCmd(), 7);
230  }
231  foreach ($this->getFormats() as $f) {
232  if ($f["key"] == $format) {
233  if (is_object($f["call_obj"])) {
234  $f["call_obj"]->{$f["call_func"]}();
235  } elseif ($this->getParentGUI() instanceof ilContainerGUI) {
236  return $this->showItemSelection();
237  } elseif ($format == "xml") { // standard procedure
238  include_once("./Services/Export/classes/class.ilExport.php");
239  $exp = new ilExport();
240  $exp->exportObject($this->obj->getType(), $this->obj->getId());
241  }
242  }
243  }
244 
245  ilUtil::sendSuccess($lng->txt("exp_file_created"), true);
246  $ilCtrl->redirect($this, "listExportFiles");
247  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$format
Definition: metadata.php:141
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 284 of file class.ilExportGUI.php.

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

285  {
286  global $ilCtrl;
287 
288  foreach ($_POST["file"] as $file) {
289  $file = explode(":", $file);
290 
291  $file[1] = basename($file[1]);
292 
293  include_once("./Services/Export/classes/class.ilExport.php");
294  $export_dir = ilExport::_getExportDirectory(
295  $this->obj->getId(),
296  str_replace("..", "", $file[0]),
297  $this->obj->getType()
298  );
299 
300  $exp_file = $export_dir . "/" . str_replace("..", "", $file[1]);
301  $exp_dir = $export_dir . "/" . substr($file[1], 0, strlen($file[1]) - 4);
302  if (@is_file($exp_file)) {
303  unlink($exp_file);
304  }
305  if (@is_dir($exp_dir)) {
306  ilUtil::delDir($exp_dir);
307  }
308 
309  // delete entry in database
310  include_once './Services/Export/classes/class.ilExportFileInfo.php';
311  $info = new ilExportFileInfo($this->obj->getId(), $file[0], $file[1]);
312  $info->delete();
313  }
314  $ilCtrl->redirect($this, "listExportFiles");
315  }
global $ilCtrl
Definition: ilias.php:18
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
$info
Definition: index.php:5
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 320 of file class.ilExportGUI.php.

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

Referenced by ilTestExportGUI\listExportFiles().

321  {
322  global $ilCtrl, $lng;
323 
324  if (!isset($_GET["file"]) ||
325  is_array($_GET["file"])) {
326  $ilCtrl->redirect($this, "listExportFiles");
327  }
328 
329  $file = explode(":", trim($_GET["file"]));
330  include_once("./Services/Export/classes/class.ilExport.php");
331  $export_dir = ilExport::_getExportDirectory(
332  $this->obj->getId(),
333  str_replace("..", "", $file[0]),
334  $this->obj->getType()
335  );
336 
337  $file[1] = basename($file[1]);
338 
340  $export_dir . "/" . $file[1],
341  $file[1]
342  );
343  }
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18
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
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
+ 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 138 of file class.ilExportGUI.php.

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

139  {
140  global $ilCtrl, $ilAccess, $ilErr, $lng;
141 
142  // this should work (at least) for repository objects
143  if (method_exists($this->obj, 'getRefId') and $this->obj->getRefId()) {
144  if (!$ilAccess->checkAccess('write', '', $this->obj->getRefId())) {
145  $ilErr->raiseError($lng->txt('permission_denied'), $ilErr->WARNING);
146  }
147  }
148 
149  $cmd = $ilCtrl->getCmd("listExportFiles");
150 
151  switch ($cmd) {
152  case "listExportFiles":
153  $this->$cmd();
154  break;
155 
156  default:
157  if (substr($cmd, 0, 7) == "create_") {
158  $this->createExportFile();
159  } elseif (substr($cmd, 0, 6) == "multi_") { // custom multi command
160  $this->handleCustomMultiCommand();
161  } else {
162  $this->$cmd();
163  }
164  break;
165  }
166  }
global $ilErr
Definition: raiseError.php:16
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 127 of file class.ilExportGUI.php.

References $custom_columns.

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

128  {
129  return $this->custom_columns;
130  }
+ Here is the caller graph for this function:

◆ getCustomMultiCommands()

ilExportGUI::getCustomMultiCommands ( )

Get custom multi commands.

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

References $custom_multi_commands.

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

117  {
119  }
+ Here is the caller graph for this function:

◆ getFormats()

ilExportGUI::getFormats ( )

Get formats.

Returns
array formats

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

References $formats.

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

83  {
84  return $this->formats;
85  }
+ Here is the caller graph for this function:

◆ getParentGUI()

ilExportGUI::getParentGUI ( )
protected

get parent gui

Returns

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

References $parent_gui.

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

57  {
58  return $this->parent_gui;
59  }
+ Here is the caller graph for this function:

◆ handleCustomMultiCommand()

ilExportGUI::handleCustomMultiCommand ( )

Handle custom multi command.

Parameters

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

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

Referenced by executeCommand().

352  {
353  global $ilCtrl;
354 
355  $cmd = substr($ilCtrl->getCmd(), 6);
356  foreach ($this->getCustomMultiCommands() as $c) {
357  if ($c["func"] == $cmd) {
358  $c["obj"]->{$c["func"]}($_POST["file"]);
359  }
360  }
361  }
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 174 of file class.ilExportGUI.php.

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

175  {
176  global $tpl, $ilToolbar, $ilCtrl, $lng;
177 
178  include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
179  $button = ilSubmitButton::getInstance();
180 
181  // creation buttons
182  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
183  if (count($this->getFormats()) > 1) {
184  // type selection
185  foreach ($this->getFormats() as $f) {
186  $options[$f["key"]] = $f["txt"];
187  }
188  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
189  $si = new ilSelectInputGUI($lng->txt("type"), "format");
190  $si->setOptions($options);
191  $ilToolbar->addInputItem($si, true);
192 
193  $button->setCaption("exp_create_file");
194  $button->setCommand("createExportFile");
195  } else {
196  $format = $this->getFormats();
197  $format = $format[0];
198 
199  $button->setCaption($lng->txt("exp_create_file") . " (" . $format["txt"] . ")", false);
200  $button->setCommand("create_" . $format["key"]);
201  }
202 
203  $ilToolbar->addButtonInstance($button);
204 
205  $table = $this->buildExportTableGUI();
206  $table->setSelectAllCheckbox("file");
207  foreach ($this->getCustomColumns() as $c) {
208  $table->addCustomColumn($c["txt"], $c["obj"], $c["func"]);
209  }
210  foreach ($this->getCustomMultiCommands() as $c) {
211  $table->addCustomMultiCommand($c["txt"], "multi_" . $c["func"]);
212  }
213  $tpl->setContent($table->getHTML());
214  }
$format
Definition: metadata.php:141
This class represents a selection list property in a property form.
$tpl
Definition: ilias.php:10
global $ilCtrl
Definition: ilias.php:18
getCustomColumns()
Get custom columns.
getFormats()
Get formats.
getCustomMultiCommands()
Get custom multi commands.
global $lng
Definition: privfeed.php:17
if(empty($password)) $table
Definition: pwgen.php:24
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ Here is the call graph for this function:

◆ saveItemSelection()

ilExportGUI::saveItemSelection ( )
protected

Save selection of subitems.

Returns

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

References $_POST, $ilCtrl, $lng, $type, 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().

385  {
386  global $tree,$objDefinition, $ilAccess, $ilCtrl,$lng;
387 
388  include_once './Services/Export/classes/class.ilExportOptions.php';
390  $eo->addOption(ilExportOptions::KEY_ROOT, 0, 0, $this->obj->getId());
391 
392  $items_selected = false;
393  foreach ($tree->getSubTree($root = $tree->getNodeData($this->getParentGUI()->object->getRefId())) as $node) {
394  if ($node['type'] == 'rolf') {
395  continue;
396  }
397  if ($node['ref_id'] == $this->getParentGUI()->object->getRefId()) {
398  $eo->addOption(
400  $node['ref_id'],
401  $node['obj_id'],
403  );
404  continue;
405  }
406  // no export available or no access
407  if (!$objDefinition->allowExport($node['type']) or !$ilAccess->checkAccess('write', '', $node['ref_id'])) {
408  $eo->addOption(
410  $node['ref_id'],
411  $node['obj_id'],
413  );
414  continue;
415  }
416 
417  $mode = isset($_POST['cp_options'][$node['ref_id']]['type']) ?
418  $_POST['cp_options'][$node['ref_id']]['type'] :
420  $eo->addOption(
422  $node['ref_id'],
423  $node['obj_id'],
424  $mode
425  );
426  if ($mode != ilExportOptions::EXPORT_OMIT) {
427  $items_selected = true;
428  }
429  }
430 
431  include_once("./Services/Export/classes/class.ilExport.php");
432  if ($items_selected) {
433  // TODO: move this to background soap
434  $eo->read();
435  $exp = new ilExport();
436  foreach ($eo->getSubitemsForCreation($this->obj->getRefId()) as $ref_id) {
437  $obj_id = ilObject::_lookupObjId($ref_id);
438  $type = ilObject::_lookupType($obj_id);
439  $exp->exportObject($type, $obj_id);
440  }
441  // Fixme: there is a naming conflict between the container settings xml and the container subitem xml.
442  sleep(1);
443  // Export container
444  include_once './Services/Export/classes/class.ilExportContainer.php';
445  $cexp = new ilExportContainer($eo);
446  $cexp->exportObject($this->obj->getType(), $this->obj->getId());
447  } else {
448  $exp = new ilExport();
449  $exp->exportObject($this->obj->getType(), $this->obj->getId());
450  }
451 
452  // Delete export options
453  $eo->delete();
454 
455  ilUtil::sendSuccess($lng->txt('export_created'), true);
456  $ilCtrl->redirect($this, "listExportFiles");
457  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$type
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
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 367 of file class.ilExportGUI.php.

References $table, $tpl, getParentGUI(), and object.

Referenced by createExportFile().

368  {
369  global $tpl;
370 
371  $tpl->addJavaScript('./Services/CopyWizard/js/ilContainer.js');
372  $tpl->setVariable('BODY_ATTRIBUTES', 'onload="ilDisableChilds(\'cmd\');"');
373 
374  include_once './Services/Export/classes/class.ilExportSelectionTableGUI.php';
375  $table = new ilExportSelectionTableGUI($this, 'listExportFiles');
376  $table->parseContainer($this->getParentGUI()->object->getRefId());
377  $this->tpl->setContent($table->getHTML());
378  }
$tpl
Definition: ilias.php:10
Create new PHPExcel object
obj_idprivate
if(empty($password)) $table
Definition: pwgen.php:24
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: