summaryrefslogtreecommitdiffstats
path: root/admin/survey/excel/PHPExcel/CachedObjectStorage
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2022-01-11 12:35:47 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2022-01-11 12:35:47 +0100
commit19985dbb8c0aa66dc4bf7905abc1148de909097d (patch)
tree2cd5a5d20d7e80fc2a51adf60d838d8a2c40999e /admin/survey/excel/PHPExcel/CachedObjectStorage
download1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.gz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.bz2
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.lz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.xz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.zst
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.zip
Diffstat (limited to '')
-rw-r--r--admin/survey/excel/PHPExcel/CachedObjectStorage/APC.php280
-rw-r--r--admin/survey/excel/PHPExcel/CachedObjectStorage/CacheBase.php252
-rw-r--r--admin/survey/excel/PHPExcel/CachedObjectStorage/DiscISAM.php205
-rw-r--r--admin/survey/excel/PHPExcel/CachedObjectStorage/ICache.php112
-rw-r--r--admin/survey/excel/PHPExcel/CachedObjectStorage/Igbinary.php138
-rw-r--r--admin/survey/excel/PHPExcel/CachedObjectStorage/Memcache.php298
-rw-r--r--admin/survey/excel/PHPExcel/CachedObjectStorage/Memory.php109
-rw-r--r--admin/survey/excel/PHPExcel/CachedObjectStorage/MemoryGZip.php123
-rw-r--r--admin/survey/excel/PHPExcel/CachedObjectStorage/MemorySerialized.php123
-rw-r--r--admin/survey/excel/PHPExcel/CachedObjectStorage/PHPTemp.php192
-rw-r--r--admin/survey/excel/PHPExcel/CachedObjectStorage/SQLite.php270
-rw-r--r--admin/survey/excel/PHPExcel/CachedObjectStorage/SQLite3.php277
-rw-r--r--admin/survey/excel/PHPExcel/CachedObjectStorage/Wincache.php280
-rw-r--r--admin/survey/excel/PHPExcel/CachedObjectStorageFactory.php239
14 files changed, 2898 insertions, 0 deletions
diff --git a/admin/survey/excel/PHPExcel/CachedObjectStorage/APC.php b/admin/survey/excel/PHPExcel/CachedObjectStorage/APC.php
new file mode 100644
index 0000000..cda4d3b
--- /dev/null
+++ b/admin/survey/excel/PHPExcel/CachedObjectStorage/APC.php
@@ -0,0 +1,280 @@
+<?php
+/**
+ * PHPExcel
+ *
+ * Copyright (c) 2006 - 2012 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version 1.7.8, 2012-10-12
+ */
+
+
+/**
+ * PHPExcel_CachedObjectStorage_APC
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ */
+class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+
+ /**
+ * Prefix used to uniquely identify cache data for this worksheet
+ *
+ * @access private
+ * @var string
+ */
+ private $_cachePrefix = null;
+
+ /**
+ * Cache timeout
+ *
+ * @access private
+ * @var integer
+ */
+ private $_cacheTime = 600;
+
+
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @access private
+ * @return void
+ * @throws Exception
+ */
+ private function _storeData() {
+ if ($this->_currentCellIsDirty) {
+ $this->_currentObject->detach();
+
+ if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
+ $this->__destruct();
+ throw new Exception('Failed to store cell '.$this->_currentObjectID.' in APC');
+ }
+ $this->_currentCellIsDirty = false;
+ }
+ $this->_currentObjectID = $this->_currentObject = null;
+ } // function _storeData()
+
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @access public
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell) {
+ if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
+ $this->_storeData();
+ }
+ $this->_cellCache[$pCoord] = true;
+
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
+
+ return $cell;
+ } // function addCacheData()
+
+
+ /**
+ * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
+ *
+ * @access public
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return void
+ * @return boolean
+ */
+ public function isDataSet($pCoord) {
+ // Check if the requested entry is the current object, or exists in the cache
+ if (parent::isDataSet($pCoord)) {
+ if ($this->_currentObjectID == $pCoord) {
+ return true;
+ }
+ // Check if the requested entry still exists in apc
+ $success = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
+ if ($success === false) {
+ // Entry no longer exists in APC, so clear it from the cache array
+ parent::deleteCacheData($pCoord);
+ throw new Exception('Cell entry '.$pCoord.' no longer exists in APC');
+ }
+ return true;
+ }
+ return false;
+ } // function isDataSet()
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @access public
+ * @param string $pCoord Coordinate of the cell
+ * @throws Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return $this->_currentObject;
+ }
+ $this->_storeData();
+
+ // Check if the entry that has been requested actually exists
+ if (parent::isDataSet($pCoord)) {
+ $obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
+ if ($obj === false) {
+ // Entry no longer exists in APC, so clear it from the cache array
+ parent::deleteCacheData($pCoord);
+ throw new Exception('Cell entry '.$pCoord.' no longer exists in APC');
+ }
+ } else {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = unserialize($obj);
+ // Re-attach the parent worksheet
+ $this->_currentObject->attach($this->_parent);
+
+ // Return requested entry
+ return $this->_currentObject;
+ } // function getCacheData()
+
+
+ /**
+ * Delete a cell in cache identified by coordinate address
+ *
+ * @access public
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws Exception
+ */
+ public function deleteCacheData($pCoord) {
+ // Delete the entry from APC
+ apc_delete($this->_cachePrefix.$pCoord.'.cache');
+
+ // Delete the entry from our cell address array
+ parent::deleteCacheData($pCoord);
+ } // function deleteCacheData()
+
+
+ /**
+ * Clone the cell collection
+ *
+ * @access public
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent) {
+ parent::copyCellCollection($parent);
+ // Get a new id for the new file name
+ $baseUnique = $this->_getUniqueID();
+ $newCachePrefix = substr(md5($baseUnique),0,8).'.';
+ $cacheList = $this->getCellList();
+ foreach($cacheList as $cellID) {
+ if ($cellID != $this->_currentObjectID) {
+ $obj = apc_fetch($this->_cachePrefix.$cellID.'.cache');
+ if ($obj === false) {
+ // Entry no longer exists in APC, so clear it from the cache array
+ parent::deleteCacheData($cellID);
+ throw new Exception('Cell entry '.$cellID.' no longer exists in APC');
+ }
+ if (!apc_store($newCachePrefix.$cellID.'.cache',$obj,$this->_cacheTime)) {
+ $this->__destruct();
+ throw new Exception('Failed to store cell '.$cellID.' in APC');
+ }
+ }
+ }
+ $this->_cachePrefix = $newCachePrefix;
+ } // function copyCellCollection()
+
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells() {
+ if ($this->_currentObject !== NULL) {
+ $this->_currentObject->detach();
+ $this->_currentObject = $this->_currentObjectID = null;
+ }
+
+ // Flush the APC cache
+ $this->__destruct();
+
+ $this->_cellCache = array();
+
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->_parent = null;
+ } // function unsetWorksheetCells()
+
+
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ * @param array of mixed $arguments Additional initialisation arguments
+ */
+ public function __construct(PHPExcel_Worksheet $parent, $arguments) {
+ $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
+
+ if ($this->_cachePrefix === NULL) {
+ $baseUnique = $this->_getUniqueID();
+ $this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
+ $this->_cacheTime = $cacheTime;
+
+ parent::__construct($parent);
+ }
+ } // function __construct()
+
+
+ /**
+ * Destroy this cell collection
+ */
+ public function __destruct() {
+ $cacheList = $this->getCellList();
+ foreach($cacheList as $cellID) {
+ apc_delete($this->_cachePrefix.$cellID.'.cache');
+ }
+ } // function __destruct()
+
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable() {
+ if (!function_exists('apc_store')) {
+ return false;
+ }
+ if (apc_sma_info() === false) {
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/admin/survey/excel/PHPExcel/CachedObjectStorage/CacheBase.php b/admin/survey/excel/PHPExcel/CachedObjectStorage/CacheBase.php
new file mode 100644
index 0000000..deaae4c
--- /dev/null
+++ b/admin/survey/excel/PHPExcel/CachedObjectStorage/CacheBase.php
@@ -0,0 +1,252 @@
+<?php
+/**
+ * PHPExcel
+ *
+ * Copyright (c) 2006 - 2012 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version 1.7.8, 2012-10-12
+ */
+
+
+/**
+ * PHPExcel_CachedObjectStorage_CacheBase
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ */
+abstract class PHPExcel_CachedObjectStorage_CacheBase {
+
+ /**
+ * Parent worksheet
+ *
+ * @var PHPExcel_Worksheet
+ */
+ protected $_parent;
+
+ /**
+ * The currently active Cell
+ *
+ * @var PHPExcel_Cell
+ */
+ protected $_currentObject = null;
+
+ /**
+ * Coordinate address of the currently active Cell
+ *
+ * @var string
+ */
+ protected $_currentObjectID = null;
+
+
+ /**
+ * Flag indicating whether the currently active Cell requires saving
+ *
+ * @var boolean
+ */
+ protected $_currentCellIsDirty = true;
+
+ /**
+ * An array of cells or cell pointers for the worksheet cells held in this cache,
+ * and indexed by their coordinate address within the worksheet
+ *
+ * @var array of mixed
+ */
+ protected $_cellCache = array();
+
+
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ */
+ public function __construct(PHPExcel_Worksheet $parent) {
+ // Set our parent worksheet.
+ // This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
+ // they are woken from a serialized state
+ $this->_parent = $parent;
+ } // function __construct()
+
+
+ /**
+ * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
+ *
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return boolean
+ */
+ public function isDataSet($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return true;
+ }
+ // Check if the requested entry exists in the cache
+ return isset($this->_cellCache[$pCoord]);
+ } // function isDataSet()
+
+
+ /**
+ * Add or Update a cell in cache
+ *
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
+ */
+ public function updateCacheData(PHPExcel_Cell $cell) {
+ return $this->addCacheData($cell->getCoordinate(),$cell);
+ } // function updateCacheData()
+
+
+ /**
+ * Delete a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws Exception
+ */
+ public function deleteCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ $this->_currentObject->detach();
+ $this->_currentObjectID = $this->_currentObject = null;
+ }
+
+ if (is_object($this->_cellCache[$pCoord])) {
+ $this->_cellCache[$pCoord]->detach();
+ unset($this->_cellCache[$pCoord]);
+ }
+ $this->_currentCellIsDirty = false;
+ } // function deleteCacheData()
+
+
+ /**
+ * Get a list of all cell addresses currently held in cache
+ *
+ * @return array of string
+ */
+ public function getCellList() {
+ return array_keys($this->_cellCache);
+ } // function getCellList()
+
+
+ /**
+ * Sort the list of all cell addresses currently held in cache by row and column
+ *
+ * @return void
+ */
+ public function getSortedCellList() {
+ $sortKeys = array();
+ foreach ($this->getCellList() as $coord) {
+ list($column,$row) = sscanf($coord,'%[A-Z]%d');
+ $sortKeys[sprintf('%09d%3s',$row,$column)] = $coord;
+ }
+ ksort($sortKeys);
+
+ return array_values($sortKeys);
+ } // function sortCellList()
+
+
+
+ /**
+ * Get highest worksheet column and highest row that have cell records
+ *
+ * @return array Highest column name and highest row number
+ */
+ public function getHighestRowAndColumn()
+ {
+ // Lookup highest column and highest row
+ $col = array('A' => '1A');
+ $row = array(1);
+ foreach ($this->getCellList() as $coord) {
+ list($c,$r) = sscanf($coord,'%[A-Z]%d');
+ $row[$r] = $r;
+ $col[$c] = strlen($c).$c;
+ }
+ if (!empty($row)) {
+ // Determine highest column and row
+ $highestRow = max($row);
+ $highestColumn = substr(max($col),1);
+ }
+
+ return array( 'row' => $highestRow,
+ 'column' => $highestColumn
+ );
+ }
+
+
+ /**
+ * Get highest worksheet column
+ *
+ * @return string Highest column name
+ */
+ public function getHighestColumn()
+ {
+ $colRow = $this->getHighestRowAndColumn();
+ return $colRow['column'];
+ }
+
+ /**
+ * Get highest worksheet row
+ *
+ * @return int Highest row number
+ */
+ public function getHighestRow()
+ {
+ $colRow = $this->getHighestRowAndColumn();
+ return $colRow['row'];
+ }
+
+
+ /**
+ * Generate a unique ID for cache referencing
+ *
+ * @return string Unique Reference
+ */
+ protected function _getUniqueID() {
+ if (function_exists('posix_getpid')) {
+ $baseUnique = posix_getpid();
+ } else {
+ $baseUnique = mt_rand();
+ }
+ return uniqid($baseUnique,true);
+ }
+
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent) {
+ $this->_parent = $parent;
+ if (($this->_currentObject !== NULL) && (is_object($this->_currentObject))) {
+ $this->_currentObject->attach($parent);
+ }
+ } // function copyCellCollection()
+
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable() {
+ return true;
+ }
+
+}
diff --git a/admin/survey/excel/PHPExcel/CachedObjectStorage/DiscISAM.php b/admin/survey/excel/PHPExcel/CachedObjectStorage/DiscISAM.php
new file mode 100644
index 0000000..d93ab05
--- /dev/null
+++ b/admin/survey/excel/PHPExcel/CachedObjectStorage/DiscISAM.php
@@ -0,0 +1,205 @@
+<?php
+/**
+ * PHPExcel
+ *
+ * Copyright (c) 2006 - 2012 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version 1.7.8, 2012-10-12
+ */
+
+
+/**
+ * PHPExcel_CachedObjectStorage_DiscISAM
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ */
+class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+
+ /**
+ * Name of the file for this cache
+ *
+ * @var string
+ */
+ private $_fileName = null;
+
+ /**
+ * File handle for this cache file
+ *
+ * @var resource
+ */
+ private $_fileHandle = null;
+
+ /**
+ * Directory/Folder where the cache file is located
+ *
+ * @var string
+ */
+ private $_cacheDirectory = NULL;
+
+
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws Exception
+ */
+ private function _storeData() {
+ if ($this->_currentCellIsDirty) {
+ $this->_currentObject->detach();
+
+ fseek($this->_fileHandle,0,SEEK_END);
+ $offset = ftell($this->_fileHandle);
+ fwrite($this->_fileHandle, serialize($this->_currentObject));
+ $this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
+ 'sz' => ftell($this->_fileHandle) - $offset
+ );
+ $this->_currentCellIsDirty = false;
+ }
+ $this->_currentObjectID = $this->_currentObject = null;
+ } // function _storeData()
+
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell) {
+ if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
+ $this->_storeData();
+ }
+
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
+
+ return $cell;
+ } // function addCacheData()
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return $this->_currentObject;
+ }
+ $this->_storeData();
+
+ // Check if the entry that has been requested actually exists
+ if (!isset($this->_cellCache[$pCoord])) {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->_currentObjectID = $pCoord;
+ fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
+ $this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
+ // Re-attach the parent worksheet
+ $this->_currentObject->attach($this->_parent);
+
+ // Return requested entry
+ return $this->_currentObject;
+ } // function getCacheData()
+
+
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent) {
+ parent::copyCellCollection($parent);
+ // Get a new id for the new file name
+ $baseUnique = $this->_getUniqueID();
+ $newFileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
+ // Copy the existing cell cache file
+ copy ($this->_fileName,$newFileName);
+ $this->_fileName = $newFileName;
+ // Open the copied cell cache file
+ $this->_fileHandle = fopen($this->_fileName,'a+');
+ } // function copyCellCollection()
+
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells() {
+ if(!is_null($this->_currentObject)) {
+ $this->_currentObject->detach();
+ $this->_currentObject = $this->_currentObjectID = null;
+ }
+ $this->_cellCache = array();
+
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->_parent = null;
+
+ // Close down the temporary cache file
+ $this->__destruct();
+ } // function unsetWorksheetCells()
+
+
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ * @param array of mixed $arguments Additional initialisation arguments
+ */
+ public function __construct(PHPExcel_Worksheet $parent, $arguments) {
+ $this->_cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== NULL))
+ ? $arguments['dir']
+ : PHPExcel_Shared_File::sys_get_temp_dir();
+
+ parent::__construct($parent);
+ if (is_null($this->_fileHandle)) {
+ $baseUnique = $this->_getUniqueID();
+ $this->_fileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
+ $this->_fileHandle = fopen($this->_fileName,'a+');
+ }
+ } // function __construct()
+
+
+ /**
+ * Destroy this cell collection
+ */
+ public function __destruct() {
+ if (!is_null($this->_fileHandle)) {
+ fclose($this->_fileHandle);
+ unlink($this->_fileName);
+ }
+ $this->_fileHandle = null;
+ } // function __destruct()
+
+}
diff --git a/admin/survey/excel/PHPExcel/CachedObjectStorage/ICache.php b/admin/survey/excel/PHPExcel/CachedObjectStorage/ICache.php
new file mode 100644
index 0000000..fd35e87
--- /dev/null
+++ b/admin/survey/excel/PHPExcel/CachedObjectStorage/ICache.php
@@ -0,0 +1,112 @@
+<?php
+/**
+ * PHPExcel
+ *
+ * Copyright (c) 2006 - 2012 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version 1.7.8, 2012-10-12
+ */
+
+
+/**
+ * PHPExcel_CachedObjectStorage_ICache
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ */
+interface PHPExcel_CachedObjectStorage_ICache
+{
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell);
+
+ /**
+ * Add or Update a cell in cache
+ *
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
+ */
+ public function updateCacheData(PHPExcel_Cell $cell);
+
+ /**
+ * Fetch a cell from cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to retrieve
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ * @throws Exception
+ */
+ public function getCacheData($pCoord);
+
+ /**
+ * Delete a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws Exception
+ */
+ public function deleteCacheData($pCoord);
+
+ /**
+ * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
+ *
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return boolean
+ */
+ public function isDataSet($pCoord);
+
+ /**
+ * Get a list of all cell addresses currently held in cache
+ *
+ * @return array of string
+ */
+ public function getCellList();
+
+ /**
+ * Get the list of all cell addresses currently held in cache sorted by column and row
+ *
+ * @return void
+ */
+ public function getSortedCellList();
+
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent);
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable();
+
+}
diff --git a/admin/survey/excel/PHPExcel/CachedObjectStorage/Igbinary.php b/admin/survey/excel/PHPExcel/CachedObjectStorage/Igbinary.php
new file mode 100644
index 0000000..5d5daf4
--- /dev/null
+++ b/admin/survey/excel/PHPExcel/CachedObjectStorage/Igbinary.php
@@ -0,0 +1,138 @@
+<?php
+/**
+ * PHPExcel
+ *
+ * Copyright (c) 2006 - 2012 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version 1.7.8, 2012-10-12
+ */
+
+
+/**
+ * PHPExcel_CachedObjectStorage_Igbinary
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ */
+class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws Exception
+ */
+ private function _storeData() {
+ if ($this->_currentCellIsDirty) {
+ $this->_currentObject->detach();
+
+ $this->_cellCache[$this->_currentObjectID] = igbinary_serialize($this->_currentObject);
+ $this->_currentCellIsDirty = false;
+ }
+ $this->_currentObjectID = $this->_currentObject = null;
+ } // function _storeData()
+
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell) {
+ if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
+ $this->_storeData();
+ }
+
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
+
+ return $cell;
+ } // function addCacheData()
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return $this->_currentObject;
+ }
+ $this->_storeData();
+
+ // Check if the entry that has been requested actually exists
+ if (!isset($this->_cellCache[$pCoord])) {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = igbinary_unserialize($this->_cellCache[$pCoord]);
+ // Re-attach the parent worksheet
+ $this->_currentObject->attach($this->_parent);
+
+ // Return requested entry
+ return $this->_currentObject;
+ } // function getCacheData()
+
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells() {
+ if(!is_null($this->_currentObject)) {
+ $this->_currentObject->detach();
+ $this->_currentObject = $this->_currentObjectID = null;
+ }
+ $this->_cellCache = array();
+
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->_parent = null;
+ } // function unsetWorksheetCells()
+
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable() {
+ if (!function_exists('igbinary_serialize')) {
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/admin/survey/excel/PHPExcel/CachedObjectStorage/Memcache.php b/admin/survey/excel/PHPExcel/CachedObjectStorage/Memcache.php
new file mode 100644
index 0000000..3e5fcb4
--- /dev/null
+++ b/admin/survey/excel/PHPExcel/CachedObjectStorage/Memcache.php
@@ -0,0 +1,298 @@
+<?php
+/**
+ * PHPExcel
+ *
+ * Copyright (c) 2006 - 2012 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version 1.7.8, 2012-10-12
+ */
+
+
+/**
+ * PHPExcel_CachedObjectStorage_Memcache
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ */
+class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+
+ /**
+ * Prefix used to uniquely identify cache data for this worksheet
+ *
+ * @var string
+ */
+ private $_cachePrefix = null;
+
+ /**
+ * Cache timeout
+ *
+ * @var integer
+ */
+ private $_cacheTime = 600;
+
+ /**
+ * Memcache interface
+ *
+ * @var resource
+ */
+ private $_memcache = null;
+
+
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws Exception
+ */
+ private function _storeData() {
+ if ($this->_currentCellIsDirty) {
+ $this->_currentObject->detach();
+
+ $obj = serialize($this->_currentObject);
+ if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
+ if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
+ $this->__destruct();
+ throw new Exception('Failed to store cell '.$this->_currentObjectID.' in MemCache');
+ }
+ }
+ $this->_currentCellIsDirty = false;
+ }
+ $this->_currentObjectID = $this->_currentObject = null;
+ } // function _storeData()
+
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell) {
+ if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
+ $this->_storeData();
+ }
+ $this->_cellCache[$pCoord] = true;
+
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
+
+ return $cell;
+ } // function addCacheData()
+
+
+ /**
+ * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
+ *
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return void
+ * @return boolean
+ */
+ public function isDataSet($pCoord) {
+ // Check if the requested entry is the current object, or exists in the cache
+ if (parent::isDataSet($pCoord)) {
+ if ($this->_currentObjectID == $pCoord) {
+ return true;
+ }
+ // Check if the requested entry still exists in Memcache
+ $success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
+ if ($success === false) {
+ // Entry no longer exists in Memcache, so clear it from the cache array
+ parent::deleteCacheData($pCoord);
+ throw new Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
+ }
+ return true;
+ }
+ return false;
+ } // function isDataSet()
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return $this->_currentObject;
+ }
+ $this->_storeData();
+
+ // Check if the entry that has been requested actually exists
+ if (parent::isDataSet($pCoord)) {
+ $obj = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
+ if ($obj === false) {
+ // Entry no longer exists in Memcache, so clear it from the cache array
+ parent::deleteCacheData($pCoord);
+ throw new Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
+ }
+ } else {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = unserialize($obj);
+ // Re-attach the parent worksheet
+ $this->_currentObject->attach($this->_parent);
+
+ // Return requested entry
+ return $this->_currentObject;
+ } // function getCacheData()
+
+
+ /**
+ * Delete a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws Exception
+ */
+ public function deleteCacheData($pCoord) {
+ // Delete the entry from Memcache
+ $this->_memcache->delete($this->_cachePrefix.$pCoord.'.cache');
+
+ // Delete the entry from our cell address array
+ parent::deleteCacheData($pCoord);
+ } // function deleteCacheData()
+
+
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent) {
+ parent::copyCellCollection($parent);
+ // Get a new id for the new file name
+ $baseUnique = $this->_getUniqueID();
+ $newCachePrefix = substr(md5($baseUnique),0,8).'.';
+ $cacheList = $this->getCellList();
+ foreach($cacheList as $cellID) {
+ if ($cellID != $this->_currentObjectID) {
+ $obj = $this->_memcache->get($this->_cachePrefix.$cellID.'.cache');
+ if ($obj === false) {
+ // Entry no longer exists in Memcache, so clear it from the cache array
+ parent::deleteCacheData($cellID);
+ throw new Exception('Cell entry '.$cellID.' no longer exists in MemCache');
+ }
+ if (!$this->_memcache->add($newCachePrefix.$cellID.'.cache',$obj,NULL,$this->_cacheTime)) {
+ $this->__destruct();
+ throw new Exception('Failed to store cell '.$cellID.' in MemCache');
+ }
+ }
+ }
+ $this->_cachePrefix = $newCachePrefix;
+ } // function copyCellCollection()
+
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells() {
+ if(!is_null($this->_currentObject)) {
+ $this->_currentObject->detach();
+ $this->_currentObject = $this->_currentObjectID = null;
+ }
+
+ // Flush the Memcache cache
+ $this->__destruct();
+
+ $this->_cellCache = array();
+
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->_parent = null;
+ } // function unsetWorksheetCells()
+
+
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ * @param array of mixed $arguments Additional initialisation arguments
+ */
+ public function __construct(PHPExcel_Worksheet $parent, $arguments) {
+ $memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
+ $memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
+ $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
+
+ if (is_null($this->_cachePrefix)) {
+ $baseUnique = $this->_getUniqueID();
+ $this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
+
+ // Set a new Memcache object and connect to the Memcache server
+ $this->_memcache = new Memcache();
+ if (!$this->_memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) {
+ throw new Exception('Could not connect to MemCache server at '.$memcacheServer.':'.$memcachePort);
+ }
+ $this->_cacheTime = $cacheTime;
+
+ parent::__construct($parent);
+ }
+ } // function __construct()
+
+
+ /**
+ * Memcache error handler
+ *
+ * @param string $host Memcache server
+ * @param integer $port Memcache port
+ * @throws Exception
+ */
+ public function failureCallback($host, $port) {
+ throw new Exception('memcache '.$host.':'.$port.' failed');
+ }
+
+
+ /**
+ * Destroy this cell collection
+ */
+ public function __destruct() {
+ $cacheList = $this->getCellList();
+ foreach($cacheList as $cellID) {
+ $this->_memcache->delete($this->_cachePrefix.$cellID.'.cache');
+ }
+ } // function __destruct()
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable() {
+ if (!function_exists('memcache_add')) {
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/admin/survey/excel/PHPExcel/CachedObjectStorage/Memory.php b/admin/survey/excel/PHPExcel/CachedObjectStorage/Memory.php
new file mode 100644
index 0000000..f368e39
--- /dev/null
+++ b/admin/survey/excel/PHPExcel/CachedObjectStorage/Memory.php
@@ -0,0 +1,109 @@
+<?php
+/**
+ * PHPExcel
+ *
+ * Copyright (c) 2006 - 2012 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version 1.7.8, 2012-10-12
+ */
+
+
+/**
+ * PHPExcel_CachedObjectStorage_Memory
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ */
+class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell) {
+ $this->_cellCache[$pCoord] = $cell;
+ return $cell;
+ } // function addCacheData()
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord) {
+ // Check if the entry that has been requested actually exists
+ if (!isset($this->_cellCache[$pCoord])) {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Return requested entry
+ return $this->_cellCache[$pCoord];
+ } // function getCacheData()
+
+
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent) {
+ parent::copyCellCollection($parent);
+
+ $newCollection = array();
+ foreach($this->_cellCache as $k => &$cell) {
+ $newCollection[$k] = clone $cell;
+ $newCollection[$k]->attach($parent);
+ }
+
+ $this->_cellCache = $newCollection;
+ }
+
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells() {
+ // Because cells are all stored as intact objects in memory, we need to detach each one from the parent
+ foreach($this->_cellCache as $k => &$cell) {
+ $cell->detach();
+ $this->_cellCache[$k] = null;
+ }
+ unset($cell);
+
+ $this->_cellCache = array();
+
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->_parent = null;
+ } // function unsetWorksheetCells()
+
+}
diff --git a/admin/survey/excel/PHPExcel/CachedObjectStorage/MemoryGZip.php b/admin/survey/excel/PHPExcel/CachedObjectStorage/MemoryGZip.php
new file mode 100644
index 0000000..6941231
--- /dev/null
+++ b/admin/survey/excel/PHPExcel/CachedObjectStorage/MemoryGZip.php
@@ -0,0 +1,123 @@
+<?php
+/**
+ * PHPExcel
+ *
+ * Copyright (c) 2006 - 2012 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version 1.7.8, 2012-10-12
+ */
+
+
+/**
+ * PHPExcel_CachedObjectStorage_MemoryGZip
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ */
+class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws Exception
+ */
+ private function _storeData() {
+ if ($this->_currentCellIsDirty) {
+ $this->_currentObject->detach();
+
+ $this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));
+ $this->_currentCellIsDirty = false;
+ }
+ $this->_currentObjectID = $this->_currentObject = null;
+ } // function _storeData()
+
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell) {
+ if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
+ $this->_storeData();
+ }
+
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
+
+ return $cell;
+ } // function addCacheData()
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return $this->_currentObject;
+ }
+ $this->_storeData();
+
+ // Check if the entry that has been requested actually exists
+ if (!isset($this->_cellCache[$pCoord])) {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord]));
+ // Re-attach the parent worksheet
+ $this->_currentObject->attach($this->_parent);
+
+ // Return requested entry
+ return $this->_currentObject;
+ } // function getCacheData()
+
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells() {
+ if(!is_null($this->_currentObject)) {
+ $this->_currentObject->detach();
+ $this->_currentObject = $this->_currentObjectID = null;
+ }
+ $this->_cellCache = array();
+
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->_parent = null;
+ } // function unsetWorksheetCells()
+
+}
diff --git a/admin/survey/excel/PHPExcel/CachedObjectStorage/MemorySerialized.php b/admin/survey/excel/PHPExcel/CachedObjectStorage/MemorySerialized.php
new file mode 100644
index 0000000..09f3b66
--- /dev/null
+++ b/admin/survey/excel/PHPExcel/CachedObjectStorage/MemorySerialized.php
@@ -0,0 +1,123 @@
+<?php
+/**
+ * PHPExcel
+ *
+ * Copyright (c) 2006 - 2012 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version 1.7.8, 2012-10-12
+ */
+
+
+/**
+ * PHPExcel_CachedObjectStorage_MemorySerialized
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ */
+class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws Exception
+ */
+ private function _storeData() {
+ if ($this->_currentCellIsDirty) {
+ $this->_currentObject->detach();
+
+ $this->_cellCache[$this->_currentObjectID] = serialize($this->_currentObject);
+ $this->_currentCellIsDirty = false;
+ }
+ $this->_currentObjectID = $this->_currentObject = null;
+ } // function _storeData()
+
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell) {
+ if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
+ $this->_storeData();
+ }
+
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
+
+ return $cell;
+ } // function addCacheData()
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return $this->_currentObject;
+ }
+ $this->_storeData();
+
+ // Check if the entry that has been requested actually exists
+ if (!isset($this->_cellCache[$pCoord])) {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = unserialize($this->_cellCache[$pCoord]);
+ // Re-attach the parent worksheet
+ $this->_currentObject->attach($this->_parent);
+
+ // Return requested entry
+ return $this->_currentObject;
+ } // function getCacheData()
+
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells() {
+ if(!is_null($this->_currentObject)) {
+ $this->_currentObject->detach();
+ $this->_currentObject = $this->_currentObjectID = null;
+ }
+ $this->_cellCache = array();
+
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->_parent = null;
+ } // function unsetWorksheetCells()
+
+}
diff --git a/admin/survey/excel/PHPExcel/CachedObjectStorage/PHPTemp.php b/admin/survey/excel/PHPExcel/CachedObjectStorage/PHPTemp.php
new file mode 100644
index 0000000..c3f2bd9
--- /dev/null
+++ b/admin/survey/excel/PHPExcel/CachedObjectStorage/PHPTemp.php
@@ -0,0 +1,192 @@
+<?php
+/**
+ * PHPExcel
+ *
+ * Copyright (c) 2006 - 2012 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version 1.7.8, 2012-10-12
+ */
+
+
+/**
+ * PHPExcel_CachedObjectStorage_PHPTemp
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ */
+class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+
+ /**
+ * Name of the file for this cache
+ *
+ * @var string
+ */
+ private $_fileHandle = null;
+
+ /**
+ * Memory limit to use before reverting to file cache
+ *
+ * @var integer
+ */
+ private $_memoryCacheSize = null;
+
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws Exception
+ */
+ private function _storeData() {
+ if ($this->_currentCellIsDirty) {
+ $this->_currentObject->detach();
+
+ fseek($this->_fileHandle,0,SEEK_END);
+ $offset = ftell($this->_fileHandle);
+ fwrite($this->_fileHandle, serialize($this->_currentObject));
+ $this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
+ 'sz' => ftell($this->_fileHandle) - $offset
+ );
+ $this->_currentCellIsDirty = false;
+ }
+ $this->_currentObjectID = $this->_currentObject = null;
+ } // function _storeData()
+
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell) {
+ if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
+ $this->_storeData();
+ }
+
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
+
+ return $cell;
+ } // function addCacheData()
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return $this->_currentObject;
+ }
+ $this->_storeData();
+
+ // Check if the entry that has been requested actually exists
+ if (!isset($this->_cellCache[$pCoord])) {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->_currentObjectID = $pCoord;
+ fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
+ $this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
+ // Re-attach the parent worksheet
+ $this->_currentObject->attach($this->_parent);
+
+ // Return requested entry
+ return $this->_currentObject;
+ } // function getCacheData()
+
+
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent) {
+ parent::copyCellCollection($parent);
+ // Open a new stream for the cell cache data
+ $newFileHandle = fopen('php://temp/maxmemory:'.$this->_memoryCacheSize,'a+');
+ // Copy the existing cell cache data to the new stream
+ fseek($this->_fileHandle,0);
+ while (!feof($this->_fileHandle)) {
+ fwrite($newFileHandle,fread($this->_fileHandle, 1024));
+ }
+ $this->_fileHandle = $newFileHandle;
+ } // function copyCellCollection()
+
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells() {
+ if(!is_null($this->_currentObject)) {
+ $this->_currentObject->detach();
+ $this->_currentObject = $this->_currentObjectID = null;
+ }
+ $this->_cellCache = array();
+
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->_parent = null;
+
+ // Close down the php://temp file
+ $this->__destruct();
+ } // function unsetWorksheetCells()
+
+
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ * @param array of mixed $arguments Additional initialisation arguments
+ */
+ public function __construct(PHPExcel_Worksheet $parent, $arguments) {
+ $this->_memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';
+
+ parent::__construct($parent);
+ if (is_null($this->_fileHandle)) {
+ $this->_fileHandle = fopen('php://temp/maxmemory:'.$this->_memoryCacheSize,'a+');
+ }
+ } // function __construct()
+
+
+ /**
+ * Destroy this cell collection
+ */
+ public function __destruct() {
+ if (!is_null($this->_fileHandle)) {
+ fclose($this->_fileHandle);
+ }
+ $this->_fileHandle = null;
+ } // function __destruct()
+
+}
diff --git a/admin/survey/excel/PHPExcel/CachedObjectStorage/SQLite.php b/admin/survey/excel/PHPExcel/CachedObjectStorage/SQLite.php
new file mode 100644
index 0000000..515573d
--- /dev/null
+++ b/admin/survey/excel/PHPExcel/CachedObjectStorage/SQLite.php
@@ -0,0 +1,270 @@
+<?php
+/**
+ * PHPExcel
+ *
+ * Copyright (c) 2006 - 2012 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version 1.7.8, 2012-10-12
+ */
+
+
+/**
+ * PHPExcel_CachedObjectStorage_SQLite
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ */
+class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+
+ /**
+ * Database table name
+ *
+ * @var string
+ */
+ private $_TableName = null;
+
+ /**
+ * Database handle
+ *
+ * @var resource
+ */
+ private $_DBHandle = null;
+
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws Exception
+ */
+ private function _storeData() {
+ if ($this->_currentCellIsDirty) {
+ $this->_currentObject->detach();
+
+ if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')"))
+ throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
+ $this->_currentCellIsDirty = false;
+ }
+ $this->_currentObjectID = $this->_currentObject = null;
+ } // function _storeData()
+
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell) {
+ if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
+ $this->_storeData();
+ }
+
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
+
+ return $cell;
+ } // function addCacheData()
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return $this->_currentObject;
+ }
+ $this->_storeData();
+
+ $query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
+ $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
+ if ($cellResultSet === false) {
+ throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
+ } elseif ($cellResultSet->numRows() == 0) {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->_currentObjectID = $pCoord;
+
+ $cellResult = $cellResultSet->fetchSingle();
+ $this->_currentObject = unserialize($cellResult);
+ // Re-attach the parent worksheet
+ $this->_currentObject->attach($this->_parent);
+
+ // Return requested entry
+ return $this->_currentObject;
+ } // function getCacheData()
+
+
+ /**
+ * Is a value set for an indexed cell?
+ *
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return boolean
+ */
+ public function isDataSet($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return true;
+ }
+
+ // Check if the requested entry exists in the cache
+ $query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
+ $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
+ if ($cellResultSet === false) {
+ throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
+ } elseif ($cellResultSet->numRows() == 0) {
+ // Return null if requested entry doesn't exist in cache
+ return false;
+ }
+ return true;
+ } // function isDataSet()
+
+
+ /**
+ * Delete a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws Exception
+ */
+ public function deleteCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ $this->_currentObject->detach();
+ $this->_currentObjectID = $this->_currentObject = null;
+ }
+
+ // Check if the requested entry exists in the cache
+ $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
+ if (!$this->_DBHandle->queryExec($query))
+ throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
+
+ $this->_currentCellIsDirty = false;
+ } // function deleteCacheData()
+
+
+ /**
+ * Get a list of all cell addresses currently held in cache
+ *
+ * @return array of string
+ */
+ public function getCellList() {
+ $query = "SELECT id FROM kvp_".$this->_TableName;
+ $cellIdsResult = $this->_DBHandle->unbufferedQuery($query,SQLITE_ASSOC);
+ if ($cellIdsResult === false)
+ throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
+
+ $cellKeys = array();
+ foreach($cellIdsResult as $row) {
+ $cellKeys[] = $row['id'];
+ }
+
+ return $cellKeys;
+ } // function getCellList()
+
+
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent) {
+ // Get a new id for the new table name
+ $tableName = str_replace('.','_',$this->_getUniqueID());
+ if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
+ AS SELECT * FROM kvp_'.$this->_TableName))
+ throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
+
+ // Copy the existing cell cache file
+ $this->_TableName = $tableName;
+ } // function copyCellCollection()
+
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells() {
+ if(!is_null($this->_currentObject)) {
+ $this->_currentObject->detach();
+ $this->_currentObject = $this->_currentObjectID = null;
+ }
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->_parent = null;
+
+ // Close down the temporary cache file
+ $this->__destruct();
+ } // function unsetWorksheetCells()
+
+
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ */
+ public function __construct(PHPExcel_Worksheet $parent) {
+ parent::__construct($parent);
+ if (is_null($this->_DBHandle)) {
+ $this->_TableName = str_replace('.','_',$this->_getUniqueID());
+ $_DBName = ':memory:';
+
+ $this->_DBHandle = new SQLiteDatabase($_DBName);
+ if ($this->_DBHandle === false)
+ throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
+ if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
+ throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
+ }
+ } // function __construct()
+
+
+ /**
+ * Destroy this cell collection
+ */
+ public function __destruct() {
+ $this->_DBHandle = null;
+ } // function __destruct()
+
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable() {
+ if (!function_exists('sqlite_open')) {
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/admin/survey/excel/PHPExcel/CachedObjectStorage/SQLite3.php b/admin/survey/excel/PHPExcel/CachedObjectStorage/SQLite3.php
new file mode 100644
index 0000000..b867b4d
--- /dev/null
+++ b/admin/survey/excel/PHPExcel/CachedObjectStorage/SQLite3.php
@@ -0,0 +1,277 @@
+<?php
+/**
+ * PHPExcel
+ *
+ * Copyright (c) 2006 - 2012 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version 1.7.8, 2012-10-12
+ */
+
+
+/**
+ * PHPExcel_CachedObjectStorage_SQLite3
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ */
+class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+
+ /**
+ * Database table name
+ *
+ * @var string
+ */
+ private $_TableName = null;
+
+ /**
+ * Database handle
+ *
+ * @var resource
+ */
+ private $_DBHandle = null;
+
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws Exception
+ */
+ private function _storeData() {
+ if ($this->_currentCellIsDirty) {
+ $this->_currentObject->detach();
+
+ $query = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)");
+ $query->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT);
+ $query->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB);
+ $result = $query->execute();
+ if ($result === false)
+ throw new Exception($this->_DBHandle->lastErrorMsg());
+ $this->_currentCellIsDirty = false;
+ }
+ $this->_currentObjectID = $this->_currentObject = null;
+ } // function _storeData()
+
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell) {
+ if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
+ $this->_storeData();
+ }
+
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
+
+ return $cell;
+ } // function addCacheData()
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return $this->_currentObject;
+ }
+ $this->_storeData();
+
+ $query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
+ $cellResult = $this->_DBHandle->querySingle($query);
+ if ($cellResult === false) {
+ throw new Exception($this->_DBHandle->lastErrorMsg());
+ } elseif (is_null($cellResult)) {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->_currentObjectID = $pCoord;
+
+ $this->_currentObject = unserialize($cellResult);
+ // Re-attach the parent worksheet
+ $this->_currentObject->attach($this->_parent);
+
+ // Return requested entry
+ return $this->_currentObject;
+ } // function getCacheData()
+
+
+ /**
+ * Is a value set for an indexed cell?
+ *
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return boolean
+ */
+ public function isDataSet($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return true;
+ }
+
+ // Check if the requested entry exists in the cache
+ $query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
+ $cellResult = $this->_DBHandle->querySingle($query);
+ if ($cellResult === false) {
+ throw new Exception($this->_DBHandle->lastErrorMsg());
+ } elseif (is_null($cellResult)) {
+ // Return null if requested entry doesn't exist in cache
+ return false;
+ }
+ return true;
+ } // function isDataSet()
+
+
+ /**
+ * Delete a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws Exception
+ */
+ public function deleteCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ $this->_currentObject->detach();
+ $this->_currentObjectID = $this->_currentObject = null;
+ }
+
+ // Check if the requested entry exists in the cache
+ $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
+ $result = $this->_DBHandle->exec($query);
+ if ($result === false)
+ throw new Exception($this->_DBHandle->lastErrorMsg());
+
+ $this->_currentCellIsDirty = false;
+ } // function deleteCacheData()
+
+
+ /**
+ * Get a list of all cell addresses currently held in cache
+ *
+ * @return array of string
+ */
+ public function getCellList() {
+ $query = "SELECT id FROM kvp_".$this->_TableName;
+ $cellIdsResult = $this->_DBHandle->query($query);
+ if ($cellIdsResult === false)
+ throw new Exception($this->_DBHandle->lastErrorMsg());
+
+ $cellKeys = array();
+ while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
+ $cellKeys[] = $row['id'];
+ }
+
+ return $cellKeys;
+ } // function getCellList()
+
+
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent) {
+ // Get a new id for the new table name
+ $tableName = str_replace('.','_',$this->_getUniqueID());
+ if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
+ AS SELECT * FROM kvp_'.$this->_TableName))
+ throw new Exception($this->_DBHandle->lastErrorMsg());
+
+ // Copy the existing cell cache file
+ $this->_TableName = $tableName;
+ } // function copyCellCollection()
+
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells() {
+ if(!is_null($this->_currentObject)) {
+ $this->_currentObject->detach();
+ $this->_currentObject = $this->_currentObjectID = null;
+ }
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->_parent = null;
+
+ // Close down the temporary cache file
+ $this->__destruct();
+ } // function unsetWorksheetCells()
+
+
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ */
+ public function __construct(PHPExcel_Worksheet $parent) {
+ parent::__construct($parent);
+ if (is_null($this->_DBHandle)) {
+ $this->_TableName = str_replace('.','_',$this->_getUniqueID());
+ $_DBName = ':memory:';
+
+ $this->_DBHandle = new SQLite3($_DBName);
+ if ($this->_DBHandle === false)
+ throw new Exception($this->_DBHandle->lastErrorMsg());
+ if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
+ throw new Exception($this->_DBHandle->lastErrorMsg());
+ }
+ } // function __construct()
+
+
+ /**
+ * Destroy this cell collection
+ */
+ public function __destruct() {
+ if (!is_null($this->_DBHandle)) {
+ $this->_DBHandle->close();
+ }
+ $this->_DBHandle = null;
+ } // function __destruct()
+
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable() {
+ if (!class_exists('SQLite3',FALSE)) {
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/admin/survey/excel/PHPExcel/CachedObjectStorage/Wincache.php b/admin/survey/excel/PHPExcel/CachedObjectStorage/Wincache.php
new file mode 100644
index 0000000..1534448
--- /dev/null
+++ b/admin/survey/excel/PHPExcel/CachedObjectStorage/Wincache.php
@@ -0,0 +1,280 @@
+<?php
+/**
+ * PHPExcel
+ *
+ * Copyright (c) 2006 - 2012 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version 1.7.8, 2012-10-12
+ */
+
+
+/**
+ * PHPExcel_CachedObjectStorage_Wincache
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ */
+class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+
+ /**
+ * Prefix used to uniquely identify cache data for this worksheet
+ *
+ * @var string
+ */
+ private $_cachePrefix = null;
+
+ /**
+ * Cache timeout
+ *
+ * @var integer
+ */
+ private $_cacheTime = 600;
+
+
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws Exception
+ */
+ private function _storeData() {
+ if ($this->_currentCellIsDirty) {
+ $this->_currentObject->detach();
+
+ $obj = serialize($this->_currentObject);
+ if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) {
+ if (!wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
+ $this->__destruct();
+ throw new Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache');
+ }
+ } else {
+ if (!wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
+ $this->__destruct();
+ throw new Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache');
+ }
+ }
+ $this->_currentCellIsDirty = false;
+ }
+
+ $this->_currentObjectID = $this->_currentObject = null;
+ } // function _storeData()
+
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell) {
+ if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
+ $this->_storeData();
+ }
+ $this->_cellCache[$pCoord] = true;
+
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
+
+ return $cell;
+ } // function addCacheData()
+
+
+ /**
+ * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
+ *
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return boolean
+ */
+ public function isDataSet($pCoord) {
+ // Check if the requested entry is the current object, or exists in the cache
+ if (parent::isDataSet($pCoord)) {
+ if ($this->_currentObjectID == $pCoord) {
+ return true;
+ }
+ // Check if the requested entry still exists in cache
+ $success = wincache_ucache_exists($this->_cachePrefix.$pCoord.'.cache');
+ if ($success === false) {
+ // Entry no longer exists in Wincache, so clear it from the cache array
+ parent::deleteCacheData($pCoord);
+ throw new Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
+ }
+ return true;
+ }
+ return false;
+ } // function isDataSet()
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return $this->_currentObject;
+ }
+ $this->_storeData();
+
+ // Check if the entry that has been requested actually exists
+ $obj = null;
+ if (parent::isDataSet($pCoord)) {
+ $success = false;
+ $obj = wincache_ucache_get($this->_cachePrefix.$pCoord.'.cache', $success);
+ if ($success === false) {
+ // Entry no longer exists in WinCache, so clear it from the cache array
+ parent::deleteCacheData($pCoord);
+ throw new Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
+ }
+ } else {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = unserialize($obj);
+ // Re-attach the parent worksheet
+ $this->_currentObject->attach($this->_parent);
+
+ // Return requested entry
+ return $this->_currentObject;
+ } // function getCacheData()
+
+
+ /**
+ * Delete a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws Exception
+ */
+ public function deleteCacheData($pCoord) {
+ // Delete the entry from Wincache
+ wincache_ucache_delete($this->_cachePrefix.$pCoord.'.cache');
+
+ // Delete the entry from our cell address array
+ parent::deleteCacheData($pCoord);
+ } // function deleteCacheData()
+
+
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent) {
+ parent::copyCellCollection($parent);
+ // Get a new id for the new file name
+ $baseUnique = $this->_getUniqueID();
+ $newCachePrefix = substr(md5($baseUnique),0,8).'.';
+ $cacheList = $this->getCellList();
+ foreach($cacheList as $cellID) {
+ if ($cellID != $this->_currentObjectID) {
+ $success = false;
+ $obj = wincache_ucache_get($this->_cachePrefix.$cellID.'.cache', $success);
+ if ($success === false) {
+ // Entry no longer exists in WinCache, so clear it from the cache array
+ parent::deleteCacheData($cellID);
+ throw new Exception('Cell entry '.$cellID.' no longer exists in Wincache');
+ }
+ if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->_cacheTime)) {
+ $this->__destruct();
+ throw new Exception('Failed to store cell '.$cellID.' in Wincache');
+ }
+ }
+ }
+ $this->_cachePrefix = $newCachePrefix;
+ } // function copyCellCollection()
+
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells() {
+ if(!is_null($this->_currentObject)) {
+ $this->_currentObject->detach();
+ $this->_currentObject = $this->_currentObjectID = null;
+ }
+
+ // Flush the WinCache cache
+ $this->__destruct();
+
+ $this->_cellCache = array();
+
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->_parent = null;
+ } // function unsetWorksheetCells()
+
+
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ * @param array of mixed $arguments Additional initialisation arguments
+ */
+ public function __construct(PHPExcel_Worksheet $parent, $arguments) {
+ $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
+
+ if (is_null($this->_cachePrefix)) {
+ $baseUnique = $this->_getUniqueID();
+ $this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
+ $this->_cacheTime = $cacheTime;
+
+ parent::__construct($parent);
+ }
+ } // function __construct()
+
+
+ /**
+ * Destroy this cell collection
+ */
+ public function __destruct() {
+ $cacheList = $this->getCellList();
+ foreach($cacheList as $cellID) {
+ wincache_ucache_delete($this->_cachePrefix.$cellID.'.cache');
+ }
+ } // function __destruct()
+
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable() {
+ if (!function_exists('wincache_ucache_add')) {
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/admin/survey/excel/PHPExcel/CachedObjectStorageFactory.php b/admin/survey/excel/PHPExcel/CachedObjectStorageFactory.php
new file mode 100644
index 0000000..d523a20
--- /dev/null
+++ b/admin/survey/excel/PHPExcel/CachedObjectStorageFactory.php
@@ -0,0 +1,239 @@
+<?php
+
+/**
+ * PHPExcel
+ *
+ * Copyright (c) 2006 - 2012 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version 1.7.8, 2012-10-12
+ */
+
+
+/**
+ * PHPExcel_CachedObjectStorageFactory
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ */
+class PHPExcel_CachedObjectStorageFactory
+{
+ const cache_in_memory = 'Memory';
+ const cache_in_memory_gzip = 'MemoryGZip';
+ const cache_in_memory_serialized = 'MemorySerialized';
+ const cache_igbinary = 'Igbinary';
+ const cache_to_discISAM = 'DiscISAM';
+ const cache_to_apc = 'APC';
+ const cache_to_memcache = 'Memcache';
+ const cache_to_phpTemp = 'PHPTemp';
+ const cache_to_wincache = 'Wincache';
+ const cache_to_sqlite = 'SQLite';
+ const cache_to_sqlite3 = 'SQLite3';
+
+
+ /**
+ * Name of the method used for cell cacheing
+ *
+ * @var string
+ */
+ private static $_cacheStorageMethod = NULL;
+
+ /**
+ * Name of the class used for cell cacheing
+ *
+ * @var string
+ */
+ private static $_cacheStorageClass = NULL;
+
+
+ /**
+ * List of all possible cache storage methods
+ *
+ * @var string[]
+ */
+ private static $_storageMethods = array(
+ self::cache_in_memory,
+ self::cache_in_memory_gzip,
+ self::cache_in_memory_serialized,
+ self::cache_igbinary,
+ self::cache_to_phpTemp,
+ self::cache_to_discISAM,
+ self::cache_to_apc,
+ self::cache_to_memcache,
+ self::cache_to_wincache,
+ self::cache_to_sqlite,
+ self::cache_to_sqlite3,
+ );
+
+
+ /**
+ * Default arguments for each cache storage method
+ *
+ * @var array of mixed array
+ */
+ private static $_storageMethodDefaultParameters = array(
+ self::cache_in_memory => array(
+ ),
+ self::cache_in_memory_gzip => array(
+ ),
+ self::cache_in_memory_serialized => array(
+ ),
+ self::cache_igbinary => array(
+ ),
+ self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB'
+ ),
+ self::cache_to_discISAM => array( 'dir' => NULL
+ ),
+ self::cache_to_apc => array( 'cacheTime' => 600
+ ),
+ self::cache_to_memcache => array( 'memcacheServer' => 'localhost',
+ 'memcachePort' => 11211,
+ 'cacheTime' => 600
+ ),
+ self::cache_to_wincache => array( 'cacheTime' => 600
+ ),
+ self::cache_to_sqlite => array(
+ ),
+ self::cache_to_sqlite3 => array(
+ ),
+ );
+
+
+ /**
+ * Arguments for the active cache storage method
+ *
+ * @var array of mixed array
+ */
+ private static $_storageMethodParameters = array();
+
+
+ /**
+ * Return the current cache storage method
+ *
+ * @return string|NULL
+ **/
+ public static function getCacheStorageMethod()
+ {
+ return self::$_cacheStorageMethod;
+ } // function getCacheStorageMethod()
+
+
+ /**
+ * Return the current cache storage class
+ *
+ * @return PHPExcel_CachedObjectStorage_ICache|NULL
+ **/
+ public static function getCacheStorageClass()
+ {
+ return self::$_cacheStorageClass;
+ } // function getCacheStorageClass()
+
+
+ /**
+ * Return the list of all possible cache storage methods
+ *
+ * @return string[]
+ **/
+ public static function getAllCacheStorageMethods()
+ {
+ return self::$_storageMethods;
+ } // function getCacheStorageMethods()
+
+
+ /**
+ * Return the list of all available cache storage methods
+ *
+ * @return string[]
+ **/
+ public static function getCacheStorageMethods()
+ {
+ $activeMethods = array();
+ foreach(self::$_storageMethods as $storageMethod) {
+ $cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $storageMethod;
+ if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) {
+ $activeMethods[] = $storageMethod;
+ }
+ }
+ return $activeMethods;
+ } // function getCacheStorageMethods()
+
+
+ /**
+ * Identify the cache storage method to use
+ *
+ * @param string $method Name of the method to use for cell cacheing
+ * @param array of mixed $arguments Additional arguments to pass to the cell caching class
+ * when instantiating
+ * @return boolean
+ **/
+ public static function initialize($method = self::cache_in_memory, $arguments = array())
+ {
+ if (!in_array($method,self::$_storageMethods)) {
+ return FALSE;
+ }
+
+ $cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
+ if (!call_user_func(array( $cacheStorageClass,
+ 'cacheMethodIsAvailable'))) {
+ return FALSE;
+ }
+
+ self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method];
+ foreach($arguments as $k => $v) {
+ if (isset(self::$_storageMethodParameters[$method][$k])) {
+ self::$_storageMethodParameters[$method][$k] = $v;
+ }
+ }
+
+ if (self::$_cacheStorageMethod === NULL) {
+ self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $method;
+ self::$_cacheStorageMethod = $method;
+ }
+ return TRUE;
+ } // function initialize()
+
+
+ /**
+ * Initialise the cache storage
+ *
+ * @param PHPExcel_Worksheet $parent Enable cell caching for this worksheet
+ * @return PHPExcel_CachedObjectStorage_ICache
+ **/
+ public static function getInstance(PHPExcel_Worksheet $parent)
+ {
+ $cacheMethodIsAvailable = TRUE;
+ if (self::$_cacheStorageMethod === NULL) {
+ $cacheMethodIsAvailable = self::initialize();
+ }
+
+ if ($cacheMethodIsAvailable) {
+ $instance = new self::$_cacheStorageClass( $parent,
+ self::$_storageMethodParameters[self::$_cacheStorageMethod]
+ );
+ if ($instance !== NULL) {
+ return $instance;
+ }
+ }
+
+ return FALSE;
+ } // function getInstance()
+
+} \ No newline at end of file