ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
XMLWriter.php
Go to the documentation of this file.
1 <?php
28 if (!defined('DATE_W3C')) {
29  define('DATE_W3C', 'Y-m-d\TH:i:sP');
30 }
31 
32 if (!defined('DEBUGMODE_ENABLED')) {
33  define('DEBUGMODE_ENABLED', false);
34 }
35 
36 
46  const STORAGE_MEMORY = 1;
47  const STORAGE_DISK = 2;
48 
54  private $_tempFileName = '';
55 
62  public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = NULL) {
63  // Open temporary storage
64  if ($pTemporaryStorage == self::STORAGE_MEMORY) {
65  $this->openMemory();
66  } else {
67  // Create temporary filename
68  if ($pTemporaryStorageFolder === NULL)
69  $pTemporaryStorageFolder = PHPExcel_Shared_File::sys_get_temp_dir();
70  $this->_tempFileName = @tempnam($pTemporaryStorageFolder, 'xml');
71 
72  // Open storage
73  if ($this->openUri($this->_tempFileName) === false) {
74  // Fallback to memory...
75  $this->openMemory();
76  }
77  }
78 
79  // Set default values
80  if (DEBUGMODE_ENABLED) {
81  $this->setIndent(true);
82  }
83  }
84 
88  public function __destruct() {
89  // Unlink temporary files
90  if ($this->_tempFileName != '') {
91  @unlink($this->_tempFileName);
92  }
93  }
94 
100  public function getData() {
101  if ($this->_tempFileName == '') {
102  return $this->outputMemory(true);
103  } else {
104  $this->flush();
105  return file_get_contents($this->_tempFileName);
106  }
107  }
108 
115  public function writeRawData($text)
116  {
117  if (is_array($text)) {
118  $text = implode("\n",$text);
119  }
120 
121  if (method_exists($this, 'writeRaw')) {
122  return $this->writeRaw(htmlspecialchars($text));
123  }
124 
125  return $this->text($text);
126  }
127 }
getData()
Get written data.
Definition: XMLWriter.php:100
__destruct()
Destructor.
Definition: XMLWriter.php:88
writeRawData($text)
Fallback method for writeRaw, introduced in PHP 5.2.
Definition: XMLWriter.php:115
static sys_get_temp_dir()
Get the systems temporary directory.
Definition: File.php:135
$text
Definition: errorreport.php:18
__construct($pTemporaryStorage=self::STORAGE_MEMORY, $pTemporaryStorageFolder=NULL)
Create a new PHPExcel_Shared_XMLWriter instance.
Definition: XMLWriter.php:62
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
const STORAGE_MEMORY
Temporary storage method.
Definition: XMLWriter.php:46