https://github.com/PHPOffice/PHPWord/issues/58 - fix for ZipArchive calls.
This commit is contained in:
parent
0c449a6a0c
commit
7e23484619
@ -55,7 +55,7 @@ class Word2007 extends AbstractReader implements IReader
|
|||||||
|
|
||||||
$return = false;
|
$return = false;
|
||||||
// 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
|
||||||
$rels = simplexml_load_string($this->getFromZipArchive($zip, "_rels/.rels"));
|
$rels = simplexml_load_string($this->getFromZipArchive($zip, "_rels/.rels"));
|
||||||
@ -120,7 +120,7 @@ class Word2007 extends AbstractReader implements IReader
|
|||||||
|
|
||||||
// Initialisations
|
// Initialisations
|
||||||
$word = new PhpWord();
|
$word = new PhpWord();
|
||||||
$zip = new ZipArchive();
|
$zip = new \ZipArchive();
|
||||||
$zip->open($pFilename);
|
$zip->open($pFilename);
|
||||||
|
|
||||||
// Read properties and documents
|
// Read properties and documents
|
||||||
|
|||||||
@ -99,7 +99,7 @@ class ZipStreamWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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'];
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class Template
|
|||||||
/**
|
/**
|
||||||
* ZipArchive
|
* ZipArchive
|
||||||
*
|
*
|
||||||
* @var ZipArchive
|
* @var \ZipArchive
|
||||||
*/
|
*/
|
||||||
private $_objZip;
|
private $_objZip;
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ class Template
|
|||||||
throw new Exception("Could not copy the template from {$strFilename} to {$this->_tempFileName}.");
|
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->_objZip->open($this->_tempFileName);
|
||||||
|
|
||||||
$this->_documentXML = $this->_objZip->getFromName('word/document.xml');
|
$this->_documentXML = $this->_objZip->getFromName('word/document.xml');
|
||||||
|
|||||||
@ -115,17 +115,17 @@ class ODText implements IWriter
|
|||||||
// Create drawing dictionary
|
// Create drawing dictionary
|
||||||
|
|
||||||
// Create new ZIP file and open it for writing
|
// Create new ZIP file and open it for writing
|
||||||
$objZip = new ZipArchive();
|
$objZip = new \ZipArchive();
|
||||||
|
|
||||||
// Try opening the ZIP file
|
// Try opening the ZIP file
|
||||||
if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
|
if ($objZip->open($pFilename, \ZipArchive::OVERWRITE) !== true) {
|
||||||
if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) {
|
if ($objZip->open($pFilename, \ZipArchive::CREATE) !== true) {
|
||||||
throw new \Exception("Could not open " . $pFilename . " for writing.");
|
throw new \Exception("Could not open " . $pFilename . " for writing.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add mimetype to ZIP file
|
// 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));
|
$objZip->addFromString('mimetype', $this->getWriterPart('mimetype')->writeMimetype($this->_document));
|
||||||
|
|
||||||
// Add content.xml to ZIP file
|
// Add content.xml to ZIP file
|
||||||
@ -151,7 +151,7 @@ class ODText implements 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();
|
||||||
|
|||||||
@ -86,11 +86,11 @@ class Word2007 implements IWriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create new ZIP file and open it for writing
|
// Create new ZIP file and open it for writing
|
||||||
$objZip = new ZipArchive();
|
$objZip = new \ZipArchive();
|
||||||
|
|
||||||
// Try opening the ZIP file
|
// Try opening the ZIP file
|
||||||
if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
|
if ($objZip->open($pFilename, \ZipArchive::OVERWRITE) !== true) {
|
||||||
if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) {
|
if ($objZip->open($pFilename, \ZipArchive::CREATE) !== true) {
|
||||||
throw new Exception("Could not open " . $pFilename . " for writing.");
|
throw new Exception("Could not open " . $pFilename . " for writing.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user