ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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$

@ilCtrl_Calls 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

return

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

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:40

References $lng, and $tpl.

Member Function Documentation

◆ addCustomColumn()

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

Add custom column.

Parameters

return

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

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

◆ addCustomMultiCommand()

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

Add custom multi command.

Parameters

return

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

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

◆ 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.

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 }

References $lng.

◆ buildExportTableGUI()

ilExportGUI::buildExportTableGUI ( )
protected
Returns
ilExportTableGUI

Reimplemented in ilTestExportGUI, and ilQuestionPoolExportGUI.

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

49 {
50 include_once("./Services/Export/classes/class.ilExportTableGUI.php");
51 $table = new ilExportTableGUI($this, "listExportFiles", $this->obj);
52 return $table;
53 }

Referenced by listExportFiles().

+ Here is the caller graph for this function:

◆ confirmDeletion()

ilExportGUI::confirmDeletion ( )

Confirm file deletion.

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

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 }
$filename
Definition: buildRTE.php:89
Confirmation screen class.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18

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

+ Here is the call graph for this function:

◆ createExportFile()

ilExportGUI::createExportFile ( )

Create export file.

Parameters

return

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

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 }
Class ilContainerGUI.
getParentGUI()
get parent gui
getFormats()
Get formats.
showItemSelection()
Show container item selection table.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

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

Referenced by executeCommand().

+ 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.

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 }
print $file
@classDescription 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.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
$info
Definition: example_052.php:80

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

+ Here is the call graph for this function:

◆ download()

ilExportGUI::download ( )

Download file.

Reimplemented in ilQuestionPoolExportGUI.

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

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"]
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.

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

+ Here is the call graph for this function:

◆ executeCommand()

ilExportGUI::executeCommand ( )

Execute command.

Parameters

return

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

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 {
171 }
172 else
173 {
174 $this->$cmd();
175 }
176 break;
177 }
178 }
createExportFile()
Create export file.
handleCustomMultiCommand()
Handle custom multi command.
$cmd
Definition: sahs_server.php:35

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

+ Here is the call graph for this function:

◆ getCustomColumns()

ilExportGUI::getCustomColumns ( )

Get custom columns.

Parameters

return

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

132 {
134 }

References $custom_columns.

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

+ Here is the caller graph for this function:

◆ getCustomMultiCommands()

ilExportGUI::getCustomMultiCommands ( )

Get custom multi commands.

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

121 {
123 }

References $custom_multi_commands.

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

+ 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.

87 {
88 return $this->formats;
89 }

References $formats.

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

+ 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.

60 {
61 return $this->parent_gui;
62 }

References $parent_gui.

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

+ Here is the caller graph for this function:

◆ handleCustomMultiCommand()

ilExportGUI::handleCustomMultiCommand ( )

Handle custom multi command.

Parameters

return

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

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 }
getCustomMultiCommands()
Get custom multi commands.

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

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listExportFiles()

ilExportGUI::listExportFiles ( )

List export files.

Parameters

return

Reimplemented in ilOrgUnitExportGUI, and ilTestExportGUI.

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

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 }
getCustomColumns()
Get custom columns.
This class represents a selection list property in a property form.
static getInstance()
Factory.
if(!is_array($argv)) $options

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

+ 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.

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 );
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 {
479 $type = ilObject::_lookupType($obj_id);
480 $exp->exportObject($type,$obj_id,'4.1.0');
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(),'4.1.0');
488 }
489 else
490 {
491 $exp = new ilExport();
492 $exp->exportObject($this->obj->getType(),$this->obj->getId(), "4.1.0");
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 newInstance($a_export_id)
Create new instance.
static allocateExportId()
Allocate a new export id.
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
$ref_id
Definition: sahs_server.php:39

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().

+ 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.

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 }

References $tpl, and getParentGUI().

Referenced by createExportFile().

+ 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: