Namespacing for ZipArchive for readers

This commit is contained in:
Mark Baker 2013-06-20 10:11:36 +01:00
parent f92cd96d6d
commit be4a1b9dca
5 changed files with 9 additions and 9 deletions

View File

@ -68,13 +68,13 @@ class Reader_OOCalc extends Reader_Abstract implements Reader_IReader
} }
// Check if zip class exists // Check if zip class exists
if (!class_exists('ZipArchive',FALSE)) { if (!class_exists('\ZipArchive',FALSE)) {
throw new Reader_Exception("ZipArchive library is not enabled"); throw new Reader_Exception("ZipArchive library is not enabled");
} }
$mimeType = 'UNKNOWN'; $mimeType = 'UNKNOWN';
// Load file // Load file
$zip = new ZipArchive; $zip = new \ZipArchive;
if ($zip->open($pFilename) === true) { if ($zip->open($pFilename) === true) {
// check if it is an OOXML archive // check if it is an OOXML archive
$stat = $zip->statName('mimetype'); $stat = $zip->statName('mimetype');
@ -117,7 +117,7 @@ class Reader_OOCalc extends Reader_Abstract implements Reader_IReader
throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }
$zip = new ZipArchive; $zip = new \ZipArchive;
if (!$zip->open($pFilename)) { if (!$zip->open($pFilename)) {
throw new Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file.");
} }
@ -169,7 +169,7 @@ class Reader_OOCalc extends Reader_Abstract implements Reader_IReader
$worksheetInfo = array(); $worksheetInfo = array();
$zip = new ZipArchive; $zip = new \ZipArchive;
if (!$zip->open($pFilename)) { if (!$zip->open($pFilename)) {
throw new Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file.");
} }
@ -324,7 +324,7 @@ class Reader_OOCalc extends Reader_Abstract implements Reader_IReader
$timezoneObj = new DateTimeZone('Europe/London'); $timezoneObj = new DateTimeZone('Europe/London');
$GMT = new DateTimeZone('UTC'); $GMT = new DateTimeZone('UTC');
$zip = new ZipArchive; $zip = new \ZipArchive;
if (!$zip->open($pFilename)) { if (!$zip->open($pFilename)) {
throw new Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file."); throw new Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file.");
} }

View File

@ -81,7 +81,7 @@ class Shared_File
$zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6); $zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6);
$archiveFile = substr($pFilename, strpos($pFilename, '#') + 1); $archiveFile = substr($pFilename, strpos($pFilename, '#') + 1);
$zip = new ZipArchive(); $zip = new \ZipArchive();
if ($zip->open($zipFile) === true) { if ($zip->open($zipFile) === true) {
$returnValue = ($zip->getFromName($archiveFile) !== false); $returnValue = ($zip->getFromName($archiveFile) !== false);
$zip->close(); $zip->close();

View File

@ -92,7 +92,7 @@ class Shared_ZipStreamWrapper {
$url['fragment'] = substr($path, $pos + 1); $url['fragment'] = substr($path, $pos + 1);
// Open archive // Open archive
$this->_archive = new ZipArchive(); $this->_archive = new \ZipArchive();
$this->_archive->open($url['host']); $this->_archive->open($url['host']);
$this->_fileNameInArchive = $url['fragment']; $this->_fileNameInArchive = $url['fragment'];

View File

@ -319,7 +319,7 @@ class Writer_Excel2007 extends Writer_Abstract implements Writer_IWriter
$imagePath = substr($imagePath, 6); $imagePath = substr($imagePath, 6);
$imagePathSplitted = explode('#', $imagePath); $imagePathSplitted = explode('#', $imagePath);
$imageZip = new ZipArchive(); $imageZip = new \ZipArchive();
$imageZip->open($imagePathSplitted[0]); $imageZip->open($imagePathSplitted[0]);
$imageContents = $imageZip->getFromName($imagePathSplitted[1]); $imageContents = $imageZip->getFromName($imagePathSplitted[1]);
$imageZip->close(); $imageZip->close();

View File

@ -26,7 +26,7 @@ Requirements
------------ ------------
The following requirements should be met prior to using PHPExcel: The following requirements should be met prior to using PHPExcel:
* PHP version 5.2.0 or higher * PHP version 5.3.0 or higher
* PHP extension php_zip enabled *) * PHP extension php_zip enabled *)
* PHP extension php_xml enabled * PHP extension php_xml enabled
* PHP extension php_gd2 enabled (if not compiled in) * PHP extension php_gd2 enabled (if not compiled in)