ILIAS  release_7 Revision v7.30-3-g800a261c036
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...
 
 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  }
$lng
global $DIC
Definition: goto.php:24
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41

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  }
$lng
global $DIC
Definition: goto.php:24

◆ 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, $DIC, $filename, $i, $lng, $tpl, and ilUtil\sendInfo().

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

◆ createExportFile()

ilExportGUI::createExportFile ( )

Create export file.

Parameters

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

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

Referenced by getCustomColumns().

248  {
249  global $DIC;
250 
251  $ilCtrl = $DIC['ilCtrl'];
252  $lng = $DIC['lng'];
253 
254  if ($ilCtrl->getCmd() == "createExportFile") {
255  $format = ilUtil::stripSlashes($_POST["format"]);
256  } else {
257  $format = substr($ilCtrl->getCmd(), 7);
258  }
259  foreach ($this->getFormats() as $f) {
260  if ($f["key"] == $format) {
261  if (is_object($f["call_obj"])) {
262  $f["call_obj"]->{$f["call_func"]}();
263  } elseif ($this->getParentGUI() instanceof ilContainerGUI) {
264  return $this->showItemSelection();
265  } elseif ($format == "xml") { // standard procedure
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  }
showItemSelection()
Show container item selection table.
$lng
global $DIC
Definition: goto.php:24
$format
Definition: metadata.php:218
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 316 of file class.ilExportGUI.php.

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

317  {
318  global $DIC;
319 
320  $ilCtrl = $DIC['ilCtrl'];
321 
322  foreach ($_POST["file"] as $file) {
323  $file = explode(":", $file);
324 
325  $file[1] = basename($file[1]);
326 
327  include_once("./Services/Export/classes/class.ilExport.php");
328  $export_dir = ilExport::_getExportDirectory(
329  $this->obj->getId(),
330  str_replace("..", "", $file[0]),
331  $this->obj->getType()
332  );
333 
334  $exp_file = $export_dir . "/" . str_replace("..", "", $file[1]);
335  $exp_dir = $export_dir . "/" . substr($file[1], 0, strlen($file[1]) - 4);
336  if (@is_file($exp_file)) {
337  unlink($exp_file);
338  }
339  if (@is_dir($exp_dir)) {
340  ilUtil::delDir($exp_dir);
341  }
342 
343  // delete entry in database
344  include_once './Services/Export/classes/class.ilExportFileInfo.php';
345  $info = new ilExportFileInfo($this->obj->getId(), $file[0], $file[1]);
346  $info->delete();
347  }
348  $ilCtrl->redirect($this, "listExportFiles");
349  }
global $DIC
Definition: goto.php:24
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
$_POST["username"]
+ Here is the call graph for this function:

◆ download()

ilExportGUI::download ( )

Download file.

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

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

Referenced by ilTestExportGUI\listExportFiles().

355  {
356  global $DIC;
357 
358  $ilCtrl = $DIC['ilCtrl'];
359  $lng = $DIC['lng'];
360 
361  if (!isset($_GET["file"]) ||
362  is_array($_GET["file"])) {
363  $ilCtrl->redirect($this, "listExportFiles");
364  }
365 
366  $file = explode(":", trim($_GET["file"]));
367  include_once("./Services/Export/classes/class.ilExport.php");
368  $export_dir = ilExport::_getExportDirectory(
369  $this->obj->getId(),
370  str_replace("..", "", $file[0]),
371  $this->obj->getType()
372  );
373 
374  $file[1] = basename($file[1]);
375 
377  $export_dir . "/" . $file[1],
378  $file[1]
379  );
380  }
$_GET["client_id"]
$lng
global $DIC
Definition: goto.php:24
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:

◆ getCustomColumns()

ilExportGUI::getCustomColumns ( )

Get custom columns.

Parameters

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

References $custom_columns, $DIC, $ilErr, $lng, ilObject\_lookupType(), createExportFile(), handleCustomMultiCommand(), ilUtil\sendFailure(), and ilExportLimitation\SET_EXPORT_DISABLED.

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

133  {
134  return $this->custom_columns;
135  }
+ Here is the call graph for this function:
+ 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 388 of file class.ilExportGUI.php.

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

Referenced by getCustomColumns().

389  {
390  global $DIC;
391 
392  $ilCtrl = $DIC['ilCtrl'];
393 
394  $cmd = substr($ilCtrl->getCmd(), 6);
395  foreach ($this->getCustomMultiCommands() as $c) {
396  if ($c["func"] == $cmd) {
397  $c["obj"]->{$c["func"]}($_POST["file"]);
398  }
399  }
400  }
$c
Definition: cli.php:37
global $DIC
Definition: goto.php:24
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 194 of file class.ilExportGUI.php.

References $c, $DIC, Vendor\Package\$f, $format, $lng, $si, $tpl, buildExportTableGUI(), getCustomColumns(), getCustomMultiCommands(), getFormats(), and ilSubmitButton\getInstance().

195  {
196  global $DIC;
197 
198  $tpl = $DIC['tpl'];
199  $ilToolbar = $DIC['ilToolbar'];
200  $ilCtrl = $DIC['ilCtrl'];
201  $lng = $DIC['lng'];
202 
203  include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
204  $button = ilSubmitButton::getInstance();
205 
206  // creation buttons
207  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
208  if (count($this->getFormats()) > 1) {
209  // type selection
210  foreach ($this->getFormats() as $f) {
211  $options[$f["key"]] = $f["txt"];
212  }
213  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
214  $si = new ilSelectInputGUI($lng->txt("type"), "format");
215  $si->setOptions($options);
216  $ilToolbar->addInputItem($si, true);
217 
218  $button->setCaption("exp_create_file");
219  $button->setCommand("createExportFile");
220  } else {
221  $format = $this->getFormats();
222  $format = $format[0];
223 
224  $button->setCaption($lng->txt("exp_create_file") . " (" . $format["txt"] . ")", false);
225  $button->setCommand("create_" . $format["key"]);
226  }
227 
228  $ilToolbar->addButtonInstance($button);
229 
230  $table = $this->buildExportTableGUI();
231  $table->setSelectAllCheckbox("file");
232  foreach ($this->getCustomColumns() as $c) {
233  $table->addCustomColumn($c["txt"], $c["obj"], $c["func"]);
234  }
235  foreach ($this->getCustomMultiCommands() as $c) {
236  $table->addCustomMultiCommand($c["txt"], "multi_" . $c["func"]);
237  }
238  $tpl->setContent($table->getHTML());
239  }
$c
Definition: cli.php:37
getCustomColumns()
Get custom columns.
$lng
global $DIC
Definition: goto.php:24
$format
Definition: metadata.php:218
getFormats()
Get formats.
getCustomMultiCommands()
Get custom multi commands.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
+ Here is the call graph for this function:

◆ saveItemSelection()

ilExportGUI::saveItemSelection ( )
protected

Save selection of subitems.

Returns

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

References $_POST, $DIC, Vendor\Package\$e, $lng, $type, ilObject\_lookupObjId(), ilObject\_lookupType(), ilExportOptions\allocateExportId(), ilExportOptions\EXPORT_BUILD, ilExportOptions\EXPORT_OMIT, getParentGUI(), ilExportOptions\KEY_ITEM_MODE, ilExportOptions\KEY_ROOT, ilExportOptions\newInstance(), ilUtil\sendFailure(), and showItemSelection().

426  {
427  global $DIC;
428 
429  $tree = $DIC['tree'];
430  $objDefinition = $DIC['objDefinition'];
431  $ilAccess = $DIC['ilAccess'];
432  $ilCtrl = $DIC['ilCtrl'];
433  $lng = $DIC['lng'];
434 
435  include_once './Services/Export/classes/class.ilExportOptions.php';
437  $eo->addOption(ilExportOptions::KEY_ROOT, 0, 0, $this->obj->getId());
438 
439  // check export limitation
440  $exp_limit = new ilExportLimitation();
441  try {
442  $exp_limit->checkLimitation(
443  $this->getParentGUI()->object->getRefId(),
444  $_POST['cp_options']
445  );
446  } catch (Exception $e) {
447  ilUtil::sendFailure($e->getMessage());
448  $this->showItemSelection();
449  return;
450  }
451 
452  $items_selected = false;
453  foreach ($tree->getSubTree($root = $tree->getNodeData($this->getParentGUI()->object->getRefId())) as $node) {
454  if ($node['type'] == 'rolf') {
455  continue;
456  }
457  if ($node['ref_id'] == $this->getParentGUI()->object->getRefId()) {
458  $eo->addOption(
460  $node['ref_id'],
461  $node['obj_id'],
463  );
464  continue;
465  }
466  // no export available or no access
467  if (!$objDefinition->allowExport($node['type']) or !$ilAccess->checkAccess('write', '', $node['ref_id'])) {
468  $eo->addOption(
470  $node['ref_id'],
471  $node['obj_id'],
473  );
474  continue;
475  }
476 
477  $mode = isset($_POST['cp_options'][$node['ref_id']]['type']) ?
478  $_POST['cp_options'][$node['ref_id']]['type'] :
480  $eo->addOption(
482  $node['ref_id'],
483  $node['obj_id'],
484  $mode
485  );
486  if ($mode != ilExportOptions::EXPORT_OMIT) {
487  $items_selected = true;
488  }
489  }
490 
491  include_once("./Services/Export/classes/class.ilExport.php");
492  if ($items_selected) {
493  // TODO: move this to background soap
494  $eo->read();
495  $exp = new ilExport();
496  foreach ($eo->getSubitemsForCreation($this->obj->getRefId()) as $ref_id) {
497  $obj_id = ilObject::_lookupObjId($ref_id);
499  $exp->exportObject($type, $obj_id);
500  }
501  // Fixme: there is a naming conflict between the container settings xml and the container subitem xml.
502  sleep(1);
503  // Export container
504  include_once './Services/Export/classes/class.ilExportContainer.php';
505  $cexp = new ilExportContainer($eo);
506  $cexp->exportObject($this->obj->getType(), $this->obj->getId());
507  } else {
508  $exp = new ilExport();
509  $exp->exportObject($this->obj->getType(), $this->obj->getId());
510  }
511 
512  // Delete export options
513  $eo->delete();
514 
515  ilUtil::sendSuccess($lng->txt('export_created'), true);
516  $ilCtrl->redirect($this, "listExportFiles");
517  }
showItemSelection()
Show container item selection table.
$type
static newInstance($a_export_id)
Create new instance.
$lng
static _lookupObjId($a_id)
global $DIC
Definition: goto.php:24
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Export limitation checker.
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 406 of file class.ilExportGUI.php.

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

Referenced by createExportFile(), and saveItemSelection().

407  {
408  global $DIC;
409 
410  $tpl = $DIC['tpl'];
411 
412  $tpl->addJavaScript('./Services/CopyWizard/js/ilContainer.js');
413  $tpl->setVariable('BODY_ATTRIBUTES', 'onload="ilDisableChilds(\'cmd\');"');
414 
415  include_once './Services/Export/classes/class.ilExportSelectionTableGUI.php';
416  $table = new ilExportSelectionTableGUI($this, 'listExportFiles');
417  $table->parseContainer($this->getParentGUI()->object->getRefId());
418  $this->tpl->setContent($table->getHTML());
419  }
global $DIC
Definition: goto.php:24
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
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: