Documentation

ImageType
in package

Image

Includes access methods and data layer. Do not, I repeat, do not access private fields, or even try to access the database directly!

Tags
version
3.0.0
subpackage

core_imagetype

copyright

CLOUDREXX CMS - CLOUDREXX AG

author

Reto Kohli reto.kohli@comvation.com

Table of Contents

Constants

DEFAULT_HEIGHT  = 240
Default height used when the type is unknown
DEFAULT_HEIGHT_THUMB  = 120
Default height used when the type is unknown
DEFAULT_QUALITY  = 95
Default quality used when the type is unknown
DEFAULT_QUALITY_THUMB  = 95
Default quality used when the type is unknown
DEFAULT_WIDTH  = 320
Default height used when the type is unknown
DEFAULT_WIDTH_THUMB  = 160
Default height used when the type is unknown
TEXT_IMAGETYPE  = "core_imagetype"
Text key for the image type

Properties

$arrImagetypes  : array<string|int, mixed>
The array of Imagetypes as initialized by {@see getArray()}, or false
$last_key  : string
The key last used when {@see getArray()} was called, or false

Methods

deleteByKey()  : bool
Delete matching image types from the database.
edit()  : Sigma
Display the imagetypes for editing
errorHandler()  : bool
Handle any error occurring in this class.
getArray()  : array<string|int, mixed>
Get an array with image type data.
getHeight()  : int
Returns the height for the given Imagetype key
getHeightThumbnail()  : int
Returns the thumbnail height for the given Imagetype key
getInfoArray()  : array<string|int, mixed>
Returns an array with the width, height and quality for both the original and thumbnail image for the given Imagetype key
getMenu()  : string
Returns either a dropdown menu for the imagetypes available or a hidden element and text for a single imagetype
getNameArray()  : array<string|int, mixed>
Get an array with image type names.
getQuality()  : int
Returns the quality for the given Imagetype key
getQualityThumbnail()  : int
Returns the thumbnail quality for the given Imagetype key
getTextIdByKey()  : bool
Returns the Text ID of the Imagetype record with the given key.
getWidth()  : int
Returns the width for the given Imagetype key
getWidthThumbnail()  : int
Returns the thumbnail width for the given Imagetype key
insert()  : bool
Insert this image type into the database.
recordExists()  : bool
Test whether a record with the given module ID and key is already present in the database.
reset()  : mixed
store()  : bool
Adds or updates the given image type.
storeFromPost()  : bool
Update and store all imagetypes found in the $_POST array
update()  : bool
Update this image type in the database.

Constants

DEFAULT_HEIGHT

Default height used when the type is unknown

public mixed DEFAULT_HEIGHT = 240

DEFAULT_HEIGHT_THUMB

Default height used when the type is unknown

public mixed DEFAULT_HEIGHT_THUMB = 120

DEFAULT_QUALITY

Default quality used when the type is unknown

public mixed DEFAULT_QUALITY = 95

DEFAULT_QUALITY_THUMB

Default quality used when the type is unknown

public mixed DEFAULT_QUALITY_THUMB = 95

DEFAULT_WIDTH

Default height used when the type is unknown

public mixed DEFAULT_WIDTH = 320

DEFAULT_WIDTH_THUMB

Default height used when the type is unknown

public mixed DEFAULT_WIDTH_THUMB = 160

TEXT_IMAGETYPE

Text key for the image type

public mixed TEXT_IMAGETYPE = "core_imagetype"

Properties

$arrImagetypes

The array of Imagetypes as initialized by {@see getArray()}, or false

private static array<string|int, mixed> $arrImagetypes = false

$last_key

The key last used when {@see getArray()} was called, or false

private static string $last_key = false

Methods

deleteByKey()

Delete matching image types from the database.

public static deleteByKey(string $key) : bool

Also deletes associated Text records.

Parameters
$key : string

The type key

Tags
global

mixed $objDatabase Database object

author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True on success, false otherwise

edit()

Display the imagetypes for editing

public static edit() : Sigma

Placeholders: The imagetypes' name is written to IMAGETYPE_NAME, and the key to IMAGETYPE_KEY. Other fields are IMAGETYPE_WIDTH, IMAGETYPE_HEIGHT, and IMAGETYPE_QUALITY for width, height, and quality, respectively. Some entries from $_CORELANG are set up. Their indices are used as placeholder name as well. If you want your imagetypes to be stored, you MUST handle the parameter 'act=imagetypes_edit' in your modules' getPage(), and call this method again.

