BlockLibrary
in package
Block
Block library class
Tags
Table of Contents
Properties
- $_arrBlocks : array<string|int, mixed>
- Block ids
- $_categories : array<string|int, mixed>
- Array of categories
- $_categoryNames : array<string|int, mixed>
- array containing the category names
- $_categoryOptions : array<string|int, mixed>
- holds the category dropdown select options
- $blockNamePrefix : string
- Block name prefix
- $availableTargeting : mixed
Methods
- __construct() : mixed
- Constructor
- _addBlock() : bool|int
- Add a new block to database
- _deleteCategory() : bool
- delete a category by id
- _getAssociatedPageIds() : array<string|int, mixed>
- Get the associated pages for a placeholder
- _getBlock() : mixed
- Get block
- _getBlocksForPage() : mixed
- _getCategories() : array<string|int, mixed>
- fill and/or return the categories array
- _getCategoriesDropdown() : string
- create the categories dropdown
- _getCategory() : array<string|int, mixed>
- return the category specified by ID
- _getChildCategories() : array<string|int, mixed>
- return all child caegories of a cateogory
- _saveCategory() : int|bool
- Save a block category
- _saveSettings() : mixed
- Save the settings associated to the block system
- _setBlock() : mixed
- Set block
- _setBlockGlobal() : mixed
- Set block Global
- _setBlockRandom() : mixed
- Set block Random
- _setBlocksForPage() : mixed
- _setCategoryBlock() : mixed
- Set category block
- _updateBlock() : bool|int
- Update an existing block
- checkTargetingCountry() : bool
- Check Country targeting option
- checkTargetingOptions() : bool
- Verify targeting options for the given block Id
- cmpByOrder() : int
- Compares two arrays by order attribute
- getBlocks() : array<string|int, mixed>
- Get blocks
- getGeoIpComponent() : ComponentController
- Get GeoIp component controller
- getSettings() : array<string|int, mixed>
- Get the settings from database
- loadTargetingSettings() : array<string|int, mixed>
- Load Targeting settings
- replacePlaceholdersInContent() : mixed
- Replace the block placeholders by their associated content within a supplied string
- parseBlockRandom() : mixed
- Generate ESI content for random block widget
- replaceBlocks() : mixed
- Replaces a placeholder with block content
- storeBlockContent() : mixed
- storePlaceholderSettings() : bool
- Store the placeholder settings for a block
- storePageAssociations() : mixed
- Store the page associations
Properties
$_arrBlocks
Block ids
public
array<string|int, mixed>
$_arrBlocks
Tags
$_categories
Array of categories
public
array<string|int, mixed>
$_categories
= array()
$_categoryNames
array containing the category names
public
array<string|int, mixed>
$_categoryNames
= array()
catId => name
$_categoryOptions
holds the category dropdown select options
public
array<string|int, mixed>
$_categoryOptions
= array()
of strings: HTML
$blockNamePrefix
Block name prefix
public
string
$blockNamePrefix
= 'BLOCK_'
Tags
$availableTargeting
protected
mixed
$availableTargeting
= array('country')
Methods
__construct()
Constructor
public
__construct() : mixed
_addBlock()
Add a new block to database
public
_addBlock(int $cat, array<string|int, mixed> $arrContent, string $name, int $start, int $end, int $blockRandom, int $blockRandom2, int $blockRandom3, int $blockRandom4, int $blockWysiwygEditor, array<string|int, mixed> $arrLangActive) : bool|int
Parameters
- $cat : int
- $arrContent : array<string|int, mixed>
- $name : string
- $start : int
- $end : int
- $blockRandom : int
- $blockRandom2 : int
- $blockRandom3 : int
- $blockRandom4 : int
- $blockWysiwygEditor : int
- $arrLangActive : array<string|int, mixed>
Return values
bool|int —the block's id
_deleteCategory()
delete a category by id
public
_deleteCategory([int $id = 0 ]) : bool
Parameters
- $id : int = 0
-
category id
Return values
bool —success
_getAssociatedPageIds()
Get the associated pages for a placeholder
public
_getAssociatedPageIds(int $blockId, string $placeholder) : array<string|int, mixed>
Parameters
- $blockId : int
-
block id
- $placeholder : string
Return values
array<string|int, mixed>_getBlock()
Get block
public
_getBlock(int $id) : mixed
Return a block
Parameters
- $id : int
Tags
Return values
mixed —content on success, false on failure
_getBlocksForPage()
public
_getBlocksForPage(mixed $page) : mixed
Parameters
- $page : mixed
_getCategories()
fill and/or return the categories array
public
_getCategories([mixed $refresh = false ]) : array<string|int, mixed>
category arrays are put in the array as first dimension elements, with their parent as key, as follows: $this->_categories[$objRS->fields['parent']][] = $objRS->fields;
just to make this clear: note that $somearray['somekey'][] = $foo adds $foo to $somearray['somekey'] rather than overwriting it.
Parameters
- $refresh : mixed = false
Tags
Return values
array<string|int, mixed> —all available categories
_getCategoriesDropdown()
create the categories dropdown
public
_getCategoriesDropdown([mixed $parent = 0 ][, mixed $catId = 0 ][, array<string|int, mixed> $arrCategories = array() ][, array<string|int, mixed> $arrOptions = array() ][, int $level = 0 ]) : string
Parameters
- $parent : mixed = 0
- $catId : mixed = 0
- $arrCategories : array<string|int, mixed> = array()
- $arrOptions : array<string|int, mixed> = array()
- $level : int = 0
Return values
string —categories as HTML options
_getCategory()
return the category specified by ID
public
_getCategory([int $id = 0 ]) : array<string|int, mixed>
Parameters
- $id : int = 0
Return values
array<string|int, mixed> —category information
_getChildCategories()
return all child caegories of a cateogory
public
_getChildCategories(mixed $id[, mixed &$_arrChildCategories = array() ]) : array<string|int, mixed>
Parameters
- $id : mixed
- $_arrChildCategories : mixed = array()
Return values
array<string|int, mixed> —IDs of children
_saveCategory()
Save a block category
public
_saveCategory(string $name, string $seperator[, int $id = 0 ][, int $parent = 0 ][, int $order = 1 ][, int $status = 1 ]) : int|bool
Parameters
- $name : string
- $seperator : string
- $id : int = 0
- $parent : int = 0
- $order : int = 1
- $status : int = 1
Return values
int|bool —Inserted ID, or false on failure
_saveSettings()
Save the settings associated to the block system
public
_saveSettings(array<string|int, mixed> $arrSettings) : mixed
Parameters
- $arrSettings : array<string|int, mixed>
Tags
_setBlock()
Set block
public
_setBlock(int $id, string &$code[, int $pageId = 0 ]) : mixed
Parse the block with the id $id
Parameters
- $id : int
-
Block ID
- $code : string
- $pageId : int = 0
Tags
_setBlockGlobal()
Set block Global
public
_setBlockGlobal(string &$code[, mixed $pageId = 0 ]) : mixed
Parse the block with the id $id
Parameters
- $code : string
- $pageId : mixed = 0
Tags
_setBlockRandom()
Set block Random
public
_setBlockRandom(string &$code, int $id[, mixed $pageId = 0 ]) : mixed
Parse the block with the id $id
Parameters
- $code : string
- $id : int
- $pageId : mixed = 0
Tags
_setBlocksForPage()
public
_setBlocksForPage(mixed $page, mixed $blockIds) : mixed
Parameters
- $page : mixed
- $blockIds : mixed
_setCategoryBlock()
Set category block
public
_setCategoryBlock(int $id, string &$code[, int $pageId = 0 ]) : mixed
Parse the category block with the id $id
Parameters
- $id : int
-
Category ID
- $code : string
- $pageId : int = 0
Tags
_updateBlock()
Update an existing block
public
_updateBlock(int $id, int $cat, array<string|int, mixed> $arrContent, string $name, int $start, int $end, int $blockRandom, int $blockRandom2, int $blockRandom3, int $blockRandom4, int $blockWysiwygEditor, array<string|int, mixed> $arrLangActive) : bool|int
Parameters
- $id : int
- $cat : int
- $arrContent : array<string|int, mixed>
- $name : string
- $start : int
- $end : int
- $blockRandom : int
- $blockRandom2 : int
- $blockRandom3 : int
- $blockRandom4 : int
- $blockWysiwygEditor : int
- $arrLangActive : array<string|int, mixed>
Return values
bool|int —the id of the block
checkTargetingCountry()
Check Country targeting option
public
checkTargetingCountry(string $filter, array<string|int, mixed> $countryIds) : bool
Parameters
- $filter : string
-
include => client country should exists in given country ids exclude => client country should not exists in given country ids
- $countryIds : array<string|int, mixed>
-
Country ids to match
Return values
bool —True when targeting country option matching to client country False otherwise
checkTargetingOptions()
Verify targeting options for the given block Id
public
checkTargetingOptions(int $blockId) : bool
Parameters
- $blockId : int
-
Block id
Return values
bool —True when all targeting options vaild, false otherwise
cmpByOrder()
Compares two arrays by order attribute
public
cmpByOrder(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
- $b : array<string|int, mixed>
Return values
int —relative position
getBlocks()
Get blocks
public
getBlocks([mixed $catId = 0 ]) : array<string|int, mixed>
Get all blocks
Parameters
- $catId : mixed = 0
Tags
Return values
array<string|int, mixed> —Array with block ids
getGeoIpComponent()
Get GeoIp component controller
public
getGeoIpComponent() : ComponentController
Return values
ComponentControllergetSettings()
Get the settings from database
public
getSettings() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —settings array
loadTargetingSettings()
Load Targeting settings
public
loadTargetingSettings(int $blockId) : array<string|int, mixed>
Parameters
- $blockId : int
-
Content block id
Return values
array<string|int, mixed> —Settings array
replacePlaceholdersInContent()
Replace the block placeholders by their associated content within a supplied string
public
static replacePlaceholdersInContent(string &$content) : mixed
Parameters
- $content : string
-
The content to replace all block placeholders by their content in
parseBlockRandom()
Generate ESI content for random block widget
protected
parseBlockRandom(mixed &$code, mixed $id[, mixed $pageId = 0 ]) : mixed
Parameters
- $code : mixed
- $id : mixed
- $pageId : mixed = 0
Tags
replaceBlocks()
Replaces a placeholder with block content
protected
replaceBlocks(string $placeholderName, string $query, int $pageId, string &$code[, string $separator = '' ][, bool $randomize = false ]) : mixed
Parameters
- $placeholderName : string
-
Name of placeholder to replace
- $query : string
-
SQL query used to fetch blocks
- $pageId : int
-
ID of the current page, 0 if no page available
- $code : string
-
(by reference) Code to replace placeholder in
- $separator : string = ''
-
(optional) Separator used to separate the blocks
- $randomize : bool = false
-
(optional) Wheter to randomize the blocks or not, default false
storeBlockContent()
protected
storeBlockContent(mixed $blockId, mixed $arrContent, mixed $arrLangActive) : mixed
Parameters
- $blockId : mixed
- $arrContent : mixed
- $arrLangActive : mixed
storePlaceholderSettings()
Store the placeholder settings for a block
protected
storePlaceholderSettings(int $blockId, int $global, int $direct, int $category, array<string|int, mixed> $globalAssociatedPages, array<string|int, mixed> $directAssociatedPages, array<string|int, mixed> $categoryAssociatedPages) : bool
Parameters
- $blockId : int
- $global : int
- $direct : int
- $category : int
- $globalAssociatedPages : array<string|int, mixed>
- $directAssociatedPages : array<string|int, mixed>
- $categoryAssociatedPages : array<string|int, mixed>
Return values
bool —it was successfully saved
storePageAssociations()
Store the page associations
private
storePageAssociations(int $blockId, array<string|int, mixed> $blockAssociatedPageIds, string $placeholder) : mixed
Parameters
- $blockId : int
-
the block id
- $blockAssociatedPageIds : array<string|int, mixed>
-
the page ids
- $placeholder : string
-
the placeholder