Class \Scrivo\PageDefinitionHints
The PageDefinitionHints class is used to prevent page definition selection in the Scrivo user interface.
In principle it is possible to create pages of any page definition underneath any other page. But from the viewpoint of the site designer this is not always desirable. The site might require specific rules such as that there are only 'main menu' pages allowed underneath the home.
Likewise, the site editor will not be facilitated when offered long lists of page definitions (with possible many irrelevant entries) each time he or she wants to add a page.
To guide the user in page definition selection the PageDefinitionHints class lists the number of occurances of pages of a specific page definition that is allowed under a page of a given page definition. For these lists it can be decided if a page definition is selectable when creating a page.
Suppose we have three page definitions: Home, Standard and Contact. Then a likely scenario is that we don't want the the editor the select the 'Home' page definition at any time, the 'Standard' page definition for as many times as desired but only as a child of a page of page definition 'Home' or 'Standard' and the 'Contact' page only once as child of the home page (the page of page definition 'Home').
Again these are merely hints. In the super-interfaces 'admin' and 'config' your still allowed to make all combinations you want. These hints are only used as a guide in the editor interface.
Implements
Defined in:
PageDefinitionHints.php.
Attr. | Name / Description |
---|---|
public |
PageDefinitionHints($context, $pageDefinitionId, $listType) Construct a pageDefinition hints object. |
Name | Description |
---|---|
CHILD_PAGE_DEFINITION_COUNT | Constant to denote we want to retrieve the list of how many times pages of other page definitions (total count) may occur underneath the current page. |
CHILD_PAGE_DEFINITION_REMAINING | Constant to denote we want to retrieve the list of how many times pages of other page definitions (remaining count) may occur underneath the current page. |
PARENT_PAGE_DEFINITION_COUNT | Constant to denote that we want to retrieve the list of how many times a page of this page definition may occur underneath pages of other page definitions. |
Attr. | Type | Name | Description |
---|---|---|---|
private | \..\Context | $context | A Scrivo context |
private | object[] | $hints | The hints array. |
private | int | $pageDefinitionId | The id of the page definition to retrieve the list. |
private | int | $type | The type of the list: \Scrivo\PageDefinitionHints::PARENT_PAGE_DEFINITION_COUNT, \Scrivo\PageDefinitionHints::CHILD_PAGE_DEFINITION_COUNT or \Scrivo\PageDefinitionHints::CHILD_PAGE_DEFINITION_REMAINING. |
Attr. | Type | Name / Description |
---|---|---|
public |
current() Get the current page definition hint when iterating. |
|
public |
key() Get the key of the current page definition hint when iterating. |
|
private |
load($children) Load the page definition hints as defined in the database. |
|
private |
loadCorrected($parentId) Load the page definition hints as defined in the database, but corrected for the currently created pages. |
|
public |
next() Get the next page definition hint when iterating. |
|
public |
offsetExists($key) Test if a hint exists at the requested index location. |
|
public | object |
offsetGet($key) Get the page definition hint for a given page definition (id). |
public |
offsetSet($key, $value) Part of the implementation of \ArrayAccess. |
|
public |
offsetUnset($key) Part of the implementation of \ArrayAccess. |
|
public |
rewind() Rewind the hints array so iterating will start at the beginning again. |
|
public |
update() Update a set of page definition hints. |
|
public |
valid() Check if the current key is valid. |
Constructor
- public PageDefinitionHints(\Scrivo\Context $context, int $pageDefinitionId, int $listType)
-
Construct a pageDefinition hints object.
Depending on the context where you want to use these hints for a number of different lists can be constructed. For instance, when defining the user interface one need lists that contain the hints as stored in the database (PARENT_PAGE_DEFINITION_COUNT or CHILD_PAGE_DEFINITION_COUNT). But in the user interface itself you'll want to to use the rules as defined but corrected for the pages already created.
Suppose there are three main menus are allowed under the a home page. The types PARENT_PAGE_DEFINITION_COUNT or CHILD_PAGE_DEFINITION_COUNT will give you that information. But if there are alreay two main menus are created under the home CHILD_PAGE_DEFINITION_REMAINING will give you the corrected result of just one main menu allowed under the a home page. *
Parameters:
Type Name Def. Description \Scrivo\Context $context A valid Scrivo context.
int $pageDefinitionId The id of the pageDefinition to create the hints for, or the page id in the case of CHILD_PAGE_DEFINITION_REMAINING.
int $listType If the listType parameter was set to \Scrivo\PageDefinitionHints::CHILD_PAGE_DEFINITION_REMAINING then the id for the page for which to correct the result needs to be supplied.
View source: PageDefinitionHints.php line 145.
Constants
- CHILD_PAGE_DEFINITION_COUNT
-
Constant to denote we want to retrieve the list of how many times pages of other page definitions (total count) may occur underneath the current page.
Value: 2
View source: PageDefinitionHints.php line 81.
- CHILD_PAGE_DEFINITION_REMAINING
-
Constant to denote we want to retrieve the list of how many times pages of other page definitions (remaining count) may occur underneath the current page.
Value: 3
View source: PageDefinitionHints.php line 88.
- PARENT_PAGE_DEFINITION_COUNT
-
Constant to denote that we want to retrieve the list of how many times a page of this page definition may occur underneath pages of other page definitions.
Value: 1
View source: PageDefinitionHints.php line 74.
Members
- private \Scrivo\Context $context
-
A Scrivo context
Inital value: null
View source: PageDefinitionHints.php line 115.
- private object[] $hints
-
The hints array.
Inital value: null
View source: PageDefinitionHints.php line 109.
- private int $pageDefinitionId
-
The id of the page definition to retrieve the list.
Inital value: 0
View source: PageDefinitionHints.php line 94.
- private int $type
-
The type of the list: \Scrivo\PageDefinitionHints::PARENT_PAGE_DEFINITION_COUNT, \Scrivo\PageDefinitionHints::CHILD_PAGE_DEFINITION_COUNT or \Scrivo\PageDefinitionHints::CHILD_PAGE_DEFINITION_REMAINING.
Inital value: 0
View source: PageDefinitionHints.php line 103.
Methods
- public current()
-
Get the current page definition hint when iterating.
View source: PageDefinitionHints.php line 229.
- public key()
-
Get the key of the current page definition hint when iterating.
View source: PageDefinitionHints.php line 236.
- private load(boolean $children=false)
-
Load the page definition hints as defined in the database.
This list can be generated from two different viewpoints: 1) pages of this page definition can be used x times under pages of some other page definition ($children==false/PARENT_PAGE_DEFINITION_COUNT), or 2) pages of some page definition can occur x times under a page using this page definition ($children==true/CHILD_PAGE_DEFINITION_COUNT)
Parameters:
Type Name Def. Description boolean $children false False (default) if you want to select how many times a page using this page definition may occur under pages of some other page definition, True if you want to select how many times a pages of some other page definition may occur under a page using this page definition.
View source: PageDefinitionHints.php line 269.
- private loadCorrected(int $parentId)
-
Load the page definition hints as defined in the database, but corrected for the currently created pages.
This is basically an extion of PageDefinitionHints::load(true)/pages of some page definition can occur x times under a page using this page definition/CHILD_PAGE_DEFINITION_COUNT and a correction for pages that are made already.
The parent page is given as an argument, the list generated is a list of page definitions and how many times new pages of each page definition are still allowed underneath the given page.
Parameters:
Type Name Def. Description int $parentId The id of the parent page.
View source: PageDefinitionHints.php line 340.
- public next()
-
Get the next page definition hint when iterating.
View source: PageDefinitionHints.php line 243.
- public offsetExists(int $key)
-
Test if a hint exists at the requested index location.
Parameters:
Type Name Def. Description int $key A page definition id used as key in the hints array.
View source: PageDefinitionHints.php line 202.
- public object offsetGet(int $key)
-
Get the page definition hint for a given page definition (id).
Parameters:
Type Name Def. Description int $key A page definition id used as key in the hints array.
Returns:
object Get the page definition hint for a given page definition (id).
Throws:
Exception Type Description \Scrivo\SystemException If the requested offset was out of range. View source: PageDefinitionHints.php line 175.
- public offsetSet(int $key, string $value)
-
Part of the implementation of \ArrayAccess.
Not applicable for PageDefinitionHints.
Parameters:
Type Name Def. Description int $key string $value Throws:
Exception Type Description \Scrivo\SystemException If this method is called. View source: PageDefinitionHints.php line 192.
- public offsetUnset(int $key)
-
Part of the implementation of \ArrayAccess.
Not applicable for PageDefinitionHints.
Parameters:
Type Name Def. Description int $key Throws:
Exception Type Description \Exception If this method is called. View source: PageDefinitionHints.php line 214.
- public rewind()
-
Rewind the hints array so iterating will start at the beginning again.
View source: PageDefinitionHints.php line 222.
- public update()
-
Update a set of page definition hints.
Note: It is assumed that you're updating a list of type PARENT_PAGE_DEFINITION_COUNT otherwise a \Scrivo\SystemException is raised.
View source: PageDefinitionHints.php line 401.
- public valid()
-
Check if the current key is valid.
View source: PageDefinitionHints.php line 250.
Documentation generated by phpDocumentor 2.0.0a12 and ScrivoDocumentor on August 29, 2013