ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilAdvancedMDRecordExportFiles Class Reference
+ Collaboration diagram for ilAdvancedMDRecordExportFiles:

Public Member Functions

 __construct ()
 Constructor.
 readFilesInfo ()
 Read files info.
 getFiles ()
 Get files.
 create ($a_xml)
 Create new export file from xml string.
 deleteByFileId ($a_timest)
 Delete by file id.
 getAbsolutePathByFileId ($a_file_basename)
 Get absolut path by file id.

Protected Attributes

 $export_dir = ''

Private Member Functions

 init ()
 init export directory

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 32 of file class.ilAdvancedMDRecordExportFiles.php.

Constructor & Destructor Documentation

ilAdvancedMDRecordExportFiles::__construct ( )

Constructor.

public

Definition at line 42 of file class.ilAdvancedMDRecordExportFiles.php.

References ilUtil\getDataDir(), and init().

{
$this->export_dir = ilUtil::getDataDir().'/ilAdvancedMetaData/export';
$this->init();
}

+ Here is the call graph for this function:

Member Function Documentation

ilAdvancedMDRecordExportFiles::create (   $a_xml)

Create new export file from xml string.

public

Parameters
stringxml presentation

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

References $ilErr, and $ilLog.

{
global $ilLog,$ilErr;
if(!$fp = @fopen($this->export_dir.'/'.time().'.xml','w+'))
{
$ilLog->write(__METHOD__.': Cannot open file '.$this->export_dir.'/'.time().'.xml');
$ilErr->raiseError('Cannot write export file.',$ilErr->WARNING);
}
@fwrite($fp,$a_xml);
@fclose($fp);
}
ilAdvancedMDRecordExportFiles::deleteByFileId (   $a_timest)

Delete by file id.

public

Definition at line 130 of file class.ilAdvancedMDRecordExportFiles.php.

References $ilLog.

{
global $ilLog;
if(!unlink($this->export_dir.'/'.$a_timest.'.xml'))
{
$ilLog->write(__METHOD__.': Cannot delete file '.$this->export_dir.'/'.$a_timest.'.xml');
return false;
}
return true;
}
ilAdvancedMDRecordExportFiles::getAbsolutePathByFileId (   $a_file_basename)

Get absolut path by file id.

public

Parameters
stringbasename of file

Definition at line 149 of file class.ilAdvancedMDRecordExportFiles.php.

References $ilLog.

{
global $ilLog;
if(!@file_exists($this->export_dir.'/'.$a_file_basename.'.xml'))
{
$ilLog->write(__METHOD__.': Cannot find file '.$this->export_dir.'/'.$a_file_basename.'.xml');
return false;
}
return $this->export_dir.'/'.$a_file_basename.'.xml';
}
ilAdvancedMDRecordExportFiles::getFiles ( )

Get files.

public

Definition at line 90 of file class.ilAdvancedMDRecordExportFiles.php.

References ilUtil\getDir().

Referenced by readFilesInfo().

{
if(!@is_dir($this->export_dir))
{
return array();
}
foreach(ilUtil::getDir($this->export_dir) as $file_name => $file_data)
{
$files[$file_name] = $file_data;
}
return $files ? $files : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDRecordExportFiles::init ( )
private

init export directory

private

Definition at line 167 of file class.ilAdvancedMDRecordExportFiles.php.

References ilUtil\makeDirParents().

Referenced by __construct().

{
if(!@is_dir($this->export_dir))
{
ilUtil::makeDirParents($this->export_dir);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDRecordExportFiles::readFilesInfo ( )

Read files info.

public

Returns
array array e.g array(records => 'ECS-Server',size => '123',created' => 121212)

Definition at line 54 of file class.ilAdvancedMDRecordExportFiles.php.

References $data, $title, and getFiles().

{
$file_info = array();
foreach($this->getFiles() as $name => $data)
{
if($data['type'] != 'file')
{
continue;
}
$file_parts = explode('.',$name);
if(!is_numeric($file_parts[0]) or (strcmp('xml',$file_parts[1]) != 0))
{
continue;
}
$file_info[$file_parts[0]]['size'] = $data['size'];
$file_info[$file_parts[0]]['date'] = $file_parts[0];
if($xml = simplexml_load_file($this->export_dir.'/'.$name))
{
$records = array();
foreach($xml->xpath('Record/Title') as $title)
{
$records[] = (string) $title;
}
$file_info[$file_parts[0]]['name'] = $records;
}
}
return $file_info ? $file_info : array();
}

+ Here is the call graph for this function:

Field Documentation

ilAdvancedMDRecordExportFiles::$export_dir = ''
protected

Definition at line 34 of file class.ilAdvancedMDRecordExportFiles.php.


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