ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC, $lng, and $tpl.

29  {
30  global $DIC;
31 
32  $lng = $DIC['lng'];
33  $tpl = $DIC['tpl'];
34 
35  $this->parent_gui = $a_parent_gui;
36  if ($a_main_obj == null) {
37  $this->obj = $a_parent_gui->object;
38  } else {
39  $this->obj = $a_main_obj;
40  }
41  $lng->loadLanguageModule("exp");
42  $this->tpl = $tpl;
43  }
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
$lng

Member Function Documentation

◆ addCustomColumn()

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

Add custom column.

Parameters

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

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

◆ addCustomMultiCommand()

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

Add custom multi command.

Parameters

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

112  {
113  $this->custom_multi_commands[] = array("txt" => $a_txt,
114  "obj" => $a_obj,
115  "func" => $a_func);
116  }

◆ 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 $DIC, and $lng.

70  {
71  global $DIC;
72 
73  $lng = $DIC['lng'];
74 
75  if ($a_txt == "") {
76  $a_txt = $lng->txt("exp_" . $a_key);
77  }
78  $this->formats[] = array("key" => $a_key, "txt" => $a_txt,
79  "call_obj" => $a_call_obj, "call_func" => $a_call_func);
80  }
global $DIC
Definition: saml.php:7
$lng

◆ buildExportTableGUI()

ilExportGUI::buildExportTableGUI ( )
protected
Returns
ilExportTableGUI

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

References $table.

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  }
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 270 of file class.ilExportGUI.php.

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

271  {
272  global $DIC;
273 
274  $ilCtrl = $DIC['ilCtrl'];
275  $tpl = $DIC['tpl'];
276  $lng = $DIC['lng'];
277 
278  if (!is_array($_POST["file"]) || count($_POST["file"]) == 0) {
279  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
280  $ilCtrl->redirect($this, "listExportFiles");
281  } else {
282  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
283  $cgui = new ilConfirmationGUI();
284  $cgui->setFormAction($ilCtrl->getFormAction($this));
285  $cgui->setHeaderText($lng->txt("exp_really_delete"));
286  $cgui->setCancel($lng->txt("cancel"), "listExportFiles");
287  $cgui->setConfirm($lng->txt("delete"), "delete");
288 
289  foreach ($_POST["file"] as $i) {
290  if (strpos($i, ':') !== false) {
291  $iarr = explode(":", $i);
292  $filename = $iarr[1];
293  } else {
294  $filename = $i;
295  }
296  $cgui->addItem("file[]", $i, $filename);
297  }
298 
299  $tpl->setContent($cgui->getHTML());
300  }
301  }
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$lng
$filename
Definition: buildRTE.php:89
$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 237 of file class.ilExportGUI.php.

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

Referenced by executeCommand().

238  {
239  global $DIC;
240 
241  $ilCtrl = $DIC['ilCtrl'];
242  $lng = $DIC['lng'];
243 
244  if ($ilCtrl->getCmd() == "createExportFile") {
245  $format = ilUtil::stripSlashes($_POST["format"]);
246  } else {
247  $format = substr($ilCtrl->getCmd(), 7);
248  }
249  foreach ($this->getFormats() as $f) {
250  if ($f["key"] == $format) {
251  if (is_object($f["call_obj"])) {
252  $f["call_obj"]->{$f["call_func"]}();
253  } elseif ($this->getParentGUI() instanceof ilContainerGUI) {
254  return $this->showItemSelection();
255  } elseif ($format == "xml") { // standard procedure
256  include_once("./Services/Export/classes/class.ilExport.php");
257  $exp = new ilExport();
258  $exp->exportObject($this->obj->getType(), $this->obj->getId());
259  }
260  }
261  }
262 
263  ilUtil::sendSuccess($lng->txt("exp_file_created"), true);
264  $ilCtrl->redirect($this, "listExportFiles");
265  }
$format
Definition: metadata.php:141
showItemSelection()
Show container item selection table.
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
$lng
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getFormats()
Get formats.
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 306 of file class.ilExportGUI.php.

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

307  {
308  global $DIC;
309 
310  $ilCtrl = $DIC['ilCtrl'];
311 
312  foreach ($_POST["file"] as $file) {
313  $file = explode(":", $file);
314 
315  $file[1] = basename($file[1]);
316 
317  include_once("./Services/Export/classes/class.ilExport.php");
318  $export_dir = ilExport::_getExportDirectory(
319  $this->obj->getId(),
320  str_replace("..", "", $file[0]),
321  $this->obj->getType()
322  );
323 
324  $exp_file = $export_dir . "/" . str_replace("..", "", $file[1]);
325  $exp_dir = $export_dir . "/" . substr($file[1], 0, strlen($file[1]) - 4);
326  if (@is_file($exp_file)) {
327  unlink($exp_file);
328  }
329  if (@is_dir($exp_dir)) {
330  ilUtil::delDir($exp_dir);
331  }
332 
333  // delete entry in database
334  include_once './Services/Export/classes/class.ilExportFileInfo.php';
335  $info = new ilExportFileInfo($this->obj->getId(), $file[0], $file[1]);
336  $info->delete();
337  }
338  $ilCtrl->redirect($this, "listExportFiles");
339  }
global $DIC
Definition: saml.php:7
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.
$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 344 of file class.ilExportGUI.php.

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

Referenced by ilTestExportGUI\listExportFiles().

