PHP Class PressBooks\Modules\Import\Epub\Epub201

Inheritance: extends PressBooks\Modules\Import\Import
Mostrar archivo Open project: pressbooks/pressbooks

Protected Properties

Property Type Description
$authors string String for authors, contributors
$basedir string OPF Basedir
$isPbEpub boolean If Pressbooks generated the epub file
$zip ZipArchive Reference to the object that represents the Epub zip folder

Public Methods

Method Description
__construct ( )
import ( array $current_import ) : boolean
setCurrentImportOption ( array $upload ) : boolean

Protected Methods

Method Description
fetchAndSaveUniqueImage ( $url, string $href ) : string Extract url from zip and load into WP using media_handle_sideload() Will return an empty string if something went wrong.
getOpf ( ) : SimpleXMLElement Return book.opf as a SimpleXML object
getZipContent ( $file, boolean $as_xml = true ) : string | SimpleXMLElement Locates an entry using its name, returns the entry contents
kneadAndInsert ( string $href, string $post_type, integer $chapter_parent ) Pummel then insert HTML into our database
kneadHref ( DOMDocument $doc, string $type, string $href ) : DOMDocument Change hrefs
kneadHtml ( string $html, string $type, string $href ) : string Pummel the HTML into WordPress compatible dough.
parseManifest ( SimpleXMLElement $xml, array $match_ids, $chapter_parent ) Parse OPF manifest nodes
parseMetadata ( SimpleXMLElement $xml ) Parse OPF metadata nodes
pbCheck ( string $copyrightFile ) : boolean Is it an EPUB generated by PB?
regexSearchReplace ( string $html ) : string Cleans imported html of unwanted tags
scrapeAndKneadImages ( DOMDocument $doc, string $href ) : DOMDocument Parse HTML snippet, save all found tags using media_handle_sideload(), return the HTML with changed paths.
setCurrentZip ( string $fullpath ) Opens a new Epub for reading, writing or modifying
tidy ( string $html ) : string

Method Details

__construct() public method

public __construct ( )

fetchAndSaveUniqueImage() protected method

Extract url from zip and load into WP using media_handle_sideload() Will return an empty string if something went wrong.
See also: media_handle_sideload
protected fetchAndSaveUniqueImage ( $url, string $href ) : string
$url string
$href string original filename, with (relative) path
return string filename

getOpf() protected method

Return book.opf as a SimpleXML object
protected getOpf ( ) : SimpleXMLElement
return SimpleXMLElement

getZipContent() protected method

Locates an entry using its name, returns the entry contents
protected getZipContent ( $file, boolean $as_xml = true ) : string | SimpleXMLElement
$file
$as_xml boolean
return string | SimpleXMLElement

import() public method

public import ( array $current_import ) : boolean
$current_import array
return boolean

kneadAndInsert() protected method

Pummel then insert HTML into our database
protected kneadAndInsert ( string $href, string $post_type, integer $chapter_parent )
$href string
$post_type string
$chapter_parent integer

kneadHref() protected method

Change hrefs
protected kneadHref ( DOMDocument $doc, string $type, string $href ) : DOMDocument
$doc DOMDocument
$type string front-matter, part, chapter, back-matter, ...
$href string original filename, with (relative) path
return DOMDocument

kneadHtml() protected method

Pummel the HTML into WordPress compatible dough.
protected kneadHtml ( string $html, string $type, string $href ) : string
$html string
$type string front-matter, part, chapter, back-matter, ...
$href string original filename, with (relative) path
return string

parseManifest() protected method

Parse OPF manifest nodes
protected parseManifest ( SimpleXMLElement $xml, array $match_ids, $chapter_parent )
$xml SimpleXMLElement
$match_ids array
$chapter_parent

parseMetadata() protected method

Parse OPF metadata nodes
protected parseMetadata ( SimpleXMLElement $xml )
$xml SimpleXMLElement

pbCheck() protected method

Is it an EPUB generated by PB?
See also: createCopyright() in /export/epub/class-pb-epub201.php
protected pbCheck ( string $copyrightFile ) : boolean
$copyrightFile string
return boolean

regexSearchReplace() protected method

Cleans imported html of unwanted tags
protected regexSearchReplace ( string $html ) : string
$html string
return string

scrapeAndKneadImages() protected method

Parse HTML snippet, save all found tags using media_handle_sideload(), return the HTML with changed paths.
protected scrapeAndKneadImages ( DOMDocument $doc, string $href ) : DOMDocument
$doc DOMDocument
$href string original filename, with (relative) path
return DOMDocument

setCurrentImportOption() public method

public setCurrentImportOption ( array $upload ) : boolean
$upload array
return boolean

setCurrentZip() protected method

Opens a new Epub for reading, writing or modifying
protected setCurrentZip ( string $fullpath )
$fullpath string

tidy() protected method

protected tidy ( string $html ) : string
$html string
return string

Property Details

$authors protected_oe property

String for authors, contributors
protected string $authors
return string

$basedir protected_oe property

OPF Basedir
protected string $basedir
return string

$isPbEpub protected_oe property

If Pressbooks generated the epub file
protected bool $isPbEpub
return boolean

$zip protected_oe property

Reference to the object that represents the Epub zip folder
protected ZipArchive $zip
return ZipArchive