Change all incorrect capitalization of the Tz\Wordpress namespace to Tz\WordPress
Showing
55 changed files
with
451 additions
and
451 deletions
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | * PHPExcel | 3 | * PHPExcel |
| 4 | * | 4 | * |
| 5 | * Copyright (c) 2006 - 2011 PHPExcel | 5 | * Copyright (c) 2006 - 2011 PHPExcel |
| 6 | * | 6 | * |
| 7 | * This library is free software; you can redistribute it and/or | 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public | 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation; either | 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2.1 of the License, or (at your option) any later version. | 10 | * version 2.1 of the License, or (at your option) any later version. |
| 11 | * | 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, | 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. | 15 | * Lesser General Public License for more details. |
| 16 | * | 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public | 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 | 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 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | * | 20 | * |
| 21 | * @category PHPExcel | 21 | * @category PHPExcel |
| 22 | * @package PHPExcel_CachedObjectStorage | 22 | * @package PHPExcel_CachedObjectStorage |
| 23 | * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | 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 | 24 | * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL |
| 25 | * @version 1.7.6, 2011-02-27 | 25 | * @version 1.7.6, 2011-02-27 |
| 26 | */ | 26 | */ |
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | /** | 29 | /** |
| 30 | * PHPExcel_CachedObjectStorage_CacheBase | 30 | * PHPExcel_CachedObjectStorage_CacheBase |
| 31 | * | 31 | * |
| 32 | * @category PHPExcel | 32 | * @category PHPExcel |
| 33 | * @package PHPExcel_CachedObjectStorage | 33 | * @package PHPExcel_CachedObjectStorage |
| 34 | * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | 34 | * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) |
| 35 | */ | 35 | */ |
| 36 | class PHPExcel_CachedObjectStorage_CacheBase { | 36 | class PHPExcel_CachedObjectStorage_CacheBase { |
| 37 | 37 | ||
| 38 | /** | 38 | /** |
| 39 | * Parent worksheet | 39 | * Parent worksheet |
| 40 | * | 40 | * |
| 41 | * @var PHPExcel_Worksheet | 41 | * @var PHPExcel_Worksheet |
| 42 | */ | 42 | */ |
| 43 | protected $_parent; | 43 | protected $_parent; |
| 44 | 44 | ||
| 45 | /** | 45 | /** |
| 46 | * The currently active Cell | 46 | * The currently active Cell |
| 47 | * | 47 | * |
| 48 | * @var PHPExcel_Cell | 48 | * @var PHPExcel_Cell |
| 49 | */ | 49 | */ |
| 50 | protected $_currentObject = null; | 50 | protected $_currentObject = null; |
| 51 | 51 | ||
| 52 | /** | 52 | /** |
| 53 | * Coordinate address of the currently active Cell | 53 | * Coordinate address of the currently active Cell |
| 54 | * | 54 | * |
| 55 | * @var string | 55 | * @var string |
| 56 | */ | 56 | */ |
| 57 | protected $_currentObjectID = null; | 57 | protected $_currentObjectID = null; |
| 58 | 58 | ||
| 59 | 59 | ||
| 60 | /** | 60 | /** |
| 61 | * An array of cells or cell pointers for the worksheet cells held in this cache, | 61 | * An array of cells or cell pointers for the worksheet cells held in this cache, |
| 62 | * and indexed by their coordinate address within the worksheet | 62 | * and indexed by their coordinate address within the worksheet |
| 63 | * | 63 | * |
| 64 | * @var array of mixed | 64 | * @var array of mixed |
| 65 | */ | 65 | */ |
| 66 | protected $_cellCache = array(); | 66 | protected $_cellCache = array(); |
| 67 | 67 | ||
| 68 | 68 | ||
| 69 | public function __construct(Tz\Wordpress\Tools\ExcelWriter\PHPExcel_Worksheet $parent) { | 69 | public function __construct(Tz\WordPress\Tools\ExcelWriter\PHPExcel_Worksheet $parent) { |
| 70 | // Set our parent worksheet. | 70 | // Set our parent worksheet. |
| 71 | // This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when | 71 | // This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when |
| 72 | // they are woken from a serialized state | 72 | // they are woken from a serialized state |
| 73 | $this->_parent = $parent; | 73 | $this->_parent = $parent; |
| 74 | } // function __construct() | 74 | } // function __construct() |
| 75 | 75 | ||
| 76 | 76 | ||
| 77 | /** | 77 | /** |
| 78 | * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? | 78 | * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? |
| 79 | * | 79 | * |
| 80 | * @param string $pCoord Coordinate address of the cell to check | 80 | * @param string $pCoord Coordinate address of the cell to check |
| 81 | * @return void | 81 | * @return void |
| 82 | * @return boolean | 82 | * @return boolean |
| 83 | */ | 83 | */ |
| 84 | public function isDataSet($pCoord) { | 84 | public function isDataSet($pCoord) { |
| 85 | if ($pCoord === $this->_currentObjectID) { | 85 | if ($pCoord === $this->_currentObjectID) { |
| 86 | return true; | 86 | return true; |
| 87 | } | 87 | } |
| 88 | // Check if the requested entry exists in the cache | 88 | // Check if the requested entry exists in the cache |
| 89 | return isset($this->_cellCache[$pCoord]); | 89 | return isset($this->_cellCache[$pCoord]); |
| 90 | } // function isDataSet() | 90 | } // function isDataSet() |
| 91 | 91 | ||
| 92 | 92 | ||
| 93 | /** | 93 | /** |
| 94 | * Add or Update a cell in cache | 94 | * Add or Update a cell in cache |
| 95 | * | 95 | * |
| 96 | * @param PHPExcel_Cell $cell Cell to update | 96 | * @param PHPExcel_Cell $cell Cell to update |
| 97 | * @return void | 97 | * @return void |
| 98 | * @throws Exception | 98 | * @throws Exception |
| 99 | */ | 99 | */ |
| 100 | public function updateCacheData(Tz\Wordpress\Tools\ExcelWriter\PHPExcel_Cell $cell) { | 100 | public function updateCacheData(Tz\WordPress\Tools\ExcelWriter\PHPExcel_Cell $cell) { |
| 101 | return $this->addCacheData($cell->getCoordinate(),$cell); | 101 | return $this->addCacheData($cell->getCoordinate(),$cell); |
| 102 | } // function updateCacheData() | 102 | } // function updateCacheData() |
| 103 | 103 | ||
| 104 | 104 | ||
| 105 | /** | 105 | /** |
| 106 | * Delete a cell in cache identified by coordinate address | 106 | * Delete a cell in cache identified by coordinate address |
| 107 | * | 107 | * |
| 108 | * @param string $pCoord Coordinate address of the cell to delete | 108 | * @param string $pCoord Coordinate address of the cell to delete |
| 109 | * @throws Exception | 109 | * @throws Exception |
| 110 | */ | 110 | */ |
| 111 | public function deleteCacheData($pCoord) { | 111 | public function deleteCacheData($pCoord) { |
| 112 | if ($pCoord === $this->_currentObjectID) { | 112 | if ($pCoord === $this->_currentObjectID) { |
| 113 | $this->_currentObject->detach(); | 113 | $this->_currentObject->detach(); |
| 114 | $this->_currentObjectID = $this->_currentObject = null; | 114 | $this->_currentObjectID = $this->_currentObject = null; |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | if (is_object($this->_cellCache[$pCoord])) { | 117 | if (is_object($this->_cellCache[$pCoord])) { |
| 118 | $this->_cellCache[$pCoord]->detach(); | 118 | $this->_cellCache[$pCoord]->detach(); |
| 119 | unset($this->_cellCache[$pCoord]); | 119 | unset($this->_cellCache[$pCoord]); |
| 120 | } | 120 | } |
| 121 | } // function deleteCacheData() | 121 | } // function deleteCacheData() |
| 122 | 122 | ||
| 123 | 123 | ||
| 124 | /** | 124 | /** |
| 125 | * Get a list of all cell addresses currently held in cache | 125 | * Get a list of all cell addresses currently held in cache |
| 126 | * | 126 | * |
| 127 | * @return array of string | 127 | * @return array of string |
| 128 | */ | 128 | */ |
| 129 | public function getCellList() { | 129 | public function getCellList() { |
| 130 | return array_keys($this->_cellCache); | 130 | return array_keys($this->_cellCache); |
| 131 | } // function getCellList() | 131 | } // function getCellList() |
| 132 | 132 | ||
| 133 | 133 | ||
| 134 | /** | 134 | /** |
| 135 | * Sort the list of all cell addresses currently held in cache by row and column | 135 | * Sort the list of all cell addresses currently held in cache by row and column |
| 136 | * | 136 | * |
| 137 | * @return void | 137 | * @return void |
| 138 | */ | 138 | */ |
| 139 | public function getSortedCellList() { | 139 | public function getSortedCellList() { |
| 140 | $sortKeys = array(); | 140 | $sortKeys = array(); |
| 141 | foreach (array_keys($this->_cellCache) as $coord) { | 141 | foreach (array_keys($this->_cellCache) as $coord) { |
| 142 | list($column,$row) = sscanf($coord,'%[A-Z]%d'); | 142 | list($column,$row) = sscanf($coord,'%[A-Z]%d'); |
| 143 | $sortKeys[sprintf('%09d%3s',$row,$column)] = $coord; | 143 | $sortKeys[sprintf('%09d%3s',$row,$column)] = $coord; |
| 144 | } | 144 | } |
| 145 | ksort($sortKeys); | 145 | ksort($sortKeys); |
| 146 | 146 | ||
| 147 | return array_values($sortKeys); | 147 | return array_values($sortKeys); |
| 148 | } // function sortCellList() | 148 | } // function sortCellList() |
| 149 | 149 | ||
| 150 | 150 | ||
| 151 | protected function _getUniqueID() { | 151 | protected function _getUniqueID() { |
| 152 | if (function_exists('posix_getpid')) { | 152 | if (function_exists('posix_getpid')) { |
| 153 | $baseUnique = posix_getpid(); | 153 | $baseUnique = posix_getpid(); |
| 154 | } else { | 154 | } else { |
| 155 | $baseUnique = mt_rand(); | 155 | $baseUnique = mt_rand(); |
| 156 | } | 156 | } |
| 157 | return uniqid($baseUnique,true); | 157 | return uniqid($baseUnique,true); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | /** | 160 | /** |
| 161 | * Clone the cell collection | 161 | * Clone the cell collection |
| 162 | * | 162 | * |
| 163 | * @return void | 163 | * @return void |
| 164 | */ | 164 | */ |
| 165 | public function copyCellCollection(PHPExcel_Worksheet $parent) { | 165 | public function copyCellCollection(PHPExcel_Worksheet $parent) { |
| 166 | $this->_parent = $parent; | 166 | $this->_parent = $parent; |
| 167 | if ((!is_null($this->_currentObject)) && (is_object($this->_currentObject))) { | 167 | if ((!is_null($this->_currentObject)) && (is_object($this->_currentObject))) { |
| 168 | $this->_currentObject->attach($parent); | 168 | $this->_currentObject->attach($parent); |
| 169 | } | 169 | } |
| 170 | } // function copyCellCollection() | 170 | } // function copyCellCollection() |
| 171 | 171 | ||
| 172 | } | 172 | } | ... | ... |
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | * PHPExcel | 3 | * PHPExcel |
| 4 | * | 4 | * |
| 5 | * Copyright (c) 2006 - 2011 PHPExcel | 5 | * Copyright (c) 2006 - 2011 PHPExcel |
| 6 | * | 6 | * |
| 7 | * This library is free software; you can redistribute it and/or | 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public | 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation; either | 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2.1 of the License, or (at your option) any later version. | 10 | * version 2.1 of the License, or (at your option) any later version. |
| 11 | * | 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, | 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. | 15 | * Lesser General Public License for more details. |
| 16 | * | 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public | 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 | 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 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | * | 20 | * |
| 21 | * @category PHPExcel | 21 | * @category PHPExcel |
| 22 | * @package PHPExcel_CachedObjectStorage | 22 | * @package PHPExcel_CachedObjectStorage |
| 23 | * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | 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 | 24 | * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL |
| 25 | * @version 1.7.6, 2011-02-27 | 25 | * @version 1.7.6, 2011-02-27 |
| 26 | */ | 26 | */ |
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | /** | 29 | /** |
| 30 | * PHPExcel_CachedObjectStorage_Memory | 30 | * PHPExcel_CachedObjectStorage_Memory |
| 31 | * | 31 | * |
| 32 | * @category PHPExcel | 32 | * @category PHPExcel |
| 33 | * @package PHPExcel_CachedObjectStorage | 33 | * @package PHPExcel_CachedObjectStorage |
| 34 | * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | 34 | * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) |
| 35 | */ | 35 | */ |
| 36 | class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { | 36 | class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { |
| 37 | 37 | ||
| 38 | /** | 38 | /** |
| 39 | * Add or Update a cell in cache identified by coordinate address | 39 | * Add or Update a cell in cache identified by coordinate address |
| 40 | * | 40 | * |
| 41 | * @param string $pCoord Coordinate address of the cell to update | 41 | * @param string $pCoord Coordinate address of the cell to update |
| 42 | * @param PHPExcel_Cell $cell Cell to update | 42 | * @param PHPExcel_Cell $cell Cell to update |
| 43 | * @return void | 43 | * @return void |
| 44 | * @throws Exception | 44 | * @throws Exception |
| 45 | */ | 45 | */ |
| 46 | public function addCacheData($pCoord, Tz\Wordpress\Tools\ExcelWriter\PHPExcel_Cell $cell) { | 46 | public function addCacheData($pCoord, Tz\WordPress\Tools\ExcelWriter\PHPExcel_Cell $cell) { |
| 47 | $this->_cellCache[$pCoord] = $cell; | 47 | $this->_cellCache[$pCoord] = $cell; |
| 48 | return $cell; | 48 | return $cell; |
| 49 | } // function addCacheData() | 49 | } // function addCacheData() |
| 50 | 50 | ||
| 51 | 51 | ||
| 52 | /** | 52 | /** |
| 53 | * Get cell at a specific coordinate | 53 | * Get cell at a specific coordinate |
| 54 | * | 54 | * |
| 55 | * @param string $pCoord Coordinate of the cell | 55 | * @param string $pCoord Coordinate of the cell |
| 56 | * @throws Exception | 56 | * @throws Exception |
| 57 | * @return PHPExcel_Cell Cell that was found, or null if not found | 57 | * @return PHPExcel_Cell Cell that was found, or null if not found |
| 58 | */ | 58 | */ |
| 59 | public function getCacheData($pCoord) { | 59 | public function getCacheData($pCoord) { |
| 60 | // Check if the entry that has been requested actually exists | 60 | // Check if the entry that has been requested actually exists |
| 61 | if (!isset($this->_cellCache[$pCoord])) { | 61 | if (!isset($this->_cellCache[$pCoord])) { |
| 62 | // Return null if requested entry doesn't exist in cache | 62 | // Return null if requested entry doesn't exist in cache |
| 63 | return null; | 63 | return null; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | // Return requested entry | 66 | // Return requested entry |
| 67 | return $this->_cellCache[$pCoord]; | 67 | return $this->_cellCache[$pCoord]; |
| 68 | } // function getCacheData() | 68 | } // function getCacheData() |
| 69 | 69 | ||
| 70 | 70 | ||
| 71 | public function copyCellCollection(PHPExcel_Worksheet $parent) { | 71 | public function copyCellCollection(PHPExcel_Worksheet $parent) { |
| 72 | parent::copyCellCollection($parent); | 72 | parent::copyCellCollection($parent); |
| 73 | 73 | ||
| 74 | $newCollection = array(); | 74 | $newCollection = array(); |
| 75 | foreach($this->_cellCache as $k => &$cell) { | 75 | foreach($this->_cellCache as $k => &$cell) { |
| 76 | $newCollection[$k] = clone $cell; | 76 | $newCollection[$k] = clone $cell; |
| 77 | $newCollection[$k]->attach($parent); | 77 | $newCollection[$k]->attach($parent); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | $this->_cellCache = $newCollection; | 80 | $this->_cellCache = $newCollection; |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | 83 | ||
| 84 | public function unsetWorksheetCells() { | 84 | public function unsetWorksheetCells() { |
| 85 | // Because cells are all stored as intact objects in memory, we need to detach each one from the parent | 85 | // Because cells are all stored as intact objects in memory, we need to detach each one from the parent |
| 86 | foreach($this->_cellCache as $k => &$cell) { | 86 | foreach($this->_cellCache as $k => &$cell) { |
| 87 | $cell->detach(); | 87 | $cell->detach(); |
| 88 | $this->_cellCache[$k] = null; | 88 | $this->_cellCache[$k] = null; |
| 89 | } | 89 | } |
| 90 | unset($cell); | 90 | unset($cell); |
| 91 | 91 | ||
| 92 | $this->_cellCache = array(); | 92 | $this->_cellCache = array(); |
| 93 | 93 | ||
| 94 | // detach ourself from the worksheet, so that it can then delete this object successfully | 94 | // detach ourself from the worksheet, so that it can then delete this object successfully |
| 95 | $this->_parent = null; | 95 | $this->_parent = null; |
| 96 | } // function unsetWorksheetCells() | 96 | } // function unsetWorksheetCells() |
| 97 | 97 | ||
| 98 | } | 98 | } | ... | ... |
| 1 | <?php | 1 | <?php |
| 2 | namespace Tz\Wordpress\Tools\ExcelWriter; | 2 | namespace Tz\WordPress\Tools\ExcelWriter; |
| 3 | 3 | ||
| 4 | class PHPExcel_CachedObjectStorageFactory { | 4 | class PHPExcel_CachedObjectStorageFactory { |
| 5 | const cache_in_memory = 'Memory'; | 5 | const cache_in_memory = 'Memory'; |
| 6 | const cache_in_memory_gzip = 'MemoryGZip'; | 6 | const cache_in_memory_gzip = 'MemoryGZip'; |
| 7 | const cache_in_memory_serialized = 'MemorySerialized'; | 7 | const cache_in_memory_serialized = 'MemorySerialized'; |
| 8 | const cache_to_discISAM = 'DiscISAM'; | 8 | const cache_to_discISAM = 'DiscISAM'; |
| 9 | const cache_to_apc = 'APC'; | 9 | const cache_to_apc = 'APC'; |
| 10 | const cache_to_memcache = 'Memcache'; | 10 | const cache_to_memcache = 'Memcache'; |
| 11 | const cache_to_phpTemp = 'PHPTemp'; | 11 | const cache_to_phpTemp = 'PHPTemp'; |
| 12 | const cache_to_wincache = 'Wincache'; | 12 | const cache_to_wincache = 'Wincache'; |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | private static $_cacheStorageMethod = null; | 15 | private static $_cacheStorageMethod = null; |
| 16 | 16 | ||
| 17 | private static $_cacheStorageClass = null; | 17 | private static $_cacheStorageClass = null; |
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | private static $_storageMethods = array( | 20 | private static $_storageMethods = array( |
| 21 | self::cache_in_memory, | 21 | self::cache_in_memory, |
| 22 | self::cache_in_memory_gzip, | 22 | self::cache_in_memory_gzip, |
| 23 | self::cache_in_memory_serialized, | 23 | self::cache_in_memory_serialized, |
| 24 | self::cache_to_phpTemp, | 24 | self::cache_to_phpTemp, |
| 25 | self::cache_to_discISAM, | 25 | self::cache_to_discISAM, |
| 26 | self::cache_to_apc, | 26 | self::cache_to_apc, |
| 27 | self::cache_to_memcache, | 27 | self::cache_to_memcache, |
| 28 | self::cache_to_wincache, | 28 | self::cache_to_wincache, |
| 29 | ); | 29 | ); |
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | private static $_storageMethodDefaultParameters = array( | 32 | private static $_storageMethodDefaultParameters = array( |
| 33 | self::cache_in_memory => array( | 33 | self::cache_in_memory => array( |
| 34 | ), | 34 | ), |
| 35 | self::cache_in_memory_gzip => array( | 35 | self::cache_in_memory_gzip => array( |
| 36 | ), | 36 | ), |
| 37 | self::cache_in_memory_serialized => array( | 37 | self::cache_in_memory_serialized => array( |
| 38 | ), | 38 | ), |
| 39 | self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB' | 39 | self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB' |
| 40 | ), | 40 | ), |
| 41 | self::cache_to_discISAM => array( | 41 | self::cache_to_discISAM => array( |
| 42 | ), | 42 | ), |
| 43 | self::cache_to_apc => array( 'cacheTime' => 600 | 43 | self::cache_to_apc => array( 'cacheTime' => 600 |
| 44 | ), | 44 | ), |
| 45 | self::cache_to_memcache => array( 'memcacheServer' => 'localhost', | 45 | self::cache_to_memcache => array( 'memcacheServer' => 'localhost', |
| 46 | 'memcachePort' => 11211, | 46 | 'memcachePort' => 11211, |
| 47 | 'cacheTime' => 600 | 47 | 'cacheTime' => 600 |
| 48 | ), | 48 | ), |
| 49 | self::cache_to_wincache => array( 'cacheTime' => 600 | 49 | self::cache_to_wincache => array( 'cacheTime' => 600 |
| 50 | ) | 50 | ) |
| 51 | ); | 51 | ); |
| 52 | 52 | ||
| 53 | 53 | ||
| 54 | private static $_storageMethodParameters = array(); | 54 | private static $_storageMethodParameters = array(); |
| 55 | 55 | ||
| 56 | 56 | ||
| 57 | public static function getCacheStorageMethod() { | 57 | public static function getCacheStorageMethod() { |
| 58 | if (!is_null(self::$_cacheStorageMethod)) { | 58 | if (!is_null(self::$_cacheStorageMethod)) { |
| 59 | return self::$_cacheStorageMethod; | 59 | return self::$_cacheStorageMethod; |
| 60 | } | 60 | } |
| 61 | return null; | 61 | return null; |
| 62 | } // function getCacheStorageMethod() | 62 | } // function getCacheStorageMethod() |
| 63 | 63 | ||
| 64 | 64 | ||
| 65 | public static function getCacheStorageClass() { | 65 | public static function getCacheStorageClass() { |
| 66 | if (!is_null(self::$_cacheStorageClass)) { | 66 | if (!is_null(self::$_cacheStorageClass)) { |
| 67 | return self::$_cacheStorageClass; | 67 | return self::$_cacheStorageClass; |
| 68 | } | 68 | } |
| 69 | return null; | 69 | return null; |
| 70 | } // function getCacheStorageClass() | 70 | } // function getCacheStorageClass() |
| 71 | 71 | ||
| 72 | 72 | ||
| 73 | public static function getCacheStorageMethods() { | 73 | public static function getCacheStorageMethods() { |
| 74 | return self::$_storageMethods; | 74 | return self::$_storageMethods; |
| 75 | } // function getCacheStorageMethods() | 75 | } // function getCacheStorageMethods() |
| 76 | 76 | ||
| 77 | 77 | ||
| 78 | public static function initialize($method = self::cache_in_memory, $arguments = array()) { | 78 | public static function initialize($method = self::cache_in_memory, $arguments = array()) { |
| 79 | if (!in_array($method,self::$_storageMethods)) { | 79 | if (!in_array($method,self::$_storageMethods)) { |
| 80 | return false; | 80 | return false; |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | switch($method) { | 83 | switch($method) { |
| 84 | case self::cache_to_apc : | 84 | case self::cache_to_apc : |
| 85 | if (!function_exists('apc_store')) { | 85 | if (!function_exists('apc_store')) { |
| 86 | return false; | 86 | return false; |
| 87 | } | 87 | } |
| 88 | if (apc_sma_info() === false) { | 88 | if (apc_sma_info() === false) { |
| 89 | return false; | 89 | return false; |
| 90 | } | 90 | } |
| 91 | break; | 91 | break; |
| 92 | case self::cache_to_memcache : | 92 | case self::cache_to_memcache : |
| 93 | if (!function_exists('memcache_add')) { | 93 | if (!function_exists('memcache_add')) { |
| 94 | return false; | 94 | return false; |
| 95 | } | 95 | } |
| 96 | break; | 96 | break; |
| 97 | case self::cache_to_wincache : | 97 | case self::cache_to_wincache : |
| 98 | if (!function_exists('wincache_ucache_add')) { | 98 | if (!function_exists('wincache_ucache_add')) { |
| 99 | return false; | 99 | return false; |
| 100 | } | 100 | } |
| 101 | break; | 101 | break; |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method]; | 104 | self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method]; |
| 105 | foreach($arguments as $k => $v) { | 105 | foreach($arguments as $k => $v) { |
| 106 | if (isset(self::$_storageMethodParameters[$method][$k])) { | 106 | if (isset(self::$_storageMethodParameters[$method][$k])) { |
| 107 | self::$_storageMethodParameters[$method][$k] = $v; | 107 | self::$_storageMethodParameters[$method][$k] = $v; |
| 108 | } | 108 | } |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | if (is_null(self::$_cacheStorageMethod)) { | 111 | if (is_null(self::$_cacheStorageMethod)) { |
| 112 | self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method; | 112 | self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method; |
| 113 | self::$_cacheStorageMethod = $method; | 113 | self::$_cacheStorageMethod = $method; |
| 114 | } | 114 | } |
| 115 | return true; | 115 | return true; |
| 116 | } // function initialize() | 116 | } // function initialize() |
| 117 | 117 | ||
| 118 | 118 | ||
| 119 | public static function getInstance(PHPExcel_Worksheet $parent) { | 119 | public static function getInstance(PHPExcel_Worksheet $parent) { |
| 120 | if (is_null(self::$_cacheStorageMethod)) { | 120 | if (is_null(self::$_cacheStorageMethod)) { |
| 121 | self::initialize(); | 121 | self::initialize(); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | $instance = new self::$_cacheStorageClass($parent,self::$_storageMethodParameters[self::$_cacheStorageMethod]); | 124 | $instance = new self::$_cacheStorageClass($parent,self::$_storageMethodParameters[self::$_cacheStorageMethod]); |
| 125 | if (!is_null($instance)) { | 125 | if (!is_null($instance)) { |
| 126 | return $instance; | 126 | return $instance; |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | return false; | 129 | return false; |
| 130 | } // function getInstance() | 130 | } // function getInstance() |
| 131 | 131 | ||
| 132 | } | 132 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | <?php | 1 | <?php |
| 2 | namespace Tz\Wordpress\Tools\ExcelWriter; | 2 | namespace Tz\WordPress\Tools\ExcelWriter; |
| 3 | /* vim: set expandtab tabstop=4 shiftwidth=4: */ | 3 | /* vim: set expandtab tabstop=4 shiftwidth=4: */ |
| 4 | // +----------------------------------------------------------------------+ | 4 | // +----------------------------------------------------------------------+ |
| 5 | // | PHP Version 4 | | 5 | // | PHP Version 4 | | ... | ... |
| 1 | <?php | 1 | <?php |
| 2 | namespace Tz\Wordpress\Tools\ExcelWriter; | 2 | namespace Tz\WordPress\Tools\ExcelWriter; |
| 3 | /* vim: set expandtab tabstop=4 shiftwidth=4: */ | 3 | /* vim: set expandtab tabstop=4 shiftwidth=4: */ |
| 4 | // +----------------------------------------------------------------------+ | 4 | // +----------------------------------------------------------------------+ |
| 5 | // | PHP Version 4 | | 5 | // | PHP Version 4 | | ... | ... |
| 1 | <?php | 1 | <?php |
| 2 | namespace Tz\Wordpress\Tools\ExcelWriter; | 2 | namespace Tz\WordPress\Tools\ExcelWriter; |
| 3 | /* vim: set expandtab tabstop=4 shiftwidth=4: */ | 3 | /* vim: set expandtab tabstop=4 shiftwidth=4: */ |
| 4 | // +----------------------------------------------------------------------+ | 4 | // +----------------------------------------------------------------------+ |
| 5 | // | PHP Version 4 | | 5 | // | PHP Version 4 | | ... | ... |
| 1 | <?php | 1 | <?php |
| 2 | namespace Tz\Wordpress\Tools\ExcelWriter; | 2 | namespace Tz\WordPress\Tools\ExcelWriter; |
| 3 | /* vim: set expandtab tabstop=4 shiftwidth=4: */ | 3 | /* vim: set expandtab tabstop=4 shiftwidth=4: */ |
| 4 | // +----------------------------------------------------------------------+ | 4 | // +----------------------------------------------------------------------+ |
| 5 | // | PHP Version 4 | | 5 | // | PHP Version 4 | | ... | ... |
| ... | @@ -122,7 +122,7 @@ function CSVExport($arr) { | ... | @@ -122,7 +122,7 @@ function CSVExport($arr) { |
| 122 | return $out; | 122 | return $out; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | function XLSExport ($arr, \Tz\Wordpress\Tools\ExcelWriter\PHPExcel $writer) { | 125 | function XLSExport ($arr, \Tz\WordPress\Tools\ExcelWriter\PHPExcel $writer) { |
| 126 | if (count($arr) < 1) return false; | 126 | if (count($arr) < 1) return false; |
| 127 | 127 | ||
| 128 | $sheet = $writer->getActiveSheet(); | 128 | $sheet = $writer->getActiveSheet(); | ... | ... |
-
Please register or sign in to post a comment