345  {
346  global $DIC;
347 
348  $ilCtrl = $DIC['ilCtrl'];
349  $lng = $DIC['lng'];
350 
351  if (!isset($_GET["file"]) ||
352  is_array($_GET["file"])) {
353  $ilCtrl->redirect($this, "listExportFiles");
354  }
355 
356  $file = explode(":", trim($_GET["file"]));
357  include_once("./Services/Export/classes/class.ilExport.php");
358  $export_dir = ilExport::_getExportDirectory(
359  $this->obj->getId(),
360  str_replace("..", "", $file[0]),
361  $this->obj->getType()
362  );
363 
364  $file[1] = basename($file[1]);
365 
367  $export_dir . "/" . $file[1],
368  $file[1]
369  );
370  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18
$lng
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
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 143 of file class.ilExportGUI.php.

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

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

◆ getCustomColumns()

ilExportGUI::getCustomColumns ( )

Get custom columns.

Parameters

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

References $custom_columns.

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

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

◆ getCustomMultiCommands()

ilExportGUI::getCustomMultiCommands ( )

Get custom multi commands.

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

References $custom_multi_commands.

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

122  {
124  }
+ Here is the caller graph for this function:

◆ getFormats()

ilExportGUI::getFormats ( )

Get formats.

Returns
array formats

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

References $formats.

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

88  {
89  return $this->formats;
90  }
+ 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 378 of file class.ilExportGUI.php.

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

Referenced by executeCommand().

379  {
380  global $DIC;
381 
382  $ilCtrl = $DIC['ilCtrl'];
383 
384  $cmd = substr($ilCtrl->getCmd(), 6);
385  foreach ($this->getCustomMultiCommands() as $c) {
386  if ($c["func"] == $cmd) {
387  $c["obj"]->{$c["func"]}($_POST["file"]);
388  }
389  }
390  }
global $DIC
Definition: saml.php:7
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 184 of file class.ilExportGUI.php.

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

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

◆ saveItemSelection()

ilExportGUI::saveItemSelection ( )
protected

Save selection of subitems.

Returns

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

References $_POST, $DIC, $ilCtrl, $lng, $root, $tree, $type, ilObject\_lookupObjId(), ilObject\_lookupType(), ilExportOptions\allocateExportId(), ilExportOptions\EXPORT_BUILD, ilExportOptions\EXPORT_OMIT, getParentGUI(), ilExportOptions\KEY_ITEM_MODE, ilExportOptions\KEY_ROOT, and ilExportOptions\newInstance().

416  {
417  global $DIC;
418 
419  $tree = $DIC['tree'];
420  $objDefinition = $DIC['objDefinition'];
421  $ilAccess = $DIC['ilAccess'];
422  $ilCtrl = $DIC['ilCtrl'];
423  $lng = $DIC['lng'];
424 
425  include_once './Services/Export/classes/class.ilExportOptions.php';
427  $eo->addOption(ilExportOptions::KEY_ROOT, 0, 0, $this->obj->getId());
428 
429  $items_selected = false;
430  foreach ($tree->getSubTree($root = $tree->getNodeData($this->getParentGUI()->object->getRefId())) as $node) {
431  if ($node['type'] == 'rolf') {
432  continue;
433  }
434  if ($node['ref_id'] == $this->getParentGUI()->object->getRefId()) {
435  $eo->addOption(
437  $node['ref_id'],
438  $node['obj_id'],
440  );
441  continue;
442  }
443  // no export available or no access
444  if (!$objDefinition->allowExport($node['type']) or !$ilAccess->checkAccess('write', '', $node['ref_id'])) {
445  $eo->addOption(
447  $node['ref_id'],
448  $node['obj_id'],
450  );
451  continue;
452  }
453 
454  $mode = isset($_POST['cp_options'][$node['ref_id']]['type']) ?
455  $_POST['cp_options'][$node['ref_id']]['type'] :
457  $eo->addOption(
459  $node['ref_id'],
460  $node['obj_id'],
461  $mode
462  );
463  if ($mode != ilExportOptions::EXPORT_OMIT) {
464  $items_selected = true;
465  }
466  }
467 
468  include_once("./Services/Export/classes/class.ilExport.php");
469  if ($items_selected) {
470  // TODO: move this to background soap
471  $eo->read();
472  $exp = new ilExport();
473  foreach ($eo->getSubitemsForCreation($this->obj->getRefId()) as $ref_id) {
474  $obj_id = ilObject::_lookupObjId($ref_id);
475  $type = ilObject::_lookupType($obj_id);
476  $exp->exportObject($type, $obj_id);
477  }
478  // Fixme: there is a naming conflict between the container settings xml and the container subitem xml.
479  sleep(1);
480  // Export container
481  include_once './Services/Export/classes/class.ilExportContainer.php';
482  $cexp = new ilExportContainer($eo);
483  $cexp->exportObject($this->obj->getType(), $this->obj->getId());
484  } else {
485  $exp = new ilExport();
486  $exp->exportObject($this->obj->getType(), $this->obj->getId());
487  }
488 
489  // Delete export options
490  $eo->delete();
491 
492  ilUtil::sendSuccess($lng->txt('export_created'), true);
493  $ilCtrl->redirect($this, "listExportFiles");
494  }
$type
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
static newInstance($a_export_id)
Create new instance.
$lng
static _lookupObjId($a_id)
$root
Definition: sabredav.php:45
static _lookupType($a_id, $a_reference=false)
lookup object type
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 396 of file class.ilExportGUI.php.

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

Referenced by createExportFile().

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