Skip to content
Browse files

Request #18345 Support for loading mimetype from Zip contents

  • Loading branch information...
1 parent 26db346 commit 32bd9a2672c5da1b9bce27380e0f803d0f72b555 @CloCkWeRX CloCkWeRX committed Dec 9, 2011
Showing with 15 additions and 7 deletions.
  1. +15 −7 OpenDocument/Storage/Zip.php
View
22 OpenDocument/Storage/Zip.php
@@ -180,14 +180,14 @@ public function checkReadability($file)
*/
protected function loadFile($file)
{
- $zip = new ZipArchive();
- if ($zip->open($file) !== true) {
+ $this->zip = new ZipArchive();
+ if ($this->zip->open($file) !== true) {
throw new OpenDocument_Exception('Cannot open ZIP file: ' . $file);
}
- $this->contentDom = $this->loadDomFromZip($zip, 'content.xml');
- $this->metaDom = $this->loadDomFromZip($zip, 'meta.xml');
- $this->settingsDom = $this->loadDomFromZip($zip, 'settings.xml');
- $this->stylesDom = $this->loadDomFromZip($zip, 'styles.xml');
+ $this->contentDom = $this->loadDomFromZip($this->zip, 'content.xml');
+ $this->metaDom = $this->loadDomFromZip($this->zip, 'meta.xml');
+ $this->settingsDom = $this->loadDomFromZip($this->zip, 'settings.xml');
+ $this->stylesDom = $this->loadDomFromZip($this->zip, 'styles.xml');
//FIXME: what to do with embedded files (e.g. images)?
}
@@ -229,7 +229,15 @@ public function getMimeType()
//FIXME: implement functionality
//load from manifest first
//if null, load from content
- return 'application/vnd.oasis.opendocument.text';
+ //return 'application/vnd.oasis.opendocument.text';
+ $file = 'mimetype';
+ $index = $this->zip->locateName($file);
+ if ($index === false) {
+ throw new OpenDocument_Exception('File not found in zip: ' . $file);
+ }
+ $mimetype = $this->zip->getFromIndex($index);
+ return $mimetype;
+
}

0 comments on commit 32bd9a2

Please sign in to comment.
Something went wrong with that request. Please try again.