Updated gui for user facility settings (#1327)
[openemr.git] / vendor / phpoffice / phpexcel / Classes / PHPExcel / Shared / XMLWriter.php
blobbeca51fc5871e09f1562c8cfc2349ff2d5b98de1
1 <?php
2 /**
3 * PHPExcel
5 * Copyright (c) 2006 - 2014 PHPExcel
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * @category PHPExcel
22 * @package PHPExcel_Shared
23 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
24 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25 * @version ##VERSION##, ##DATE##
28 if (!defined('DATE_W3C')) {
29 define('DATE_W3C', 'Y-m-d\TH:i:sP');
32 if (!defined('DEBUGMODE_ENABLED')) {
33 define('DEBUGMODE_ENABLED', false);
37 /**
38 * PHPExcel_Shared_XMLWriter
40 * @category PHPExcel
41 * @package PHPExcel_Shared
42 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
44 class PHPExcel_Shared_XMLWriter extends XMLWriter {
45 /** Temporary storage method */
46 const STORAGE_MEMORY = 1;
47 const STORAGE_DISK = 2;
49 /**
50 * Temporary filename
52 * @var string
54 private $_tempFileName = '';
56 /**
57 * Create a new PHPExcel_Shared_XMLWriter instance
59 * @param int $pTemporaryStorage Temporary storage location
60 * @param string $pTemporaryStorageFolder Temporary storage folder
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');
72 // Open storage
73 if ($this->openUri($this->_tempFileName) === false) {
74 // Fallback to memory...
75 $this->openMemory();
79 // Set default values
80 if (DEBUGMODE_ENABLED) {
81 $this->setIndent(true);
85 /**
86 * Destructor
88 public function __destruct() {
89 // Unlink temporary files
90 if ($this->_tempFileName != '') {
91 @unlink($this->_tempFileName);
95 /**
96 * Get written data
98 * @return $data
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);
110 * Fallback method for writeRaw, introduced in PHP 5.2
112 * @param string $text
113 * @return string
115 public function writeRawData($text)
117 if (is_array($text)) {
118 $text = implode("\n",$text);
121 if (method_exists($this, 'writeRaw')) {
122 return $this->writeRaw(htmlspecialchars($text));
125 return $this->text($text);