ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups 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.
 addFormat ($a_key, $a_txt="", $a_call_obj=null, $a_call_func="")
 Add formats.
 getFormats ()
 Get formats.
 addCustomColumn ($a_txt, $a_obj, $a_func)
 Add custom column.
 addCustomMultiCommand ($a_txt, $a_obj, $a_func)
 Add custom multi command.
 getCustomMultiCommands ()
 Get custom multi commands.
 getCustomColumns ()
 Get custom columns.
 executeCommand ()
 Execute command.
 listExportFiles ()
 List export files.
 createExportFile ()
 Create export file.
 confirmDeletion ()
 Confirm file deletion.
 delete ()
 Delete files.
 download ()
 Download file.
 handleCustomMultiCommand ()
 Handle custom multi command.

Protected Member Functions

 buildExportTableGUI ()
 getParentGUI ()
 get parent gui
 showItemSelection ()
 Show container item selection table.
 saveItemSelection ()
 Save selection of subitems.

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

ilExportGUI::__construct (   $a_parent_gui,
  $a_main_obj = null 
)

Constuctor.

Parameters
@return

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

References $lng, and $tpl.

{
global $lng,$tpl;
$this->parent_gui = $a_parent_gui;
if ($a_main_obj == null)
{
$this->obj = $a_parent_gui->object;
}
else
{
$this->obj = $a_main_obj;
}
$lng->loadLanguageModule("exp");
$this->tpl = $tpl;
}

Member Function Documentation

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

Add custom column.

Parameters
@return

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

{
$this->custom_columns[] = array("txt" => $a_txt,
"obj" => $a_obj,
"func" => $a_func);
}
ilExportGUI::addCustomMultiCommand (   $a_txt,
  $a_obj,
  $a_func 
)

Add custom multi command.

Parameters
@return

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

{
$this->custom_multi_commands[] = array("txt" => $a_txt,
"obj" => $a_obj,
"func" => $a_func);
}
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.

{
global $lng;
if ($a_txt == "")
{
$a_txt = $lng->txt("exp_".$a_key);
}
$this->formats[] = array("key" => $a_key, "txt" => $a_txt,
"call_obj" => $a_call_obj, "call_func" => $a_call_func);
}
ilExportGUI::buildExportTableGUI ( )
protected
Returns
ilExportTableGUI

Reimplemented in ilTestExportGUI, and ilQuestionPoolExportGUI.

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

Referenced by listExportFiles().

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

+ Here is the caller graph for this function:

ilExportGUI::confirmDeletion ( )

Confirm file deletion.

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

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

{
global $ilCtrl, $tpl, $lng;
if (!is_array($_POST["file"]) || count($_POST["file"]) == 0)
{
ilUtil::sendInfo($lng->txt("no_checkbox"), true);
$ilCtrl->redirect($this, "listExportFiles");
}
else
{
include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
$cgui = new ilConfirmationGUI();
$cgui->setFormAction($ilCtrl->getFormAction($this));
$cgui->setHeaderText($lng->txt("exp_really_delete"));
$cgui->setCancel($lng->txt("cancel"), "listExportFiles");
$cgui->setConfirm($lng->txt("delete"), "delete");
foreach ($_POST["file"] as $i)
{
if(strpos($i, ':') !== false)
{
$iarr = explode(":", $i);
$filename = $iarr[1];
}
else
{
$filename = $i;
}
$cgui->addItem("file[]", $i, $filename);
}
$tpl->setContent($cgui->getHTML());
}
}

+ Here is the call graph for this function:

ilExportGUI::createExportFile ( )

Create export file.

Parameters
@return

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

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

Referenced by executeCommand().

