mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2025-02-18 07:23:16 +03:00
PSR-2 standardization
This commit is contained in:
parent
ee8062fece
commit
33a5fbed72
@ -35,21 +35,21 @@ namespace PHPExcel;
|
||||
* @package PHPExcel\CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class CachedObjectStorage_APC extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
|
||||
|
||||
class CachedObjectStorage_APC extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_cachePrefix = null;
|
||||
protected $cachePrefix = null;
|
||||
|
||||
/**
|
||||
* Cache timeout
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $_cacheTime = 600;
|
||||
protected $cacheTime = 600;
|
||||
|
||||
|
||||
/**
|
||||
@ -59,59 +59,62 @@ class CachedObjectStorage_APC extends CachedObjectStorage_CacheBase implements C
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
|
||||
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');
|
||||
throw new Exception('Failed to store cell '.$this->currentObjectID.' in APC');
|
||||
}
|
||||
$this->_currentCellIsDirty = false;
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 PHPExcel\Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
public function addCacheData($pCoord, Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
$this->_cellCache[$pCoord] = true;
|
||||
$this->cellCache[$pCoord] = true;
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = 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) {
|
||||
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) {
|
||||
if ($this->currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in apc
|
||||
$success = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
||||
$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);
|
||||
@ -120,26 +123,25 @@ class CachedObjectStorage_APC extends CachedObjectStorage_CacheBase implements C
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // function isDataSet()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel\Exception
|
||||
* @return PHPExcel\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
||||
$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);
|
||||
@ -151,98 +153,95 @@ class CachedObjectStorage_APC extends CachedObjectStorage_CacheBase implements C
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize($obj);
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = unserialize($obj);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
public function deleteCacheData($pCoord)
|
||||
{
|
||||
// Delete the entry from APC
|
||||
apc_delete($this->_cachePrefix.$pCoord.'.cache');
|
||||
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
|
||||
* @throws PHPExcel\Exception
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(Worksheet $parent) {
|
||||
public function copyCellCollection(Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
$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');
|
||||
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)) {
|
||||
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()
|
||||
|
||||
$this->cachePrefix = $newCachePrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if ($this->currentObject !== null) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
|
||||
// Flush the APC cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->_cellCache = array();
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
@ -250,29 +249,29 @@ class CachedObjectStorage_APC extends CachedObjectStorage_CacheBase implements C
|
||||
* @param PHPExcel\Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(Worksheet $parent, $arguments) {
|
||||
public function __construct(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;
|
||||
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() {
|
||||
public function __destruct()
|
||||
{
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
apc_delete($this->_cachePrefix.$cellID.'.cache');
|
||||
apc_delete($this->cachePrefix.$cellID.'.cache');
|
||||
}
|
||||
} // function __destruct()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
@ -280,14 +279,8 @@ class CachedObjectStorage_APC extends CachedObjectStorage_CacheBase implements C
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!function_exists('apc_store')) {
|
||||
return false;
|
||||
}
|
||||
if (apc_sma_info() === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
return function_exists('apc_store') && (apc_sma_info() !== false);
|
||||
}
|
||||
}
|
||||
|
@ -35,36 +35,35 @@ namespace PHPExcel;
|
||||
* @package PHPExcel\CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
abstract class CachedObjectStorage_CacheBase {
|
||||
|
||||
abstract class CachedObjectStorage_CacheBase
|
||||
{
|
||||
/**
|
||||
* Parent worksheet
|
||||
*
|
||||
* @var PHPExcel\Worksheet
|
||||
*/
|
||||
protected $_parent;
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* The currently active Cell
|
||||
*
|
||||
* @var PHPExcel\Cell
|
||||
*/
|
||||
protected $_currentObject = null;
|
||||
protected $currentObject = null;
|
||||
|
||||
/**
|
||||
* Coordinate address of the currently active Cell
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_currentObjectID = null;
|
||||
|
||||
protected $currentObjectID = null;
|
||||
|
||||
/**
|
||||
* Flag indicating whether the currently active Cell requires saving
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_currentCellIsDirty = true;
|
||||
protected $currentCellIsDirty = true;
|
||||
|
||||
/**
|
||||
* An array of cells or cell pointers for the worksheet cells held in this cache,
|
||||
@ -72,7 +71,7 @@ abstract class CachedObjectStorage_CacheBase {
|
||||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
protected $_cellCache = array();
|
||||
protected $cellCache = array();
|
||||
|
||||
|
||||
/**
|
||||
@ -80,13 +79,13 @@ abstract class CachedObjectStorage_CacheBase {
|
||||
*
|
||||
* @param PHPExcel\Worksheet $parent The worksheet for this cell collection
|
||||
*/
|
||||
public function __construct(Worksheet $parent) {
|
||||
public function __construct(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()
|
||||
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the parent worksheet for this cell collection
|
||||
@ -95,7 +94,7 @@ abstract class CachedObjectStorage_CacheBase {
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->_parent;
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,14 +103,14 @@ abstract class CachedObjectStorage_CacheBase {
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
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()
|
||||
|
||||
return isset($this->cellCache[$pCoord]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a cell object from one address to another
|
||||
@ -120,19 +119,19 @@ abstract class CachedObjectStorage_CacheBase {
|
||||
* @param string $toAddress Destination address of the cell to move
|
||||
* @return boolean
|
||||
*/
|
||||
public function moveCell($fromAddress, $toAddress) {
|
||||
if ($fromAddress === $this->_currentObjectID) {
|
||||
$this->_currentObjectID = $toAddress;
|
||||
public function moveCell($fromAddress, $toAddress)
|
||||
{
|
||||
if ($fromAddress === $this->currentObjectID) {
|
||||
$this->currentObjectID = $toAddress;
|
||||
}
|
||||
$this->_currentCellIsDirty = true;
|
||||
if (isset($this->_cellCache[$fromAddress])) {
|
||||
$this->_cellCache[$toAddress] = &$this->_cellCache[$fromAddress];
|
||||
unset($this->_cellCache[$fromAddress]);
|
||||
$this->currentCellIsDirty = true;
|
||||
if (isset($this->cellCache[$fromAddress])) {
|
||||
$this->cellCache[$toAddress] = &$this->cellCache[$fromAddress];
|
||||
unset($this->cellCache[$fromAddress]);
|
||||
}
|
||||
|
||||
return true;
|
||||
} // function moveCell()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache
|
||||
@ -141,10 +140,10 @@ abstract class CachedObjectStorage_CacheBase {
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function updateCacheData(Cell $cell) {
|
||||
return $this->addCacheData($cell->getCoordinate(),$cell);
|
||||
} // function updateCacheData()
|
||||
|
||||
public function updateCacheData(Cell $cell)
|
||||
{
|
||||
return $this->addCacheData($cell->getCoordinate(), $cell);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
@ -152,47 +151,46 @@ abstract class CachedObjectStorage_CacheBase {
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
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]);
|
||||
if (is_object($this->cellCache[$pCoord])) {
|
||||
$this->cellCache[$pCoord]->detach();
|
||||
unset($this->cellCache[$pCoord]);
|
||||
}
|
||||
$this->_currentCellIsDirty = false;
|
||||
} // function deleteCacheData()
|
||||
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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()
|
||||
|
||||
public function getCellList()
|
||||
{
|
||||
return array_keys($this->cellCache);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the list of all cell addresses currently held in cache by row and column
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSortedCellList() {
|
||||
public function getSortedCellList()
|
||||
{
|
||||
$sortKeys = array();
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord,'%[A-Z]%d', $column, $row);
|
||||
$sortKeys[sprintf('%09d%3s',$row,$column)] = $coord;
|
||||
sscanf($coord, '%[A-Z]%d', $column, $row);
|
||||
$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
|
||||
@ -205,22 +203,22 @@ abstract class CachedObjectStorage_CacheBase {
|
||||
$col = array('A' => '1A');
|
||||
$row = array(1);
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
sscanf($coord,'%[A-Z]%d', $c, $r);
|
||||
sscanf($coord, '%[A-Z]%d', $c, $r);
|
||||
$row[$r] = $r;
|
||||
$col[$c] = strlen($c).$c;
|
||||
}
|
||||
if (!empty($row)) {
|
||||
// Determine highest column and row
|
||||
$highestRow = max($row);
|
||||
$highestColumn = substr(max($col),1);
|
||||
$highestColumn = substr(max($col), 1);
|
||||
}
|
||||
|
||||
return array( 'row' => $highestRow,
|
||||
'column' => $highestColumn
|
||||
);
|
||||
return array(
|
||||
'row' => $highestRow,
|
||||
'column' => $highestColumn
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the cell address of the currently active cell object
|
||||
*
|
||||
@ -228,7 +226,7 @@ abstract class CachedObjectStorage_CacheBase {
|
||||
*/
|
||||
public function getCurrentAddress()
|
||||
{
|
||||
return $this->_currentObjectID;
|
||||
return $this->currentObjectID;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -238,7 +236,7 @@ abstract class CachedObjectStorage_CacheBase {
|
||||
*/
|
||||
public function getCurrentColumn()
|
||||
{
|
||||
sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);
|
||||
sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
|
||||
return $column;
|
||||
}
|
||||
|
||||
@ -249,7 +247,7 @@ abstract class CachedObjectStorage_CacheBase {
|
||||
*/
|
||||
public function getCurrentRow()
|
||||
{
|
||||
sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);
|
||||
sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
|
||||
return $row;
|
||||
}
|
||||
|
||||
@ -275,19 +273,19 @@ abstract class CachedObjectStorage_CacheBase {
|
||||
return $colRow['row'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate a unique ID for cache referencing
|
||||
*
|
||||
* @return string Unique Reference
|
||||
*/
|
||||
protected function _getUniqueID() {
|
||||
protected function getUniqueID()
|
||||
{
|
||||
if (function_exists('posix_getpid')) {
|
||||
$baseUnique = posix_getpid();
|
||||
} else {
|
||||
$baseUnique = mt_rand();
|
||||
}
|
||||
return uniqid($baseUnique,true);
|
||||
return uniqid($baseUnique, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -296,16 +294,16 @@ abstract class CachedObjectStorage_CacheBase {
|
||||
* @param PHPExcel\Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(Worksheet $parent) {
|
||||
$this->_currentCellIsDirty;
|
||||
$this->_storeData();
|
||||
public function copyCellCollection(Worksheet $parent)
|
||||
{
|
||||
$this->currentCellIsDirty;
|
||||
$this->storeData();
|
||||
|
||||
$this->_parent = $parent;
|
||||
if (($this->_currentObject !== null) && (is_object($this->_currentObject))) {
|
||||
$this->_currentObject->attach($this);
|
||||
$this->parent = $parent;
|
||||
if (($this->currentObject !== null) && (is_object($this->currentObject))) {
|
||||
$this->currentObject->attach($this);
|
||||
}
|
||||
} // function copyCellCollection()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
@ -313,7 +311,8 @@ abstract class CachedObjectStorage_CacheBase {
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -35,28 +35,28 @@ namespace PHPExcel;
|
||||
* @package PHPExcel\CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class CachedObjectStorage_DiscISAM extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
|
||||
|
||||
class CachedObjectStorage_DiscISAM extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Name of the file for this cache
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_fileName = null;
|
||||
private $fileName = null;
|
||||
|
||||
/**
|
||||
* File handle for this cache file
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $_fileHandle = null;
|
||||
private $fileHandle = null;
|
||||
|
||||
/**
|
||||
* Directory/Folder where the cache file is located
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_cacheDirectory = null;
|
||||
private $cacheDirectory = null;
|
||||
|
||||
|
||||
/**
|
||||
@ -66,22 +66,22 @@ class CachedObjectStorage_DiscISAM extends CachedObjectStorage_CacheBase impleme
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
protected 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(
|
||||
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
|
||||
'sz' => ftell($this->fileHandle) - $offset
|
||||
);
|
||||
$this->_currentCellIsDirty = false;
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
@ -91,18 +91,18 @@ class CachedObjectStorage_DiscISAM extends CachedObjectStorage_CacheBase impleme
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
public function addCacheData($pCoord, Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
@ -111,82 +111,82 @@ class CachedObjectStorage_DiscISAM extends CachedObjectStorage_CacheBase impleme
|
||||
* @throws PHPExcel\Exception
|
||||
* @return PHPExcel\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
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']));
|
||||
$this->currentObjectID = $pCoord;
|
||||
fseek($this->fileHandle, $this->cellCache[$pCoord]['ptr']);
|
||||
$this->currentObject = unserialize(fread($this->fileHandle, $this->cellCache[$pCoord]['sz']));
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel\Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(Worksheet $parent) {
|
||||
public function copyCellCollection(Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$newFileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$newFileName = $this->cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
|
||||
// Copy the existing cell cache file
|
||||
copy ($this->_fileName,$newFileName);
|
||||
$this->_fileName = $newFileName;
|
||||
copy ($this->fileName, $newFileName);
|
||||
$this->fileName = $newFileName;
|
||||
// Open the copied cell cache file
|
||||
$this->_fileHandle = fopen($this->_fileName,'a+');
|
||||
} // function copyCellCollection()
|
||||
|
||||
$this->fileHandle = fopen($this->fileName, 'a+');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
$this->parent = null;
|
||||
|
||||
// Close down the temporary cache file
|
||||
$this->__destruct();
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
@ -194,29 +194,29 @@ class CachedObjectStorage_DiscISAM extends CachedObjectStorage_CacheBase impleme
|
||||
* @param PHPExcel\Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(Worksheet $parent, $arguments) {
|
||||
$this->_cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== nul))
|
||||
public function __construct(Worksheet $parent, $arguments)
|
||||
{
|
||||
$this->cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== null))
|
||||
? $arguments['dir']
|
||||
: 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+');
|
||||
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);
|
||||
public function __destruct()
|
||||
{
|
||||
if (!is_null($this->fileHandle)) {
|
||||
fclose($this->fileHandle);
|
||||
unlink($this->fileName);
|
||||
}
|
||||
$this->_fileHandle = null;
|
||||
} // function __destruct()
|
||||
|
||||
$this->fileHandle = null;
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ namespace PHPExcel;
|
||||
* @package PHPExcel\CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class CachedObjectStorage_Igbinary extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
|
||||
|
||||
class CachedObjectStorage_Igbinary extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
@ -44,16 +44,16 @@ class CachedObjectStorage_Igbinary extends CachedObjectStorage_CacheBase impleme
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
$this->_cellCache[$this->_currentObjectID] = igbinary_serialize($this->_currentObject);
|
||||
$this->_currentCellIsDirty = false;
|
||||
$this->cellCache[$this->currentObjectID] = igbinary_serialize($this->currentObject);
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
@ -63,18 +63,18 @@ class CachedObjectStorage_Igbinary extends CachedObjectStorage_CacheBase impleme
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
public function addCacheData($pCoord, Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
@ -83,59 +83,59 @@ class CachedObjectStorage_Igbinary extends CachedObjectStorage_CacheBase impleme
|
||||
* @throws PHPExcel\Exception
|
||||
* @return PHPExcel\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
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]);
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = igbinary_unserialize($this->cellCache[$pCoord]);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
@ -143,12 +143,8 @@ class CachedObjectStorage_Igbinary extends CachedObjectStorage_CacheBase impleme
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!function_exists('igbinary_serialize')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
return function_exists('igbinary_serialize');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,28 +35,28 @@ namespace PHPExcel;
|
||||
* @package PHPExcel\CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class CachedObjectStorage_Memcache extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
|
||||
|
||||
class CachedObjectStorage_Memcache extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_cachePrefix = null;
|
||||
private $cachePrefix = null;
|
||||
|
||||
/**
|
||||
* Cache timeout
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_cacheTime = 600;
|
||||
private $cacheTime = 600;
|
||||
|
||||
/**
|
||||
* Memcache interface
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $_memcache = null;
|
||||
private $memcache = null;
|
||||
|
||||
|
||||
/**
|
||||
@ -66,22 +66,31 @@ class CachedObjectStorage_Memcache extends CachedObjectStorage_CacheBase impleme
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
protected 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)) {
|
||||
$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');
|
||||
throw new Exception('Failed to store cell '.$this->currentObjectID.' in MemCache');
|
||||
}
|
||||
}
|
||||
$this->_currentCellIsDirty = false;
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
@ -91,19 +100,19 @@ class CachedObjectStorage_Memcache extends CachedObjectStorage_CacheBase impleme
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
public function addCacheData($pCoord, Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
$this->_cellCache[$pCoord] = true;
|
||||
$this->cellCache[$pCoord] = true;
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = 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?
|
||||
@ -112,14 +121,15 @@ class CachedObjectStorage_Memcache extends CachedObjectStorage_CacheBase impleme
|
||||
* @return void
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
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) {
|
||||
if ($this->currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in Memcache
|
||||
$success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
|
||||
$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);
|
||||
@ -128,8 +138,7 @@ class CachedObjectStorage_Memcache extends CachedObjectStorage_CacheBase impleme
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // function isDataSet()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
@ -138,15 +147,17 @@ class CachedObjectStorage_Memcache extends CachedObjectStorage_CacheBase impleme
|
||||
* @throws PHPExcel\Exception
|
||||
* @return PHPExcel\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID)
|
||||
{
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$obj = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
|
||||
$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);
|
||||
@ -158,44 +169,43 @@ class CachedObjectStorage_Memcache extends CachedObjectStorage_CacheBase impleme
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize($obj);
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = unserialize($obj);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
public function deleteCacheData($pCoord)
|
||||
{
|
||||
// Delete the entry from Memcache
|
||||
$this->_memcache->delete($this->_cachePrefix.$pCoord.'.cache');
|
||||
$this->memcache->delete($this->cachePrefix.$pCoord.'.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
} // function deleteCacheData()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
@ -204,50 +214,50 @@ class CachedObjectStorage_Memcache extends CachedObjectStorage_CacheBase impleme
|
||||
* @throws PHPExcel\Exception
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(Worksheet $parent) {
|
||||
public function copyCellCollection(Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
$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');
|
||||
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)) {
|
||||
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;
|
||||
$this->cachePrefix = $newCachePrefix;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
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();
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
@ -255,27 +265,38 @@ class CachedObjectStorage_Memcache extends CachedObjectStorage_CacheBase impleme
|
||||
* @param PHPExcel\Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(Worksheet $parent, $arguments) {
|
||||
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
|
||||
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
|
||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||
public function __construct(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).'.';
|
||||
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->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;
|
||||
$this->cacheTime = $cacheTime;
|
||||
|
||||
parent::__construct($parent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Memcache error handler
|
||||
*
|
||||
@ -283,20 +304,21 @@ class CachedObjectStorage_Memcache extends CachedObjectStorage_CacheBase impleme
|
||||
* @param integer $port Memcache port
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function failureCallback($host, $port) {
|
||||
public function failureCallback($host, $port)
|
||||
{
|
||||
throw new Exception('memcache '.$host.':'.$port.' failed');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
public function __destruct()
|
||||
{
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
$this->_memcache->delete($this->_cachePrefix.$cellID.'.cache');
|
||||
foreach ($cacheList as $cellID) {
|
||||
$this->memcache->delete($this->cachePrefix.$cellID.'.cache');
|
||||
}
|
||||
} // function __destruct()
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
@ -304,12 +326,8 @@ class CachedObjectStorage_Memcache extends CachedObjectStorage_CacheBase impleme
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!function_exists('memcache_add')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
return function_exists('memcache_add');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,15 +35,15 @@ namespace PHPExcel;
|
||||
* @package PHPExcel\CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class CachedObjectStorage_Memory extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
|
||||
|
||||
class CachedObjectStorage_Memory extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Dummy method callable from CacheBase, but unused by Memory cache
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _storeData() {
|
||||
} // function _storeData()
|
||||
protected function storeData() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
@ -54,14 +54,13 @@ class CachedObjectStorage_Memory extends CachedObjectStorage_CacheBase implement
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, Cell $cell) {
|
||||
$this->_cellCache[$pCoord] = $cell;
|
||||
$this->cellCache[$pCoord] = $cell;
|
||||
|
||||
// Set current entry to the new/updated entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->currentObjectID = $pCoord;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
@ -70,21 +69,21 @@ class CachedObjectStorage_Memory extends CachedObjectStorage_CacheBase implement
|
||||
* @throws PHPExcel\Exception
|
||||
* @return PHPExcel\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
$this->_currentObjectID = null;
|
||||
if (!isset($this->cellCache[$pCoord])) {
|
||||
$this->currentObjectID = null;
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->currentObjectID = $pCoord;
|
||||
|
||||
// Return requested entry
|
||||
return $this->_cellCache[$pCoord];
|
||||
} // function getCacheData()
|
||||
|
||||
return $this->cellCache[$pCoord];
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
@ -92,36 +91,36 @@ class CachedObjectStorage_Memory extends CachedObjectStorage_CacheBase implement
|
||||
* @param PHPExcel\Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(Worksheet $parent) {
|
||||
public function copyCellCollection(Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
|
||||
$newCollection = array();
|
||||
foreach($this->_cellCache as $k => &$cell) {
|
||||
foreach($this->cellCache as $k => &$cell) {
|
||||
$newCollection[$k] = clone $cell;
|
||||
$newCollection[$k]->attach($this);
|
||||
}
|
||||
|
||||
$this->_cellCache = $newCollection;
|
||||
$this->cellCache = $newCollection;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
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) {
|
||||
foreach($this->cellCache as $k => &$cell) {
|
||||
$cell->detach();
|
||||
$this->_cellCache[$k] = null;
|
||||
$this->cellCache[$k] = null;
|
||||
}
|
||||
unset($cell);
|
||||
|
||||
$this->_cellCache = array();
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
$this->parent = null;
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ namespace PHPExcel;
|
||||
* @package PHPExcel\CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class CachedObjectStorage_MemoryGZip extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
|
||||
|
||||
class CachedObjectStorage_MemoryGZip extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
@ -44,16 +44,16 @@ class CachedObjectStorage_MemoryGZip extends CachedObjectStorage_CacheBase imple
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
$this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));
|
||||
$this->_currentCellIsDirty = false;
|
||||
$this->cellCache[$this->currentObjectID] = gzdeflate(serialize($this->currentObject));
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
@ -63,18 +63,18 @@ class CachedObjectStorage_MemoryGZip extends CachedObjectStorage_CacheBase imple
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
public function addCacheData($pCoord, Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
@ -83,28 +83,28 @@ class CachedObjectStorage_MemoryGZip extends CachedObjectStorage_CacheBase imple
|
||||
* @throws PHPExcel\Exception
|
||||
* @return PHPExcel\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
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]));
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = unserialize(gzinflate($this->cellCache[$pCoord]));
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
@ -112,28 +112,27 @@ class CachedObjectStorage_MemoryGZip extends CachedObjectStorage_CacheBase imple
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if(!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
$this->parent = null;
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ namespace PHPExcel;
|
||||
* @package PHPExcel\CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class CachedObjectStorage_MemorySerialized extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
|
||||
|
||||
class CachedObjectStorage_MemorySerialized extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
@ -44,16 +44,16 @@ class CachedObjectStorage_MemorySerialized extends CachedObjectStorage_CacheBase
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
$this->_cellCache[$this->_currentObjectID] = serialize($this->_currentObject);
|
||||
$this->_currentCellIsDirty = false;
|
||||
$this->cellCache[$this->currentObjectID] = serialize($this->currentObject);
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
@ -63,18 +63,18 @@ class CachedObjectStorage_MemorySerialized extends CachedObjectStorage_CacheBase
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
public function addCacheData($pCoord, Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
@ -83,57 +83,57 @@ class CachedObjectStorage_MemorySerialized extends CachedObjectStorage_CacheBase
|
||||
* @throws PHPExcel\Exception
|
||||
* @return PHPExcel\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
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]);
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = unserialize($this->cellCache[$pCoord]);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if(!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
$this->parent = null;
|
||||
}
|
||||
}
|
||||
|
@ -33,21 +33,21 @@
|
||||
* @package PHPExcel\CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class CachedObjectStorage_PHPTemp extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
|
||||
|
||||
class CachedObjectStorage_PHPTemp extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Name of the file for this cache
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_fileHandle = null;
|
||||
private $fileHandle = null;
|
||||
|
||||
/**
|
||||
* Memory limit to use before reverting to file cache
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_memoryCacheSize = null;
|
||||
private $memoryCacheSize = null;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
@ -56,21 +56,21 @@ class CachedObjectStorage_PHPTemp extends CachedObjectStorage_CacheBase implemen
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
protected 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
|
||||
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->currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
@ -80,18 +80,18 @@ class CachedObjectStorage_PHPTemp extends CachedObjectStorage_CacheBase implemen
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
public function addCacheData($pCoord, Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
@ -100,82 +100,82 @@ class CachedObjectStorage_PHPTemp extends CachedObjectStorage_CacheBase implemen
|
||||
* @throws PHPExcel\Exception
|
||||
* @return PHPExcel\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
$this->storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
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']));
|
||||
$this->currentObjectID = $pCoord;
|
||||
fseek($this->fileHandle,$this->cellCache[$pCoord]['ptr']);
|
||||
$this->currentObject = unserialize(fread($this->fileHandle,$this->cellCache[$pCoord]['sz']));
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel\Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(Worksheet $parent) {
|
||||
public function copyCellCollection(Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
// Open a new stream for the cell cache data
|
||||
$newFileHandle = fopen('php://temp/maxmemory:'.$this->_memoryCacheSize,'a+');
|
||||
$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));
|
||||
fseek($this->fileHandle,0);
|
||||
while (!feof($this->fileHandle)) {
|
||||
fwrite($newFileHandle,fread($this->fileHandle, 1024));
|
||||
}
|
||||
$this->_fileHandle = $newFileHandle;
|
||||
} // function copyCellCollection()
|
||||
|
||||
$this->fileHandle = $newFileHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if(!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
$this->parent = null;
|
||||
|
||||
// Close down the php://temp file
|
||||
$this->__destruct();
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
@ -183,24 +183,24 @@ class CachedObjectStorage_PHPTemp extends CachedObjectStorage_CacheBase implemen
|
||||
* @param PHPExcel\Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(Worksheet $parent, $arguments) {
|
||||
$this->_memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';
|
||||
public function __construct(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+');
|
||||
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);
|
||||
public function __destruct()
|
||||
{
|
||||
if (!is_null($this->fileHandle)) {
|
||||
fclose($this->fileHandle);
|
||||
}
|
||||
$this->_fileHandle = null;
|
||||
} // function __destruct()
|
||||
|
||||
$this->fileHandle = null;
|
||||
}
|
||||
}
|
||||
|
@ -35,21 +35,22 @@ namespace PHPExcel;
|
||||
* @package PHPExcel\CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
|
||||
|
||||
class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Database table name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_TableName = null;
|
||||
private $TableName = null;
|
||||
|
||||
/**
|
||||
* Database handle
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $_DBHandle = null;
|
||||
private $DBHandle = null;
|
||||
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
@ -58,17 +59,17 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
protected 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;
|
||||
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()
|
||||
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
@ -78,18 +79,18 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
public function addCacheData($pCoord, Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
@ -98,33 +99,33 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
* @throws PHPExcel\Exception
|
||||
* @return PHPExcel\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
$this->storeData();
|
||||
|
||||
$query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
|
||||
$cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
|
||||
$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()));
|
||||
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;
|
||||
$this->currentObjectID = $pCoord;
|
||||
|
||||
$cellResult = $cellResultSet->fetchSingle();
|
||||
$this->_currentObject = unserialize($cellResult);
|
||||
$this->currentObject = unserialize($cellResult);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a value set for an indexed cell?
|
||||
@ -132,23 +133,23 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
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);
|
||||
$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()));
|
||||
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
|
||||
@ -156,20 +157,20 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
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()
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a cell object from one address to another
|
||||
@ -178,39 +179,40 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
* @param string $toAddress Destination address of the cell to move
|
||||
* @return boolean
|
||||
*/
|
||||
public function moveCell($fromAddress, $toAddress) {
|
||||
if ($fromAddress === $this->_currentObjectID) {
|
||||
$this->_currentObjectID = $toAddress;
|
||||
public function moveCell($fromAddress, $toAddress)
|
||||
{
|
||||
if ($fromAddress === $this->currentObjectID) {
|
||||
$this->currentObjectID = $toAddress;
|
||||
}
|
||||
|
||||
$query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$toAddress."'";
|
||||
$result = $this->_DBHandle->exec($query);
|
||||
$query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$toAddress."'";
|
||||
$result = $this->DBHandle->exec($query);
|
||||
if ($result === false)
|
||||
throw new Exception($this->_DBHandle->lastErrorMsg());
|
||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||
|
||||
$query = "UPDATE kvp_".$this->_TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
|
||||
$result = $this->_DBHandle->exec($query);
|
||||
$query = "UPDATE kvp_".$this->TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
|
||||
$result = $this->DBHandle->exec($query);
|
||||
if ($result === false)
|
||||
throw new Exception($this->_DBHandle->lastErrorMsg());
|
||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||
|
||||
return true;
|
||||
} // function moveCell()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$query = "SELECT id FROM kvp_".$this->_TableName;
|
||||
$cellIdsResult = $this->_DBHandle->unbufferedQuery($query,SQLITE_ASSOC);
|
||||
$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()));
|
||||
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
|
||||
$cellKeys = array();
|
||||
foreach($cellIdsResult as $row) {
|
||||
@ -218,8 +220,7 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
}
|
||||
|
||||
return $cellKeys;
|
||||
} // function getCellList()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
@ -227,69 +228,69 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
* @param PHPExcel\Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(Worksheet $parent) {
|
||||
$this->_currentCellIsDirty;
|
||||
$this->_storeData();
|
||||
public function copyCellCollection(Worksheet $parent)
|
||||
{
|
||||
$this->currentCellIsDirty;
|
||||
$this->storeData();
|
||||
|
||||
// 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()));
|
||||
$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()
|
||||
|
||||
$this->TableName = $tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
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;
|
||||
$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(Worksheet $parent) {
|
||||
public function __construct(Worksheet $parent)
|
||||
{
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->_DBHandle)) {
|
||||
$this->_TableName = str_replace('.','_',$this->_getUniqueID());
|
||||
$_DBName = ':memory:';
|
||||
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()));
|
||||
$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() {
|
||||
if (!is_null($this->_DBHandle)) {
|
||||
$this->_DBHandle->queryExec('DROP TABLE kvp_'.$this->_TableName);
|
||||
public function __destruct()
|
||||
{
|
||||
if (!is_null($this->DBHandle)) {
|
||||
$this->DBHandle->queryExec('DROP TABLE kvp_'.$this->TableName);
|
||||
}
|
||||
$this->_DBHandle = null;
|
||||
} // function __destruct()
|
||||
|
||||
$this->DBHandle = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
@ -297,11 +298,8 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!function_exists('sqlite_open')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
return function_exists('sqlite_open');
|
||||
}
|
||||
}
|
||||
|
@ -35,49 +35,50 @@ namespace PHPExcel;
|
||||
* @package PHPExcel\CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
|
||||
|
||||
class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Database table name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_TableName = null;
|
||||
private $TableName = null;
|
||||
|
||||
/**
|
||||
* Database handle
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $_DBHandle = null;
|
||||
private $DBHandle = null;
|
||||
|
||||
/**
|
||||
* Prepared statement for a SQLite3 select query
|
||||
*
|
||||
* @var SQLite3Stmt
|
||||
*/
|
||||
private $_selectQuery;
|
||||
private $selectQuery;
|
||||
|
||||
/**
|
||||
* Prepared statement for a SQLite3 insert query
|
||||
*
|
||||
* @var SQLite3Stmt
|
||||
*/
|
||||
private $_insertQuery;
|
||||
private $insertQuery;
|
||||
|
||||
/**
|
||||
* Prepared statement for a SQLite3 update query
|
||||
*
|
||||
* @var SQLite3Stmt
|
||||
*/
|
||||
private $_updateQuery;
|
||||
private $updateQuery;
|
||||
|
||||
/**
|
||||
* Prepared statement for a SQLite3 delete query
|
||||
*
|
||||
* @var SQLite3Stmt
|
||||
*/
|
||||
private $_deleteQuery;
|
||||
private $deleteQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
@ -86,20 +87,20 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
$this->_insertQuery->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT);
|
||||
$this->_insertQuery->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB);
|
||||
$result = $this->_insertQuery->execute();
|
||||
$this->insertQuery->bindValue('id', $this->currentObjectID, SQLITE3_TEXT);
|
||||
$this->insertQuery->bindValue('data', serialize($this->currentObject), SQLITE3_BLOB);
|
||||
$result = $this->insertQuery->execute();
|
||||
if ($result === false)
|
||||
throw new Exception($this->_DBHandle->lastErrorMsg());
|
||||
$this->_currentCellIsDirty = false;
|
||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
@ -109,18 +110,18 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
public function addCacheData($pCoord, Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = $cell;
|
||||
$this->currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
@ -129,16 +130,17 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
||||
* @throws PHPExcel\Exception
|
||||
* @return PHPExcel\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
$this->storeData();
|
||||
|
||||
$this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
|
||||
$cellResult = $this->_selectQuery->execute();
|
||||
$this->selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
|
||||
$cellResult = $this->selectQuery->execute();
|
||||
if ($cellResult === false) {
|
||||
throw new Exception($this->_DBHandle->lastErrorMsg());
|
||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
|
||||
if ($cellData === false) {
|
||||
@ -147,16 +149,15 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->currentObjectID = $pCoord;
|
||||
|
||||
$this->_currentObject = unserialize($cellData['value']);
|
||||
$this->currentObject = unserialize($cellData['value']);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a value set for an indexed cell?
|
||||
@ -164,22 +165,22 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
public function isDataSet($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
|
||||
$cellResult = $this->_selectQuery->execute();
|
||||
$this->selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
|
||||
$cellResult = $this->selectQuery->execute();
|
||||
if ($cellResult === false) {
|
||||
throw new Exception($this->_DBHandle->lastErrorMsg());
|
||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
|
||||
|
||||
return ($cellData === false) ? false : true;
|
||||
} // function isDataSet()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
@ -187,21 +188,21 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
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
|
||||
$this->_deleteQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
|
||||
$result = $this->_deleteQuery->execute();
|
||||
$this->deleteQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
|
||||
$result = $this->deleteQuery->execute();
|
||||
if ($result === false)
|
||||
throw new Exception($this->_DBHandle->lastErrorMsg());
|
||||
|
||||
$this->_currentCellIsDirty = false;
|
||||
} // function deleteCacheData()
|
||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a cell object from one address to another
|
||||
@ -210,40 +211,41 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
||||
* @param string $toAddress Destination address of the cell to move
|
||||
* @return boolean
|
||||
*/
|
||||
public function moveCell($fromAddress, $toAddress) {
|
||||
if ($fromAddress === $this->_currentObjectID) {
|
||||
$this->_currentObjectID = $toAddress;
|
||||
public function moveCell($fromAddress, $toAddress)
|
||||
{
|
||||
if ($fromAddress === $this->currentObjectID) {
|
||||
$this->currentObjectID = $toAddress;
|
||||
}
|
||||
|
||||
$this->_deleteQuery->bindValue('id',$toAddress,SQLITE3_TEXT);
|
||||
$result = $this->_deleteQuery->execute();
|
||||
$this->deleteQuery->bindValue('id', $toAddress, SQLITE3_TEXT);
|
||||
$result = $this->deleteQuery->execute();
|
||||
if ($result === false)
|
||||
throw new Exception($this->_DBHandle->lastErrorMsg());
|
||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||
|
||||
$this->_updateQuery->bindValue('toid',$toAddress,SQLITE3_TEXT);
|
||||
$this->_updateQuery->bindValue('fromid',$fromAddress,SQLITE3_TEXT);
|
||||
$result = $this->_updateQuery->execute();
|
||||
$this->updateQuery->bindValue('toid', $toAddress, SQLITE3_TEXT);
|
||||
$this->updateQuery->bindValue('fromid', $fromAddress, SQLITE3_TEXT);
|
||||
$result = $this->updateQuery->execute();
|
||||
if ($result === false)
|
||||
throw new Exception($this->_DBHandle->lastErrorMsg());
|
||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||
|
||||
return true;
|
||||
} // function moveCell()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
$query = "SELECT id FROM kvp_".$this->_TableName;
|
||||
$cellIdsResult = $this->_DBHandle->query($query);
|
||||
$query = "SELECT id FROM kvp_".$this->TableName;
|
||||
$cellIdsResult = $this->DBHandle->query($query);
|
||||
if ($cellIdsResult === false)
|
||||
throw new Exception($this->_DBHandle->lastErrorMsg());
|
||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||
|
||||
$cellKeys = array();
|
||||
while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
|
||||
@ -251,8 +253,7 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
||||
}
|
||||
|
||||
return $cellKeys;
|
||||
} // function getCellList()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
@ -260,74 +261,75 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
||||
* @param PHPExcel\Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(Worksheet $parent) {
|
||||
$this->_currentCellIsDirty;
|
||||
$this->_storeData();
|
||||
public function copyCellCollection(Worksheet $parent)
|
||||
{
|
||||
$this->currentCellIsDirty;
|
||||
$this->storeData();
|
||||
|
||||
// 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());
|
||||
$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()
|
||||
|
||||
$this->TableName = $tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
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;
|
||||
$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(Worksheet $parent) {
|
||||
public function __construct(Worksheet $parent)
|
||||
{
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->_DBHandle)) {
|
||||
$this->_TableName = str_replace('.','_',$this->_getUniqueID());
|
||||
$_DBName = ':memory:';
|
||||
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());
|
||||
$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());
|
||||
}
|
||||
|
||||
$this->_selectQuery = $this->_DBHandle->prepare("SELECT value FROM kvp_".$this->_TableName." WHERE id = :id");
|
||||
$this->_insertQuery = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)");
|
||||
$this->_updateQuery = $this->_DBHandle->prepare("UPDATE kvp_".$this->_TableName." SET id=:toId WHERE id=:fromId");
|
||||
$this->_deleteQuery = $this->_DBHandle->prepare("DELETE FROM kvp_".$this->_TableName." WHERE id = :id");
|
||||
} // function __construct()
|
||||
|
||||
$this->selectQuery = $this->DBHandle->prepare("SELECT value FROM kvp_".$this->TableName." WHERE id = :id");
|
||||
$this->insertQuery = $this->DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES(:id,:data)");
|
||||
$this->updateQuery = $this->DBHandle->prepare("UPDATE kvp_".$this->TableName." SET id=:toId WHERE id=:fromId");
|
||||
$this->deleteQuery = $this->DBHandle->prepare("DELETE FROM kvp_".$this->TableName." WHERE id = :id");
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
if (!is_null($this->_DBHandle)) {
|
||||
$this->_DBHandle->exec('DROP TABLE kvp_'.$this->_TableName);
|
||||
$this->_DBHandle->close();
|
||||
public function __destruct()
|
||||
{
|
||||
if (!is_null($this->DBHandle)) {
|
||||
$this->DBHandle->exec('DROP TABLE kvp_'.$this->TableName);
|
||||
$this->DBHandle->close();
|
||||
}
|
||||
$this->_DBHandle = null;
|
||||
} // function __destruct()
|
||||
$this->DBHandle = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -336,11 +338,8 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!class_exists('SQLite3', false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
return class_exists('SQLite3', false);
|
||||
}
|
||||
}
|
||||
|
@ -35,21 +35,21 @@ namespace PHPExcel;
|
||||
* @package PHPExcel\CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache {
|
||||
|
||||
class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase implements CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_cachePrefix = null;
|
||||
private $cachePrefix = null;
|
||||
|
||||
/**
|
||||
* Cache timeout
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_cacheTime = 600;
|
||||
private $cacheTime = 600;
|
||||
|
||||
|
||||
/**
|
||||
@ -59,28 +59,28 @@ class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase impleme
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
protected function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
protected 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)) {
|
||||
$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');
|
||||
throw new Exception('Failed to store cell '.$this->currentObjectID.' in WinCache');
|
||||
}
|
||||
} else {
|
||||
if (!wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
|
||||
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');
|
||||
throw new Exception('Failed to store cell '.$this->currentObjectID.' in WinCache');
|
||||
}
|
||||
}
|
||||
$this->_currentCellIsDirty = false;
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
@ -90,19 +90,19 @@ class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase impleme
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
public function addCacheData($pCoord, Cell $cell)
|
||||
{
|
||||
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
|
||||
$this->storeData();
|
||||
}
|
||||
$this->_cellCache[$pCoord] = true;
|
||||
$this->cellCache[$pCoord] = true;
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = 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?
|
||||
@ -110,14 +110,15 @@ class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase impleme
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
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) {
|
||||
if ($this->currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in cache
|
||||
$success = wincache_ucache_exists($this->_cachePrefix.$pCoord.'.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);
|
||||
@ -126,8 +127,7 @@ class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase impleme
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // function isDataSet()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
@ -136,17 +136,18 @@ class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase impleme
|
||||
* @throws PHPExcel\Exception
|
||||
* @return PHPExcel\Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
$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);
|
||||
$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);
|
||||
@ -158,44 +159,43 @@ class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase impleme
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize($obj);
|
||||
$this->currentObjectID = $pCoord;
|
||||
$this->currentObject = unserialize($obj);
|
||||
// Re-attach this as the cell's parent
|
||||
$this->_currentObject->attach($this);
|
||||
$this->currentObject->attach($this);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
return $this->currentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
if ($this->_currentObjectID !== null) {
|
||||
$this->_storeData();
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
|
||||
return parent::getCellList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
public function deleteCacheData($pCoord)
|
||||
{
|
||||
// Delete the entry from Wincache
|
||||
wincache_ucache_delete($this->_cachePrefix.$pCoord.'.cache');
|
||||
wincache_ucache_delete($this->cachePrefix.$pCoord.'.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
} // function deleteCacheData()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
@ -203,51 +203,51 @@ class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase impleme
|
||||
* @param PHPExcel\Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(Worksheet $parent) {
|
||||
public function copyCellCollection(Worksheet $parent)
|
||||
{
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique), 0, 8).'.';
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
if ($cellID != $this->_currentObjectID) {
|
||||
if ($cellID != $this->currentObjectID) {
|
||||
$success = false;
|
||||
$obj = wincache_ucache_get($this->_cachePrefix.$cellID.'.cache', $success);
|
||||
$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)) {
|
||||
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()
|
||||
|
||||
$this->cachePrefix = $newCachePrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
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();
|
||||
$this->cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
@ -255,29 +255,29 @@ class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase impleme
|
||||
* @param PHPExcel\Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(Worksheet $parent, $arguments) {
|
||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||
public function __construct(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;
|
||||
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() {
|
||||
public function __destruct()
|
||||
{
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
wincache_ucache_delete($this->_cachePrefix.$cellID.'.cache');
|
||||
wincache_ucache_delete($this->cachePrefix.$cellID.'.cache');
|
||||
}
|
||||
} // function __destruct()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
@ -285,12 +285,8 @@ class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase impleme
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!function_exists('wincache_ucache_add')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
public static function cacheMethodIsAvailable()
|
||||
{
|
||||
return function_exists('wincache_ucache_add');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -56,14 +56,14 @@ class CachedObjectStorageFactory
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $_cacheStorageMethod = null;
|
||||
protected static $cacheStorageMethod = null;
|
||||
|
||||
/**
|
||||
* Name of the class used for cell cacheing
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $_cacheStorageClass = null;
|
||||
protected static $cacheStorageClass = null;
|
||||
|
||||
|
||||
/**
|
||||
@ -71,7 +71,7 @@ class CachedObjectStorageFactory
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $_storageMethods = array(
|
||||
protected static $storageMethods = array(
|
||||
self::cache_in_memory,
|
||||
self::cache_in_memory_gzip,
|
||||
self::cache_in_memory_serialized,
|
||||
@ -91,7 +91,7 @@ class CachedObjectStorageFactory
|
||||
*
|
||||
* @var array of mixed array
|
||||
*/
|
||||
protected static $_storageMethodDefaultParameters = array(
|
||||
protected static $storageMethodDefaultParameters = array(
|
||||
self::cache_in_memory => array(
|
||||
),
|
||||
self::cache_in_memory_gzip => array(
|
||||
@ -128,7 +128,7 @@ class CachedObjectStorageFactory
|
||||
*
|
||||
* @var array of mixed array
|
||||
*/
|
||||
protected static $_storageMethodParameters = array();
|
||||
protected static $storageMethodParameters = array();
|
||||
|
||||
|
||||
/**
|
||||
@ -138,7 +138,7 @@ class CachedObjectStorageFactory
|
||||
**/
|
||||
public static function getCacheStorageMethod()
|
||||
{
|
||||
return self::$_cacheStorageMethod;
|
||||
return self::$cacheStorageMethod;
|
||||
} // function getCacheStorageMethod()
|
||||
|
||||
|
||||
@ -149,7 +149,7 @@ class CachedObjectStorageFactory
|
||||
**/
|
||||
public static function getCacheStorageClass()
|
||||
{
|
||||
return self::$_cacheStorageClass;
|
||||
return self::$cacheStorageClass;
|
||||
} // function getCacheStorageClass()
|
||||
|
||||
|
||||
@ -160,7 +160,7 @@ class CachedObjectStorageFactory
|
||||
**/
|
||||
public static function getAllCacheStorageMethods()
|
||||
{
|
||||
return self::$_storageMethods;
|
||||
return self::$storageMethods;
|
||||
} // function getCacheStorageMethods()
|
||||
|
||||
|
||||
@ -172,7 +172,7 @@ class CachedObjectStorageFactory
|
||||
public static function getCacheStorageMethods()
|
||||
{
|
||||
$activeMethods = array();
|
||||
foreach(self::$_storageMethods as $storageMethod) {
|
||||
foreach (self::$storageMethods as $storageMethod) {
|
||||
$cacheStorageClass = 'PHPExcel\CachedObjectStorage_' . $storageMethod;
|
||||
if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) {
|
||||
$activeMethods[] = $storageMethod;
|
||||
@ -185,34 +185,32 @@ class CachedObjectStorageFactory
|
||||
/**
|
||||
* Identify the cache storage method to use
|
||||
*
|
||||
* @param string $method Name of the method to use for cell cacheing
|
||||
* @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
|
||||
* when instantiating
|
||||
* @return boolean
|
||||
**/
|
||||
public static function initialize($method = self::cache_in_memory, $arguments = array())
|
||||
{
|
||||
if (!in_array($method, self::$_storageMethods)) {
|
||||
if (!in_array($method, self::$storageMethods)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$cacheStorageClass = __NAMESPACE__ . '\CachedObjectStorage_'.$method;
|
||||
if (!call_user_func(
|
||||
array($cacheStorageClass, 'cacheMethodIsAvailable')
|
||||
)) {
|
||||
if (!call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method];
|
||||
self::$storageMethodParameters[$method] = self::$storageMethodDefaultParameters[$method];
|
||||
foreach($arguments as $k => $v) {
|
||||
if (array_key_exists($k, self::$_storageMethodParameters[$method])) {
|
||||
self::$_storageMethodParameters[$method][$k] = $v;
|
||||
if (array_key_exists($k, self::$storageMethodParameters[$method])) {
|
||||
self::$storageMethodParameters[$method][$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if (self::$_cacheStorageMethod === null) {
|
||||
self::$_cacheStorageClass = 'CachedObjectStorage_' . $method;
|
||||
self::$_cacheStorageMethod = $method;
|
||||
if (self::$cacheStorageMethod === null) {
|
||||
self::$cacheStorageClass = 'CachedObjectStorage_' . $method;
|
||||
self::$cacheStorageMethod = $method;
|
||||
}
|
||||
return true;
|
||||
} // function initialize()
|
||||
@ -227,14 +225,14 @@ class CachedObjectStorageFactory
|
||||
public static function getInstance(Worksheet $parent)
|
||||
{
|
||||
$cacheMethodIsAvailable = true;
|
||||
if (self::$_cacheStorageMethod === null) {
|
||||
if (self::$cacheStorageMethod === null) {
|
||||
$cacheMethodIsAvailable = self::initialize();
|
||||
}
|
||||
|
||||
$cacheStorageClass = __NAMESPACE__ . '\\' . self::$_cacheStorageClass;
|
||||
$cacheStorageClass = __NAMESPACE__ . '\\' . self::$cacheStorageClass;
|
||||
if ($cacheMethodIsAvailable) {
|
||||
$instance = new $cacheStorageClass( $parent,
|
||||
self::$_storageMethodParameters[self::$_cacheStorageMethod]
|
||||
self::$storageMethodParameters[self::$cacheStorageMethod]
|
||||
);
|
||||
if ($instance !== null) {
|
||||
return $instance;
|
||||
@ -251,8 +249,8 @@ class CachedObjectStorageFactory
|
||||
**/
|
||||
public static function finalize()
|
||||
{
|
||||
self::$_cacheStorageMethod = null;
|
||||
self::$_cacheStorageClass = null;
|
||||
self::$_storageMethodParameters = array();
|
||||
self::$cacheStorageMethod = null;
|
||||
self::$cacheStorageClass = null;
|
||||
self::$storageMethodParameters = array();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user