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.


Constructor summary

Attr. Name / Description
public

PageDefinitionHints($context, $pageDefinitionId, $listType)

Construct a pageDefinition hints object.

Constant summary

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.

Member summary

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.

Method summary

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.


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

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

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


Members


				
private \Scrivo\Context $context

A Scrivo context

Inital value: null


				
private object[] $hints

The hints array.

Inital value: null


				
private int $pageDefinitionId

The id of the page definition to retrieve the list.

Inital value: 0


				
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


Methods

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(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.

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.

public next()

Get the next page definition hint when iterating.

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.

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.
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.
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.
public rewind()

Rewind the hints array so iterating will start at the beginning again.

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.

public valid()

Check if the current key is valid.


Documentation generated by phpDocumentor 2.0.0a12 and ScrivoDocumentor on August 29, 2013