ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $this->export_dir .= "_" . $a_obj_id;
47 }
48 $this->init();
49 }
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 106 of file class.ilAdvancedMDRecordExportFiles.php.

107 {
108 global $DIC;
109
110 $ilLog = $DIC['ilLog'];
111
112 if (!$fp = @fopen($this->export_dir . '/' . time() . '.xml', 'w+')) {
113 $ilLog->write(__METHOD__ . ': Cannot open file ' . $this->export_dir . '/' . time() . '.xml');
114
115 require_once './Services/Exceptions/classes/class.ilException.php';
116 throw new ilException('Cannot write export file.');
117 }
118
119 @fwrite($fp, $a_xml);
120 @fclose($fp);
121 }
Base class for ILIAS Exception handling.
global $DIC
Definition: saml.php:7

References $DIC, and $ilLog.

◆ deleteByFileId()

ilAdvancedMDRecordExportFiles::deleteByFileId (   $a_timest)

Delete by file id.

@access public

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

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

References $DIC, and $ilLog.

◆ getAbsolutePathByFileId()

ilAdvancedMDRecordExportFiles::getAbsolutePathByFileId (   $a_file_basename)

Get absolut path by file id.

@access public

Parameters
stringbasename of file

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

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

References $DIC, and $ilLog.

◆ getFiles()

ilAdvancedMDRecordExportFiles::getFiles ( )

Get files.

@access public

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

89 {
90 if (!@is_dir($this->export_dir)) {
91 return array();
92 }
93 foreach (ilUtil::getDir($this->export_dir) as $file_name => $file_data) {
94 $files[$file_name] = $file_data;
95 }
96 return $files ? $files : array();
97 }
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
$files
Definition: metarefresh.php:49

References $files, and 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 168 of file class.ilAdvancedMDRecordExportFiles.php.

169 {
170 if (!@is_dir($this->export_dir)) {
171 ilUtil::makeDirParents($this->export_dir);
172 }
173 }
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 57 of file class.ilAdvancedMDRecordExportFiles.php.

58 {
59 $file_info = array();
60 foreach ($this->getFiles() as $name => $data) {
61 if ($data['type'] != 'file') {
62 continue;
63 }
64 $file_parts = explode('.', $name);
65 if (!is_numeric($file_parts[0]) or (strcmp('xml', $file_parts[1]) != 0)) {
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 $records = array();
73 foreach ($xml->xpath('Record/Title') as $title) {
74 $records[] = (string) $title;
75 }
76 $file_info[$file_parts[0]]['name'] = $records;
77 }
78 }
79 return $file_info ? $file_info : array();
80 }
$records
Definition: simple_test.php:22
$data
Definition: bench.php:6

References $data, $name, $records, $title, $xml, 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: