ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilExport Class Reference
+ Collaboration diagram for ilExport:

Public Member Functions

 _getExportDirectory ($a_obj_id, $a_type="xml", $a_obj_type="")
 Get export directory.
 _getExportFiles ($a_obj_id, $a_export_types="", $a_obj_type="")
 Get Export Files.
 _createExportDirectory ($a_obj_id, $a_export_type="xml", $a_obj_type="")
 Create export directory.
 _generateIndexFile ($a_filename, $a_obj_id, $a_files, $a_type="")
 Generates an index.html file including links to all xml files included (for container exports)

Static Public Member Functions

static _getFileTypeString ($a_obj_type)
 Get file type string.
static _getValidExportSubItems ($a_ref_id)
 Get a list of subitems of a repository resource, that implement the export.
static _getLastExportFileDate ($a_obj_id, $a_type="", $a_obj_type="")
 Get date of last export file.
static _getLastExportFileInformation ($a_obj_id, $a_type="", $a_obj_type="")
 Get last export file information.

Static Public Attributes

static $export_implementer = array("tst", "lm", "glo")
static $file_type_str = array("tst" => "test_")

Detailed Description

Definition at line 13 of file class.ilExport.php.

Member Function Documentation

ilExport::_createExportDirectory (   $a_obj_id,
  $a_export_type = "xml",
  $a_obj_type = "" 
)

Create export directory.

Definition at line 184 of file class.ilExport.php.

References $ilErr, ilObject\_lookupType(), ilUtil\getDataDir(), and ilUtil\makeDir().

Referenced by ilObjGlossary\createExportDirectory().

