BlockManager
extends BlockLibrary
in package
Block
block module 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
- $_index : int
- row class index
- $_objTpl : object
- Template object
- $_pageTitle : string
- Page title
- $_strErrMessage : string
- error message
- $_strOkMessage : string
- Okay message
- $blockNamePrefix : string
- Block name prefix
- $availableTargeting : mixed
- $act : mixed
Methods
- __construct() : mixed
- PHP5 constructor
- _activateBlock() : mixed
- activate block
- _addBlock() : bool|int
- Add a new block to database
- _deactivateBlock() : mixed
- deactivate block
- _delBlock() : mixed
- del block
- _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
- _globalBlock() : mixed
- add to global
- _globalBlockOff() : mixed
- del the global
- _parseCategories() : mixed
- recursively parse the categories
- _parseHours() : void
- parses the hours dropdown
- _parseMinutes() : void
- parses the minutes dropdown
- _parseTimestamp() : int
- parse the date and time from the form submit and convert into a timestamp
- _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
- _showOverview() : mixed
- Show overview
- _showSettings() : mixed
- Show settings
- _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
- deleteCategory() : mixed
- editCategory() : mixed
- prepare and show the edit category page
- getBlocks() : array<string|int, mixed>
- Get blocks
- getGeoIpComponent() : ComponentController
- Get GeoIp component controller
- getPage() : mixed
- Get page
- getSelectedPages() : string
- Get selected pages for a block to display in overview page
- getSettings() : array<string|int, mixed>
- Get the settings from database
- loadTargetingSettings() : array<string|int, mixed>
- Load Targeting settings
- removeTargetingSetting() : mixed
- Remove the targeting settings from database
- replacePlaceholdersInContent() : mixed
- Replace the block placeholders by their associated content within a supplied string
- saveCategory() : mixed
- saves a category
- storeTargetingSetting() : mixed
- Store the targeting setting in to database
- storeTargetingSettings() : mixed
- Store the targeting settings in to database
- getVersion() : mixed
- Gets and returns current versions from block related entities
- parseBlockRandom() : mixed
- Generate ESI content for random block widget
- replaceBlocks() : mixed
- Replaces a placeholder with block content
- setNavigation() : void
- showCategories() : void
- show the categories
- storeBlockContent() : mixed
- storePlaceholderSettings() : bool
- Store the placeholder settings for a block
- storeVersions() : mixed
- Stores versions for all referencing entities serialised in block
- _showModifyBlock() : mixed
- Show modify block
- getPageSelections() : array<string|int, mixed>
- Get content of select for page selections
- parseLanguageOptionsByPlaceholder() : mixed
- Parse the language options for the placeholder settings
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
$_index
row class index
public
int
$_index
= 0
$_objTpl
Template object
public
object
$_objTpl
Tags
$_pageTitle
Page title
public
string
$_pageTitle
Tags
$_strErrMessage
error message
public
string
$_strErrMessage
= ''
Tags
$_strOkMessage
Okay message
public
string
$_strOkMessage
= ''
Tags
$blockNamePrefix
Block name prefix
public
string
$blockNamePrefix
= 'BLOCK_'
Tags
$availableTargeting
protected
mixed
$availableTargeting
= array('country')
$act
private
mixed
$act
= ''
Methods
__construct()
PHP5 constructor
public
__construct() : mixed
Tags
_activateBlock()
activate block
public
_activateBlock() : mixed
change the status from a block
Tags
_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
_deactivateBlock()
deactivate block
public
_deactivateBlock() : mixed
change the status from a block
Tags
_delBlock()
del block
public
_delBlock() : mixed
delete a block
Tags
_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
_globalBlock()
add to global
public
_globalBlock() : mixed
change the status from a block
Tags
_globalBlockOff()
del the global
public
_globalBlockOff() : mixed
change the status from a block
Tags
_parseCategories()
recursively parse the categories
public
_parseCategories(array<string|int, mixed> $arrCategories[, int $level = 0 ]) : mixed
Parameters
- $arrCategories : array<string|int, mixed>
- $level : int = 0
_parseHours()
parses the hours dropdown
public
_parseHours(int $date) : void
Parameters
- $date : int
-
selects the options according to timestamp $date
_parseMinutes()
parses the minutes dropdown
public
_parseMinutes(int $date) : void
Parameters
- $date : int
-
selects the options according to timestamp $date
_parseTimestamp()
parse the date and time from the form submit and convert into a timestamp
public
_parseTimestamp(mixed $name) : int
Parameters
- $name : mixed
Return values
int —timestamps
_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
_showOverview()
Show overview
public
_showOverview() : mixed
Show the blocks overview page
Tags
_showSettings()
Show settings
public
_showSettings() : mixed
Show the settings page
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
deleteCategory()
public
deleteCategory() : mixed
editCategory()
prepare and show the edit category page
public
editCategory() : mixed
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
ComponentControllergetPage()
Get page
public
getPage() : mixed
Get a page of the block system administration
Tags
getSelectedPages()
Get selected pages for a block to display in overview page
public
getSelectedPages(int $blockId, string $placeholder, PageRepository $pageRepo) : string
Parameters
- $blockId : int
-
Block id
- $placeholder : string
-
Placeholder (global, direct)
- $pageRepo : PageRepository
-
PageRepository instance
Tags
Return values
string —Return the selected pages as
getSettings()
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
removeTargetingSetting()
Remove the targeting settings from database
public
removeTargetingSetting(int $blockId, string $type) : mixed
Parameters
- $blockId : int
-
Content block id
- $type : string
-
Targeting type (country)
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
saveCategory()
saves a category
public
saveCategory() : mixed
storeTargetingSetting()
Store the targeting setting in to database
public
storeTargetingSetting(int $blockId, string $filter, string $type[, array<string|int, mixed> $arrayValues = array() ]) : mixed
Parameters
- $blockId : int
-
Content block id
- $filter : string
-
Targeting filter type (include/exclude)
- $type : string
-
Targeting type (country)
- $arrayValues : array<string|int, mixed> = array()
-
Target selected option values
storeTargetingSettings()
Store the targeting settings in to database
public
storeTargetingSettings(int $blockId, int $targetingStatus[, array<string|int, mixed> $targeting = array() ]) : mixed
Parameters
- $blockId : int
-
Content block id
- $targetingStatus : int
-
status
- $targeting : array<string|int, mixed> = array()
-
Array settings of targeting to store
getVersion()
Gets and returns current versions from block related entities
protected
getVersion(mixed $entities) : mixed
Parameters
- $entities : mixed
-
array block related entities
Tags
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
setNavigation()
protected
setNavigation() : void
showCategories()
show the categories
protected
showCategories([bool $addView = false ]) : void
Parameters
- $addView : bool = false
Tags
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
storeVersions()
Stores versions for all referencing entities serialised in block
protected
storeVersions(mixed $block) : mixed
Parameters
- $block : mixed
-
\Cx\Modules\Block\Model\Entity\Block block to store referencing version of entities
_showModifyBlock()
Show modify block
private
_showModifyBlock([mixed $copy = false ]) : mixed
Show the block modification page
Parameters
- $copy : mixed = false
Tags
getPageSelections()
Get content of select for page selections
private
getPageSelections(array<string|int, mixed> $pageTitlesTree, array<string|int, mixed> $blockAssociatedPageIds) : array<string|int, mixed>
Parameters
- $pageTitlesTree : array<string|int, mixed>
-
all nodes
- $blockAssociatedPageIds : array<string|int, mixed>
-
the associated page ids
Return values
array<string|int, mixed> —the content for the html select
parseLanguageOptionsByPlaceholder()
Parse the language options for the placeholder settings
private
parseLanguageOptionsByPlaceholder(array<string|int, mixed> $arrActiveSystemFrontendLanguages, string $placeholder) : mixed
Parameters
- $arrActiveSystemFrontendLanguages : array<string|int, mixed>
- $placeholder : string
-
the placeholder