Class \Scrivo\PageSet

A Scrivo Page set is a group of Scrivo pages with a common parent id.

A page set is actually a simple array of (child) pages but it does a couple of things extra:

  • When serialized only the ids are stored.
  • When iteratering, counting or getting pages from the array only the readable pages in the array will be taken into account.

Page sets are a part of a Scrivo page and are used to retrieve and iterate through the child pages (or path) of a page.

Implements
Defined in: PageSet.php.


Constructor summary

Attr. Name / Description
public

PageSet($page)

Construct a page set.

Member summary

Attr. Type Name Description
private \..\int[] $ids An array containing the keys of the items array, used when serializing.
private \..\Page[] $items The array containing the pages or page ids.
private \..\Page $page The parent page of the set.

Method summary

Attr. Type Name / Description
public

__sleep()

When serializing retrieve the don't store the items array but just the keys.

public

__wakeup()

When unserializing restore the items array only the id.

private

check($id)

When reading the items array always check of the actual entry is an instantiated Scrivo page.

public int

count()

The page count of pages in the set.

public \..\Page

current()

Get the current page from the page set when iterating.

public \..\Page

key()

Get the key(id) of the current page from the page set when iterating.

public \..\Page

next()

Get the current page from the page set and move the internal pointer to the next page in the set.

public boolean

offsetExists($id)

Test if page is set in the page set.

public \..\Page

offsetGet($id)

Get a page with a specific id from the page set.

public

offsetSet($id, $page)

Set a page in the page set.

public

offsetUnset($id)

It is not possible to unset pages in a page set.

public

prepend($page)

Add a page to the beginning of the set.

public

rewind()

Rewind the page set so that iterating will start at the beginning.

public boolean

valid()

Test if the current page is valid.

 


Constructor

public PageSet(\Scrivo\Page $page)

Construct a page set.

Parameters:

Type Name Def. Description
\Scrivo\Page $page

The parent page of the page set.


Members


				
private \Scrivo\int[id] $ids

An array containing the keys of the items array, used when serializing.

Inital value: null


				
private \Scrivo\Page[id] $items

The array containing the pages or page ids.

Inital value: array()


				
private \Scrivo\Page $page

The parent page of the set.

Inital value: null


Methods

public __sleep()

When serializing retrieve the don't store the items array but just the keys.

return array An array with the names of the serializable members.

public __wakeup()

When unserializing restore the items array only the id.

private check(int $id)

When reading the items array always check of the actual entry is an instantiated Scrivo page.

If not, get that page and store it in the items array.

Parameters:

Type Name Def. Description
int $id

The page id of the entry to check.

public int count()

The page count of pages in the set.

Note that returned page count depends on whether the pages are readable for the user defined in the Scrivo context. So the returned count is always equeal or less that the actual count of pages in the items array.

Returns:

int The page count of pages in the set.

public \Scrivo\Page current()

Get the current page from the page set when iterating.

Returns:

\Scrivo\Page Get the current page from the page set when iterating.

public \Scrivo\Page key()

Get the key(id) of the current page from the page set when iterating.

Returns:

\Scrivo\Page Get the key(id) of the current page from the page set when iterating.

public \Scrivo\Page next()

Get the current page from the page set and move the internal pointer to the next page in the set.

Returns:

\Scrivo\Page Get the current page from the page set and move the internal pointer to the next page in the set.

public boolean offsetExists(int $id)

Test if page is set in the page set.

Parameters:

Type Name Def. Description
int $id

A Scrivo page id to test.

Returns:

boolean Test if page is set in the page set.

public \Scrivo\Page offsetGet(int $id)

Get a page with a specific id from the page set.

Parameters:

Type Name Def. Description
int $id

A Scrivo page id to test.

Returns:

\Scrivo\Page Get a page with a specific id from the page set.

public offsetSet(int $id, \Scrivo\Page $page)

Set a page in the page set.

Parameters:

Type Name Def. Description
int $id

A Scrivo page id.

\Scrivo\Page $page

The parent page of the page set.

public offsetUnset(int $id)

It is not possible to unset pages in a page set.

Calling this method will raise a system exception.

Parameters:

Type Name Def. Description
int $id

A Scrivo page id to unset.

public prepend(\Scrivo\Page $page)

Add a page to the beginning of the set.

Parameters:

Type Name Def. Description
\Scrivo\Page $page

The parent page of the page set.

public rewind()

Rewind the page set so that iterating will start at the beginning.

public boolean valid()

Test if the current page is valid.

Returns:

boolean Test if the current page is valid.


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