{
global $ilErr;
if ($a_obj_type == "")
{
$a_obj_type = ilObject::_lookupType($a_obj_id);
}
$data_dir = ilUtil::getDataDir()."/".$a_obj_type."_data";
ilUtil::makeDir($data_dir);
if(!is_writable($data_dir))
{
$ilErr->raiseError("Data Directory (".$data_dir
.") not writeable.",$ilErr->FATAL);
}
// create resource data directory
$res_dir = $data_dir."/".$a_obj_type."_".$a_obj_id;
ilUtil::makeDir($res_dir);
if(!@is_dir($res_dir))
{
$ilErr->raiseError("Creation of Glossary Directory failed.",$ilErr->FATAL);
}
// create Export subdirectory (data_dir/glo_data/glo_<id>/Export)
if ($a_export_type != "xml")
{
$export_dir = $res_dir."/export_".$a_export_type;
}
else
{
$export_dir = $res_dir."/export";
}
ilUtil::makeDir($export_dir);
if(!@is_dir($export_dir))
{
$ilErr->raiseError("Creation of Export Directory failed.",$ilErr->FATAL);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilExport::_generateIndexFile (   $a_filename,
  $a_obj_id,
  $a_files,
  $a_type = "" 
)

Generates an index.html file including links to all xml files included (for container exports)

Definition at line 231 of file class.ilExport.php.

References $f, $file, $lng, ilObject\_lookupTitle(), ilObject\_lookupType(), and ilUtil\getStyleSheetLocation().

Referenced by ilCourseArchives\addXML().

{
global $lng;
$lng->loadLanguageModule("export");
if ($a_type == "")
{
$a_type = ilObject::_lookupType($a_obj_id);
}
$a_tpl = new ilTemplate("tpl.main.html", true, true);
$location_stylesheet = ilUtil::getStyleSheetLocation();
$a_tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
$a_tpl->getStandardTemplate();
$a_tpl->setTitle(ilObject::_lookupTitle($a_obj_id));
$a_tpl->setDescription($lng->txt("export_export_date").": ".
date('Y-m-d H:i:s', time())." (".date_default_timezone_get().")");
$f_tpl = new ilTemplate("tpl.export_list.html", true, true, "Services/Export");
foreach ($a_files as $file)
{
$f_tpl->setCurrentBlock("file_row");
$f_tpl->setVariable("TITLE", $file["title"]);
$f_tpl->setVariable("TYPE", $lng->txt("obj_".$file["type"]));
$f_tpl->setVariable("FILE", $file["file"]);
$f_tpl->parseCurrentBlock();
}
$a_tpl->setContent($f_tpl->get());
$index_content = $a_tpl->get("DEFAULT", false, false, false, true, false, false);
$f = fopen ($a_filename, "w");
fwrite($f, $index_content);
fclose($f);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilExport::_getExportDirectory (   $a_obj_id,
  $a_type = "xml",
  $a_obj_type = "" 
)

Get export directory.

Parameters
integerObject ID
stringExport Type ("xml", "html", ...)
stringObject Type

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

References ilObject\_lookupType(), and ilUtil\getDataDir().

Referenced by ilCourseArchives\__addZipFiles(), _getExportFiles(), and ilObjGlossary\getExportDirectory().

{
if ($a_obj_type == "")
{
$a_obj_type = ilObject::_lookupType($a_obj_id);
}
if ($a_type != "xml")
{
$export_dir = ilUtil::getDataDir()."/".$a_obj_type."_data"."/".$a_obj_type."_".$a_obj_id."/export_".$a_type;
}
else
{
$export_dir = ilUtil::getDataDir()."/".$a_obj_type."_data"."/".$a_obj_type."_".$a_obj_id."/export";
}
return $export_dir;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilExport::_getExportFiles (   $a_obj_id,
  $a_export_types = "",
  $a_obj_type = "" 
)

Get Export Files.

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

References $dir, $file, $type, _getExportDirectory(), _getFileTypeString(), and ilObject\_lookupType().

Referenced by _getLastExportFileDate(), _getLastExportFileInformation(), and ilObjGlossary\getExportFiles().

{
if ($a_obj_type == "")
{
$a_obj_type = ilObject::_lookupType($a_obj_id);
}
if ($a_export_types == "")
{
$a_export_types = array("xml");
}
if (!is_array($a_export_types))
{
$a_export_types = array($a_export_types);
}
// initialize array
$file = array();
$types = $a_export_types;
foreach($types as $type)
{
$dir = ilExport::_getExportDirectory($a_obj_id, $type, $a_obj_type);
// quit if import dir not available
if (!@is_dir($dir) or
!is_writeable($dir))
{
continue;
}
// open directory
$h_dir = dir($dir);
// get files and save the in the array
while ($entry = $h_dir->read())
{
if ($entry != "." and
$entry != ".." and
substr($entry, -4) == ".zip" and
ereg("^[0-9]{10}_{2}[0-9]+_{2}(".ilExport::_getFileTypeString($a_obj_type)."_)*[0-9]+\.zip\$", $entry))
{
$ts = substr($entry, 0, strpos($entry, "__"));
$file[$entry.$type] = array("type" => $type, "file" => $entry,
"size" => filesize($dir."/".$entry),
"timestamp" => $ts);
}
}
// close import directory
$h_dir->close();
}
// sort files
ksort ($file);
reset ($file);
return $file;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilExport::_getFileTypeString (   $a_obj_type)
static

Get file type string.

Parameters
stringObject Type

Definition at line 27 of file class.ilExport.php.

Referenced by _getExportFiles().

{
if (!empty(self::$file_type_str[$a_obj_type]))
{
return self::$file_type_str[$a_obj_type];
}
else
{
return $a_obj_type;
}
}

+ Here is the caller graph for this function:

static ilExport::_getLastExportFileDate (   $a_obj_id,
  $a_type = "",
  $a_obj_type = "" 
)
static

Get date of last export file.

Definition at line 66 of file class.ilExport.php.

References $files, _getExportFiles(), and ilUtil\sortArray().

Referenced by _getValidExportSubItems().

{
$files = ilExport::_getExportFiles($a_obj_id, $a_type, $a_obj_type);
if (is_array($files))
{
$files = ilUtil::sortArray($files, "timestamp", "desc");
return $files[0]["timestamp"];
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilExport::_getLastExportFileInformation (   $a_obj_id,
  $a_type = "",
  $a_obj_type = "" 
)
static

Get last export file information.

Definition at line 80 of file class.ilExport.php.

References $files, _getExportFiles(), and ilUtil\sortArray().

Referenced by ilCourseArchives\__addZipFiles().

{
$files = ilExport::_getExportFiles($a_obj_id, $a_type, $a_obj_type);
if (is_array($files))
{
$files = ilUtil::sortArray($files, "timestamp", "desc");
return $files[0];
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilExport::_getValidExportSubItems (   $a_ref_id)
static

Get a list of subitems of a repository resource, that implement the export.

Includes also information on last export file.

Definition at line 43 of file class.ilExport.php.

References _getLastExportFileDate().

Referenced by ilSubItemSelectionTableGUI\ilSubItemSelectionTableGUI().

{
global $tree;
$valid_items = array();
$sub_items = $tree->getSubTree($tree->getNodeData($a_ref_id));
foreach ($sub_items as $sub_item)
{
if (in_array($sub_item["type"], self::$export_implementer))
{
$valid_items[] = array("type" => $sub_item["type"],
"title" => $sub_item["title"], "ref_id" => $sub_item["child"],
"obj_id" => $sub_item["obj_id"],
"timestamp" =>
ilExport::_getLastExportFileDate($sub_item["obj_id"], "xml", $sub_item["type"]));
}
}
return $valid_items;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilExport::$export_implementer = array("tst", "lm", "glo")
static

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

ilExport::$file_type_str = array("tst" => "test_")
static

Definition at line 20 of file class.ilExport.php.


The documentation for this class was generated from the following file: