123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php
- if (!defined('DATE_W3C')) {
- define('DATE_W3C', 'Y-m-d\TH:i:sP');
- }
- if (!defined('DEBUGMODE_ENABLED')) {
- define('DEBUGMODE_ENABLED', false);
- }
- class PHPExcel_Shared_XMLWriter extends XMLWriter
- {
-
- const STORAGE_MEMORY = 1;
- const STORAGE_DISK = 2;
-
- private $tempFileName = '';
-
- public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = null)
- {
-
- if ($pTemporaryStorage == self::STORAGE_MEMORY) {
- $this->openMemory();
- } else {
-
- if ($pTemporaryStorageFolder === null) {
- $pTemporaryStorageFolder = PHPExcel_Shared_File::sys_get_temp_dir();
- }
- $this->tempFileName = @tempnam($pTemporaryStorageFolder, 'xml');
-
- if ($this->openUri($this->tempFileName) === false) {
-
- $this->openMemory();
- }
- }
-
- if (DEBUGMODE_ENABLED) {
- $this->setIndent(true);
- }
- }
-
- public function __destruct()
- {
-
- if ($this->tempFileName != '') {
- @unlink($this->tempFileName);
- }
- }
-
- public function getData()
- {
- if ($this->tempFileName == '') {
- return $this->outputMemory(true);
- } else {
- $this->flush();
- return file_get_contents($this->tempFileName);
- }
- }
-
- public function writeRawData($text)
- {
- if (is_array($text)) {
- $text = implode("\n", $text);
- }
- if (method_exists($this, 'writeRaw')) {
- return $this->writeRaw(htmlspecialchars($text));
- }
- return $this->text($text);
- }
- }
|