ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

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  if ($a_obj_id) {
46  $this->export_dir .= "_" . $a_obj_id;
47  }
48  $this->init();
49  }
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 106 of file class.ilAdvancedMDRecordExportFiles.php.

References $ilLog, and time.

107  {
108  global $ilLog;
109 
110  if (!$fp = @fopen($this->export_dir . '/' . time() . '.xml', 'w+')) {
111  $ilLog->write(__METHOD__ . ': Cannot open file ' . $this->export_dir . '/' . time() . '.xml');
112 
113  require_once './Services/Exceptions/classes/class.ilException.php';
114  throw new ilException('Cannot write export file.');
115  }
116 
117  @fwrite($fp, $a_xml);
118  @fclose($fp);
119  }
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ deleteByFileId()

ilAdvancedMDRecordExportFiles::deleteByFileId (   $a_timest)

Delete by file id.

public

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

References $ilLog.

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

◆ getAbsolutePathByFileId()

ilAdvancedMDRecordExportFiles::getAbsolutePathByFileId (   $a_file_basename)

Get absolut path by file id.

public

Parameters
stringbasename of file

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

References $ilLog.

146  {
147  global $ilLog;
148 
149  if (!@file_exists($this->export_dir . '/' . $a_file_basename . '.xml')) {
150  $ilLog->write(__METHOD__ . ': Cannot find file ' . $this->export_dir . '/' . $a_file_basename . '.xml');
151  return false;
152  }
153  return $this->export_dir . '/' . $a_file_basename . '.xml';
154  }

◆ getFiles()

ilAdvancedMDRecordExportFiles::getFiles ( )

Get files.

public

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

References $files, array, and ilUtil\getDir().

Referenced by readFilesInfo().

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  }
$files
Definition: add-vimline.php:18
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
Create styles array
The data for the language used.
+ 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 162 of file class.ilAdvancedMDRecordExportFiles.php.

References ilUtil\makeDirParents().

Referenced by __construct().

163  {
164  if (!@is_dir($this->export_dir)) {
165  ilUtil::makeDirParents($this->export_dir);
166  }
167  }
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 57 of file class.ilAdvancedMDRecordExportFiles.php.

References $data, $name, $records, $title, $xml, array, getFiles(), and string.

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  }
Add rich text string
$records
Definition: simple_test.php:22
$xml
Definition: metadata.php:240
if($format !==null) $name
Definition: metadata.php:146
Create styles array
The data for the language used.
+ 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: