Chyrp

Page

The Page model.

See Also

Model

Summary
Page The Page model.
Functions
__construct Model::grab
find Model::search
add Adds a page to the database.
update Updates the given page.
delete Deletes the given page.  Calls the “delete_page” trigger and passes the Page as an argument.
exists Checks if a page exists.
check_url Checks if a given clean URL is already being used as another page’s URL.
url Returns a page’s URL.
parent Returns a page’s parent.  Example: $page->parent()->parent()->title
children Returns a page’s children.
user Returns a page’s creator.  Example: $page->user()->full_name
edit_link Outputs an edit link for the page, if the <User.can> edit_page.
delete_link Outputs a delete link for the page, if the <User.can> delete_page.

Functions

__construct

public function __construct( $page_id,   
$options  =  array() )

See Also

Model::grab

find

static function find( $options  =  array(),
$options_for_object  =  array() )

See Also

Model::search

add

static function add( $title,   
$body,   
$parent_id,   
$show_in_list,   
$list_order  =  0,
$clean,   
$url,   
$created_at  =  null,
$updated_at  =  null,
$user_id  =  null )

Adds a page to the database.

Calls the add_page trigger with the inserted ID.

Parameters

$title The Title for the new page.
$body The Body for the new page.
$parent_id The ID of the new page’s parent page (0 for none).
$show_in_list Whether or not to show it in the pages list.
$clean The sanitized URL (or empty to default to “(feather).(new page’s id)”).
$url The unique URL (or empty to default to “(feather).(new page’s id)”).
$created_at The new page’s “created” timestamp.
$updated_at The new page’s “last updated” timestamp.
$user_id The ID of the user that created the page.  Defaults to the visitor’s ID.

Returns

$id The newly created page’s ID.

See Also

update

update

public function update( $title,   
$body,   
$parent_id,   
$show_in_list,   
$list_order,   
$url,   
$update_timestamp  =  true )

Updates the given page.

Parameters

$title The new Title.
$body The new Bod.
$parent_id The new parent ID.
$show_in_list Whether or not to show it in the pages list.
$url The new page URL.

delete

static function delete( $id,   
$recursive  =  false )

Deletes the given page.  Calls the “delete_page” trigger and passes the Page as an argument.

Parameters

$id The page to delete.  Child pages if this page will be removed as well.

exists

static function exists( $page_id )

Checks if a page exists.

Parameters

$page_id The page ID to check

Returns

true if a page with that ID is in the database.

check_url

static function check_url( $clean )

Checks if a given clean URL is already being used as another page’s URL.

Parameters

$clean The clean URL to check.

Returns

$url The unique version of the passed clean URL.  If it’s not used, it’s the same as $clean.  If it is, a number is appended.

url

public function url()

Returns a page’s URL.

parent

public function parent()

Returns a page’s parent.  Example: $page->parent()->parent()->title

children

public function children()

Returns a page’s children.

user

public function user()

Returns a page’s creator.  Example: $page->user()->full_name

edit_link

public function edit_link( $text  =  null,
$before  =  null,
$after  =  null )

Outputs an edit link for the page, if the <User.can> edit_page.

Parameters

$text The text to show for the link.
$before If the link can be shown, show this before it.
$after If the link can be shown, show this after it.

delete_link

public function delete_link( $text  =  null,
$before  =  null,
$after  =  null )

Outputs a delete link for the page, if the <User.can> delete_page.

Parameters

$text The text to show for the link.
$before If the link can be shown, show this before it.
$after If the link can be shown, show this after it.