PHP Class PressBooks\Modules\Import\Import

ファイルを表示 Open project: pressbooks/pressbooks

Public Properties

Property Type Description
$logsEmail array Email addresses to send logs.

Public Methods

Method Description
createTmpFile ( ) : string Create a temporary file that automatically gets deleted on __sleep()
formSubmit ( ) Catch form submissions
import ( array $current_import ) : boolean
isFormSubmission ( ) : boolean Check if a user submitted something to options-general.php?page=pb_import
log ( string $message, array $more_info = [] ) Log something using wp_mail() and error_log(), include useful WordPress info.
revokeCurrentImport ( ) : boolean Delete 'pressbooks_current_import' option, delete the file too.
setCurrentImportOption ( array $upload ) : boolean Mandatory setCurrentImportOption() method, creates WP option 'pressbooks_current_import'

Protected Methods

Method Description
determinePostType ( string $id ) : string Check against what the user selected for post_type in our form
flaggedForImport ( $id ) : boolean Check against what the user selected for import in our form
getChapterParent ( ) : integer Get a valid Part id to act as post_parent to a Chapter
properImageExtension ( string $path_to_file, string $filename ) : string Checks if the file extension matches its mimetype, returns a modified filename if they don't match.
tidy ( string $html ) : string Tidy HTML

Method Details

createTmpFile() public method

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

determinePostType() protected method

Check against what the user selected for post_type in our form
protected determinePostType ( string $id ) : string
$id string
return string

flaggedForImport() protected method

Check against what the user selected for import in our form
protected flaggedForImport ( $id ) : boolean
$id
return boolean

formSubmit() public static method

Catch form submissions
public static formSubmit ( )

getChapterParent() protected method

Get a valid Part id to act as post_parent to a Chapter
protected getChapterParent ( ) : integer
return integer

import() abstract public method

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

isFormSubmission() static public method

Check if a user submitted something to options-general.php?page=pb_import
static public isFormSubmission ( ) : boolean
return boolean

log() static public method

Note: This method is here temporarily. We are using it to find & fix bugs for the first iterations of import. Do not count on this method being here in the future.
Deprecation:
static public log ( string $message, array $more_info = [] )
$message string
$more_info array

properImageExtension() protected method

Checks if the file extension matches its mimetype, returns a modified filename if they don't match.
protected properImageExtension ( string $path_to_file, string $filename ) : string
$path_to_file string
$filename string
return string - modified filename if the extension did not match the mimetype, otherwise returns the filename that was passed to it

revokeCurrentImport() public method

Delete 'pressbooks_current_import' option, delete the file too.
public revokeCurrentImport ( ) : boolean
return boolean

setCurrentImportOption() abstract public method

$upload should look something like: Array ( [file] => /home/dac514/public_html/bdolor/wp-content/uploads/sites/2/2013/04/Hello-World-13662149822.epub [url] => http://localhost/~dac514/bdolor/helloworld/wp-content/uploads/sites/2/2013/04/Hello-World-13662149822.epub [type] => application/epub+zip ) 'pressbooks_current_import' should look something like: Array ( [file] => '/home/dac514/public_html/bdolor/wp-content/uploads/sites/2/imports/Hello-World-1366214982.epub' [file_type] => 'application/epub+zip' [type_of] => 'epub' [chapters] => Array ( [some-id] => 'Some title' [front-cover] => 'Front Cover' [chapter-001] => 'Some other title' ) )
See also: wp_handle_upload
abstract public setCurrentImportOption ( array $upload ) : boolean
$upload array An associative array of file attributes
return boolean

tidy() protected method

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

Property Details

$logsEmail static_oe public_oe property

Email addresses to send logs.
Deprecation:
static public array $logsEmail
return array