PHP Class RainLab\Pages\Classes\Page

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

Méthodes publiques

Свойство 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

Свойство 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.

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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 méthode

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

afterCreate() public méthode

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

appendToMeta() protected méthode

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

beforeCreate() public méthode

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

beforeValidate() public méthode

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

buildMenuTree() public static méthode

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.
Résultat array Returns an array containing the page information

clearMenuCache() public static méthode

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

delete() public méthode

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

fill() public méthode

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

flattenTwigNode() protected méthode

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

generateFilenameFromCode() protected méthode

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

getChildren() public méthode

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

getLayoutObject() public méthode

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

getLayoutOptions() public méthode

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

getMenuCacheKey() protected static méthode

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

getMenuTypeInfo() public static méthode

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
Résultat array Returns an array

getParent() public méthode

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

getPlaceholdersAttribute() public méthode

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

getProcessedMarkup() public méthode

public getProcessedMarkup ( )

getProcessedPlaceholderMarkup() public méthode

public getProcessedPlaceholderMarkup ( $placeholderName, $placeholderContents )

getRichEditorTypeInfo() public static méthode

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
Résultat array

getTwigContent() public méthode

Returns the Twig content string
public getTwigContent ( )

getValidationAttributes() protected méthode

Returns the attributes used for validation.
protected getValidationAttributes ( ) : array
Résultat array

initCmsComponents() public méthode

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

listLayoutPlaceholders() public méthode

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

listLayoutSyntaxFields() public méthode

listStaticPageMenuOptions() protected static méthode

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
Résultat array Returns an array

removeFromMeta() protected méthode

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

resolveMenuItem() public static méthode

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.
Résultat mixed Returns an array. Returns null if the item cannot be resolved.

setPlaceholdersAttribute() public méthode

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
Résultat void

url() public static méthode

Guide for the page reference: - chairs -> content/static-pages/chairs.htm
public static url ( $name ) : string
Résultat 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