Methods summary
public
|
#
__construct( Template $tpl = null )
Create a new page in memory.
Create a new page in memory.
Parameters
- $tpl
Template Template object this page should use.
|
public
|
#
__destruct( )
Destruct this page instance
Destruct this page instance
|
public
|
|
public
Page
|
#
set( string $key, mixed $value )
Set the value of a page property
Set the value of a page property
Parameters
- $key
string Property to set
- $value
mixed
Returns
PageReference to this Page
See
|
public
|
#
setFieldValue( string $key, mixed $value, boolean $load = true )
Set the value of a field that is defined in the page's Fieldgroup
Set the value of a field that is defined in the page's Fieldgroup
This may not be called when outputFormatting is on.
This is for internal use. API should generally use the set() method, but this
is kept public for the minority of instances where it's useful.
Parameters
- $key
string
- $value
mixed
- $load
boolean Should the existing value be loaded for change comparisons? (applicable only to
non-autoload fields)
|
public
mixed
|
#
get( string $key )
Get the value of a requested Page property
Get the value of a requested Page property
Parameters
Returns
mixed
See
|
protected
null|mixed
|
#
getFieldFirstValue( string $multiKey )
Given a Multi Key, determine if there are multiple keys requested and return
the first non-empty value
Given a Multi Key, determine if there are multiple keys requested and return
the first non-empty value
A Multi Key is a string with multiple field names split by pipes, i.e.
headline|title
Example: browser_title|headline|title - Return the value of the first field
that is non-empty
Parameters
Returns
null|mixed Returns null if no values match, or if there aren't multiple keys split by "|"
chars
|
protected
null|mixed
|
#
getFieldValue( string $key )
Get the value for a non-native page field, and call upon Fieldtype to join it
if not autojoined
Get the value for a non-native page field, and call upon Fieldtype to join it
if not autojoined
Parameters
Returns
null|mixed
|
public
|
#
getUnformatted( $key )
Get the raw/unformatted value of a field, regardless of what
$this->outputFormatting is set at
Get the raw/unformatted value of a field, regardless of what
$this->outputFormatting is set at
|
public
mixed|null
|
#
__get( string $key )
Parameters
Returns
mixed|null
See
|
public
|
|
protected
|
#
setStatus( $value )
Set the 'status' setting, with some built-in protections
Set the 'status' setting, with some built-in protections
|
protected
|
#
setTemplate( $tpl )
Set this Page's Template object
Set this Page's Template object
|
protected
|
#
setParent( Page $parent )
Set this page's parent Page
Set this page's parent Page
|
protected
this
|
#
setUser( User|integer|string $user, string $userType )
Set either the createdUser or the modifiedUser
Set either the createdUser or the modifiedUser
Parameters
- $user
User|integer|string User object or integer/string representation of User
- $userType
string Must be either 'created' or 'modified'
Returns
this
|
public
|
#
parent( )
Return this page's parent Page
Return this page's parent Page
|
public
|
#
find( string $selector = '', $options = array() )
Find Pages in the descendent hierarchy
Find Pages in the descendent hierarchy
Same as Pages::find() except that the results are limited to descendents of
this Page
Parameters
- $selector
string
- $options
|
public
PageArray
|
#
children( string $selector = '', $options = array() )
Return this page's children pages, optionally filtered by a selector
Return this page's children pages, optionally filtered by a selector
Parameters
- $selector
string Selector to use, or blank to return all children
- $options
Returns
|
public
Page|NullPage
|
#
child( string $selector = '', $options = array() )
Return the page's first single child that matches the given selector.
Return the page's first single child that matches the given selector.
Same as children() but returns a Page object or NullPage (with id=0) rather
than a PageArray
Parameters
- $selector
string Selector to use, or blank to return the first child.
- $options
Returns
|
public
|
#
parents( )
Return this page's parent pages.
Return this page's parent pages.
|
public
Page
|
#
rootParent( )
Get the lowest-level, non-homepage parent of this page
Get the lowest-level, non-homepage parent of this page
rootParents typically comprise the first level of navigation on a site.
Returns
|
public
|
#
siblings( $selector = '' )
Return this Page's sibling pages, optionally filtered by a selector.
Return this Page's sibling pages, optionally filtered by a selector.
|
public
Page|NullPage
|
#
next( PageArray $siblings = null )
Return the next sibling page
Return the next sibling page
If given a PageArray of siblings (containing the current) it will return the
next sibling relative to the provided PageArray.
Be careful with this function when the page has a lot of siblings. It has to
load them all, so this function is best avoided at large scale, unless you
provide your own already-reduced siblings list (like from pagination)
Parameters
- $siblings
PageArray Optional siblings to use instead of the default.
Returns
Page|NullPageReturns the next sibling page, or a NullPage if none found.
|
public
Page|NullPage
|
#
prev( PageArray $siblings = null )
Return the previous sibling page
Return the previous sibling page
If given a PageArray of siblings (containing the current) it will return the
previous sibling relative to the provided PageArray.
Be careful with this function when the page has a lot of siblings. It has to
load them all, so this function is best avoided at large scale, unless you
provide your own already-reduced siblings list (like from pagination)
Parameters
- $siblings
PageArray Optional siblings to use instead of the default.
Returns
Page|NullPageReturns the previous sibling page, or a NullPage if none found.
|
public
|
#
save( Field|string $field = null )
Save this page to the database.
Save this page to the database.
To hook into this (___save), use 'Pages::save' To hook into a field-only
save, use 'Pages::saveField'
Parameters
- $field
Field|string Optional field to save (name of field or Field object)
|
public
boolean
|
#
delete( )
Delete this page from the Database
Delete this page from the Database
Throws WireException if action not allowed. See Pages::delete for a hookable
version.
Returns
boolean True on success
|
public
boolean
|
#
trash( )
Move this page to the trash
Move this page to the trash
Throws WireException if action is not allowed. See Pages::trash for a
hookable version.
Returns
boolean True on success
|
public
|
#
getIterator( )
Allow iteration of the page's properties with foreach(), fulfilling
IteratorAggregate interface.
Allow iteration of the page's properties with foreach(), fulfilling
IteratorAggregate interface.
Implementation of
|
public
boolean
|
#
isChanged( string $what = '' )
Has the Page (or optionally one of it's fields) changed since it was
loaded?
Has the Page (or optionally one of it's fields) changed since it was
loaded?
Assumes that Pages has turned on this Page's change tracking with a call to
setTrackChanges(). Pages that are new (i.e. don't yet exist in the DB) always
return true.
Parameters
- $what
string If specified, only checks the given property for changes rather than the whole
page.
Returns
boolean
Implementation of
|
public
|
#
__toString( )
Returns the Page's ID in a string
Returns the Page's ID in a string
|
public
|
#
path( )
Returns the Page's path from the site root.
Returns the Page's path from the site root.
|
protected
|
#
___path( )
Provides the hookable implementation for the path() method.
Provides the hookable implementation for the path() method.
The method we're using here by having a real path() function above is
slightly quicker than just letting PW's hook handler handle it all. We're taking
this approach since path() is a function that can feasibly be called hundreds or
thousands of times in a request, so we want it as optimized as possible.
|
public
|
#
url( )
Like path() but comes from server document root (which may or may not be
different)
Like path() but comes from server document root (which may or may not be
different)
Does not include urlSegment, if applicable. Does not include protocol and
hostname -- use httpUrl() for that.
See
|
public
|
#
httpUrl( )
Like URL, but includes the protocol and hostname
Like URL, but includes the protocol and hostname
|
protected
TemplateFile
|
#
getTemplateFile( )
Get the output TemplateFile object for rendering this page
Get the output TemplateFile object for rendering this page
You can retrieve the results of this by calling $page->out or
$page->output
Returns
|
public
|
#
getInputfields( )
Return a Inputfield object that contains all the custom Inputfield objects
required to edit this page
Return a Inputfield object that contains all the custom Inputfield objects
required to edit this page
|
public
boolean
|
#
is( integer|string|Selectors $status )
Does this page have the specified status number or template name?
Does this page have the specified status number or template name?
See status flag constants at top of Page class
Parameters
- $status
integer|string|Selectors Status number or Template name or selector string/object
Returns
boolean
|
public
boolean
|
#
matches( string|Selectors $s )
Given a Selectors object or a selector string, return whether this Page
matches it
Given a Selectors object or a selector string, return whether this Page
matches it
Parameters
Returns
boolean
|
public
this
|
#
addStatus( integer $statusFlag )
Add the specified status flag to this page's status
Add the specified status flag to this page's status
Parameters
Returns
this
|
public
this
|
#
removeStatus( integer $statusFlag )
Remove the specified status flag from this page's status
Remove the specified status flag from this page's status
Parameters
Returns
this
|
public
boolean
|
#
isHidden( )
Does this page have a 'hidden' status?
Does this page have a 'hidden' status?
Returns
boolean
|
public
|
#
isNew( )
Is this Page new? (i.e. doesn't yet exist in DB)
Is this Page new? (i.e. doesn't yet exist in DB)
|
public
|
#
isLoaded( )
Is the page fully loaded?
Is the page fully loaded?
|
public
boolean
|
#
isTrash( )
Is this Page in the trash?
Is this Page in the trash?
Returns
boolean
|
public
this
|
#
setIsNew( boolean $isNew )
Set the value for isNew, i.e. doesn't exist in the DB
Set the value for isNew, i.e. doesn't exist in the DB
Parameters
Returns
this
|
public
|
#
setIsLoaded( boolean $isLoaded )
Set that the Page is fully loaded
Set that the Page is fully loaded
Pages::getById sets this once it has completed loading the page This method
also triggers the loaded() method that hooks may listen to
Parameters
|
protected
|
#
processFieldDataQueue( )
Process and instantiate any data in the fieldDataQueue
Process and instantiate any data in the fieldDataQueue
This happens after setIsLoaded(true) is called
|
public
|
#
___loaded( )
For hooks to listen to, triggered when page is loaded and ready
For hooks to listen to, triggered when page is loaded and ready
|
public
this
|
#
setOutputFormatting( boolean $outputFormatting = true )
Set if this page's output is allowed to be filtered by runtime
formatters.
Set if this page's output is allowed to be filtered by runtime
formatters.
Pages used for output should have it on. Pages you intend to manipulate and
save should have it off.
Parameters
- $outputFormatting
boolean @outputFormatting Optional, default true
Returns
this
|
public
boolean
|
#
outputFormatting( )
Return true if outputFormatting is on, false if not.
Return true if outputFormatting is on, false if not.
Returns
boolean
|
public
boolean
|
#
of( boolean $outputFormatting = null )
Shorter version of setOutputFormatting() and outputFormatting() function
Shorter version of setOutputFormatting() and outputFormatting() function
Always returns the current state of outputFormatting like the
outputFormatting() function (and unlike setOutputFormatting()) You may
optionally specify a boolean value for $outputFormatting which will set the
current state, like setOutputFormatting().
Parameters
- $outputFormatting
boolean If specified, sets outputFormatting ON or OFF. If not specified,
outputFormatting status does not change.
Returns
boolean Current outputFormatting state.
|
public
PageFilesManager
|
#
filesManager( )
Return instance of PagefileManager specific to this Page
Return instance of PagefileManager specific to this Page
Returns
PageFilesManager
|
public
|
#
uncache( )
Prepare the page and it's fields for removal from runtime memory, called
primarily by Pages::uncache()
Prepare the page and it's fields for removal from runtime memory, called
primarily by Pages::uncache()
|
public
|
#
__isset( $key )
Ensures that isset() and empty() work for this classes properties.
Ensures that isset() and empty() work for this classes properties.
|
public
Page|NullPage
|
#
getAccessParent( )
Returns the parent page that has the template from which we get our
role/access settings from
Returns the parent page that has the template from which we get our
role/access settings from
Returns
|
public
Template|null
|
#
getAccessTemplate( )
Returns the template from which we get our role/access settings from
Returns the template from which we get our role/access settings from
Returns
|
public
PageArray
|
#
getAccessRoles( )
Return the PageArray of roles that have access to this page
Return the PageArray of roles that have access to this page
This is determined from the page's template. If the page's template has roles
turned off, then it will go down the tree till it finds usable roles to use.
Returns
|
public
boolean
|
#
hasAccessRole( string|integer|Role $role )
Returns whether this page has the given access role
Returns whether this page has the given access role
Given access role may be a role name, role ID or Role object
Parameters
- $role
string|integer|Role
Returns
boolean
|
Properties summary
protected
|
$template
|
|
#
The Template this page is using (object)
The Template this page is using (object)
|
protected
|
$parent
|
null |
#
Parent Page - Instance of Page
Parent Page - Instance of Page
|
protected
array
|
$fieldDataQueue
|
array() |
#
Field data that queues while the page is loading.
Field data that queues while the page is loading.
Once setIsLoaded(true) is called, this data is processed and instantiated
into the Page and the fieldDataQueue is emptied (and no longer relevant)
|
protected
boolean
|
$isNew
|
true |
#
Is this a new page (not yet existing in the database)?
Is this a new page (not yet existing in the database)?
|
protected
boolean
|
$isLoaded
|
true |
#
Is this Page finished loading from the DB (i.e. Pages::getById)?
Is this Page finished loading from the DB (i.e. Pages::getById)?
When false, it is assumed that any values set need to be woken up. When
false, it also assumes that built-in properties (like name) don't need to be
sanitized.
Note: must be kept in the 'true' state. Pages::getById sets it to false
before populating data and then back to true when done.
|
protected
boolean
|
$outputFormatting
|
false |
#
Is this page allowing it's output to be formatted?
Is this page allowing it's output to be formatted?
If so, the page may not be saveable because calls to $page->get(field) are
returning versions of variables that may have been formatted at runtime for
output. An exception will be thrown if you attempt to set the value of a
formatted field when $outputFormatting is on.
Output formatting should be turned off for pages that you are manipulating
and saving. Whereas it should be turned on for pages that are being used for
output on a public site. Having it on means that Textformatters and any other
output formatters will be executed on any values returned by this page.
Likewise, any values you set to the page while outputFormatting is set to true
are considered potentially corrupt.
|
protected
integer
|
$instanceID
|
0 |
#
A unique instance ID assigned to the page at the time it's loaded (for
debugging purposes only)
A unique instance ID assigned to the page at the time it's loaded (for
debugging purposes only)
|
public static
array
|
$instanceIDs
|
array() |
#
IDs for all the instances of pages, used for debugging and testing.
IDs for all the instances of pages, used for debugging and testing.
Indexed by $instanceID => $pageID
|
public static
array
|
$loadingStack
|
array() |
#
Stack of ID indexed Page objects that are currently in the loading
process.
Stack of ID indexed Page objects that are currently in the loading
process.
Used to avoid possible circular references when multiple pages referencing
each other are being populated at the same time.
|
protected
integer
|
$pageNum
|
1 |
#
The current page number, starting from 1
The current page number, starting from 1
|
protected
|
$config
|
null |
#
Reference to main config, optimization so that get() method doesn't get
called
Reference to main config, optimization so that get() method doesn't get
called
|
protected
array
|
$settings
|
array(
'id' => 0,
'name' => '',
'status' => 1,
'numChildren' => 0,
'sort' => 0,
'sortfield' => 'sort',
'modified_users_id',
'created_users_id',
) |
#
Page-specific settings which are either saved in pages table, or generated at
runtime.
Page-specific settings which are either saved in pages table, or generated at
runtime.
|