PHP Class Utilities, BicBucStriim

Show file Open project: rvolz/BicBucStriim Class Usage Examples

Public Methods

Method Description
bookPath ( string $cd, string $bp, string $file ) : string Return the true path of a book.
stringStartsWith ( string $haystack, string $needle ) : boolean Check if a string starts with a substring.
titleMimeType ( string $file_path ) : string Return the MIME type for an ebook file.
transparentImage ( integer $width, integer $height ) : image Create an image with transparent background.

Method Details

bookPath() static public method

Works around a strange feature of Calibre where middle components of names are capitalized, eg "Aliette de Bodard" -> "Aliette De Bodard". The directory name uses the capitalized form, the book path stored in the DB uses the original form.
static public bookPath ( string $cd, string $bp, string $file ) : string
$cd string Calibre library directory
$bp string book path, as stored in the DB
$file string file name
return string the filesystem path to the book file

stringStartsWith() static public method

Works around a strange feature of Calibre where middle components of names are capitalized, eg "Aliette de Bodard" -> "Aliette De Bodard". The directory name uses the capitalized form, the book path stored in the DB uses the original form.
static public stringStartsWith ( string $haystack, string $needle ) : boolean
$haystack string String to be searched
$needle string String to search for
return boolean true if $haystack starts with $needle, case insensitive

titleMimeType() static public method

To reduce search time the function checks first wether the file has a well known extension. If not two functions are tried. If all fails 'application/force-download' is returned to force the download of the unknown format.
static public titleMimeType ( string $file_path ) : string
$file_path string path to ebook file
return string MIME type

transparentImage() static public method

see http://stackoverflow.com/questions/279236/how-do-i-resize-pngs-with-transparency-in-php#279310
static public transparentImage ( integer $width, integer $height ) : image
$width integer
$height integer
return image