Return values
Sigma

The Template object

errorHandler()

Handle any error occurring in this class.

public errorHandler() : bool

Tries to fix known problems with the database table.

Tags
global

mixed $objDatabase Database object

author

Reto Kohli reto.kohli@comvation.com

Return values
bool

False. Always.

getArray()

Get an array with image type data.

public static getArray([string $key = false ]) : array<string|int, mixed>

The $key argument may be empty (defaults to false), a single string, or an array of strings. Only matching keys are returned in the array. The array returned looks like array( key => array( 'width' => width, 'height' => height, 'quality' => quality, 'width_thumb' => thumbnail width, 'height_thumb' => thumbnail height, 'quality_thumb' => thumbnail quality, 'text_id' => Image type Text ID, 'name' => Image type name, ), ... more ... ) The array elements are ordered by key, ascending. Uses the MODULE_ID constant.

Parameters
$key : string = false

The optional type key or key array

Tags
static
global

mixed $objDatabase Database object

author

Reto Kohli reto.kohli@comvation.com

Return values
array<string|int, mixed>

The type data array on success, false otherwise

getHeight()

Returns the height for the given Imagetype key

public static getHeight(string $key) : int

If the Imagetype info cannot be retrieved, returns the default value.

Parameters
$key : string

The Imagetype key

Return values
int

The Imagetype height

getHeightThumbnail()

Returns the thumbnail height for the given Imagetype key

public static getHeightThumbnail(string $key) : int

If the Imagetype info cannot be found, returns the default value. This is the case if the $key is empty or an array, if the Imagetype is unknown, or if the array of Imagetypes cannot be retrieved.

Parameters
$key : string

The Imagetype key

Return values
int

The Imagetype thumbnail height

getInfoArray()

Returns an array with the width, height and quality for both the original and thumbnail image for the given Imagetype key

public static getInfoArray([string $key = false ]) : array<string|int, mixed>

