From 3d06c77fc1a49d04555ce240ba64bc06383adc10 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 10 Aug 2014 21:01:46 +0400 Subject: [PATCH] Minor refactoring of "Shared\ZipArchive" class. --- src/PhpWord/Shared/ZipArchive.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php index 38781a80..157959e8 100644 --- a/src/PhpWord/Shared/ZipArchive.php +++ b/src/PhpWord/Shared/ZipArchive.php @@ -158,7 +158,7 @@ class ZipArchive { if (!$this->usePclzip) { if ($this->zip->close() === false) { - throw new Exception("Could not close zip file $this->filename."); + throw new Exception("Could not close zip file {$this->filename}."); } } @@ -233,7 +233,7 @@ class ZipArchive $tempFile = false; if ($filenameParts['basename'] != $localnameParts['basename']) { $tempFile = true; // temp file created - $temppath = $this->tempDir . '/' . $localnameParts['basename']; + $temppath = $this->tempDir . DIRECTORY_SEPARATOR . $localnameParts['basename']; copy($filename, $temppath); $filename = $temppath; $filenameParts = pathinfo($temppath); @@ -246,7 +246,7 @@ class ZipArchive if ($tempFile) { // Remove temp file, if created - @unlink($this->tempDir . '/' . $localnameParts["basename"]); + unlink($this->tempDir . DIRECTORY_SEPARATOR . $localnameParts['basename']); } return ($res == 0) ? false : true; @@ -266,19 +266,19 @@ class ZipArchive $filenameParts = pathinfo($localname); // Write $contents to a temp file - $handle = fopen($this->tempDir . '/' . $filenameParts["basename"], "wb"); + $handle = fopen($this->tempDir . DIRECTORY_SEPARATOR . $filenameParts['basename'], 'wb'); fwrite($handle, $contents); fclose($handle); // Add temp file to zip - $filename = $this->tempDir . '/' . $filenameParts["basename"]; + $filename = $this->tempDir . DIRECTORY_SEPARATOR . $filenameParts['basename']; $pathRemoved = $this->tempDir; $pathAdded = $filenameParts['dirname']; $res = $zip->add($filename, PCLZIP_OPT_REMOVE_PATH, $pathRemoved, PCLZIP_OPT_ADD_PATH, $pathAdded); // Remove temp file - @unlink($this->tempDir . '/' . $filenameParts["basename"]); + @unlink($this->tempDir . DIRECTORY_SEPARATOR . $filenameParts['basename']); return ($res == 0) ? false : true; } @@ -338,7 +338,7 @@ class ZipArchive $extracted = $zip->extractByIndex($listIndex, PCLZIP_OPT_EXTRACT_AS_STRING); } if ((is_array($extracted)) && ($extracted != 0)) { - $contents = $extracted[0]["content"]; + $contents = $extracted[0]['content']; } return $contents; @@ -377,8 +377,8 @@ class ZipArchive $listCount = count($list); $listIndex = -1; for ($i = 0; $i < $listCount; ++$i) { - if (strtolower($list[$i]["filename"]) == strtolower($filename) || - strtolower($list[$i]["stored_filename"]) == strtolower($filename)) { + if (strtolower($list[$i]['filename']) == strtolower($filename) || + strtolower($list[$i]['stored_filename']) == strtolower($filename)) { $listIndex = $i; break; }