ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilAdvancedMDRecordExportFiles Class Reference
+ Collaboration diagram for ilAdvancedMDRecordExportFiles:

Public Member Functions

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

Protected Attributes

 $export_dir = ''
 

Private Member Functions

 init ()
 init export directory More...
 

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

◆ __construct()

ilAdvancedMDRecordExportFiles::__construct ( )

Constructor.

public

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

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

43  {
44  $this->export_dir = ilUtil::getDataDir().'/ilAdvancedMetaData/export';
45  $this->init();
46  }
static getDataDir()
get data directory (outside webspace)
+ Here is the call graph for this function:

Member Function Documentation

◆ create()

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.

111  {
112  global $ilLog,$ilErr;
113 
114  if(!$fp = @fopen($this->export_dir.'/'.time().'.xml','w+'))
115  {
116  $ilLog->write(__METHOD__.': Cannot open file '.$this->export_dir.'/'.time().'.xml');
117  $ilErr->raiseError('Cannot write export file.',$ilErr->WARNING);
118  }
119 
120  @fwrite($fp,$a_xml);
121  @fclose($fp);
122  }

◆ deleteByFileId()

ilAdvancedMDRecordExportFiles::deleteByFileId (   $a_timest)

Delete by file id.

public

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

References $ilLog.

131  {
132  global $ilLog;
133 
134  if(!unlink($this->export_dir.'/'.$a_timest.'.xml'))
135  {
136  $ilLog->write(__METHOD__.': Cannot delete file '.$this->export_dir.'/'.$a_timest.'.xml');
137  return false;
138  }
139  return true;
140  }

◆ getAbsolutePathByFileId()

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.

150  {
151  global $ilLog;
152 
153  if(!@file_exists($this->export_dir.'/'.$a_file_basename.'.xml'))
154  {
155  $ilLog->write(__METHOD__.': Cannot find file '.$this->export_dir.'/'.$a_file_basename.'.xml');
156  return false;
157  }
158  return $this->export_dir.'/'.$a_file_basename.'.xml';
159  }

◆ getFiles()

ilAdvancedMDRecordExportFiles::getFiles ( )

Get files.

public

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

References ilUtil\getDir().

Referenced by readFilesInfo().

91  {
92  if(!@is_dir($this->export_dir))
93  {
94  return array();
95  }
96  foreach(ilUtil::getDir($this->export_dir) as $file_name => $file_data)
97  {
98  $files[$file_name] = $file_data;
99  }
100  return $files ? $files : array();
101  }
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

ilAdvancedMDRecordExportFiles::init ( )
private

init export directory

private

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

References ilUtil\makeDirParents().

Referenced by __construct().

168  {
169  if(!@is_dir($this->export_dir))
170  {
171  ilUtil::makeDirParents($this->export_dir);
172  }
173  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readFilesInfo()

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, $records, and getFiles().

55  {
56  $file_info = array();
57  foreach($this->getFiles() as $name => $data)
58  {
59  if($data['type'] != 'file')
60  {
61  continue;
62  }
63  $file_parts = explode('.',$name);
64  if(!is_numeric($file_parts[0]) or (strcmp('xml',$file_parts[1]) != 0))
65  {
66  continue;
67  }
68  $file_info[$file_parts[0]]['size'] = $data['size'];
69  $file_info[$file_parts[0]]['date'] = $file_parts[0];
70 
71  if($xml = simplexml_load_file($this->export_dir.'/'.$name))
72  {
73  $records = array();
74  foreach($xml->xpath('Record/Title') as $title)
75  {
76  $records[] = (string) $title;
77  }
78  $file_info[$file_parts[0]]['name'] = $records;
79  }
80  }
81  return $file_info ? $file_info : array();
82  }
$records
Definition: simple_test.php:17
+ Here is the call graph for this function:

Field Documentation

◆ $export_dir

ilAdvancedMDRecordExportFiles::$export_dir = ''
protected

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


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