PHP Class RainLab\Pages\Classes\Page

Author: Alexey Bobkov, Samuel Georges
Inheritance: extends Cms\Classes\Content
Mostra file Open project: rainlab/pages-plugin Class Usage Examples

Public Properties

Property Type Description
$attributeNames The array of custom attribute names.
$implement
$parentFileName Contains the page parent file name. This property is used by the page editor internally.
$rules The rules to be applied to the data.
$translatable Attributes that support translation, if available.
$translatableModel Translation model used for translation, if available.

Protected Properties

Property Type Description
$childrenCache
$dirName The container name associated with the model, eg: pages.
$fillable Properties that can be set with fill()
$menuTreeCache
$parentCache
$processedBlockMarkupCache
$processedMarkupCache
$purgeable List of attribute names which are not considered "settings".
$wrapCode Wrap code section in PHP tags.

Public Methods

Method Description
__construct ( array $attributes = [] ) Creates an instance of the object and associates it with a CMS theme.
afterCreate ( ) Triggered after a new object is saved.
beforeCreate ( ) Triggered before a new object is saved.
beforeValidate ( ) Validates the object properties.
buildMenuTree ( Cms\Classes\Theme $theme ) : array Builds and caches a menu item tree.
clearMenuCache ( Cms\Classes\Theme $theme ) Clears the menu item cache
delete ( ) : array Deletes the object from the disk.
fill ( array $attributes ) Sets the object attributes.
getChildren ( ) : array Returns all the child pages that belong to this one.
getLayoutObject ( ) : Cms\Classes\Layout Looks up the Layout Cms object for this page.
getLayoutOptions ( ) : array Returns a list of layouts available in the theme.
getMenuTypeInfo ( string $type ) : array Handler for the pages.menuitem.getTypeInfo event.
getParent ( ) : mixed Returns the parent page that belongs to this one, or null.
getPlaceholdersAttribute ( ) : array Parses the page placeholder {% put %} tags and extracts the placeholder values.
getProcessedMarkup ( )
getProcessedPlaceholderMarkup ( $placeholderName, $placeholderContents )
getRichEditorTypeInfo ( string $type ) : array Handler for the backend.richeditor.getTypeInfo event.
getTwigContent ( ) Returns the Twig content string
initCmsComponents ( $cmsController ) Initializes CMS components associated with the page.
listLayoutPlaceholders ( ) : array Returns information about placeholders defined in the page layout.
listLayoutSyntaxFields ( )
resolveMenuItem ( RainLab\Pages\Classes\MenuItem $item, string $url, Cms\Classes\Theme $theme ) : mixed Handler for the pages.menuitem.resolveItem event.
setPlaceholdersAttribute ( array $value ) : void Takes an array of placeholder data (key: code, value: content) and renders it as a single string of Twig markup against the "code" attribute.
url ( $name ) : string Helper that makes a URL for a static page in the active theme.

Protected Methods

Method Description
appendToMeta ( ) Adds this page to the meta index.
flattenTwigNode ( $node ) : array Recursively flattens a twig node and children
generateFilenameFromCode ( ) * Generate a file name based on the URL
getMenuCacheKey ( $theme ) Returns a cache key for this record.
getValidationAttributes ( ) : array Returns the attributes used for validation.
listStaticPageMenuOptions ( ) : array Returns a list of options for the Reference drop-down menu in the menu item configuration form, when the Static Page item type is selected.
removeFromMeta ( ) Removes this page to the meta index.

Method Details

__construct() public method

Creates an instance of the object and associates it with a CMS theme.
public __construct ( array $attributes = [] )
$attributes array

afterCreate() public method

Triggered after a new object is saved.
public afterCreate ( )

appendToMeta() protected method

Adds this page to the meta index.
protected appendToMeta ( )

beforeCreate() public method

Triggered before a new object is saved.
public beforeCreate ( )

beforeValidate() public method

Throws a ValidationException in case of an error.
public beforeValidate ( )

buildMenuTree() public static method

This method is used internally for menu items and breadcrumbs.
public static buildMenuTree ( Cms\Classes\Theme $theme ) : array
$theme Cms\Classes\Theme Specifies the current theme.
return array Returns an array containing the page information

clearMenuCache() public static method

Clears the menu item cache
public static clearMenuCache ( Cms\Classes\Theme $theme )
$theme Cms\Classes\Theme Specifies the current theme.

delete() public method

Recursively deletes subpages. Returns a list of file names of deleted pages.
public delete ( ) : array
return array

fill() public method

Sets the object attributes.
public fill ( array $attributes )
$attributes array A list of attributes to set.

flattenTwigNode() protected method

Recursively flattens a twig node and children
protected flattenTwigNode ( $node ) : array
$node
return array A flat array of twig nodes

generateFilenameFromCode() protected method

* Generate a file name based on the URL
protected generateFilenameFromCode ( )

getChildren() public method

Returns all the child pages that belong to this one.
public getChildren ( ) : array
return array

getLayoutObject() public method

