diff --git a/README.md b/README.md
index ebb6e66..452f2f7 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ See the examples for example usage. The php files have "some" doumentation in th
### Import
Add this requirement to your `composer.json` file:
```json
- "grandt/phpepub": ">=4.0.1"
+ "grandt/phpepub": ">=4.0.2"
```
### Composer
@@ -42,7 +42,7 @@ Once composer is installed you can create the `composer.json` file to import thi
```json
{
"require": {
- "grandt/phpepub": ">=4.0.1",
+ "grandt/phpepub": ">=4.0.2",
"php": ">=5.3.0"
}
}
diff --git a/REVISION.TXT b/REVISION.TXT
index 1b7259c..9d338da 100644
--- a/REVISION.TXT
+++ b/REVISION.TXT
@@ -1,4 +1,8 @@
---------------------------------------------------------------------
+Rev. 4.0.2 - 2015-09-15
+* Changed: Added function addFileToMETAINF to enable users to add the apple ibooks metadata.
+* $book->addFileToMETAINF("com.apple.ibooks.display-options.xml", $xmldata);
+---------------------------------------------------------------------
Rev. 4.0.1 - 2015-06-29
* Changed: Included J. King's DrUUID library rather than using composer. The only available package remained in "dev" stability.
* http://jkingweb.ca/code/php/lib.uuid/
diff --git a/composer.json b/composer.json
index 44331f2..f5fa00c 100644
--- a/composer.json
+++ b/composer.json
@@ -5,7 +5,7 @@
"keywords": ["epub", "e-book"],
"homepage": "https://github.com/Grandt/PHPZip",
"license": "LGPL-2.1",
- "version": "4.0.1",
+ "version": "4.0.2",
"minimum-stability": "stable",
"authors": [
{
diff --git a/src/PHPePub/Core/EPub.php b/src/PHPePub/Core/EPub.php
index eaeb7b6..3a2f0d4 100644
--- a/src/PHPePub/Core/EPub.php
+++ b/src/PHPePub/Core/EPub.php
@@ -868,6 +868,29 @@ function getMimeTypeFromExtension($ext) {
return "application/octet-stream";
}
+ /**
+ * Add a file to the META-INF directory.
+ * Bloody Apple and their bloody proprietary ways of doing things.
+ *
+ * @param string $fileName Filename to use for the file, must be unique for the book.
+ * @param string $fileData File data
+ *
+ * @return bool $success
+ */
+ function addFileToMETAINF($fileName, $fileData) {
+ if ($this->isFinalized) {
+ return false;
+ }
+ if (!$this->isInitialized) {
+ $this->initialize();
+ }
+ $fileName = $this->normalizeFileName($fileName);
+
+ $this->zip->addFile($fileData, "META-INF/" . $fileName);
+
+ return true;
+ }
+
/**
* Add dynamically generated data as a file to the book.
*
diff --git a/tests/EPub.Example1.php b/tests/EPub.Example1.php
index c90e6ec..824e157 100644
--- a/tests/EPub.Example1.php
+++ b/tests/EPub.Example1.php
@@ -89,6 +89,7 @@
$book->buildTOC(NULL, "toc", "Table of Contents", TRUE, TRUE);
// function buildTOC($cssFileName = NULL, $tocCSSClass = "toc", $title = "Table of Contents", $addReferences = TRUE, $addToIndex = FALSE, $tocFileName = "TOC.xhtml") {
+$book->addFileToMETAINF("com.apple.ibooks.display-options.xml", "\n