PHP Class Pressbooks\Modules\Export\Epub\Epub201

Inheritance: extends Pressbooks\Modules\Export\Export
Afficher le fichier Open project: pressbooks/pressbooks Class Usage Examples

Méthodes publiques

Свойство Type Description
$timeout integer Used with wp_remote_get()

Protected Properties

Свойство Type Description
$compressImages boolean
$coverImage string Used to set cover-image in OPF for kindlegen compatibility.
$cssOverrides string CSS overrides
$dir $var string
$exportStylePath string Fullpath to book CSS file.
$extraCss string Extra CSS (to be used by child classes if necessary)
$fetchedFontCache array
$fetchedImageCache array
$filext string
$fixme array Used by HtmLawed with $GLOBALS['hl_Ids']
$frontMatterLastPos integer | boolean Last known front matter position. Used to insert the TOC in the correct place.
$frontMatterPos integer Keep track of where we are using this variable.
$hasIntroduction boolean Sometimes the user will omit an introduction so we must inject the style in either the first part or the first chapter ourselves.
$lang string Main language of document, two letter code
$manifest array Generated by createOEPBS(), used by createToc(), createOPF(), and creatdNCX() Note: Only XHTML files go in the manifest array (images are done automatically)
$numbered boolean
$romanizePartNumbers boolean Hack to romanize part numbers
$stylesheet string
$suffix $var string
$supportedFontExtensions string Regular expression for supported fonts (used in #($supportedFontExtensions)#i')
$supportedImageExtensions string Regular expression for supported images (used in #($supportedImageExtensions)#i')
$tmpDir string Temporary directory used to build EPUB, no trailing slash!

Méthodes publiques

Méthode Description
__construct ( array $args )
__destruct ( ) Delete temporary directory when done.
convert ( ) : boolean Create $this->outputPath
fixAnnoyingCharacters ( string $html ) : string | void Fix annoying characters that the user probably didn't do on purpose
hasDependencies ( ) : boolean Dependency check.
mediaType ( string $file ) : mixed | string Override mimeType, get rid of '; charset=binary'
validate ( ) : boolean Check the sanity of $this->outputPath

Méthodes protégées

Méthode Description
buildManifestAssetsHtml ( ) : string Find all the image files, insert them into the OPF file
createBackMatter ( array $book_contents, array $metadata )
createBeforeTitle ( array $book_contents, array $metadata )
createContainer ( ) Create Open Publication Structure 2.0.1 container.
createCopyright ( array $book_contents, array $metadata )
createCover ( array $book_contents, array $metadata )
createDedicationAndEpigraph ( array $book_contents, array $metadata )
createFrontMatter ( array $book_contents, array $metadata )
createNCX ( array $book_contents, array $metadata ) Create NCX file.
createOEPBS ( array $book_contents, array $metadata ) Create OEBPS/* files.
createOPF ( array $book_contents, array $metadata ) Create OPF File.
createPartsAndChapters ( array $book_contents, array $metadata )
createPromo ( array $book_contents, array $metadata )
createStylesheet ( ) Create stylesheet. Change $this->stylesheet to a filename used by subsequent methods.
createTitle ( array $book_contents, array $metadata )
createToc ( array $book_contents, array $metadata ) Uses $this->manifest to generate itself.
deleteTmpDir ( ) Create a temporary directory
fetchAndSaveUniqueFont ( $url, $fullpath ) : string Fetch a font with wp_remote_get(), save it to $fullpath with a unique name.
fetchAndSaveUniqueImage ( $url, $fullpath ) : string Fetch an image with wp_remote_get(), save it to $fullpath with a unique name.
fuzzyHrefMatch ( $url, string $type, integer $pos ) : boolean | string Try to determine if a URL is pointing to internal content. TODO: Refactor, for the love of all that is holy.
fuzzyImageNameMatch ( string $file1, string $file2 ) : boolean Fuzzy image name match.
kneadHref ( DOMDocument $doc, string $type, integer $pos ) : DOMDocument Change hrefs
kneadHtml ( string $html, string $type, integer $pos ) : string Pummel the HTML into EPUB compatible dough.
positionOfToc ( ) : integer Determine position of TOC based on Chicago Manual Of Style.
preProcessBookContents ( $book_contents ) : mixed
preProcessPostContent ( string $content ) : string
scrapeAndKneadImages ( DOMDocument $doc ) : DOMDocument Parse HTML snippet, download all found tags into /OEBPS/assets/, return the HTML with changed paths.
scrapeAndKneadMedia ( DOMDocument $doc ) : DOMDocument This is a stub for an Epub3 feature Do nothing
scrapeKneadAndSaveCss ( string $path_to_original_stylesheet, string $path_to_copy_of_stylesheet ) Parse CSS, copy assets, rewrite copy.
themeOptionsOverrides ( ) Override based on Theme Options
tidy ( string $html ) : string Tidy HTML
zipEpub ( $filename ) : boolean Zip the contents of an EPUB following the conventions outlined in Open Publication Structure 2.0.1

Method Details

__construct() public méthode

public __construct ( array $args )
$args array

__destruct() public méthode

Delete temporary directory when done.
public __destruct ( )

buildManifestAssetsHtml() protected méthode

Find all the image files, insert them into the OPF file
protected buildManifestAssetsHtml ( ) : string
Résultat string

convert() public méthode

Create $this->outputPath
public convert ( ) : boolean
Résultat boolean

createBackMatter() protected méthode

protected createBackMatter ( array $book_contents, array $metadata )
$book_contents array
$metadata array

createBeforeTitle() protected méthode

protected createBeforeTitle ( array $book_contents, array $metadata )
$book_contents array
$metadata array

createContainer() protected méthode

Create Open Publication Structure 2.0.1 container.
protected createContainer ( )

createCopyright() protected méthode

protected createCopyright ( array $book_contents, array $metadata )
$book_contents array
$metadata array

createCover() protected méthode

protected createCover ( array $book_contents, array $metadata )
$book_contents array
$metadata array

createDedicationAndEpigraph() protected méthode

protected createDedicationAndEpigraph ( array $book_contents, array $metadata )
$book_contents array
$metadata array

createFrontMatter() protected méthode

protected createFrontMatter ( array $book_contents, array $metadata )
$book_contents array
$metadata array

createNCX() protected méthode

Create NCX file.
protected createNCX ( array $book_contents, array $metadata )
$book_contents array
$metadata array

createOEPBS() protected méthode

Create OEBPS/* files.
protected createOEPBS ( array $book_contents, array $metadata )
$book_contents array
$metadata array

createOPF() protected méthode

Create OPF File.
protected createOPF ( array $book_contents, array $metadata )
$book_contents array
$metadata array

createPartsAndChapters() protected méthode

protected createPartsAndChapters ( array $book_contents, array $metadata )
$book_contents array
$metadata array

createPromo() protected méthode

protected createPromo ( array $book_contents, array $metadata )
$book_contents array
$metadata array

createStylesheet() protected méthode

Create stylesheet. Change $this->stylesheet to a filename used by subsequent methods.
protected createStylesheet ( )

createTitle() protected méthode

protected createTitle ( array $book_contents, array $metadata )
$book_contents array
$metadata array

createToc() protected méthode

Uses $this->manifest to generate itself.
protected createToc ( array $book_contents, array $metadata )
$book_contents array
$metadata array

deleteTmpDir() protected méthode

Create a temporary directory
protected deleteTmpDir ( )

fetchAndSaveUniqueFont() protected méthode

Will return an empty string if something went wrong.
protected fetchAndSaveUniqueFont ( $url, $fullpath ) : string
$url string
$fullpath string
Résultat string filename

fetchAndSaveUniqueImage() protected méthode

Will return an empty string if something went wrong.
protected fetchAndSaveUniqueImage ( $url, $fullpath ) : string
$url string
$fullpath string
Résultat string filename

fixAnnoyingCharacters() public méthode

Fix annoying characters that the user probably didn't do on purpose
public fixAnnoyingCharacters ( string $html ) : string | void
$html string
Résultat string | void

fuzzyHrefMatch() protected méthode

Try to determine if a URL is pointing to internal content. TODO: Refactor, for the love of all that is holy.
protected fuzzyHrefMatch ( $url, string $type, integer $pos ) : boolean | string
$url
$type string front-matter, part, chapter, back-matter, ...
$pos integer (optional) position of content, used when creating filenames like: chapter-001, chapter-002, ...
Résultat boolean | string

fuzzyImageNameMatch() protected méthode

For example: We consider both 'href' and 'src' above 'the same'
protected fuzzyImageNameMatch ( string $file1, string $file2 ) : boolean
$file1 string
$file2 string
Résultat boolean

hasDependencies() static public méthode

Dependency check.
static public hasDependencies ( ) : boolean
Résultat boolean

kneadHref() protected méthode

Change hrefs
protected kneadHref ( DOMDocument $doc, string $type, integer $pos ) : DOMDocument
$doc DOMDocument
$type string front-matter, part, chapter, back-matter, ...
$pos integer (optional) position of content, used when creating filenames like: chapter-001, chapter-002, ...
Résultat DOMDocument

kneadHtml() protected méthode

Pummel the HTML into EPUB compatible dough.
protected kneadHtml ( string $html, string $type, integer $pos ) : string
$html string
$type string front-matter, part, chapter, back-matter, ...
$pos integer (optional) position of content, used when creating filenames like: chapter-001, chapter-002, ...
Résultat string

mediaType() public méthode

Override mimeType, get rid of '; charset=binary'
public mediaType ( string $file ) : mixed | string
$file string
Résultat mixed | string

positionOfToc() protected méthode

Determine position of TOC based on Chicago Manual Of Style.
protected positionOfToc ( ) : integer
Résultat integer

preProcessBookContents() protected méthode

protected preProcessBookContents ( $book_contents ) : mixed
$book_contents
Résultat mixed

preProcessPostContent() protected méthode

protected preProcessPostContent ( string $content ) : string
$content string
Résultat string

scrapeAndKneadImages() protected méthode

Parse HTML snippet, download all found tags into /OEBPS/assets/, return the HTML with changed paths.
protected scrapeAndKneadImages ( DOMDocument $doc ) : DOMDocument
$doc DOMDocument
Résultat DOMDocument

scrapeAndKneadMedia() protected méthode

This is a stub for an Epub3 feature Do nothing
protected scrapeAndKneadMedia ( DOMDocument $doc ) : DOMDocument
$doc DOMDocument
Résultat DOMDocument

scrapeKneadAndSaveCss() protected méthode

Parse CSS, copy assets, rewrite copy.
protected scrapeKneadAndSaveCss ( string $path_to_original_stylesheet, string $path_to_copy_of_stylesheet )
$path_to_original_stylesheet string *
$path_to_copy_of_stylesheet string

themeOptionsOverrides() protected méthode

Override based on Theme Options
protected themeOptionsOverrides ( )

tidy() protected méthode

Tidy HTML
protected tidy ( string $html ) : string
$html string
Résultat string

validate() public méthode

Check the sanity of $this->outputPath
public validate ( ) : boolean
Résultat boolean

zipEpub() protected méthode

Zip the contents of an EPUB following the conventions outlined in Open Publication Structure 2.0.1
protected zipEpub ( $filename ) : boolean
$filename
Résultat boolean

Property Details

$compressImages protected_oe property

protected bool $compressImages
Résultat boolean

$coverImage protected_oe property

Used to set cover-image in OPF for kindlegen compatibility.
protected string $coverImage
Résultat string

$cssOverrides protected_oe property

CSS overrides
protected string $cssOverrides
Résultat string

$dir protected_oe property

$var string
protected $dir

$exportStylePath protected_oe property

Fullpath to book CSS file.
protected string $exportStylePath
Résultat string

$extraCss protected_oe property

Extra CSS (to be used by child classes if necessary)
protected string $extraCss
Résultat string

$fetchedFontCache protected_oe property

protected array $fetchedFontCache
Résultat array

$fetchedImageCache protected_oe property

protected array $fetchedImageCache
Résultat array

$filext protected_oe property

protected string $filext
Résultat string

$fixme protected_oe property

Used by HtmLawed with $GLOBALS['hl_Ids']
protected array $fixme
Résultat array

$frontMatterLastPos protected_oe property

Last known front matter position. Used to insert the TOC in the correct place.
protected int|bool $frontMatterLastPos
Résultat integer | boolean

$frontMatterPos protected_oe property

Keep track of where we are using this variable.
protected int $frontMatterPos
Résultat integer

$hasIntroduction protected_oe property

Sometimes the user will omit an introduction so we must inject the style in either the first part or the first chapter ourselves.
protected bool $hasIntroduction
Résultat boolean

$lang protected_oe property

Main language of document, two letter code
protected string $lang
Résultat string

$manifest protected_oe property

Generated by createOEPBS(), used by createToc(), createOPF(), and creatdNCX() Note: Only XHTML files go in the manifest array (images are done automatically)
protected array $manifest
Résultat array

$numbered protected_oe property

protected bool $numbered
Résultat boolean

$romanizePartNumbers protected_oe property

Hack to romanize part numbers
protected bool $romanizePartNumbers
Résultat boolean

$stylesheet protected_oe property

protected string $stylesheet
Résultat string

$suffix protected_oe property

$var string
protected $suffix

$supportedFontExtensions protected_oe property

Regular expression for supported fonts (used in #($supportedFontExtensions)#i')
protected string $supportedFontExtensions
Résultat string

$supportedImageExtensions protected_oe property

Regular expression for supported images (used in #($supportedImageExtensions)#i')
protected string $supportedImageExtensions
Résultat string

$timeout public_oe property

Used with wp_remote_get()
public int $timeout
Résultat integer

$tmpDir protected_oe property

Temporary directory used to build EPUB, no trailing slash!
protected string $tmpDir
Résultat string