If the key is not found, the default sizes are returned in the array. The returned array looks like array( 'width' => image width, 'height' => image height, 'quality => image quality, 'width_thumb' => thumbnail width, 'height_thumb' => thumbnail height, 'quality_thumb' => thumbnail quality, )

Parameters
$key : string = false

The Imagetype key

Return values
array<string|int, mixed>

The Imagetype info array

getMenu()

Returns either a dropdown menu for the imagetypes available or a hidden element and text for a single imagetype

public static getMenu(string $name[, string $selected = '' ][, mixed $imagetype_key = '' ][, string $attribute = null ]) : string

The $name parameter SHOULD be the same as the name attribute used for a corresponding element created by Html::getImageChooserUpload(). The string '_type' will be appended to the element name. If the optional $imagetype_key is empty or not an array, no image type can be selected. If it's false, the image type field is omitted altogether. If it's empty but not false, the selected Image type is used. If it's a string, the type is set to that value, overriding the selected type. If it's an array, the Image type can be selected from its values, and the selected key is preselected. The array keys SHOULD contain the Imagetype key, its values the Imagetype names in the current language. See Image::updatePostImages() and Image::uploadAndStore() for more information and examples.

Parameters
$name : string

The base name for the element

$selected : string = ''

The optional preselected key

$imagetype_key : mixed = ''

The optional Image type key or Imagetype array. Defaults to the empty string

$attribute : string = null

The optional attributes

Return values
string

The image type dropdown menu HTML code, The image type name and hidden element, or the empty string

getNameArray()

Get an array with image type names.

public static getNameArray([string $key = false ]) : array<string|int, mixed>

See getArray() for details. The array returned looks like array( key => Imagetype name, ... more ... ) The array elements are ordered by key, ascending. Uses the MODULE_ID constant.

Parameters
$key : string = false

The optional type key or key array

Tags
static
global

mixed $objDatabase Database object

author

Reto Kohli reto.kohli@comvation.com

Return values
array<string|int, mixed>

The type name array on success, false otherwise

getQuality()

Returns the quality for the given Imagetype key

public static getQuality(string $key) : int

If the Imagetype info cannot be retrieved, returns the default value.

Parameters
$key : string

The Imagetype key

Return values
int

The Imagetype quality

getQualityThumbnail()

Returns the thumbnail quality for the given Imagetype key

public static getQualityThumbnail(string $key) : int

If the Imagetype info cannot be found, returns the default value. This is the case if the $key is empty or an array, if the Imagetype is unknown, or if the array of Imagetypes cannot be retrieved.

Parameters
$key : string

The Imagetype key

Return values
int

The Imagetype thumbnail quality

getTextIdByKey()

Returns the Text ID of the Imagetype record with the given key.

public getTextIdByKey(string $key) : bool

This works almost the same as recordExists() does, except that you may have to check the result for null, as the Text entry may be missing for any existing key.

Parameters
$key : string

The type key

Tags
global

mixed $objDatabase Database object

author

Reto Kohli reto.kohli@comvation.com

Return values
bool

The Text ID or null if the key exists, false otherwise

getWidth()

Returns the width for the given Imagetype key

public static getWidth(string $key) : int

If the Imagetype info cannot be retrieved, returns the default value.

Parameters
$key : string

The Imagetype key

Return values
int

The Imagetype width

getWidthThumbnail()

Returns the thumbnail width for the given Imagetype key

public static getWidthThumbnail(string $key) : int

If the Imagetype info cannot be found, returns the default value. This is the case if the $key is empty or an array, if the Imagetype is unknown, or if the array of Imagetypes cannot be retrieved.

Parameters
$key : string

The Imagetype key

Return values
int

The Imagetype thumbnail width

insert()

Insert this image type into the database.

public insert(string $key, int $text_id[, int $width = 'NULL' ][, int $height = 'NULL' ][, int $quality = 'NULL' ][, mixed $width_thumb = 'NULL' ][, mixed $height_thumb = 'NULL' ][, mixed $quality_thumb = 'NULL' ]) : bool

Uses the current language ID found in the FRONTEND_LANG_ID constant.

Parameters
$key : string

The type key

$text_id : int

The type description Text ID

$width : int = 'NULL'

The width

$height : int = 'NULL'

The height

$quality : int = 'NULL'

The quality

$width_thumb : mixed = 'NULL'
$height_thumb : mixed = 'NULL'
$quality_thumb : mixed = 'NULL'
Tags
global

mixed $objDatabase Database object

author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True on success, false otherwise

recordExists()

Test whether a record with the given module ID and key is already present in the database.

public recordExists(string $key) : bool
Parameters
$key : string

The type key

Tags
global

mixed $objDatabase Database object

author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True if the record exists, false otherwise

store()

Adds or updates the given image type.

public store(string $key, string $imagetype[, int $width = 'NULL' ][, int $height = 'NULL' ][, int $quality = 'NULL' ][, int $width_thumb = 'NULL' ][, int $height_thumb = 'NULL' ][, int $quality_thumb = 'NULL' ]) : bool

If a record with the given module ID and key already exists, it is updated, otherwise it is inserted. Also adds or updates the Text entry. Only the language selected in FRONTEND_LANG_ID is affected.

Parameters
$key : string

The type key

$imagetype : string

The type description

$width : int = 'NULL'

The width

$height : int = 'NULL'

The height

$quality : int = 'NULL'

The quality

$width_thumb : int = 'NULL'

The thumbnail width

$height_thumb : int = 'NULL'

The thumbnail height

$quality_thumb : int = 'NULL'

The thumbnail quality

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True on success, false otherwise

storeFromPost()

Update and store all imagetypes found in the $_POST array

public static storeFromPost() : bool
Return values
bool

True on success, the empty string if none was changed, or false on failure

update()

Update this image type in the database.

public update(string $key, int $text_id[, int $width = 'NULL' ][, int $height = 'NULL' ][, int $quality = 'NULL' ][, int $width_thumb = 'NULL' ][, int $height_thumb = 'NULL' ][, int $quality_thumb = 'NULL' ]) : bool

Note that associations to module ID and key can NOT be modified. If you need to change an image type this way, you have to delete() and re-insert() it.

Parameters
$key : string

The type key

$text_id : int

The type description Text ID

$width : int = 'NULL'

The width

$height : int = 'NULL'

The height

$quality : int = 'NULL'

The quality

$width_thumb : int = 'NULL'

The thumbnail width

$height_thumb : int = 'NULL'

The thumbnail height

$quality_thumb : int = 'NULL'

The thumbnail quality

Tags
global

mixed $objDatabase Database object

author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True on success, false otherwise


        
On this page

Search results