Skip to content

Commit

Permalink
Added "Dangermode"
Browse files Browse the repository at this point in the history
Added Dangermode to allow users access to the ePub structure in the
unlikely case they need it.
  • Loading branch information
Grandt committed Sep 15, 2015
1 parent dee0c55 commit 1cd3898
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 11 deletions.
4 changes: 4 additions & 0 deletions REVISION.TXT
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---------------------------------------------------------------------
Rev. 4.0.4 - 2015-09-15
* Added: "DANGERMODE" to allow the user to get and manipulate the internal structure should they need it.
* Note, IF you really need to do any of this, let me know, in case it is really something the package itself should do.
---------------------------------------------------------------------
Rev. 4.0.3 - 2015-09-15
* Changed: Added functions addCustomNamespace, addCustomPrefix, addCustomMetaValue and addCustomMetaProperty
* to enable users to add needed namespaces or prefixes (prefixes are only supported in ePub3)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"keywords": ["epub", "e-book"],
"homepage": "https://github.com/Grandt/PHPZip",
"license": "LGPL-2.1",
"version": "4.0.3",
"version": "4.0.4",
"minimum-stability": "stable",
"authors": [
{
Expand Down
49 changes: 47 additions & 2 deletions src/PHPePub/Core/EPub.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
* @author A. Grandt <php@grandt.com>
* @copyright 2009-2014 A. Grandt
* @license GNU LGPL 2.1
* @version 4.0.3
* @version 4.0.4
* @link http://www.phpclasses.org/package/6115
* @link https://github.com/Grandt/PHPePub
*/
class EPub {
const VERSION = '4.0.3';
const VERSION = '4.0.4';

const IDENTIFIER_UUID = 'UUID';
const IDENTIFIER_URI = 'URI';
Expand Down Expand Up @@ -121,6 +121,8 @@ class EPub {
private $htmlContentHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n<title></title>\n</head>\n<body>\n";
private $htmlContentFooter = "</body>\n</html>\n";

private $dangermode = false;

/**
* Class constructor.
*
Expand Down Expand Up @@ -2739,4 +2741,47 @@ function html2text($string) {
function getLog() {
return $this->log->getLog();
}

/**
* Set or clear "Dangermode"
*
* Dangermode allows the user to access the structure of the ePub directly,
* potentially leading to defective files.
*
* @param bool $dangermode
*/
function setDangermode($dangermode) {
$this->dangermode = $dangermode === true;
}

/**
* The Opf data isn't generated before the ePub is finalized.
*
* @return null|Opf the Opf structure class.
*/
function DANGER_getOpf() {
return $this->dangermode ? $this->opf : null;
}

/**
* The Ncx data isn't generated before the ePub is finalized.
*
* @return null|Ncx The Ncx Navigation class
*/
function DANGER_getNcx() {
return $this->dangermode ? $this->ncx : null;
}

/**
* The Zip file isn't completed before the ePub is finalized,
* however files added ARE packed and written to it immediately,
* and their contents can't be altered.
*
* See the phpzip/phpzip composer package for usage.
*
* @return null|Zip The actual zip file.
*/
function DANGER_getZip() {
return $this->dangermode ? $this->zip : null;
}
}
5 changes: 1 addition & 4 deletions src/PHPePub/Core/Structure/Ncx.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@
* ePub NCX file structure
*
* @author A. Grandt <php@grandt.com>
* @copyright 2009-2014 A. Grandt
* @copyright 2009-2015 A. Grandt
* @license GNU LGPL, Attribution required for commercial implementations, requested for everything else.
* @version 3.30
*/
class Ncx {
const _VERSION = 3.30;

const MIMETYPE = "application/x-dtbncx+xml";

private $bookVersion = EPub::BOOK_VERSION_EPUB2;
Expand Down
5 changes: 1 addition & 4 deletions src/PHPePub/Core/Structure/Opf.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@
* ePub OPF file structure
*
* @author A. Grandt <php@grandt.com>
* @copyright 2009-2014 A. Grandt
* @copyright 2009-2015 A. Grandt
* @license GNU LGPL, Attribution required for commercial implementations, requested for everything else.
* @version 3.30
*/
class Opf {
const _VERSION = 3.30;

/* Core Media types.
* These types are the only guaranteed mime types any ePub reader must understand.
* Any other type muse define a fall back whose fallback chain will end in one of these.
Expand Down

0 comments on commit 1cd3898

Please sign in to comment.