File Source for XMLWriter.php

PHPExcel_Shared

# Source for file XMLWriter.php

Documentation is available at XMLWriter.php

1. <?php
2. /**
3. * PHPExcel
4. *
5. * Copyright (c) 2006 - 2011 PHPExcel
6. *
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.
11. *
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.
16. *
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
20. *
21. * @category PHPExcel
22. * @package PHPExcel_Shared
23. * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25. * @version 1.7.6, 2011-02-27
26. */
28. if (! defined('DATE_W3C')) {
29. define('DATE_W3C', 'Y-m-d\TH:i:sP');
30. }
32. if (! defined('DEBUGMODE_ENABLED')) {
33. define('DEBUGMODE_ENABLED', false);
34. }
37. /**
38. * PHPExcel_Shared_XMLWriter
39. *
40. * @category PHPExcel
41. * @package PHPExcel_Shared
42. * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
43. */
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
51. *
52. * @var string
53. */
54. private $_tempFileName = '';
56. /**
57. * Create a new PHPExcel_Shared_XMLWriter instance
58. *
59. * @param int $pTemporaryStorage Temporary storage location
60. * @param string $pTemporaryStorageFolder Temporary storage folder
61. */
62. public function __construct($pTemporaryStorage = self:: STORAGE_MEMORY, $pTemporaryStorageFolder = './') {
63. // Open temporary storage
64. if ($pTemporaryStorage == self:: STORAGE_MEMORY) {
65. $this->openMemory();
66. } else {
67. // Create temporary filename
68. $this->_tempFileName = @ tempnam($pTemporaryStorageFolder, 'xml');
70. // Open storage
71. if ($this->openUri($this->_tempFileName) === false) {
72. // Fallback to memory...
73. $this->openMemory();
74. }
75. }
77. // Set default values
78. if ( DEBUGMODE_ENABLED) {
79. $this->setIndent(true);
80. }
81. }
83. /**
84. * Destructor
85. */
86. public function __destruct() {
87. // Unlink temporary files
88. if ($this->_tempFileName != '') {
89. @ unlink($this->_tempFileName);
90. }
91. }
93. /**
94. * Get written data
95. *
96. * @return $data
97. */
98. public function getData() {
99. if ($this->_tempFileName == '') {
100. return $this->outputMemory(true);
101. } else {
102. $this->flush();
103. return file_get_contents($this->_tempFileName);
104. }
105. }
107. /**
108. * Fallback method for writeRaw, introduced in PHP 5.2
109. *
110. * @param string $text
111. * @return string
112. */
113. public function writeRawData($text)
114. {
115. if ( method_exists($this, 'writeRaw')) {
116. return $this->writeRaw( htmlspecialchars($text));
117. }
119. return $this->text($text);
120. }
121. }

Documentation generated on Sun, 27 Feb 2011 16:37:30 -0800 by phpDocumentor 1.4.3