PHP Class Backend\Modules\Pages\Engine\Model

Author: Tijs Verkoyen ([email protected])
Author: Davy Hellemans ([email protected])
Author: Matthias Mullie ([email protected])
Author: Jeroen Desloovere ([email protected])
Show file Open project: forkcms/forkcms Class Usage Examples

Public Methods

Method Description
buildCache ( string $language = null ) Build the cache
copy ( string $from, string $to ) Copy pages
createHtml ( string $type = 'page', integer $depth, integer $parentId = 1, string $html = '' ) : string Creates the html for the menu
delete ( integer $id, string $language = null, integer $revisionId = null ) : boolean Delete a page
exists ( integer $id ) : boolean Check if a page exists
get ( integer $id, integer $revisionId = null, string $language = null ) : mixed Get the data for a record
getBlocks ( integer $id, integer $revisionId = null, string $language = null ) : array Get blocks for a certain page/revision
getByTag ( integer $tagId ) : array Get all items by a given tag id
getCacheBuilder ( ) : CacheBuilder
getEncodedRedirectURL ( string $redirectURL ) : string Get encoded redirect URL
getFirstChildId ( integer $pageId ) : mixed Get the first child for a given parent
getFullURL ( integer $id ) : string Get the full-URL for a given menuId
getLatestRevision ( integer $id, string $language = null ) : integer Get latest revision id for a page.
getMaximumBlockId ( ) : integer Get the maximum unique id for blocks
getMaximumPageId ( string $language = null ) : integer Get the maximum unique id for pages
getMaximumSequence ( integer $parentId, string $language = null ) : integer Get the maximum sequence inside a leaf
getPagesForDropdown ( string $language = null ) : array Get the pages for usage in a dropdown menu
getSubtree ( array $navigation, integer $parentId ) : string Get the subtree for a root element
getTree ( array $ids, array $data = null, integer $level = 1, string $language = null ) : array Get all pages/level
getTreeHTML ( ) : string Get the tree
getTypes ( ) : array Get the possible block types
getURL ( string $url, integer $id = null, integer $parentId, boolean $isAction = false ) : string Get an unique URL for a page
insert ( array $page ) : integer Insert a page
insertBlocks ( array $blocks ) Insert multiple blocks at once
move ( integer $id, integer $droppedOn, string $typeOfDrop, string $tree, string $language = null ) : boolean Move a page
update ( array $page ) : integer Update a page
updatePagesTemplates ( integer $oldTemplateId, integer $newTemplateId, boolean $overwrite = false ) Switch templates for all existing pages

Method Details

buildCache() public static method

Build the cache
public static buildCache ( string $language = null )
$language string The language to build the cache for, if not passed we use the working language.

copy() public static method

Copy pages
public static copy ( string $from, string $to )
$from string The language code to copy the pages from.
$to string The language code we want to copy the pages to.

createHtml() public static method

Creates the html for the menu
public static createHtml ( string $type = 'page', integer $depth, integer $parentId = 1, string $html = '' ) : string
$type string The type of navigation.
$depth integer The maximum depth to show.
$parentId integer The Id to start from.
$html string Will hold the created HTML.
return string

delete() public static method

Delete a page
public static delete ( integer $id, string $language = null, integer $revisionId = null ) : boolean
$id integer The id of the page to delete.
$language string The language wherein the page will be deleted, if not provided we will use the working language.
$revisionId integer If specified the given revision will be deleted, used for deleting drafts.
return boolean

exists() public static method

Check if a page exists
public static exists ( integer $id ) : boolean
$id integer The id to check for existence.
return boolean

get() public static method

Get the data for a record
public static get ( integer $id, integer $revisionId = null, string $language = null ) : mixed
$id integer The Id of the page to fetch.
$revisionId integer
$language string The language to use while fetching the page.
return mixed False if the record can't be found, otherwise an array with all data.

getBlocks() public static method