Looks up the Layout Cms object for this page.
public getLayoutObject ( ) : Cms\Classes\Layout
return Cms\Classes\Layout

getLayoutOptions() public method

This method is used by the form widget.
public getLayoutOptions ( ) : array
return array Returns an array of strings.

getMenuCacheKey() protected static method

Returns a cache key for this record.
protected static getMenuCacheKey ( $theme )

getMenuTypeInfo() public static method

Returns a menu item type information. The type information is returned as array with the following elements: - references - a list of the item type reference options. The options are returned in the ["key"] => "title" format for options that don't have sub-options, and in the format ["key"] => ["title"=>"Option title", "items"=>[...]] for options that have sub-options. Optional, required only if the menu item type requires references. - nesting - Boolean value indicating whether the item type supports nested items. Optional, false if omitted. - dynamicItems - Boolean value indicating whether the item type could generate new menu items. Optional, false if omitted. - cmsPages - a list of CMS pages (objects of the Cms\Classes\Page class), if the item type requires a CMS page reference to resolve the item URL.
public static getMenuTypeInfo ( string $type ) : array
$type string Specifies the menu item type
return array Returns an array

getParent() public method

Returns the parent page that belongs to this one, or null.
public getParent ( ) : mixed
return mixed

getPlaceholdersAttribute() public method

Parses the page placeholder {% put %} tags and extracts the placeholder values.
public getPlaceholdersAttribute ( ) : array
return array Returns an associative array of the placeholder names and values.

getProcessedMarkup() public method

public getProcessedMarkup ( )

getProcessedPlaceholderMarkup() public method

public getProcessedPlaceholderMarkup ( $placeholderName, $placeholderContents )

getRichEditorTypeInfo() public static method

Returns a menu item type information. The type information is returned as array
public static getRichEditorTypeInfo ( string $type ) : array
$type string Specifies the page link type
return array

getTwigContent() public method

Returns the Twig content string
public getTwigContent ( )

getValidationAttributes() protected method

Returns the attributes used for validation.
protected getValidationAttributes ( ) : array
return array

initCmsComponents() public method

Initializes CMS components associated with the page.
public initCmsComponents ( $cmsController )

listLayoutPlaceholders() public method

Returns information about placeholders defined in the page layout.
public listLayoutPlaceholders ( ) : array
return array Returns an associative array of the placeholder name and codes.

listLayoutSyntaxFields() public method

listStaticPageMenuOptions() protected static method

Returns a list of options for the Reference drop-down menu in the menu item configuration form, when the Static Page item type is selected.
protected static listStaticPageMenuOptions ( ) : array
return array Returns an array

removeFromMeta() protected method

Removes this page to the meta index.
protected removeFromMeta ( )

resolveMenuItem() public static method

Returns information about a menu item. The result is an array with the following keys: - url - the menu item URL. Not required for menu item types that return all available records. The URL should be returned relative to the website root and include the subdirectory, if any. Use the Cms::url() helper to generate the URLs. - isActive - determines whether the menu item is active. Not required for menu item types that return all available records. - items - an array of arrays with the same keys (url, isActive, items) + the title key. The items array should be added only if the $item's $nesting property value is TRUE.
public static resolveMenuItem ( RainLab\Pages\Classes\MenuItem $item, string $url, Cms\Classes\Theme $theme ) : mixed
$item RainLab\Pages\Classes\MenuItem Specifies the menu item.
$url string Specifies the current page URL, normalized, in lower case The URL is specified relative to the website root, it includes the subdirectory name, if any.
$theme Cms\Classes\Theme Specifies the current theme.
return mixed Returns an array. Returns null if the item cannot be resolved.

setPlaceholdersAttribute() public method

Takes an array of placeholder data (key: code, value: content) and renders it as a single string of Twig markup against the "code" attribute.
public setPlaceholdersAttribute ( array $value ) : void
$value array
return void

url() public static method

Guide for the page reference: - chairs -> content/static-pages/chairs.htm
public static url ( $name ) : string
return string

Property Details

$attributeNames public_oe property

The array of custom attribute names.
public $attributeNames

$childrenCache protected_oe property

protected $childrenCache

$dirName protected_oe property

The container name associated with the model, eg: pages.
protected $dirName

$fillable protected_oe property

Properties that can be set with fill()
protected $fillable

$implement public_oe property

public $implement

$menuTreeCache protected_oe static_oe property

protected static $menuTreeCache

$parentCache protected_oe property

protected $parentCache

$parentFileName public_oe property

Contains the page parent file name. This property is used by the page editor internally.
public $parentFileName

$processedBlockMarkupCache protected_oe property

protected $processedBlockMarkupCache

$processedMarkupCache protected_oe property

protected $processedMarkupCache

$purgeable protected_oe property

List of attribute names which are not considered "settings".
protected $purgeable

$rules public_oe property

The rules to be applied to the data.
public $rules

$translatable public_oe property

Attributes that support translation, if available.
public $translatable

$translatableModel public_oe property

Translation model used for translation, if available.
public $translatableModel

$wrapCode protected_oe property

Wrap code section in PHP tags.
protected $wrapCode