mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-29 16:56:03 +03:00
More work on PSR-2ing the library
This commit is contained in:
parent
33a5fbed72
commit
a453d68430
@ -67,8 +67,8 @@ class CachedObjectStorage_APC extends CachedObjectStorage_CacheBase implements C
|
||||
if (!apc_store(
|
||||
$this->cachePrefix.$this->currentObjectID.'.cache',
|
||||
serialize($this->currentObject),
|
||||
$this->cacheTime)
|
||||
) {
|
||||
$this->cacheTime
|
||||
)) {
|
||||
$this->__destruct();
|
||||
throw new Exception('Failed to store cell '.$this->currentObjectID.' in APC');
|
||||
}
|
||||
@ -268,7 +268,7 @@ class CachedObjectStorage_APC extends CachedObjectStorage_CacheBase implements C
|
||||
public function __destruct()
|
||||
{
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
foreach ($cacheList as $cellID) {
|
||||
apc_delete($this->cachePrefix.$cellID.'.cache');
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ class CachedObjectStorage_DiscISAM extends CachedObjectStorage_CacheBase impleme
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$newFileName = $this->cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
|
||||
// Copy the existing cell cache file
|
||||
copy ($this->fileName, $newFileName);
|
||||
copy($this->fileName, $newFileName);
|
||||
$this->fileName = $newFileName;
|
||||
// Open the copied cell cache file
|
||||
$this->fileHandle = fopen($this->fileName, 'a+');
|
||||
|
@ -78,7 +78,8 @@ class CachedObjectStorage_Memcache extends CachedObjectStorage_CacheBase impleme
|
||||
null,
|
||||
$this->cacheTime
|
||||
)) {
|
||||
if (!$this->memcache->add($this->cachePrefix.$this->currentObjectID.'.cache',
|
||||
if (!$this->memcache->add(
|
||||
$this->cachePrefix.$this->currentObjectID.'.cache',
|
||||
$obj,
|
||||
null,
|
||||
$this->cacheTime
|
||||
@ -149,8 +150,7 @@ class CachedObjectStorage_Memcache extends CachedObjectStorage_CacheBase impleme
|
||||
*/
|
||||
public function getCacheData($pCoord)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID)
|
||||
{
|
||||
if ($pCoord === $this->currentObjectID) {
|
||||
return $this->currentObject;
|
||||
}
|
||||
$this->storeData();
|
||||
|
@ -42,7 +42,8 @@ class CachedObjectStorage_Memory extends CachedObjectStorage_CacheBase implement
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function storeData() {
|
||||
protected function storeData()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,7 +54,8 @@ class CachedObjectStorage_Memory extends CachedObjectStorage_CacheBase implement
|
||||
* @return PHPExcel\Cell
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, Cell $cell) {
|
||||
public function addCacheData($pCoord, Cell $cell)
|
||||
{
|
||||
$this->cellCache[$pCoord] = $cell;
|
||||
|
||||
// Set current entry to the new/updated entry
|
||||
@ -96,7 +98,7 @@ class CachedObjectStorage_Memory extends CachedObjectStorage_CacheBase implement
|
||||
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);
|
||||
}
|
||||
@ -112,7 +114,7 @@ class CachedObjectStorage_Memory extends CachedObjectStorage_CacheBase implement
|
||||
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;
|
||||
}
|
||||
|
@ -111,7 +111,8 @@ class CachedObjectStorage_MemoryGZip extends CachedObjectStorage_CacheBase imple
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
public function getCellList()
|
||||
{
|
||||
if ($this->currentObjectID !== null) {
|
||||
$this->storeData();
|
||||
}
|
||||
@ -126,7 +127,7 @@ class CachedObjectStorage_MemoryGZip extends CachedObjectStorage_CacheBase imple
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if(!is_null($this->currentObject)) {
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ class CachedObjectStorage_MemorySerialized extends CachedObjectStorage_CacheBase
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if(!is_null($this->currentObject)) {
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
|
@ -26,6 +26,8 @@
|
||||
*/
|
||||
|
||||
|
||||
namespace PHPExcel;
|
||||
|
||||
/**
|
||||
* PHPExcel\CachedObjectStorage_PHPTemp
|
||||
*
|
||||
@ -61,7 +63,7 @@ class CachedObjectStorage_PHPTemp extends CachedObjectStorage_CacheBase implemen
|
||||
if ($this->currentCellIsDirty) {
|
||||
$this->currentObject->detach();
|
||||
|
||||
fseek($this->fileHandle,0,SEEK_END);
|
||||
fseek($this->fileHandle, 0, SEEK_END);
|
||||
$offset = ftell($this->fileHandle);
|
||||
fwrite($this->fileHandle, serialize($this->currentObject));
|
||||
$this->cellCache[$this->currentObjectID] = array('ptr' => $offset,
|
||||
@ -115,8 +117,8 @@ class CachedObjectStorage_PHPTemp extends CachedObjectStorage_CacheBase implemen
|
||||
|
||||
// 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']));
|
||||
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);
|
||||
|
||||
@ -148,11 +150,11 @@ class CachedObjectStorage_PHPTemp extends CachedObjectStorage_CacheBase implemen
|
||||
{
|
||||
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);
|
||||
fseek($this->fileHandle, 0);
|
||||
while (!feof($this->fileHandle)) {
|
||||
fwrite($newFileHandle,fread($this->fileHandle, 1024));
|
||||
fwrite($newFileHandle, fread($this->fileHandle, 1024));
|
||||
}
|
||||
$this->fileHandle = $newFileHandle;
|
||||
}
|
||||
@ -164,7 +166,7 @@ class CachedObjectStorage_PHPTemp extends CachedObjectStorage_CacheBase implemen
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if(!is_null($this->currentObject)) {
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
@ -189,7 +191,7 @@ class CachedObjectStorage_PHPTemp extends CachedObjectStorage_CacheBase implemen
|
||||
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->fileHandle)) {
|
||||
$this->fileHandle = fopen('php://temp/maxmemory:'.$this->memoryCacheSize,'a+');
|
||||
$this->fileHandle = fopen('php://temp/maxmemory:'.$this->memoryCacheSize, 'a+');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,9 +63,12 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
{
|
||||
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))."')"))
|
||||
$query = "INSERT OR REPLACE INTO kvp_" . $this->TableName .
|
||||
" VALUES('" . $this->currentObjectID . "','" .
|
||||
sqlite_escape_string(serialize($this->currentObject)) . "')";
|
||||
if (!$this->DBHandle->queryExec($query)) {
|
||||
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
}
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
@ -107,7 +110,7 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
$this->storeData();
|
||||
|
||||
$query = "SELECT value FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
|
||||
$cellResultSet = $this->DBHandle->query($query,SQLITE_ASSOC);
|
||||
$cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC);
|
||||
if ($cellResultSet === false) {
|
||||
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
} elseif ($cellResultSet->numRows() == 0) {
|
||||
@ -141,7 +144,7 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
|
||||
// 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);
|
||||
$cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC);
|
||||
if ($cellResultSet === false) {
|
||||
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
} elseif ($cellResultSet->numRows() == 0) {
|
||||
@ -166,8 +169,9 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
|
||||
if (!$this->DBHandle->queryExec($query))
|
||||
if (!$this->DBHandle->queryExec($query)) {
|
||||
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
}
|
||||
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
@ -186,14 +190,14 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
}
|
||||
|
||||
$query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$toAddress."'";
|
||||
$result = $this->DBHandle->exec($query);
|
||||
if ($result === false)
|
||||
if (!$this->DBHandle->exec($query)) {
|
||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
$query = "UPDATE kvp_".$this->TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
|
||||
$result = $this->DBHandle->exec($query);
|
||||
if ($result === false)
|
||||
if (!$this->DBHandle->exec($query)) {
|
||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -210,12 +214,13 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
}
|
||||
|
||||
$query = "SELECT id FROM kvp_".$this->TableName;
|
||||
$cellIdsResult = $this->DBHandle->unbufferedQuery($query,SQLITE_ASSOC);
|
||||
if ($cellIdsResult === false)
|
||||
$cellIdsResult = $this->DBHandle->unbufferedQuery($query, SQLITE_ASSOC);
|
||||
if (!$cellIdsResult) {
|
||||
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
}
|
||||
|
||||
$cellKeys = array();
|
||||
foreach($cellIdsResult as $row) {
|
||||
foreach ($cellIdsResult as $row) {
|
||||
$cellKeys[] = $row['id'];
|
||||
}
|
||||
|
||||
@ -234,10 +239,14 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
$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))
|
||||
$tableName = str_replace('.', '_', $this->getUniqueID());
|
||||
$result = $this->DBHandle->queryExec(
|
||||
'CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
|
||||
AS SELECT * FROM kvp_'.$this->TableName
|
||||
);
|
||||
if (!$result) {
|
||||
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
}
|
||||
|
||||
// Copy the existing cell cache file
|
||||
$this->TableName = $tableName;
|
||||
@ -250,7 +259,7 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if(!is_null($this->currentObject)) {
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
@ -270,16 +279,21 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
||||
{
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->DBHandle)) {
|
||||
$this->TableName = str_replace('.','_',$this->getUniqueID());
|
||||
$this->TableName = str_replace('.', '_', $this->getUniqueID());
|
||||
$DBName = ':memory:';
|
||||
|
||||
$this->DBHandle = new SQLiteDatabase($DBName);
|
||||
if ($this->DBHandle === false)
|
||||
if (!$this->DBHandle) {
|
||||
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)'))
|
||||
}
|
||||
$result = $this->DBHandle->queryExec(
|
||||
'CREATE TABLE kvp_'.$this->TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'
|
||||
);
|
||||
if (!$result) {
|
||||
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
|
@ -95,8 +95,9 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
||||
$this->insertQuery->bindValue('id', $this->currentObjectID, SQLITE3_TEXT);
|
||||
$this->insertQuery->bindValue('data', serialize($this->currentObject), SQLITE3_BLOB);
|
||||
$result = $this->insertQuery->execute();
|
||||
if ($result === false)
|
||||
if (!$result) {
|
||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
$this->currentObjectID = $this->currentObject = null;
|
||||
@ -198,8 +199,9 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
||||
// Check if the requested entry exists in the cache
|
||||
$this->deleteQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
|
||||
$result = $this->deleteQuery->execute();
|
||||
if ($result === false)
|
||||
if (!$result) {
|
||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
$this->currentCellIsDirty = false;
|
||||
}
|
||||
@ -219,14 +221,16 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
||||
|
||||
$this->deleteQuery->bindValue('id', $toAddress, SQLITE3_TEXT);
|
||||
$result = $this->deleteQuery->execute();
|
||||
if ($result === false)
|
||||
if (!$result) {
|
||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
$this->updateQuery->bindValue('toid', $toAddress, SQLITE3_TEXT);
|
||||
$this->updateQuery->bindValue('fromid', $fromAddress, SQLITE3_TEXT);
|
||||
$result = $this->updateQuery->execute();
|
||||
if ($result === false)
|
||||
if (!$result) {
|
||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -267,10 +271,13 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
||||
$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))
|
||||
$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;
|
||||
@ -283,7 +290,7 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if(!is_null($this->currentObject)) {
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
@ -307,16 +314,27 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
||||
$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)'))
|
||||
if (!$this->DBHandle) {
|
||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||
}
|
||||
$query = 'CREATE TABLE kvp_'.$this->TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)';
|
||||
if (!$this->DBHandle->exec($query)) {
|
||||
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");
|
||||
$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"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,7 +59,7 @@ class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase impleme
|
||||
* @return void
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
protected function _storeData()
|
||||
protected function storeData()
|
||||
{
|
||||
if ($this->currentCellIsDirty) {
|
||||
$this->currentObject->detach();
|
||||
@ -210,11 +210,11 @@ class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase impleme
|
||||
$baseUnique = $this->getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique), 0, 8).'.';
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
foreach ($cacheList as $cellID) {
|
||||
if ($cellID != $this->currentObjectID) {
|
||||
$success = false;
|
||||
$obj = wincache_ucache_get($this->cachePrefix.$cellID.'.cache', $success);
|
||||
if ($success === false) {
|
||||
if (!$success) {
|
||||
// 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');
|
||||
@ -235,7 +235,7 @@ class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase impleme
|
||||
*/
|
||||
public function unsetWorksheetCells()
|
||||
{
|
||||
if(!is_null($this->currentObject)) {
|
||||
if (!is_null($this->currentObject)) {
|
||||
$this->currentObject->detach();
|
||||
$this->currentObject = $this->currentObjectID = null;
|
||||
}
|
||||
@ -274,7 +274,7 @@ class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase impleme
|
||||
public function __destruct()
|
||||
{
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
foreach ($cacheList as $cellID) {
|
||||
wincache_ucache_delete($this->cachePrefix.$cellID.'.cache');
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,8 @@ namespace PHPExcel;
|
||||
* @package PHPExcel\Calculation
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class CalcEngine_CyclicReferenceStack {
|
||||
class CalcEngine_CyclicReferenceStack
|
||||
{
|
||||
|
||||
/**
|
||||
* The call stack for calculated cells
|
||||
@ -50,7 +51,8 @@ class CalcEngine_CyclicReferenceStack {
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function count() {
|
||||
public function count()
|
||||
{
|
||||
return count($this->stack);
|
||||
}
|
||||
|
||||
@ -59,7 +61,8 @@ class CalcEngine_CyclicReferenceStack {
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function push($value) {
|
||||
public function push($value)
|
||||
{
|
||||
$this->stack[] = $value;
|
||||
} // function push()
|
||||
|
||||
@ -68,7 +71,8 @@ class CalcEngine_CyclicReferenceStack {
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function pop() {
|
||||
public function pop()
|
||||
{
|
||||
return array_pop($this->stack);
|
||||
} // function pop()
|
||||
|
||||
@ -77,14 +81,16 @@ class CalcEngine_CyclicReferenceStack {
|
||||
*
|
||||
* @param mixed $value The value to test
|
||||
*/
|
||||
public function onStack($value) {
|
||||
public function onStack($value)
|
||||
{
|
||||
return in_array($value, $this->stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the stack
|
||||
*/
|
||||
public function clear() {
|
||||
public function clear()
|
||||
{
|
||||
$this->stack = array();
|
||||
} // function push()
|
||||
|
||||
@ -93,7 +99,8 @@ class CalcEngine_CyclicReferenceStack {
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function showStack() {
|
||||
public function showStack()
|
||||
{
|
||||
return $this->stack;
|
||||
}
|
||||
}
|
||||
|
@ -34,8 +34,8 @@ namespace PHPExcel;
|
||||
* @package PHPExcel\Calculation
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class CalcEngine_Logger {
|
||||
|
||||
class CalcEngine_Logger
|
||||
{
|
||||
/**
|
||||
* Flag to determine whether a debug log should be generated by the calculation engine
|
||||
* If true, then a debug log will be generated
|
||||
@ -43,7 +43,7 @@ class CalcEngine_Logger {
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_writeDebugLog = false;
|
||||
private $writeDebugLog = false;
|
||||
|
||||
/**
|
||||
* Flag to determine whether a debug log should be echoed by the calculation engine
|
||||
@ -53,21 +53,21 @@ class CalcEngine_Logger {
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_echoDebugLog = false;
|
||||
private $echoDebugLog = false;
|
||||
|
||||
/**
|
||||
* The debug log generated by the calculation engine
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private $_debugLog = array();
|
||||
private $debugLog = array();
|
||||
|
||||
/**
|
||||
* The calculation engine cell reference stack
|
||||
*
|
||||
* @var PHPExcel\CalcEngine_CyclicReferenceStack
|
||||
*/
|
||||
private $_cellStack;
|
||||
private $cellStack;
|
||||
|
||||
|
||||
/**
|
||||
@ -75,8 +75,9 @@ class CalcEngine_Logger {
|
||||
*
|
||||
* @param PHPExcel\CalcEngine_CyclicReferenceStack $stack
|
||||
*/
|
||||
public function __construct(CalcEngine_CyclicReferenceStack $stack) {
|
||||
$this->_cellStack = $stack;
|
||||
public function __construct(CalcEngine_CyclicReferenceStack $stack)
|
||||
{
|
||||
$this->cellStack = $stack;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,8 +85,9 @@ class CalcEngine_Logger {
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setWriteDebugLog($pValue = false) {
|
||||
$this->_writeDebugLog = $pValue;
|
||||
public function setWriteDebugLog($pValue = false)
|
||||
{
|
||||
$this->writeDebugLog = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,8 +95,9 @@ class CalcEngine_Logger {
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getWriteDebugLog() {
|
||||
return $this->_writeDebugLog;
|
||||
public function getWriteDebugLog()
|
||||
{
|
||||
return $this->writeDebugLog;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,8 +105,9 @@ class CalcEngine_Logger {
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setEchoDebugLog($pValue = false) {
|
||||
$this->_echoDebugLog = $pValue;
|
||||
public function setEchoDebugLog($pValue = false)
|
||||
{
|
||||
$this->echoDebugLog = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,26 +115,28 @@ class CalcEngine_Logger {
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getEchoDebugLog() {
|
||||
return $this->_echoDebugLog;
|
||||
public function getEchoDebugLog()
|
||||
{
|
||||
return $this->echoDebugLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write an entry to the calculation engine debug log
|
||||
*/
|
||||
public function writeDebugLog() {
|
||||
public function writeDebugLog()
|
||||
{
|
||||
// Only write the debug log if logging is enabled
|
||||
if ($this->_writeDebugLog) {
|
||||
if ($this->writeDebugLog) {
|
||||
$message = implode(func_get_args());
|
||||
$cellReference = implode(' -> ', $this->_cellStack->showStack());
|
||||
if ($this->_echoDebugLog) {
|
||||
$cellReference = implode(' -> ', $this->cellStack->showStack());
|
||||
if ($this->echoDebugLog) {
|
||||
echo $cellReference,
|
||||
($this->_cellStack->count() > 0 ? ' => ' : ''),
|
||||
($this->cellStack->count() > 0 ? ' => ' : ''),
|
||||
$message,
|
||||
PHP_EOL;
|
||||
}
|
||||
$this->_debugLog[] = $cellReference .
|
||||
($this->_cellStack->count() > 0 ? ' => ' : '') .
|
||||
$this->debugLog[] = $cellReference .
|
||||
($this->cellStack->count() > 0 ? ' => ' : '') .
|
||||
$message;
|
||||
}
|
||||
}
|
||||
@ -138,8 +144,9 @@ class CalcEngine_Logger {
|
||||
/**
|
||||
* Clear the calculation engine debug log
|
||||
*/
|
||||
public function clearLog() {
|
||||
$this->_debugLog = array();
|
||||
public function clearLog()
|
||||
{
|
||||
$this->debugLog = array();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,7 +154,8 @@ class CalcEngine_Logger {
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getLog() {
|
||||
return $this->_debugLog;
|
||||
public function getLog()
|
||||
{
|
||||
return $this->debugLog;
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,8 @@
|
||||
* @package PHPExcel\Calculation
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class Calculation_Exception extends Exception {
|
||||
class Calculation_Exception extends Exception
|
||||
{
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
@ -43,7 +44,8 @@ class Calculation_Exception extends Exception {
|
||||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||
{
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
|
@ -35,7 +35,8 @@ namespace PHPExcel;
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class Exception extends \Exception {
|
||||
class Exception extends \Exception
|
||||
{
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
@ -45,7 +46,8 @@ class Exception extends \Exception {
|
||||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||
{
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
|
@ -42,14 +42,14 @@ class HashTable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_items = array();
|
||||
public $items = array();
|
||||
|
||||
/**
|
||||
* HashTable key map
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_keyMap = array();
|
||||
public $keyMap = array();
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel\HashTable
|
||||
@ -71,7 +71,8 @@ class HashTable
|
||||
* @param PHPExcel\IComparable[] $pSource Source array to create HashTable from
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function addFromSource($pSource = null) {
|
||||
public function addFromSource($pSource = null)
|
||||
{
|
||||
// Check if an array was passed
|
||||
if ($pSource == null) {
|
||||
return;
|
||||
@ -90,11 +91,12 @@ class HashTable
|
||||
* @param PHPExcel\IComparable $pSource Item to add
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function add(IComparable $pSource = null) {
|
||||
public function add(IComparable $pSource = null)
|
||||
{
|
||||
$hash = $pSource->getHashCode();
|
||||
if (!isset($this->_items[$hash])) {
|
||||
$this->_items[$hash] = $pSource;
|
||||
$this->_keyMap[count($this->_items) - 1] = $hash;
|
||||
$this->items[$hash] = $pSource;
|
||||
$this->keyMap[count($this->items) - 1] = $hash;
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,22 +106,23 @@ class HashTable
|
||||
* @param PHPExcel\IComparable $pSource Item to remove
|
||||
* @throws PHPExcel\Exception
|
||||
*/
|
||||
public function remove(IComparable $pSource = null) {
|
||||
public function remove(IComparable $pSource = null)
|
||||
{
|
||||
$hash = $pSource->getHashCode();
|
||||
if (isset($this->_items[$hash])) {
|
||||
unset($this->_items[$hash]);
|
||||
if (isset($this->items[$hash])) {
|
||||
unset($this->items[$hash]);
|
||||
|
||||
$deleteKey = -1;
|
||||
foreach ($this->_keyMap as $key => $value) {
|
||||
foreach ($this->keyMap as $key => $value) {
|
||||
if ($deleteKey >= 0) {
|
||||
$this->_keyMap[$key - 1] = $value;
|
||||
$this->keyMap[$key - 1] = $value;
|
||||
}
|
||||
|
||||
if ($value == $hash) {
|
||||
$deleteKey = $key;
|
||||
}
|
||||
}
|
||||
unset($this->_keyMap[count($this->_keyMap) - 1]);
|
||||
unset($this->keyMap[count($this->keyMap) - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,9 +130,10 @@ class HashTable
|
||||
* Clear HashTable
|
||||
*
|
||||
*/
|
||||
public function clear() {
|
||||
$this->_items = array();
|
||||
$this->_keyMap = array();
|
||||
public function clear()
|
||||
{
|
||||
$this->items = array();
|
||||
$this->keyMap = array();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,8 +141,9 @@ class HashTable
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count() {
|
||||
return count($this->_items);
|
||||
public function count()
|
||||
{
|
||||
return count($this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,8 +152,9 @@ class HashTable
|
||||
* @param string $pHashCode
|
||||
* @return int Index
|
||||
*/
|
||||
public function getIndexForHashCode($pHashCode = '') {
|
||||
return array_search($pHashCode, $this->_keyMap);
|
||||
public function getIndexForHashCode($pHashCode = '')
|
||||
{
|
||||
return array_search($pHashCode, $this->keyMap);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,9 +164,10 @@ class HashTable
|
||||
* @return PHPExcel\IComparable
|
||||
*
|
||||
*/
|
||||
public function getByIndex($pIndex = 0) {
|
||||
if (isset($this->_keyMap[$pIndex])) {
|
||||
return $this->getByHashCode( $this->_keyMap[$pIndex] );
|
||||
public function getByIndex($pIndex = 0)
|
||||
{
|
||||
if (isset($this->keyMap[$pIndex])) {
|
||||
return $this->getByHashCode( $this->keyMap[$pIndex] );
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -173,9 +180,10 @@ class HashTable
|
||||
* @return PHPExcel\IComparable
|
||||
*
|
||||
*/
|
||||
public function getByHashCode($pHashCode = '') {
|
||||
if (isset($this->_items[$pHashCode])) {
|
||||
return $this->_items[$pHashCode];
|
||||
public function getByHashCode($pHashCode = '')
|
||||
{
|
||||
if (isset($this->items[$pHashCode])) {
|
||||
return $this->items[$pHashCode];
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -186,14 +194,16 @@ class HashTable
|
||||
*
|
||||
* @return PHPExcel\IComparable[]
|
||||
*/
|
||||
public function toArray() {
|
||||
return $this->_items;
|
||||
public function toArray()
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
public function __clone()
|
||||
{
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
|
@ -35,7 +35,8 @@ namespace PHPExcel;
|
||||
* @package PHPExcel\Reader
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class Reader_Exception extends Exception {
|
||||
class Reader_Exception extends Exception
|
||||
{
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
@ -45,7 +46,8 @@ class Reader_Exception extends Exception {
|
||||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||
{
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
|
@ -35,7 +35,8 @@ namespace PHPExcel;
|
||||
* @package PHPExcel\Writer
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class Writer_Exception extends Exception {
|
||||
class Writer_Exception extends Exception
|
||||
{
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
@ -45,7 +46,8 @@ class Writer_Exception extends Exception {
|
||||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||
{
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -330,9 +330,9 @@ abstract class Writer_PDF_Core extends Writer_HTML
|
||||
protected function prepareForSave($pFilename = null)
|
||||
{
|
||||
// garbage collect
|
||||
$this->_phpExcel->garbageCollect();
|
||||
$this->phpExcel->garbageCollect();
|
||||
|
||||
$this->_saveArrayReturnType = Calculation::getArrayReturnType();
|
||||
$this->saveArrayReturnType = Calculation::getArrayReturnType();
|
||||
Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE);
|
||||
|
||||
// Open file
|
||||
@ -342,7 +342,7 @@ abstract class Writer_PDF_Core extends Writer_HTML
|
||||
}
|
||||
|
||||
// Set PDF
|
||||
$this->_isPdf = true;
|
||||
$this->isPdf = true;
|
||||
// Build CSS
|
||||
$this->buildCSS(true);
|
||||
|
||||
@ -360,6 +360,6 @@ abstract class Writer_PDF_Core extends Writer_HTML
|
||||
// Close file
|
||||
fclose($fileHandle);
|
||||
|
||||
Calculation::setArrayReturnType($this->_saveArrayReturnType);
|
||||
Calculation::setArrayReturnType($this->saveArrayReturnType);
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class Writer_PDF_tcPDF extends Writer_PDF_Core implements Writer_IWriter
|
||||
$pdf->setFontSubsetting(false);
|
||||
// Set margins, converting inches to points (using 72 dpi)
|
||||
$pdf->SetMargins($printMargins->getLeft() * 72, $printMargins->getTop() * 72, $printMargins->getRight() * 72);
|
||||
$pdf->SetAutoPageBreak(TRUE, $printMargins->getBottom() * 72);
|
||||
$pdf->SetAutoPageBreak(true, $printMargins->getBottom() * 72);
|
||||
|
||||
$pdf->setPrintHeader(false);
|
||||
$pdf->setPrintFooter(false);
|
||||
|
Loading…
Reference in New Issue
Block a user