{
global $ilCtrl, $lng;
if ($ilCtrl->getCmd() == "createExportFile")
{
$format = ilUtil::stripSlashes($_POST["format"]);
}
else
{
$format = substr($ilCtrl->getCmd(), 7);
}
foreach ($this->getFormats() as $f)
{
if ($f["key"] == $format)
{
if (is_object($f["call_obj"]))
{
$f["call_obj"]->$f["call_func"]();
}
elseif($this->getParentGUI() instanceof ilContainerGUI)
{
return $this->showItemSelection();
}
else if ($format == "xml") // standard procedure
{
include_once("./Services/Export/classes/class.ilExport.php");
$exp = new ilExport();
$exp->exportObject($this->obj->getType(),$this->obj->getId(), "5.0.0");
}
}
}
ilUtil::sendSuccess($lng->txt("exp_file_created"), true);
$ilCtrl->redirect($this, "listExportFiles");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilExportGUI::delete ( )

Delete files.

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

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

{
global $ilCtrl;
foreach($_POST["file"] as $file)
{
$file = explode(":", $file);
$file[1] = basename($file[1]);
include_once("./Services/Export/classes/class.ilExport.php");
$export_dir = ilExport::_getExportDirectory($this->obj->getId(),
str_replace("..", "", $file[0]), $this->obj->getType());
$exp_file = $export_dir."/".str_replace("..", "", $file[1]);
$exp_dir = $export_dir."/".substr($file[1], 0, strlen($file[1]) - 4);
if (@is_file($exp_file))
{
unlink($exp_file);
}
if (@is_dir($exp_dir))
{
ilUtil::delDir($exp_dir);
}
// delete entry in database
include_once './Services/Export/classes/class.ilExportFileInfo.php';
$info = new ilExportFileInfo($this->obj->getId(),$file[0],$file[1]);
$info->delete();
}
$ilCtrl->redirect($this, "listExportFiles");
}

+ Here is the call graph for this function:

ilExportGUI::download ( )

Download file.

Reimplemented in ilQuestionPoolExportGUI.

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

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

{
global $ilCtrl, $lng;
if(!isset($_GET["file"]) ||
is_array($_GET["file"]))
{
$ilCtrl->redirect($this, "listExportFiles");
}
$file = explode(":", trim($_GET["file"]));
include_once("./Services/Export/classes/class.ilExport.php");
$export_dir = ilExport::_getExportDirectory($this->obj->getId(),
str_replace("..", "", $file[0]), $this->obj->getType());
$file[1] = basename($file[1]);
ilUtil::deliverFile($export_dir."/".$file[1],
$file[1]);
}

+ Here is the call graph for this function:

ilExportGUI::executeCommand ( )

Execute command.

Parameters
@return

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

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

{
global $ilCtrl, $ilAccess, $ilErr, $lng;
// this should work (at least) for repository objects
if(method_exists($this->obj, 'getRefId') and $this->obj->getRefId())
{
if(!$ilAccess->checkAccess('write','',$this->obj->getRefId()))
{
$ilErr->raiseError($lng->txt('permission_denied'),$ilErr->WARNING);
}
}
$cmd = $ilCtrl->getCmd("listExportFiles");
switch ($cmd)
{
case "listExportFiles":
$this->$cmd();
break;
default:
if (substr($cmd, 0, 7) == "create_")
{
$this->createExportFile();
}
else if (substr($cmd, 0, 6) == "multi_") // custom multi command
{
}
else
{
$this->$cmd();
}
break;
}
}

+ Here is the call graph for this function:

ilExportGUI::getCustomColumns ( )

Get custom columns.

Parameters
@return

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

References $custom_columns.

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

{
}

+ Here is the caller graph for this function:

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

+ Here is the caller graph for this function:

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

{
}

+ Here is the caller graph for this function:

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

{
}

+ Here is the caller graph for this function:

ilExportGUI::handleCustomMultiCommand ( )

Handle custom multi command.

Parameters
@return

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

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

Referenced by executeCommand().

{
global $ilCtrl;
$cmd = substr($ilCtrl->getCmd(), 6);
foreach ($this->getCustomMultiCommands() as $c)
{
if ($c["func"] == $cmd)
{
$c["obj"]->$c["func"]($_POST["file"]);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilExportGUI::listExportFiles ( )

List export files.

Parameters
@return

Reimplemented in ilTestExportGUI.

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

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

{
global $tpl, $ilToolbar, $ilCtrl, $lng;
include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
// creation buttons
$ilToolbar->setFormAction($ilCtrl->getFormAction($this));
if (count($this->getFormats()) > 1)
{
// type selection
foreach ($this->getFormats() as $f)
{
$options[$f["key"]] = $f["txt"];
}
include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
$si = new ilSelectInputGUI($lng->txt("type"), "format");
$si->setOptions($options);
$ilToolbar->addInputItem($si, true);
$button->setCaption("exp_create_file");
$button->setCommand("createExportFile");
}
else
{
$format = $this->getFormats();
$format = $format[0];
$button->setCaption($lng->txt("exp_create_file")." (".$format["txt"].")", false);
$button->setCommand("create_".$format["key"]);
}
$ilToolbar->addButtonInstance($button);
$table = $this->buildExportTableGUI();
$table->setSelectAllCheckbox("file");
foreach ($this->getCustomColumns() as $c)
{
$table->addCustomColumn($c["txt"], $c["obj"], $c["func"]);
}
foreach ($this->getCustomMultiCommands() as $c)
{
$table->addCustomMultiCommand($c["txt"], "multi_".$c["func"]);
}
$tpl->setContent($table->getHTML());
}

+ Here is the call graph for this function:

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

{
global $tree,$objDefinition, $ilAccess, $ilCtrl,$lng;
include_once './Services/Export/classes/class.ilExportOptions.php';
$eo->addOption(ilExportOptions::KEY_ROOT,0,0,$this->obj->getId());
$items_selected = false;
foreach($tree->getSubTree($root = $tree->getNodeData($this->getParentGUI()->object->getRefId())) as $node)
{
if($node['type'] == 'rolf')
{
continue;
}
if($node['ref_id'] == $this->getParentGUI()->object->getRefId())
{
$eo->addOption(
$node['ref_id'],
$node['obj_id'],
);
continue;
}
// no export available or no access
if(!$objDefinition->allowExport($node['type']) or !$ilAccess->checkAccess('write','',$node['ref_id']))
{
$eo->addOption(
$node['ref_id'],
$node['obj_id'],
);
continue;
}
$mode = isset($_POST['cp_options'][$node['ref_id']]['type']) ?
$_POST['cp_options'][$node['ref_id']]['type'] :
$eo->addOption(
$node['ref_id'],
$node['obj_id'],
$mode
);
{
$items_selected = true;
}
}
include_once("./Services/Export/classes/class.ilExport.php");
if($items_selected)
{
// TODO: move this to background soap
$eo->read();
$exp = new ilExport();
foreach($eo->getSubitemsForCreation($this->obj->getRefId()) as $ref_id)
{
$obj_id = ilObject::_lookupObjId($ref_id);
$type = ilObject::_lookupType($obj_id);
$exp->exportObject($type,$obj_id,'4.1.0');
}
// Fixme: there is a naming conflict between the container settings xml and the container subitem xml.
sleep(1);
// Export container
include_once './Services/Export/classes/class.ilExportContainer.php';
$cexp = new ilExportContainer($eo);
$cexp->exportObject($this->obj->getType(),$this->obj->getId(),'4.1.0');
}
else
{
$exp = new ilExport();
$exp->exportObject($this->obj->getType(),$this->obj->getId(), "4.1.0");
}
// Delete export options
$eo->delete();
ilUtil::sendSuccess($lng->txt('export_created'),true);
$ilCtrl->redirect($this, "listExportFiles");
}

+ Here is the call graph for this function:

ilExportGUI::showItemSelection ( )
protected

Show container item selection table.

Returns

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

References $tpl, and getParentGUI().

Referenced by createExportFile().

{
global $tpl;
$tpl->addJavaScript('./Services/CopyWizard/js/ilContainer.js');
$tpl->setVariable('BODY_ATTRIBUTES','onload="ilDisableChilds(\'cmd\');"');
include_once './Services/Export/classes/class.ilExportSelectionTableGUI.php';
$table = new ilExportSelectionTableGUI($this,'listExportFiles');
$table->parseContainer($this->getParentGUI()->object->getRefId());
$this->tpl->setContent($table->getHTML());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilExportGUI::$custom_columns = array()
protected

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

Referenced by getCustomColumns().

ilExportGUI::$custom_multi_commands = array()
protected

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

Referenced by getCustomMultiCommands().

ilExportGUI::$formats = array()
protected

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

Referenced by getFormats().

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: