ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilAdvancedMDRecordExportFiles Class Reference
+ Collaboration diagram for ilAdvancedMDRecordExportFiles:

Public Member Functions

 __construct ($a_obj_id=null)
 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 (   $a_obj_id = null)

Constructor.

@access public

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

43 {
44 $this->export_dir = ilUtil::getDataDir().'/ilAdvancedMetaData/export';
45 if($a_obj_id)
46 {
47 $this->export_dir .= "_".$a_obj_id;
48 }
49 $this->init();
50 }
static getDataDir()
get data directory (outside webspace)

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

+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilAdvancedMDRecordExportFiles::create (   $a_xml)

Create new export file from xml string.

@access public

Parameters
stringxml presentation

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

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

References $ilErr, and $ilLog.

◆ deleteByFileId()

ilAdvancedMDRecordExportFiles::deleteByFileId (   $a_timest)

Delete by file id.

@access public

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

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

References $ilLog.

◆ getAbsolutePathByFileId()

ilAdvancedMDRecordExportFiles::getAbsolutePathByFileId (   $a_file_basename)

Get absolut path by file id.

@access public

Parameters
stringbasename of file

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

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

References $ilLog.

◆ getFiles()

ilAdvancedMDRecordExportFiles::getFiles ( )

Get files.

@access public

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

95 {
96 if(!@is_dir($this->export_dir))
97 {
98 return array();
99 }
100 foreach(ilUtil::getDir($this->export_dir) as $file_name => $file_data)
101 {
102 $files[$file_name] = $file_data;
103 }
104 return $files ? $files : array();
105 }
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory

References ilUtil\getDir().

Referenced by readFilesInfo().

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

◆ init()

ilAdvancedMDRecordExportFiles::init ( )
private

init export directory

@access private

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

172 {
173 if(!@is_dir($this->export_dir))
174 {
175 ilUtil::makeDirParents($this->export_dir);
176 }
177 }
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References ilUtil\makeDirParents().

Referenced by __construct().

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

◆ readFilesInfo()

ilAdvancedMDRecordExportFiles::readFilesInfo ( )

Read files info.

@access public

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

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

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

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

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