Bugfix: Work item 15518 - PCLZip library issue

References to ZipArchive Constants when ZipArchive class isn't available

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@70307 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2011-03-14 13:52:49 +00:00
parent 34c4aa18ee
commit 9704feec19
4 changed files with 21 additions and 2 deletions

View File

@ -42,6 +42,13 @@ class PHPExcel_Settings
const ZIPARCHIVE = 'ZipArchive'; const ZIPARCHIVE = 'ZipArchive';
/**
* Reference to the class used for Zip file management
* e.g.
* ZipArchive
*
* @var string
*/
private static $_zipClass = self::ZIPARCHIVE; private static $_zipClass = self::ZIPARCHIVE;

View File

@ -38,6 +38,11 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PCLZip/pclzip.lib.php';
class PHPExcel_Shared_ZipArchive class PHPExcel_Shared_ZipArchive
{ {
/** constants */
const OVERWRITE = 'OVERWRITE';
const CREATE = 'CREATE';
/** /**
* Temporary storage directory * Temporary storage directory
* *

View File

@ -224,12 +224,18 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
$zipClass = PHPExcel_Settings::getZipClass(); $zipClass = PHPExcel_Settings::getZipClass();
$objZip = new $zipClass(); $objZip = new $zipClass();
// Retrieve OVERWRITE and CREATE constants from the instantiated zip class
// This method of accessing constant values from a dynamic class should work with all appropriate versions of PHP
$ro = new ReflectionObject($objZip);
$zipOverWrite = $ro->getConstant('OVERWRITE');
$zipCreate = $ro->getConstant('CREATE');
if (file_exists($pFilename)) { if (file_exists($pFilename)) {
unlink($pFilename); unlink($pFilename);
} }
// Try opening the ZIP file // Try opening the ZIP file
if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) { if ($objZip->open($pFilename, $zipOverWrite) !== true) {
if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) { if ($objZip->open($pFilename, $zipCreate) !== true) {
throw new Exception("Could not open " . $pFilename . " for writing."); throw new Exception("Could not open " . $pFilename . " for writing.");
} }
} }

View File

@ -25,6 +25,7 @@
Fixed in SVN: Fixed in SVN:
- Bugfix: (MBaker) Work item 15459 - Invalid cell coordinate in Autofilter for Excel2007 Writer - Bugfix: (MBaker) Work item 15459 - Invalid cell coordinate in Autofilter for Excel2007 Writer
- Bugfix: (MBaker) Work item 15518 - PCLZip library issue
- General: (MBaker) Work item 15405 - Two easy to fix Issues concerning PHPExcel_Token_Stack (l10n/UC) - General: (MBaker) Work item 15405 - Two easy to fix Issues concerning PHPExcel_Token_Stack (l10n/UC)
- General: (MBaker) Work item 15461 - Locale file paths not fit for windows - General: (MBaker) Work item 15461 - Locale file paths not fit for windows