VuFind API Documentation

Loader extends ImageLoader
in package

QR Code Generator

Tags
category

VuFind

author

Andrew S. Nagy vufind-tech@lists.sourceforge.net

author

Demian Katz demian.katz@villanova.edu

author

Luke O'Sullivan l.osullivan@swansea.ac.uk

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Wiki

Table of Contents

$allowedFileExtensions  : array<string|int, mixed>
Array containing map of allowed file extensions to mimetypes (to be extended)
$configuredFailImage  : string
User-configured image to load from theme on error.
$contentType  : string
Content type of data in $image property
$defaultFailImage  : string
Default image to load from theme if user-configured option fails.
$defaultParams  : string
The default params used to generate the QRCode
$image  : string
Property for storing raw image data; may be null if image is unavailable
$themeTools  : ThemeInfo
Theme tools
__construct()  : mixed
Constructor
getContentType()  : string
Get the content type of the current image (not meant to be called until after contentType is populated)
getDefaults()  : array<string|int, mixed>
Get default parameters.
getImage()  : string
Get the image data (not meant to be called until after image is populated)
loadQRCode()  : void
Set up a QR code image
loadUnavailable()  : void
Load the user-specified "cover unavailable" graphic (or default if none specified).
setThemeInfo()  : void
Setter for dependency
debug()  : void
Log a debug message.
fetchQRCode()  : bool
Generate a QR code image
getContentTypeFromExtension()  : string
Get the content-type for a file based on extension. Throw an exception if an illegal extension is provided.
loadDefaultFailImage()  : void
Display the default "cover unavailable" graphic.
log()  : void
Send a message to the logger.
logError()  : void
Log an error message.
logWarning()  : void
Log a warning message.
mapErrorLevel()  : ErrorCorrectionLevel
Map an incoming error correction level parameter to a valid constant.
searchTheme()  : string|bool
Find a file in the themes (return false if no file exists).

Properties

$allowedFileExtensions

Array containing map of allowed file extensions to mimetypes (to be extended)

protected array<string|int, mixed> $allowedFileExtensions = ['gif' => 'image/gif', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'png' => 'image/png', 'tiff' => 'image/tiff', 'tif' => 'image/tiff']

$configuredFailImage

User-configured image to load from theme on error.

protected string $configuredFailImage = null

$contentType

Content type of data in $image property

protected string $contentType = null

$defaultFailImage

Default image to load from theme if user-configured option fails.

protected string $defaultFailImage = 'images/noCover2.gif'

$defaultParams

The default params used to generate the QRCode

protected string $defaultParams = ['level' => 'L', 'size' => '3', 'margin' => '4']

$image

Property for storing raw image data; may be null if image is unavailable

protected string $image = null

Methods

__construct()

Constructor

public __construct(Config $config, ThemeInfo $theme) : mixed
Parameters
$config : Config

VuFind configuration

$theme : ThemeInfo

VuFind theme tools

Return values
mixed

getContentType()

Get the content type of the current image (not meant to be called until after contentType is populated)

public getContentType() : string
Return values
string

getDefaults()

Get default parameters.

public getDefaults() : array<string|int, mixed>
Return values
array<string|int, mixed>

getImage()

Get the image data (not meant to be called until after image is populated)

public getImage() : string
Return values
string

loadQRCode()

Set up a QR code image

public loadQRCode(string $text[, array<string|int, mixed> $rawParams = [] ]) : void
Parameters
$text : string

The QR code text

$rawParams : array<string|int, mixed> = []

QR code parameters (level/size/margin)

Return values
void

loadUnavailable()

Load the user-specified "cover unavailable" graphic (or default if none specified).

public loadUnavailable() : void
Tags
author

Thomas Schwaerzler vufind-tech@lists.sourceforge.net

Return values
void

setThemeInfo()

Setter for dependency

public setThemeInfo(ThemeInfo $theme) : void
Parameters
$theme : ThemeInfo

VuFind theme tools

Return values
void

debug()

Log a debug message.

protected debug(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

fetchQRCode()

Generate a QR code image

protected fetchQRCode(string $text, int $size, int $margin, ErrorCorrectionLevelInterface $level) : bool
Parameters
$text : string

The QR code text

$size : int

QR code width/height (in pixels)

$margin : int

QR code margin (in pixels)

$level : ErrorCorrectionLevelInterface

Error correction level object

Return values
bool

True if image displayed, false on failure.

getContentTypeFromExtension()

Get the content-type for a file based on extension. Throw an exception if an illegal extension is provided.

protected getContentTypeFromExtension(string $filename) : string
Parameters
$filename : string

Filename to analyze.

Tags
throws
Exception
Return values
string

loadDefaultFailImage()

Display the default "cover unavailable" graphic.

protected loadDefaultFailImage() : void
Return values
void

log()

Send a message to the logger.

protected log(string $level, string $message[, array<string|int, mixed> $context = [] ][, bool $prependClass = false ]) : void
Parameters
$level : string

Log level

$message : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = false

Prepend class name to message?

Return values
void

logError()

Log an error message.

protected logError(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

logWarning()

Log a warning message.

protected logWarning(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

mapErrorLevel()

Map an incoming error correction level parameter to a valid constant.

protected mapErrorLevel(string $level) : ErrorCorrectionLevel
Parameters
$level : string

Error correction level parameter

Return values
ErrorCorrectionLevel

searchTheme()

Find a file in the themes (return false if no file exists).

protected searchTheme(string $path[, array<string|int, mixed> $formats = [''] ]) : string|bool
Parameters
$path : string

Relative path of file to find.

$formats : array<string|int, mixed> = ['']

Optional array of suffixes to add to $path while searching theme (used to check multiple extensions in each theme).

Return values
string|bool

Search results