PHP Class Pressbooks\Modules\Export\Export

Show file Open project: pressbooks/pressbooks Class Usage Examples

Public Properties

Property Type Description
$errorsEmail array Email addresses to send log errors.

Protected Properties

Property Type Description
$outputPath Location where data is held until ready to be displayed.
$reservedIds array Reserved html IDs.

Public Methods

Method Description
convert ( ) : boolean Mandatory convert method, create $this->outputPath
createTmpFile ( ) : string Create a temporary file that automatically gets deleted on __sleep()
fixAnnoyingCharacters ( string $html ) : string Fix annoying characters that the user probably didn't do on purpose
formSubmit ( ) Catch form submissions
getExportFolder ( ) : string Get the fullpath to the Exports folder.
getExportScriptPath ( string $type ) : string Return the fullpath to an export module's Javascript file.
getExportStylePath ( string $type ) : string Return the fullpath to an export module's style file.
getOutputPath ( ) : string Return $this->outputPath
injectHouseStyles ( string $css ) : string Inject house styles into CSS
isFormSubmission ( ) : boolean Check if a user submitted something to admin.php?page=pb_export
isParsingSubsections ( ) : boolean Is section parsing enabled?
logError ( string $message, array $more_info = [] ) Log errors using wp_mail() and error_log(), include useful WordPress info.
mimeType ( string $file ) : string Detect MIME Content-type for a file.
nonce ( string $timestamp ) : string Create a NONCE using WordPress' NONCE_KEY and a Unix timestamp.
setLocale ( string $lang ) : string Hook for add_filter('locale ', .
timestampedFileName ( string $extension, boolean $fullpath = true ) : string Create a timestamped filename.
validate ( ) : boolean Mandatory validate method, check the sanity of $this->outputPath
verifyNonce ( string $timestamp, string $md5 ) : boolean Verify that a NONCE was created within a range of 5 minutes and is valid.

Protected Methods

Method Description
createTmpDir ( ) : string Create a temporary directory, no trailing slash!
doCopyrightLicense ( array $metadata, string $title = '', integer $id = null, string $section_author = '' ) : string Will create an html blob of copyright information, returns empty string if user doesn't want it displayed
downloadExportFile ( string $filename ) Download an .htaccess protected file from the exports directory.
loadTemplate ( string $path, array $vars = [] ) : string Simple template system.
obliterateDir ( string $dirname, boolean $only_empty = false ) : boolean Recursively delete all contents of a directory.
preProcessPostName ( string $id ) : string Check a post_name against a list of reserved IDs, sanitize for use as an XML ID.
transformXML ( string $content, string $path_to_xsl ) : string Convert an XML string via XSLT file.

Method Details

convert() abstract public method

Mandatory convert method, create $this->outputPath
abstract public convert ( ) : boolean
return boolean

createTmpDir() protected method

Create a temporary directory, no trailing slash!
protected createTmpDir ( ) : string
return string

createTmpFile() public method

Create a temporary file that automatically gets deleted on __sleep()
public createTmpFile ( ) : string
return string fullpath

doCopyrightLicense() protected method

Will create an html blob of copyright information, returns empty string if user doesn't want it displayed
protected doCopyrightLicense ( array $metadata, string $title = '', integer $id = null, string $section_author = '' ) : string
$metadata array
$title string
$id integer
$section_author string
return string $html blob

downloadExportFile() protected static method

Download an .htaccess protected file from the exports directory.
protected static downloadExportFile ( string $filename )
$filename string sanitized $_GET['download_export_file']

fixAnnoyingCharacters() public method

Fix annoying characters that the user probably didn't do on purpose
public fixAnnoyingCharacters ( string $html ) : string
$html string
return string

formSubmit() static public method

Catch form submissions
static public formSubmit ( )

getExportFolder() static public method

Create if not there. Create .htaccess protection if missing.
static public getExportFolder ( ) : string
return string fullpath

getExportScriptPath() public method

Return the fullpath to an export module's Javascript file.
public getExportScriptPath ( string $type ) : string
$type string
return string

getExportStylePath() public method

Return the fullpath to an export module's style file.
public getExportStylePath ( string $type ) : string
$type string
return string

getOutputPath() public method

Return $this->outputPath
public getOutputPath ( ) : string
return string

injectHouseStyles() static public method

Inject house styles into CSS
static public injectHouseStyles ( string $css ) : string
$css string
return string

isFormSubmission() static public method

Check if a user submitted something to admin.php?page=pb_export
static public isFormSubmission ( ) : boolean
return boolean

isParsingSubsections() static public method

Is section parsing enabled?
static public isParsingSubsections ( ) : boolean
return boolean

loadTemplate() protected method

Simple template system.
protected loadTemplate ( string $path, array $vars = [] ) : string
$path string
$vars array (optional)
return string

logError() public method

Log errors using wp_mail() and error_log(), include useful WordPress info.
public logError ( string $message, array $more_info = [] )
$message string
$more_info array

mimeType() static public method

Detect MIME Content-type for a file.
static public mimeType ( string $file ) : string
$file string fullpath
return string

nonce() public method

Create a NONCE using WordPress' NONCE_KEY and a Unix timestamp.
See also: verifyNonce
public nonce ( string $timestamp ) : string
$timestamp string unix timestamp
return string

obliterateDir() protected method

Recursively delete all contents of a directory.
protected obliterateDir ( string $dirname, boolean $only_empty = false ) : boolean
$dirname string
$only_empty boolean
return boolean

preProcessPostName() protected method

Check a post_name against a list of reserved IDs, sanitize for use as an XML ID.
protected preProcessPostName ( string $id ) : string
$id string
return string

setLocale() static public method

..), change the book language
static public setLocale ( string $lang ) : string
$lang string
return string

timestampedFileName() public method

Create a timestamped filename.
public timestampedFileName ( string $extension, boolean $fullpath = true ) : string
$extension string
$fullpath boolean
return string

transformXML() protected method

Convert an XML string via XSLT file.
protected transformXML ( string $content, string $path_to_xsl ) : string
$content string
$path_to_xsl string
return string

validate() abstract public method

Mandatory validate method, check the sanity of $this->outputPath
abstract public validate ( ) : boolean
return boolean

verifyNonce() public method

Verify that a NONCE was created within a range of 5 minutes and is valid.
See also: nonce
public verifyNonce ( string $timestamp, string $md5 ) : boolean
$timestamp string unix timestamp
$md5 string
return boolean

Property Details

$errorsEmail public property

Email addresses to send log errors.
public array $errorsEmail
return array

$outputPath protected property

Location where data is held until ready to be displayed.
protected $outputPath

$reservedIds protected property

Reserved html IDs.
protected array $reservedIds
return array