Get blocks for a certain page/revision
public static getBlocks ( integer $id, integer $revisionId = null, string $language = null ) : array
$id integer The id of the page.
$revisionId integer The revision to grab.
$language string The language to use.
return array

getByTag() public static method

Get all items by a given tag id
public static getByTag ( integer $tagId ) : array
$tagId integer The id of the tag.
return array

getCacheBuilder() public static method

public static getCacheBuilder ( ) : CacheBuilder
return CacheBuilder

getEncodedRedirectURL() public static method

Get encoded redirect URL
public static getEncodedRedirectURL ( string $redirectURL ) : string
$redirectURL string
return string

getFirstChildId() public static method

Get the first child for a given parent
public static getFirstChildId ( integer $pageId ) : mixed
$pageId integer The Id of the page to get the first child for.
return mixed

getFullURL() public static method

Get the full-URL for a given menuId
public static getFullURL ( integer $id ) : string
$id integer The Id of the page to get the URL for.
return string

getLatestRevision() public static method

Get latest revision id for a page.
public static getLatestRevision ( integer $id, string $language = null ) : integer
$id integer The id of the page.
$language string The language to use.
return integer

getMaximumBlockId() public static method

Get the maximum unique id for blocks
public static getMaximumBlockId ( ) : integer
return integer

getMaximumPageId() public static method

Get the maximum unique id for pages
public static getMaximumPageId ( string $language = null ) : integer
$language string The language to use, if not provided we will use the working language.
return integer

getMaximumSequence() public static method

Get the maximum sequence inside a leaf
public static getMaximumSequence ( integer $parentId, string $language = null ) : integer
$parentId integer The Id of the parent.
$language string The language to use, if not provided we will use the working language.
return integer

getPagesForDropdown() public static method

Get the pages for usage in a dropdown menu
public static getPagesForDropdown ( string $language = null ) : array
$language string The language to use, if not provided we will use the working language.
return array

getSubtree() public static method

Get the subtree for a root element
public static getSubtree ( array $navigation, integer $parentId ) : string
$navigation array The navigation array.
$parentId integer The id of the parent.
return string

getTree() public static method

Get all pages/level
public static getTree ( array $ids, array $data = null, integer $level = 1, string $language = null ) : array
$ids array The parentIds.
$data array A holder for the generated data.
$level integer The counter for the level.
$language string The language.
return array

getTreeHTML() public static method

Get the tree
public static getTreeHTML ( ) : string
return string

getTypes() public static method

Get the possible block types
public static getTypes ( ) : array
return array

getURL() public static method

Get an unique URL for a page
public static getURL ( string $url, integer $id = null, integer $parentId, boolean $isAction = false ) : string
$url string The URL to base on.
$id integer The id to ignore.
$parentId integer The parent for the page to create an url for.
$isAction boolean Is this page an action.
return string

insert() public static method

Insert a page
public static insert ( array $page ) : integer
$page array The data for the page.
return integer

insertBlocks() public static method

Insert multiple blocks at once
public static insertBlocks ( array $blocks )
$blocks array The blocks to insert.

move() public static method

Move a page
public static move ( integer $id, integer $droppedOn, string $typeOfDrop, string $tree, string $language = null ) : boolean
$id integer The id for the page that has to be moved.
$droppedOn integer The id for the page where to page has been dropped on.
$typeOfDrop string The type of drop, possible values are: before, after, inside.
$tree string The tree the item is dropped on, possible values are: main, meta, footer, root.
$language string The language to use, if not provided we will use the working language.
return boolean

update() public static method

Update a page
public static update ( array $page ) : integer
$page array The new data for the page.
return integer

updatePagesTemplates() public static method

Switch templates for all existing pages
public static updatePagesTemplates ( integer $oldTemplateId, integer $newTemplateId, boolean $overwrite = false )
$oldTemplateId integer The id of the new template to replace.
$newTemplateId integer The id of the new template to use.
$overwrite boolean Overwrite all pages with default blocks.