From 7e23484619904702dde3c37b68bdd11739654912 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sat, 22 Mar 2014 16:13:43 +0400 Subject: [PATCH] https://github.com/PHPOffice/PHPWord/issues/58 - fix for ZipArchive calls. --- src/Reader/Word2007.php | 4 ++-- src/Shared/ZipStreamWrapper.php | 2 +- src/Template.php | 4 ++-- src/Writer/ODText.php | 10 +++++----- src/Writer/Word2007.php | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Reader/Word2007.php b/src/Reader/Word2007.php index 2620b580..f978e03d 100644 --- a/src/Reader/Word2007.php +++ b/src/Reader/Word2007.php @@ -55,7 +55,7 @@ class Word2007 extends AbstractReader implements IReader $return = false; // Load file - $zip = new ZipArchive(); + $zip = new \ZipArchive(); if ($zip->open($pFilename) === true) { // check if it is an OOXML archive $rels = simplexml_load_string($this->getFromZipArchive($zip, "_rels/.rels")); @@ -120,7 +120,7 @@ class Word2007 extends AbstractReader implements IReader // Initialisations $word = new PhpWord(); - $zip = new ZipArchive(); + $zip = new \ZipArchive(); $zip->open($pFilename); // Read properties and documents diff --git a/src/Shared/ZipStreamWrapper.php b/src/Shared/ZipStreamWrapper.php index 4a8bac6c..2676ac55 100644 --- a/src/Shared/ZipStreamWrapper.php +++ b/src/Shared/ZipStreamWrapper.php @@ -99,7 +99,7 @@ class ZipStreamWrapper } // Open archive - $this->_archive = new ZipArchive(); + $this->_archive = new \ZipArchive(); $this->_archive->open($url['host']); $this->_fileNameInArchive = $url['fragment']; diff --git a/src/Template.php b/src/Template.php index f934257e..a248de7f 100644 --- a/src/Template.php +++ b/src/Template.php @@ -35,7 +35,7 @@ class Template /** * ZipArchive * - * @var ZipArchive + * @var \ZipArchive */ private $_objZip; @@ -72,7 +72,7 @@ class Template throw new Exception("Could not copy the template from {$strFilename} to {$this->_tempFileName}."); } - $this->_objZip = new ZipArchive(); + $this->_objZip = new \ZipArchive(); $this->_objZip->open($this->_tempFileName); $this->_documentXML = $this->_objZip->getFromName('word/document.xml'); diff --git a/src/Writer/ODText.php b/src/Writer/ODText.php index 312b3d5f..c8a2c75a 100644 --- a/src/Writer/ODText.php +++ b/src/Writer/ODText.php @@ -115,17 +115,17 @@ class ODText implements IWriter // Create drawing dictionary // Create new ZIP file and open it for writing - $objZip = new ZipArchive(); + $objZip = new \ZipArchive(); // Try opening the ZIP file - if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) { - if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) { + if ($objZip->open($pFilename, \ZipArchive::OVERWRITE) !== true) { + if ($objZip->open($pFilename, \ZipArchive::CREATE) !== true) { throw new \Exception("Could not open " . $pFilename . " for writing."); } } // Add mimetype to ZIP file - //@todo Not in ZIPARCHIVE::CM_STORE mode + //@todo Not in \ZipArchive::CM_STORE mode $objZip->addFromString('mimetype', $this->getWriterPart('mimetype')->writeMimetype($this->_document)); // Add content.xml to ZIP file @@ -151,7 +151,7 @@ class ODText implements IWriter $imagePath = substr($imagePath, 6); $imagePathSplitted = explode('#', $imagePath); - $imageZip = new ZipArchive(); + $imageZip = new \ZipArchive(); $imageZip->open($imagePathSplitted[0]); $imageContents = $imageZip->getFromName($imagePathSplitted[1]); $imageZip->close(); diff --git a/src/Writer/Word2007.php b/src/Writer/Word2007.php index be142870..de31e71e 100644 --- a/src/Writer/Word2007.php +++ b/src/Writer/Word2007.php @@ -86,11 +86,11 @@ class Word2007 implements IWriter } // Create new ZIP file and open it for writing - $objZip = new ZipArchive(); + $objZip = new \ZipArchive(); // Try opening the ZIP file - if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) { - if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) { + if ($objZip->open($pFilename, \ZipArchive::OVERWRITE) !== true) { + if ($objZip->open($pFilename, \ZipArchive::CREATE) !== true) { throw new Exception("Could not open " . $pFilename . " for writing."); } }