From: <te...@us...> - 2015-03-31 09:13:28
|
Revision: 7247 http://sourceforge.net/p/web-erp/reponame/7247 Author: tehonu Date: 2015-03-31 09:13:24 +0000 (Tue, 31 Mar 2015) Log Message: ----------- Added PHPExcel and one script PcAnalysis.php, for further analysis of petty cash expenses, downloading an excel File Modified Paths: -------------- trunk/includes/MainMenuLinksArray.php Added Paths: ----------- trunk/Classes/ trunk/Classes/PHPExcel/ trunk/Classes/PHPExcel/Autoloader.php trunk/Classes/PHPExcel/CachedObjectStorage/ trunk/Classes/PHPExcel/CachedObjectStorage/APC.php trunk/Classes/PHPExcel/CachedObjectStorage/CacheBase.php trunk/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php trunk/Classes/PHPExcel/CachedObjectStorage/ICache.php trunk/Classes/PHPExcel/CachedObjectStorage/Igbinary.php trunk/Classes/PHPExcel/CachedObjectStorage/Memcache.php trunk/Classes/PHPExcel/CachedObjectStorage/Memory.php trunk/Classes/PHPExcel/CachedObjectStorage/MemoryGZip.php trunk/Classes/PHPExcel/CachedObjectStorage/MemorySerialized.php trunk/Classes/PHPExcel/CachedObjectStorage/PHPTemp.php trunk/Classes/PHPExcel/CachedObjectStorage/SQLite.php trunk/Classes/PHPExcel/CachedObjectStorage/SQLite3.php trunk/Classes/PHPExcel/CachedObjectStorage/Wincache.php trunk/Classes/PHPExcel/CachedObjectStorageFactory.php trunk/Classes/PHPExcel/CalcEngine/ trunk/Classes/PHPExcel/CalcEngine/CyclicReferenceStack.php trunk/Classes/PHPExcel/CalcEngine/Logger.php trunk/Classes/PHPExcel/Calculation/ trunk/Classes/PHPExcel/Calculation/Database.php trunk/Classes/PHPExcel/Calculation/DateTime.php trunk/Classes/PHPExcel/Calculation/Engineering.php trunk/Classes/PHPExcel/Calculation/Exception.php trunk/Classes/PHPExcel/Calculation/ExceptionHandler.php trunk/Classes/PHPExcel/Calculation/Financial.php trunk/Classes/PHPExcel/Calculation/FormulaParser.php trunk/Classes/PHPExcel/Calculation/FormulaToken.php trunk/Classes/PHPExcel/Calculation/Function.php trunk/Classes/PHPExcel/Calculation/Functions.php trunk/Classes/PHPExcel/Calculation/Logical.php trunk/Classes/PHPExcel/Calculation/LookupRef.php trunk/Classes/PHPExcel/Calculation/MathTrig.php trunk/Classes/PHPExcel/Calculation/Statistical.php trunk/Classes/PHPExcel/Calculation/TextData.php trunk/Classes/PHPExcel/Calculation/Token/ trunk/Classes/PHPExcel/Calculation/Token/Stack.php trunk/Classes/PHPExcel/Calculation/functionlist.txt trunk/Classes/PHPExcel/Calculation.php trunk/Classes/PHPExcel/Cell/ trunk/Classes/PHPExcel/Cell/AdvancedValueBinder.php trunk/Classes/PHPExcel/Cell/DataType.php trunk/Classes/PHPExcel/Cell/DataValidation.php trunk/Classes/PHPExcel/Cell/DefaultValueBinder.php trunk/Classes/PHPExcel/Cell/Hyperlink.php trunk/Classes/PHPExcel/Cell/IValueBinder.php trunk/Classes/PHPExcel/Cell.php trunk/Classes/PHPExcel/Chart/ trunk/Classes/PHPExcel/Chart/Axis.php trunk/Classes/PHPExcel/Chart/DataSeries.php trunk/Classes/PHPExcel/Chart/DataSeriesValues.php trunk/Classes/PHPExcel/Chart/Exception.php trunk/Classes/PHPExcel/Chart/GridLines.php trunk/Classes/PHPExcel/Chart/Layout.php trunk/Classes/PHPExcel/Chart/Legend.php trunk/Classes/PHPExcel/Chart/PlotArea.php trunk/Classes/PHPExcel/Chart/Properties.php trunk/Classes/PHPExcel/Chart/Renderer/ trunk/Classes/PHPExcel/Chart/Renderer/PHP Charting Libraries.txt trunk/Classes/PHPExcel/Chart/Renderer/jpgraph.php trunk/Classes/PHPExcel/Chart/Title.php trunk/Classes/PHPExcel/Chart.php trunk/Classes/PHPExcel/Comment.php trunk/Classes/PHPExcel/DocumentProperties.php trunk/Classes/PHPExcel/DocumentSecurity.php trunk/Classes/PHPExcel/Exception.php trunk/Classes/PHPExcel/HashTable.php trunk/Classes/PHPExcel/IComparable.php trunk/Classes/PHPExcel/IOFactory.php trunk/Classes/PHPExcel/NamedRange.php trunk/Classes/PHPExcel/Reader/ trunk/Classes/PHPExcel/Reader/Abstract.php trunk/Classes/PHPExcel/Reader/CSV.php trunk/Classes/PHPExcel/Reader/DefaultReadFilter.php trunk/Classes/PHPExcel/Reader/Excel2003XML.php trunk/Classes/PHPExcel/Reader/Excel2007/ trunk/Classes/PHPExcel/Reader/Excel2007/Chart.php trunk/Classes/PHPExcel/Reader/Excel2007/Theme.php trunk/Classes/PHPExcel/Reader/Excel2007.php trunk/Classes/PHPExcel/Reader/Excel5/ trunk/Classes/PHPExcel/Reader/Excel5/Escher.php trunk/Classes/PHPExcel/Reader/Excel5/MD5.php trunk/Classes/PHPExcel/Reader/Excel5/RC4.php trunk/Classes/PHPExcel/Reader/Excel5.php trunk/Classes/PHPExcel/Reader/Exception.php trunk/Classes/PHPExcel/Reader/Gnumeric.php trunk/Classes/PHPExcel/Reader/HTML.php trunk/Classes/PHPExcel/Reader/IReadFilter.php trunk/Classes/PHPExcel/Reader/IReader.php trunk/Classes/PHPExcel/Reader/OOCalc.php trunk/Classes/PHPExcel/Reader/SYLK.php trunk/Classes/PHPExcel/ReferenceHelper.php trunk/Classes/PHPExcel/RichText/ trunk/Classes/PHPExcel/RichText/ITextElement.php trunk/Classes/PHPExcel/RichText/Run.php trunk/Classes/PHPExcel/RichText/TextElement.php trunk/Classes/PHPExcel/RichText.php trunk/Classes/PHPExcel/Settings.php trunk/Classes/PHPExcel/Shared/ trunk/Classes/PHPExcel/Shared/CodePage.php trunk/Classes/PHPExcel/Shared/Date.php trunk/Classes/PHPExcel/Shared/Drawing.php trunk/Classes/PHPExcel/Shared/Escher/ trunk/Classes/PHPExcel/Shared/Escher/DgContainer/ trunk/Classes/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/ trunk/Classes/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php trunk/Classes/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php trunk/Classes/PHPExcel/Shared/Escher/DgContainer.php trunk/Classes/PHPExcel/Shared/Escher/DggContainer/ trunk/Classes/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/ trunk/Classes/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/ trunk/Classes/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php trunk/Classes/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php trunk/Classes/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php trunk/Classes/PHPExcel/Shared/Escher/DggContainer.php trunk/Classes/PHPExcel/Shared/Escher.php trunk/Classes/PHPExcel/Shared/Excel5.php trunk/Classes/PHPExcel/Shared/File.php trunk/Classes/PHPExcel/Shared/Font.php trunk/Classes/PHPExcel/Shared/JAMA/ trunk/Classes/PHPExcel/Shared/JAMA/CHANGELOG.TXT trunk/Classes/PHPExcel/Shared/JAMA/CholeskyDecomposition.php trunk/Classes/PHPExcel/Shared/JAMA/EigenvalueDecomposition.php trunk/Classes/PHPExcel/Shared/JAMA/LUDecomposition.php trunk/Classes/PHPExcel/Shared/JAMA/Matrix.php trunk/Classes/PHPExcel/Shared/JAMA/QRDecomposition.php trunk/Classes/PHPExcel/Shared/JAMA/SingularValueDecomposition.php trunk/Classes/PHPExcel/Shared/JAMA/utils/ trunk/Classes/PHPExcel/Shared/JAMA/utils/Error.php trunk/Classes/PHPExcel/Shared/JAMA/utils/Maths.php trunk/Classes/PHPExcel/Shared/OLE/ trunk/Classes/PHPExcel/Shared/OLE/ChainedBlockStream.php trunk/Classes/PHPExcel/Shared/OLE/PPS/ trunk/Classes/PHPExcel/Shared/OLE/PPS/File.php trunk/Classes/PHPExcel/Shared/OLE/PPS/Root.php trunk/Classes/PHPExcel/Shared/OLE/PPS.php trunk/Classes/PHPExcel/Shared/OLE.php trunk/Classes/PHPExcel/Shared/OLERead.php trunk/Classes/PHPExcel/Shared/PCLZip/ trunk/Classes/PHPExcel/Shared/PCLZip/gnu-lgpl.txt trunk/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php trunk/Classes/PHPExcel/Shared/PCLZip/readme.txt trunk/Classes/PHPExcel/Shared/PasswordHasher.php trunk/Classes/PHPExcel/Shared/String.php trunk/Classes/PHPExcel/Shared/TimeZone.php trunk/Classes/PHPExcel/Shared/XMLWriter.php trunk/Classes/PHPExcel/Shared/ZipArchive.php trunk/Classes/PHPExcel/Shared/ZipStreamWrapper.php trunk/Classes/PHPExcel/Shared/trend/ trunk/Classes/PHPExcel/Shared/trend/bestFitClass.php trunk/Classes/PHPExcel/Shared/trend/exponentialBestFitClass.php trunk/Classes/PHPExcel/Shared/trend/linearBestFitClass.php trunk/Classes/PHPExcel/Shared/trend/logarithmicBestFitClass.php trunk/Classes/PHPExcel/Shared/trend/polynomialBestFitClass.php trunk/Classes/PHPExcel/Shared/trend/powerBestFitClass.php trunk/Classes/PHPExcel/Shared/trend/trendClass.php trunk/Classes/PHPExcel/Style/ trunk/Classes/PHPExcel/Style/Alignment.php trunk/Classes/PHPExcel/Style/Border.php trunk/Classes/PHPExcel/Style/Borders.php trunk/Classes/PHPExcel/Style/Color.php trunk/Classes/PHPExcel/Style/Conditional.php trunk/Classes/PHPExcel/Style/Fill.php trunk/Classes/PHPExcel/Style/Font.php trunk/Classes/PHPExcel/Style/NumberFormat.php trunk/Classes/PHPExcel/Style/Protection.php trunk/Classes/PHPExcel/Style/Supervisor.php trunk/Classes/PHPExcel/Style.php trunk/Classes/PHPExcel/Worksheet/ trunk/Classes/PHPExcel/Worksheet/AutoFilter/ trunk/Classes/PHPExcel/Worksheet/AutoFilter/Column/ trunk/Classes/PHPExcel/Worksheet/AutoFilter/Column/Rule.php trunk/Classes/PHPExcel/Worksheet/AutoFilter/Column.php trunk/Classes/PHPExcel/Worksheet/AutoFilter.php trunk/Classes/PHPExcel/Worksheet/BaseDrawing.php trunk/Classes/PHPExcel/Worksheet/CellIterator.php trunk/Classes/PHPExcel/Worksheet/ColumnDimension.php trunk/Classes/PHPExcel/Worksheet/Drawing/ trunk/Classes/PHPExcel/Worksheet/Drawing/Shadow.php trunk/Classes/PHPExcel/Worksheet/Drawing.php trunk/Classes/PHPExcel/Worksheet/HeaderFooter.php trunk/Classes/PHPExcel/Worksheet/HeaderFooterDrawing.php trunk/Classes/PHPExcel/Worksheet/MemoryDrawing.php trunk/Classes/PHPExcel/Worksheet/PageMargins.php trunk/Classes/PHPExcel/Worksheet/PageSetup.php trunk/Classes/PHPExcel/Worksheet/Protection.php trunk/Classes/PHPExcel/Worksheet/Row.php trunk/Classes/PHPExcel/Worksheet/RowDimension.php trunk/Classes/PHPExcel/Worksheet/RowIterator.php trunk/Classes/PHPExcel/Worksheet/SheetView.php trunk/Classes/PHPExcel/Worksheet.php trunk/Classes/PHPExcel/WorksheetIterator.php trunk/Classes/PHPExcel/Writer/ trunk/Classes/PHPExcel/Writer/Abstract.php trunk/Classes/PHPExcel/Writer/CSV.php trunk/Classes/PHPExcel/Writer/Excel2007/ trunk/Classes/PHPExcel/Writer/Excel2007/Chart.php trunk/Classes/PHPExcel/Writer/Excel2007/Comments.php trunk/Classes/PHPExcel/Writer/Excel2007/ContentTypes.php trunk/Classes/PHPExcel/Writer/Excel2007/DocProps.php trunk/Classes/PHPExcel/Writer/Excel2007/Drawing.php trunk/Classes/PHPExcel/Writer/Excel2007/Rels.php trunk/Classes/PHPExcel/Writer/Excel2007/RelsRibbon.php trunk/Classes/PHPExcel/Writer/Excel2007/RelsVBA.php trunk/Classes/PHPExcel/Writer/Excel2007/StringTable.php trunk/Classes/PHPExcel/Writer/Excel2007/Style.php trunk/Classes/PHPExcel/Writer/Excel2007/Theme.php trunk/Classes/PHPExcel/Writer/Excel2007/Workbook.php trunk/Classes/PHPExcel/Writer/Excel2007/Worksheet.php trunk/Classes/PHPExcel/Writer/Excel2007/WriterPart.php trunk/Classes/PHPExcel/Writer/Excel2007.php trunk/Classes/PHPExcel/Writer/Excel5/ trunk/Classes/PHPExcel/Writer/Excel5/BIFFwriter.php trunk/Classes/PHPExcel/Writer/Excel5/Escher.php trunk/Classes/PHPExcel/Writer/Excel5/Font.php trunk/Classes/PHPExcel/Writer/Excel5/Parser.php trunk/Classes/PHPExcel/Writer/Excel5/Workbook.php trunk/Classes/PHPExcel/Writer/Excel5/Worksheet.php trunk/Classes/PHPExcel/Writer/Excel5/Xf.php trunk/Classes/PHPExcel/Writer/Excel5.php trunk/Classes/PHPExcel/Writer/Exception.php trunk/Classes/PHPExcel/Writer/HTML.php trunk/Classes/PHPExcel/Writer/IWriter.php trunk/Classes/PHPExcel/Writer/OpenDocument/ trunk/Classes/PHPExcel/Writer/OpenDocument/Cell/ trunk/Classes/PHPExcel/Writer/OpenDocument/Cell/Comment.php trunk/Classes/PHPExcel/Writer/OpenDocument/Content.php trunk/Classes/PHPExcel/Writer/OpenDocument/Meta.php trunk/Classes/PHPExcel/Writer/OpenDocument/MetaInf.php trunk/Classes/PHPExcel/Writer/OpenDocument/Mimetype.php trunk/Classes/PHPExcel/Writer/OpenDocument/Settings.php trunk/Classes/PHPExcel/Writer/OpenDocument/Styles.php trunk/Classes/PHPExcel/Writer/OpenDocument/Thumbnails.php trunk/Classes/PHPExcel/Writer/OpenDocument/WriterPart.php trunk/Classes/PHPExcel/Writer/OpenDocument.php trunk/Classes/PHPExcel/Writer/PDF/ trunk/Classes/PHPExcel/Writer/PDF/Core.php trunk/Classes/PHPExcel/Writer/PDF/DomPDF.php trunk/Classes/PHPExcel/Writer/PDF/mPDF.php trunk/Classes/PHPExcel/Writer/PDF/tcPDF.php trunk/Classes/PHPExcel/Writer/PDF.php trunk/Classes/PHPExcel/locale/ trunk/Classes/PHPExcel/locale/bg/ trunk/Classes/PHPExcel/locale/bg/config trunk/Classes/PHPExcel/locale/cs/ trunk/Classes/PHPExcel/locale/cs/config trunk/Classes/PHPExcel/locale/cs/functions trunk/Classes/PHPExcel/locale/da/ trunk/Classes/PHPExcel/locale/da/config trunk/Classes/PHPExcel/locale/da/functions trunk/Classes/PHPExcel/locale/de/ trunk/Classes/PHPExcel/locale/de/config trunk/Classes/PHPExcel/locale/de/functions trunk/Classes/PHPExcel/locale/en/ trunk/Classes/PHPExcel/locale/en/uk/ trunk/Classes/PHPExcel/locale/en/uk/config trunk/Classes/PHPExcel/locale/es/ trunk/Classes/PHPExcel/locale/es/config trunk/Classes/PHPExcel/locale/es/functions trunk/Classes/PHPExcel/locale/fi/ trunk/Classes/PHPExcel/locale/fi/config trunk/Classes/PHPExcel/locale/fi/functions trunk/Classes/PHPExcel/locale/fr/ trunk/Classes/PHPExcel/locale/fr/config trunk/Classes/PHPExcel/locale/fr/functions trunk/Classes/PHPExcel/locale/hu/ trunk/Classes/PHPExcel/locale/hu/config trunk/Classes/PHPExcel/locale/hu/functions trunk/Classes/PHPExcel/locale/it/ trunk/Classes/PHPExcel/locale/it/config trunk/Classes/PHPExcel/locale/it/functions trunk/Classes/PHPExcel/locale/nl/ trunk/Classes/PHPExcel/locale/nl/config trunk/Classes/PHPExcel/locale/nl/functions trunk/Classes/PHPExcel/locale/no/ trunk/Classes/PHPExcel/locale/no/config trunk/Classes/PHPExcel/locale/no/functions trunk/Classes/PHPExcel/locale/pl/ trunk/Classes/PHPExcel/locale/pl/config trunk/Classes/PHPExcel/locale/pl/functions trunk/Classes/PHPExcel/locale/pt/ trunk/Classes/PHPExcel/locale/pt/br/ trunk/Classes/PHPExcel/locale/pt/br/config trunk/Classes/PHPExcel/locale/pt/br/functions trunk/Classes/PHPExcel/locale/pt/config trunk/Classes/PHPExcel/locale/pt/functions trunk/Classes/PHPExcel/locale/ru/ trunk/Classes/PHPExcel/locale/ru/config trunk/Classes/PHPExcel/locale/ru/functions trunk/Classes/PHPExcel/locale/sv/ trunk/Classes/PHPExcel/locale/sv/config trunk/Classes/PHPExcel/locale/sv/functions trunk/Classes/PHPExcel/locale/tr/ trunk/Classes/PHPExcel/locale/tr/config trunk/Classes/PHPExcel/locale/tr/functions trunk/Classes/PHPExcel.php trunk/PcAnalysis.php Added: trunk/Classes/PHPExcel/Autoloader.php =================================================================== --- trunk/Classes/PHPExcel/Autoloader.php (rev 0) +++ trunk/Classes/PHPExcel/Autoloader.php 2015-03-31 09:13:24 UTC (rev 7247) @@ -0,0 +1,89 @@ +<?php +/** + * PHPExcel + * + * Copyright (c) 2006 - 2014 PHPExcel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * @category PHPExcel + * @package PHPExcel + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version ##VERSION##, ##DATE## + */ + +PHPExcel_Autoloader::Register(); +// As we always try to run the autoloader before anything else, we can use it to do a few +// simple checks and initialisations +//PHPExcel_Shared_ZipStreamWrapper::register(); +// check mbstring.func_overload +if (ini_get('mbstring.func_overload') & 2) { + throw new PHPExcel_Exception('Multibyte function overloading in PHP must be disabled for string functions (2).'); +} +PHPExcel_Shared_String::buildCharacterSets(); + + +/** + * PHPExcel_Autoloader + * + * @category PHPExcel + * @package PHPExcel + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + */ +class PHPExcel_Autoloader +{ + /** + * Register the Autoloader with SPL + * + */ + public static function Register() { + if (function_exists('__autoload')) { + // Register any existing autoloader function with SPL, so we don't get any clashes + spl_autoload_register('__autoload'); + } + // Register ourselves with SPL + if (version_compare(PHP_VERSION, '5.3.0') >= 0) { + return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'), true, true); + } else { + return spl_autoload_register(array('PHPExcel_Autoloader', 'Load')); + } + } // function Register() + + + /** + * Autoload a class identified by name + * + * @param string $pClassName Name of the object to load + */ + public static function Load($pClassName){ + if ((class_exists($pClassName,FALSE)) || (strpos($pClassName, 'PHPExcel') !== 0)) { + // Either already loaded, or not a PHPExcel class request + return FALSE; + } + + $pClassFilePath = PHPEXCEL_ROOT . + str_replace('_',DIRECTORY_SEPARATOR,$pClassName) . + '.php'; + + if ((file_exists($pClassFilePath) === FALSE) || (is_readable($pClassFilePath) === FALSE)) { + // Can't load + return FALSE; + } + + require($pClassFilePath); + } // function Load() + +} Added: trunk/Classes/PHPExcel/CachedObjectStorage/APC.php =================================================================== --- trunk/Classes/PHPExcel/CachedObjectStorage/APC.php (rev 0) +++ trunk/Classes/PHPExcel/CachedObjectStorage/APC.php 2015-03-31 09:13:24 UTC (rev 7247) @@ -0,0 +1,295 @@ +<?php +/** + * PHPExcel + * + * Copyright (c) 2006 - 2014 PHPExcel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * @category PHPExcel + * @package PHPExcel_CachedObjectStorage + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version ##VERSION##, ##DATE## + */ + + +/** + * PHPExcel_CachedObjectStorage_APC + * + * @category PHPExcel + * @package PHPExcel_CachedObjectStorage + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + */ +class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { + + /** + * Prefix used to uniquely identify cache data for this worksheet + * + * @access private + * @var string + */ + private $_cachePrefix = null; + + /** + * Cache timeout + * + * @access private + * @var integer + */ + private $_cacheTime = 600; + + + /** + * Store cell data in cache for the current cell object if it's "dirty", + * and the 'nullify' the current cell object + * + * @access private + * @return void + * @throws PHPExcel_Exception + */ + protected function _storeData() { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { + $this->_currentObject->detach(); + + if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) { + $this->__destruct(); + throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in APC'); + } + $this->_currentCellIsDirty = false; + } + $this->_currentObjectID = $this->_currentObject = null; + } // function _storeData() + + + /** + * Add or Update a cell in cache identified by coordinate address + * + * @access public + * @param string $pCoord Coordinate address of the cell to update + * @param PHPExcel_Cell $cell Cell to update + * @return PHPExcel_Cell + * @throws PHPExcel_Exception + */ + public function addCacheData($pCoord, PHPExcel_Cell $cell) { + if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { + $this->_storeData(); + } + $this->_cellCache[$pCoord] = true; + + $this->_currentObjectID = $pCoord; + $this->_currentObject = $cell; + $this->_currentCellIsDirty = true; + + return $cell; + } // function addCacheData() + + + /** + * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? + * + * @access public + * @param string $pCoord Coordinate address of the cell to check + * @throws PHPExcel_Exception + * @return boolean + */ + public function isDataSet($pCoord) { + // Check if the requested entry is the current object, or exists in the cache + if (parent::isDataSet($pCoord)) { + if ($this->_currentObjectID == $pCoord) { + return true; + } + // Check if the requested entry still exists in apc + $success = apc_fetch($this->_cachePrefix.$pCoord.'.cache'); + if ($success === FALSE) { + // Entry no longer exists in APC, so clear it from the cache array + parent::deleteCacheData($pCoord); + throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache'); + } + 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; + } + $this->_storeData(); + + // Check if the entry that has been requested actually exists + if (parent::isDataSet($pCoord)) { + $obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache'); + if ($obj === FALSE) { + // Entry no longer exists in APC, so clear it from the cache array + parent::deleteCacheData($pCoord); + throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache'); + } + } else { + // Return null if requested entry doesn't exist in cache + return null; + } + + // Set current entry to the requested entry + $this->_currentObjectID = $pCoord; + $this->_currentObject = unserialize($obj); + // Re-attach this as the cell's parent + $this->_currentObject->attach($this); + + // Return requested entry + return $this->_currentObject; + } // function getCacheData() + + + /** + * Get a list of all cell addresses currently held in cache + * + * @return string[] + */ + 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) { + // Delete the entry from APC + apc_delete($this->_cachePrefix.$pCoord.'.cache'); + + // Delete the entry from our cell address array + parent::deleteCacheData($pCoord); + } // function deleteCacheData() + + + /** + * Clone the cell collection + * + * @access public + * @param PHPExcel_Worksheet $parent The new worksheet + * @throws PHPExcel_Exception + * @return void + */ + public function copyCellCollection(PHPExcel_Worksheet $parent) { + parent::copyCellCollection($parent); + // Get a new id for the new file name + $baseUnique = $this->_getUniqueID(); + $newCachePrefix = substr(md5($baseUnique),0,8).'.'; + $cacheList = $this->getCellList(); + foreach($cacheList as $cellID) { + if ($cellID != $this->_currentObjectID) { + $obj = apc_fetch($this->_cachePrefix.$cellID.'.cache'); + if ($obj === FALSE) { + // Entry no longer exists in APC, so clear it from the cache array + parent::deleteCacheData($cellID); + throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in APC'); + } + if (!apc_store($newCachePrefix.$cellID.'.cache',$obj,$this->_cacheTime)) { + $this->__destruct(); + throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in APC'); + } + } + } + $this->_cachePrefix = $newCachePrefix; + } // function copyCellCollection() + + + /** + * Clear the cell collection and disconnect from our parent + * + * @return void + */ + public function unsetWorksheetCells() { + if ($this->_currentObject !== NULL) { + $this->_currentObject->detach(); + $this->_currentObject = $this->_currentObjectID = null; + } + + // Flush the APC cache + $this->__destruct(); + + $this->_cellCache = array(); + + // detach ourself from the worksheet, so that it can then delete this object successfully + $this->_parent = null; + } // function unsetWorksheetCells() + + + /** + * Initialise this new cell collection + * + * @param PHPExcel_Worksheet $parent The worksheet for this cell collection + * @param array of mixed $arguments Additional initialisation arguments + */ + public function __construct(PHPExcel_Worksheet $parent, $arguments) { + $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600; + + if ($this->_cachePrefix === NULL) { + $baseUnique = $this->_getUniqueID(); + $this->_cachePrefix = substr(md5($baseUnique),0,8).'.'; + $this->_cacheTime = $cacheTime; + + parent::__construct($parent); + } + } // function __construct() + + + /** + * Destroy this cell collection + */ + public function __destruct() { + $cacheList = $this->getCellList(); + foreach($cacheList as $cellID) { + apc_delete($this->_cachePrefix.$cellID.'.cache'); + } + } // function __destruct() + + + /** + * Identify whether the caching method is currently available + * Some methods are dependent on the availability of certain extensions being enabled in the PHP build + * + * @return boolean + */ + public static function cacheMethodIsAvailable() { + if (!function_exists('apc_store')) { + return FALSE; + } + if (apc_sma_info() === FALSE) { + return FALSE; + } + + return TRUE; + } + +} Added: trunk/Classes/PHPExcel/CachedObjectStorage/CacheBase.php =================================================================== --- trunk/Classes/PHPExcel/CachedObjectStorage/CacheBase.php (rev 0) +++ trunk/Classes/PHPExcel/CachedObjectStorage/CacheBase.php 2015-03-31 09:13:24 UTC (rev 7247) @@ -0,0 +1,347 @@ +<?php +/** + * PHPExcel + * + * Copyright (c) 2006 - 2014 PHPExcel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * @category PHPExcel + * @package PHPExcel_CachedObjectStorage + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version ##VERSION##, ##DATE## + */ + + +/** + * PHPExcel_CachedObjectStorage_CacheBase + * + * @category PHPExcel + * @package PHPExcel_CachedObjectStorage + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + */ +abstract class PHPExcel_CachedObjectStorage_CacheBase { + + /** + * Parent worksheet + * + * @var PHPExcel_Worksheet + */ + protected $_parent; + + /** + * The currently active Cell + * + * @var PHPExcel_Cell + */ + protected $_currentObject = null; + + /** + * Coordinate address of the currently active Cell + * + * @var string + */ + protected $_currentObjectID = null; + + + /** + * Flag indicating whether the currently active Cell requires saving + * + * @var boolean + */ + protected $_currentCellIsDirty = true; + + /** + * An array of cells or cell pointers for the worksheet cells held in this cache, + * and indexed by their coordinate address within the worksheet + * + * @var array of mixed + */ + protected $_cellCache = array(); + + + /** + * Initialise this new cell collection + * + * @param PHPExcel_Worksheet $parent The worksheet for this cell collection + */ + public function __construct(PHPExcel_Worksheet $parent) { + // Set our parent worksheet. + // This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when + // they are woken from a serialized state + $this->_parent = $parent; + } // function __construct() + + + /** + * Return the parent worksheet for this cell collection + * + * @return PHPExcel_Worksheet + */ + public function getParent() + { + return $this->_parent; + } + + /** + * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? + * + * @param string $pCoord Coordinate address of the cell to check + * @return boolean + */ + public function isDataSet($pCoord) { + if ($pCoord === $this->_currentObjectID) { + return true; + } + // Check if the requested entry exists in the cache + return isset($this->_cellCache[$pCoord]); + } // function isDataSet() + + + /** + * Move a cell object from one address to another + * + * @param string $fromAddress Current address of the cell to move + * @param string $toAddress Destination address of the cell to move + * @return boolean + */ + 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]); + } + + return TRUE; + } // function moveCell() + + + /** + * Add or Update a cell in cache + * + * @param PHPExcel_Cell $cell Cell to update + * @return PHPExcel_Cell + * @throws PHPExcel_Exception + */ + public function updateCacheData(PHPExcel_Cell $cell) { + return $this->addCacheData($cell->getCoordinate(),$cell); + } // function updateCacheData() + + + /** + * Delete a cell in cache identified by coordinate address + * + * @param string $pCoord Coordinate address of the cell to delete + * @throws PHPExcel_Exception + */ + public function deleteCacheData($pCoord) { + if ($pCoord === $this->_currentObjectID) { + $this->_currentObject->detach(); + $this->_currentObjectID = $this->_currentObject = null; + } + + if (is_object($this->_cellCache[$pCoord])) { + $this->_cellCache[$pCoord]->detach(); + unset($this->_cellCache[$pCoord]); + } + $this->_currentCellIsDirty = false; + } // function deleteCacheData() + + + /** + * Get a list of all cell addresses currently held in cache + * + * @return string[] + */ + public function getCellList() { + return array_keys($this->_cellCache); + } // function getCellList() + + + /** + * Sort the list of all cell addresses currently held in cache by row and column + * + * @return string[] + */ + public function getSortedCellList() { + $sortKeys = array(); + foreach ($this->getCellList() as $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 + * + * @return array Highest column name and highest row number + */ + public function getHighestRowAndColumn() + { + // Lookup highest column and highest row + $col = array('A' => '1A'); + $row = array(1); + foreach ($this->getCellList() as $coord) { + 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); + } + + return array( 'row' => $highestRow, + 'column' => $highestColumn + ); + } + + + /** + * Return the cell address of the currently active cell object + * + * @return string + */ + public function getCurrentAddress() + { + return $this->_currentObjectID; + } + + /** + * Return the column address of the currently active cell object + * + * @return string + */ + public function getCurrentColumn() + { + sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row); + return $column; + } + + /** + * Return the row address of the currently active cell object + * + * @return integer + */ + public function getCurrentRow() + { + sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row); + return (integer) $row; + } + + /** + * Get highest worksheet column + * + * @param string $row Return the highest column for the specified row, + * or the highest column of any row if no row number is passed + * @return string Highest column name + */ + public function getHighestColumn($row = null) + { + if ($row == null) { + $colRow = $this->getHighestRowAndColumn(); + return $colRow['column']; + } + + $columnList = array(1); + foreach ($this->getCellList() as $coord) { + sscanf($coord,'%[A-Z]%d', $c, $r); + if ($r != $row) { + continue; + } + $columnList[] = PHPExcel_Cell::columnIndexFromString($c); + } + return PHPExcel_Cell::stringFromColumnIndex(max($columnList) - 1); + } + + /** + * Get highest worksheet row + * + * @param string $column Return the highest row for the specified column, + * or the highest row of any column if no column letter is passed + * @return int Highest row number + */ + public function getHighestRow($column = null) + { + if ($column == null) { + $colRow = $this->getHighestRowAndColumn(); + return $colRow['row']; + } + + $rowList = array(0); + foreach ($this->getCellList() as $coord) { + sscanf($coord,'%[A-Z]%d', $c, $r); + if ($c != $column) { + continue; + } + $rowList[] = $r; + } + + return max($rowList); + } + + + /** + * Generate a unique ID for cache referencing + * + * @return string Unique Reference + */ + protected function _getUniqueID() { + if (function_exists('posix_getpid')) { + $baseUnique = posix_getpid(); + } else { + $baseUnique = mt_rand(); + } + return uniqid($baseUnique,true); + } + + /** + * Clone the cell collection + * + * @param PHPExcel_Worksheet $parent The new worksheet + * @return void + */ + public function copyCellCollection(PHPExcel_Worksheet $parent) { + $this->_currentCellIsDirty; + $this->_storeData(); + + $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 + * Some methods are dependent on the availability of certain extensions being enabled in the PHP build + * + * @return boolean + */ + public static function cacheMethodIsAvailable() { + return true; + } + +} Added: trunk/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php =================================================================== --- trunk/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php (rev 0) +++ trunk/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php 2015-03-31 09:13:24 UTC (rev 7247) @@ -0,0 +1,219 @@ +<?php +/** + * PHPExcel + * + * Copyright (c) 2006 - 2014 PHPExcel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * @category PHPExcel + * @package PHPExcel_CachedObjectStorage + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version ##VERSION##, ##DATE## + */ + + +/** + * PHPExcel_CachedObjectStorage_DiscISAM + * + * @category PHPExcel + * @package PHPExcel_CachedObjectStorage + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + */ +class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { + + /** + * Name of the file for this cache + * + * @var string + */ + private $_fileName = NULL; + + /** + * File handle for this cache file + * + * @var resource + */ + private $_fileHandle = NULL; + + /** + * Directory/Folder where the cache file is located + * + * @var string + */ + private $_cacheDirectory = NULL; + + + /** + * Store cell data in cache for the current cell object if it's "dirty", + * and the 'nullify' the current cell object + * + * @return void + * @throws PHPExcel_Exception + */ + protected function _storeData() { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { + $this->_currentObject->detach(); + + fseek($this->_fileHandle,0,SEEK_END); + $offset = ftell($this->_fileHandle); + fwrite($this->_fileHandle, serialize($this->_currentObject)); + $this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset, + 'sz' => ftell($this->_fileHandle) - $offset + ); + $this->_currentCellIsDirty = false; + } + $this->_currentObjectID = $this->_currentObject = null; + } // function _storeData() + + + /** + * Add or Update a cell in cache identified by coordinate address + * + * @param string $pCoord Coordinate address of the cell to update + * @param PHPExcel_Cell $cell Cell to update + * @return PHPExcel_Cell + * @throws PHPExcel_Exception + */ + public function addCacheData($pCoord, PHPExcel_Cell $cell) { + if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { + $this->_storeData(); + } + + $this->_currentObjectID = $pCoord; + $this->_currentObject = $cell; + $this->_currentCellIsDirty = true; + + return $cell; + } // function addCacheData() + + + /** + * Get cell at a specific coordinate + * + * @param string $pCoord Coordinate of the cell + * @throws 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; + } + $this->_storeData(); + + // Check if the entry that has been requested actually exists + if (!isset($this->_cellCache[$pCoord])) { + // Return null if requested entry doesn't exist in cache + return null; + } + + // Set current entry to the requested entry + $this->_currentObjectID = $pCoord; + fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']); + $this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz'])); + // Re-attach this as the cell's parent + $this->_currentObject->attach($this); + + // Return requested entry + return $this->_currentObject; + } // function getCacheData() + + + /** + * Get a list of all cell addresses currently held in cache + * + * @return string[] + */ + 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(PHPExcel_Worksheet $parent) { + parent::copyCellCollection($parent); + // Get a new id for the new file name + $baseUnique = $this->_getUniqueID(); + $newFileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache'; + // Copy the existing cell cache file + copy ($this->_fileName,$newFileName); + $this->_fileName = $newFileName; + // Open the copied cell cache file + $this->_fileHandle = fopen($this->_fileName,'a+'); + } // function copyCellCollection() + + + /** + * Clear the cell collection and disconnect from our parent + * + * @return void + */ + public function unsetWorksheetCells() { + if(!is_null($this->_currentObject)) { + $this->_currentObject->detach(); + $this->_currentObject = $this->_currentObjectID = null; + } + $this->_cellCache = array(); + + // detach ourself from the worksheet, so that it can then delete this object successfully + $this->_parent = null; + + // Close down the temporary cache file + $this->__destruct(); + } // function unsetWorksheetCells() + + + /** + * Initialise this new cell collection + * + * @param PHPExcel_Worksheet $parent The worksheet for this cell collection + * @param array of mixed $arguments Additional initialisation arguments + */ + public function __construct(PHPExcel_Worksheet $parent, $arguments) { + $this->_cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== NULL)) + ? $arguments['dir'] + : PHPExcel_Shared_File::sys_get_temp_dir(); + + parent::__construct($parent); + if (is_null($this->_fileHandle)) { + $baseUnique = $this->_getUniqueID(); + $this->_fileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache'; + $this->_fileHandle = fopen($this->_fileName,'a+'); + } + } // function __construct() + + + /** + * Destroy this cell collection + */ + public function __destruct() { + if (!is_null($this->_fileHandle)) { + fclose($this->_fileHandle); + unlink($this->_fileName); + } + $this->_fileHandle = null; + } // function __destruct() + +} Added: trunk/Classes/PHPExcel/CachedObjectStorage/ICache.php =================================================================== --- trunk/Classes/PHPExcel/CachedObjectStorage/ICache.php (rev 0) +++ trunk/Classes/PHPExcel/CachedObjectStorage/ICache.php 2015-03-31 09:13:24 UTC (rev 7247) @@ -0,0 +1,112 @@ +<?php +/** + * PHPExcel + * + * Copyright (c) 2006 - 2014 PHPExcel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * @category PHPExcel + * @package PHPExcel_CachedObjectStorage + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version ##VERSION##, ##DATE## + */ + + +/** + * PHPExcel_CachedObjectStorage_ICache + * + * @category PHPExcel + * @package PHPExcel_CachedObjectStorage + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + */ +interface PHPExcel_CachedObjectStorage_ICache +{ + /** + * Add or Update a cell in cache identified by coordinate address + * + * @param string $pCoord Coordinate address of the cell to update + * @param PHPExcel_Cell $cell Cell to update + * @return PHPExcel_Cell + * @throws PHPExcel_Exception + */ + public function addCacheData($pCoord, PHPExcel_Cell $cell); + + /** + * Add or Update a cell in cache + * + * @param PHPExcel_Cell $cell Cell to update + * @return PHPExcel_Cell + * @throws PHPExcel_Exception + */ + public function updateCacheData(PHPExcel_Cell $cell); + + /** + * Fetch a cell from cache identified by coordinate address + * + * @param string $pCoord Coordinate address of the cell to retrieve + * @return PHPExcel_Cell Cell that was found, or null if not found + * @throws PHPExcel_Exception + */ + public function getCacheData($pCoord); + + /** + * Delete a cell in cache identified by coordinate address + * + * @param string $pCoord Coordinate address of the cell to delete + * @throws PHPExcel_Exception + */ + public function deleteCacheData($pCoord); + + /** + * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? + * + * @param string $pCoord Coordinate address of the cell to check + * @return boolean + */ + public function isDataSet($pCoord); + + /** + * Get a list of all cell addresses currently held in cache + * + * @return string[] + */ + public function getCellList(); + + /** + * Get the list of all cell addresses currently held in cache sorted by column and row + * + * @return string[] + */ + public function getSortedCellList(); + + /** + * Clone the cell collection + * + * @param PHPExcel_Worksheet $parent The new worksheet + * @return void + */ + public function copyCellCollection(PHPExcel_Worksheet $parent); + + /** + * Identify whether the caching method is currently available + * Some methods are dependent on the availability of certain extensions being enabled in the PHP build + * + * @return boolean + */ + public static function cacheMethodIsAvailable(); + +} Added: trunk/Classes/PHPExcel/CachedObjectStorage/Igbinary.php =================================================================== --- trunk/Classes/PHPExcel/CachedObjectStorage/Igbinary.php (rev 0) +++ trunk/Classes/PHPExcel/CachedObjectStorage/Igbinary.php 2015-03-31 09:13:24 UTC (rev 7247) @@ -0,0 +1,152 @@ +<?php +/** + * PHPExcel + * + * Copyright (c) 2006 - 2014 PHPExcel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * @category PHPExcel + * @package PHPExcel_CachedObjectStorage + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version ##VERSION##, ##DATE## + */ + + +/** + * PHPExcel_CachedObjectStorage_Igbinary + * + * @category PHPExcel + * @package PHPExcel_CachedObjectStorage + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + */ +class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { + + /** + * Store cell data in cache for the current cell object if it's "dirty", + * and the 'nullify' the current cell object + * + * @return void + * @throws PHPExcel_Exception + */ + protected function _storeData() { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { + $this->_currentObject->detach(); + + $this->_cellCache[$this->_currentObjectID] = igbinary_serialize($this->_currentObject); + $this->_currentCellIsDirty = false; + } + $this->_currentObjectID = $this->_currentObject = null; + } // function _storeData() + + + /** + * Add or Update a cell in cache identified by coordinate address + * + * @param string $pCoord Coordinate address of the cell to update + * @param PHPExcel_Cell $cell Cell to update + * @return PHPExcel_Cell + * @throws PHPExcel_Exception + */ + public function addCacheData($pCoord, PHPExcel_Cell $cell) { + if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { + $this->_storeData(); + } + + $this->_currentObjectID = $pCoord; + $this->_currentObject = $cell; + $this->_currentCellIsDirty = true; + + return $cell; + } // function addCacheData() + + + /** + * Get cell at a specific coordinate + * + * @param string $pCoord Coordinate of the cell + * @throws 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; + } + $this->_storeData(); + + // Check if the entry that has been requested actually exists + if (!isset($this->_cellCache[$pCoord])) { + // Return null if requested entry doesn't exist in cache + return null; + } + + // Set current entry to the requested entry + $this->_currentObjectID = $pCoord; + $this->_currentObject = igbinary_unserialize($this->_cellCache[$pCoord]); + // Re-attach this as the cell's parent + $this->_currentObject->attach($this); + + // Return requested entry + return $this->_currentObject; + } // function getCacheData() + + + /** + * Get a list of all cell addresses currently held in cache + * + * @return string[] + */ + 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; + } + $this->_cellCache = array(); + + // detach ourself from the worksheet, so that it can then delete this object successfully + $this->_parent = null; + } // function unsetWorksheetCells() + + + /** + * Identify whether the caching method is currently available + * Some methods are dependent on the availability of certain extensions being enabled in the PHP build + * + * @return boolean + */ + public static function cacheMethodIsAvailable() { + if (!function_exists('igbinary_serialize')) { + return false; + } + + return true; + } + +} Added: trunk/Classes/PHPExcel/CachedObjectStorage/Memcache.php =================================================================== --- trunk/Classes/PHPExcel/CachedObjectStorage/Memcache.php (rev 0) +++ trunk/Classes/PHPExcel/CachedObjectStorage/Memcache.php 2015-03-31 09:13:24 UTC (rev 7247) @@ -0,0 +1,312 @@ +<?php +/** + * PHPExcel + * + * Copyright (c) 2006 - 2014 PHPExcel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * @category PHPExcel + * @package PHPExcel_CachedObjectStorage + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version ##VERSION##, ##DATE## + */ + + +/** + * PHPExcel_CachedObjectStorage_Memcache + * + * @category PHPExcel + * @package PHPExcel_CachedObjectStorage + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) + */ +class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { + + /** + * Prefix used to uniquely identify cache data for this worksheet + * + * @var string + */ + private $_cachePrefix = null; + + /** + * Cache timeout + * + * @var integer + */ + private $_cacheTime = 600; + + /** + * Memcache interface + * + * @var resource + */ + private $_memcache = null; + + + /** + * Store cell data in cache for the current cell object if it's "dirty", + * and the 'nullify' the current cell object + * + * @return void + * @throws PHPExcel_Exception + */ + protected function _storeData() { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { + $this->_currentObject->detach(); + + $obj = serialize($this->_currentObject); + if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) { + if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) { + $this->__destruct(); + throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in MemCache'); + } + } + $this->_currentCellIsDirty = false; + } + $this->_currentObjectID = $this->_currentObject = null; + } // function _storeData() + + + /** + * Add or Update a cell in cache identified by coordinate address + * + * @param string $pCoord Coordinate address of the cell to update + * @param PHPExcel_Cell $cell Cell to update + * @return PHPExcel_Cell + * @throws PHPExcel_Exception + */ + public function addCacheData($pCoord, PHPExcel_Cell $cell) { + if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { + $this->_storeData(); + } + $this->_cellCache[$pCoord] = true; + + $this->_currentObjectID = $pCoord; + $this->_currentObject = $cell; + $this->_currentCellIsDirty = true; + + return $cell; + } // function addCacheData() + + + /** + * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? + * + * @param string $pCoord Coordinate address of the cell to check + * @return boolean + * @return boolean + */ + public function isDataSet($pCoord) { + // Check if the requested entry is the current object, or exists in the cache + if (parent::isDataSet($pCoord)) { + if ($this->_currentObjectID == $pCoord) { + return true; + } + // Check if the requested entry still exists in Memcache + $success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache'); + if ($success === false) { + // Entry no longer exists in Memcache, so clear it from the cache array + parent::deleteCacheData($pCoord); + throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache'); + } + return true; + } + return false; + } // function isDataSet() + + + /** + * Get cell at a specific coordinate + * + * @param string $pCoord Coordinate of the cell + * @throws 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; + } + $this->_storeData(); + + // Check if the entry that has been requested actually exists + if (parent::isDataSet($pCoord)) { + $obj = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache'); + if ($obj === false) { + // Entry no longer exists in Memcache, so clear it from the cache array + parent::deleteCacheData($pCoord); + throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache'); + } + } else { + // Return null if requested entry doesn't exist in cache + return null; + } + + // Set current entry to the requested entry + $this->_currentObjectID = $pCoord; + $this->_currentObject = unserialize($obj); + // Re-attach this as the cell's parent + $this->_currentObject->attach($this); + + // Return requested entry + return $this->_currentObject; + } // function getCacheData() + + + /** + * Get a list of all cell addresses currently held in cache + * + * @return string[] + */ + publi... [truncated message content] |