- Home
- About
- Testimonials
- Demos
- Download
- Documentation
- Blogs
- Forum
- Support

Packages:
default
System
System.Caching
System.Collections
System.Data
System.Data.ActiveRecord
System.Data.ActiveRecord.Relations
System.Data.ActiveRecord.Scaffold
System.Data.ActiveReecord.Scaffold.InputBuilder
System.Data.Commom.Sqlite
System.Data.Common
System.Data.Common.Mssql
System.Data.Common.Mysql
System.Data.Common.Oracle
System.Data.Common.Pgsql
System.Data.Common.Sqlite
System.Data.DataGateway
System.Data.SqlMap
System.Data.SqlMap.Configuration
System.Data.SqlMap.Statements
System.Exceptions
System.I18N
System.IO
System.Security
System.Util
System.Web
System.Web.Services
System.Web.UI
System.Web.UI.ActiveControls
System.Web.UI.WebControls
System.Web.UI.WebControls.assets
System.Xml
Classes:
IFeedContentProvider
TFeedService
TJsonResponse
TJsonService
TPageConfiguration
TPageService
TSoapServer
TSoapService

Keyword

# Class TPageService

    TComponent
       |
       --TApplicationComponent
          |
          --TService
             |
             --TPageService

TPageService class.

TPageService implements the service for serving user page requests.

Pages that are available to client users are stored under a directory specified by BasePath. The directory may contain subdirectories. Pages serving for a similar goal are usually placed under the same directory. A directory may contain a configuration file config.xml whose content is similar to that of application configuration file.

A page is requested via page path, which is a dot-connected directory names appended by the page name. Assume '<BasePath>/Users/Admin' is the directory containing the page 'Update'. Then the page can be requested via 'Users.Admin.Update'. By default, the BasePath of the page service is the "pages" directory under the application base path. You may change this default by setting BasePath with a different path you prefer.

Page name refers to the file name (without extension) of the page template. In order to differentiate from the common control template files, the extension name of the page template files must be '.page'. If there is a PHP file with the same page name under the same directory as the template file, that file will be considered as the page class file and the file name is the page class name. If such a file is not found, the page class is assumed as TPage.

Modules can be configured and loaded in page directory configurations. Configuration of a module in a subdirectory will overwrite its parent directory's configuration, if both configurations refer to the same module.

By default, TPageService will automatically load two modules:

- TTemplateManager : manages page and control templates
- TThemeManager : manages themes used in a Prado application

In page directory configurations, static authorization rules can also be specified, which governs who and which roles can access particular pages. Refer to TAuthorizationRule for more details about authorization rules. Page authorization rules can be configured within an <authorization> tag in each page directory configuration as follows, <authorization> <deny pages="Update" users="?" /> <allow pages="Admin" roles="administrator" /> <deny pages="Admin" users="*" /> </authorization> where the 'pages' attribute may be filled with a sequence of comma-separated page IDs. If 'pages' attribute does not appear in a rule, the rule will be applied to all pages in this directory and all subdirectories (recursively). Application of authorization rules are in a bottom-up fashion, starting from the directory containing the requested page up to all parent directories. The first matching rule will be used. The last rule always allows all users accessing to any resources.
Since: 3.0
Author: Qiang Xue <qiang.xue@gmail.com>

Method Summary
protected void | applyConfiguration ( TPageConfiguration $config) Applies a page configuration.
string | constructUrl ( string $pagePath, array $getParams, boolean $encodeAmpersand, boolean $encodeGetItems) Constructs a URL with specified page path and GET parameters.
protected TPage | createPage ( string $pagePath) Creates a page instance based on requested page path.
protected string | determineRequestedPagePath () Determines the requested page path.
string | getBasePageClass ()
string | getBasePath ()
string | getDefaultPage ()
string | getDefaultPageUrl ()
TPage | getRequestedPage ()
string | getRequestedPagePath ()
TTemplateManager | getTemplateManager ()
TThemeManager | getThemeManager ()
void | init ( TXmlElement $config) Initializes the service.
protected void | initPageContext ( TPageConfiguration $pageConfig) Initializes page context.
protected TPageConfiguration | loadPageConfig ( TXmlElement $config) Collects configuration for a page.
void | run () Runs the service.
protected void | runPage ( TPage $page, array $properties) Executes a page.
void | setBasePageClass ( string $value) Sets the base page class name (in namespace format).
void | setBasePath ( string $value)
void | setDefaultPage ( string $value)
void | setTemplateManager ( TTemplateManager $value)
void | setThemeManager ( TThemeManager $value)

Methods Inherited From TService
TService::getEnabled(), TService::getID(), TService::init(), TService::run(), TService::setEnabled(), TService::setID()

Methods Inherited From TApplicationComponent
TApplicationComponent::getApplication(), TApplicationComponent::getRequest(), TApplicationComponent::getResponse(), TApplicationComponent::getService(), TApplicationComponent::getSession(), TApplicationComponent::getUser(), TApplicationComponent::publishAsset(), TApplicationComponent::publishFilePath()

Methods Inherited From TComponent

TComponent::addParsedObject(), TComponent::attachEventHandler(), TComponent::canGetProperty(), TComponent::canSetProperty(), TComponent::createdOnTemplate(), TComponent::detachEventHandler(), TComponent::evaluateExpression(), TComponent::evaluateStatements(), TComponent::getEventHandlers(), TComponent::getSubProperty(), TComponent::hasEvent(), TComponent::hasEventHandler(), TComponent::hasProperty(), TComponent::raiseEvent(), TComponent::setSubProperty(), TComponent::__get(), TComponent::__set()

Constant Summary
string | CONFIG_CACHE_PREFIX | Prefix of ID used for storing parsed configuration in cache
string | CONFIG_FILE | Configuration file name
string | DEFAULT_BASEPATH | Default base path
string | PAGE_FILE_EXT | Page template file extension

Method Details

## applyConfiguration

protected void applyConfiguration | (TPageConfiguration $config )

Applies a page configuration.

Input
TPageConfiguration | $config | the configuration
Output
Exception

## constructUrl

public string constructUrl | (string $pagePath , array $getParams , boolean $encodeAmpersand , boolean $encodeGetItems )

Constructs a URL with specified page path and GET parameters.

Input
string | $pagePath | page path
array | $getParams | list of GET parameters, null if no GET parameters required
boolean | $encodeAmpersand | whether to encode the ampersand in URL, defaults to true.
boolean | $encodeGetItems | whether to encode the GET parameters (their names and values), defaults to true.
Output
string | URL for the page and GET parameters
Exception

## createPage

protected TPage createPage | (string $pagePath )

Creates a page instance based on requested page path.

Input
string | $pagePath | requested page path
Output
TPage | the requested page instance
Exception
throws | THttpException if requested page path is invalid
throws | TConfigurationException if the page class cannot be found

## determineRequestedPagePath

protected string determineRequestedPagePath | ()

Determines the requested page path.

Output
string | page path requested
Exception

## getBasePageClass

public string getBasePageClass | ()

Output
string | base page class name in namespace format. Defaults to 'TPage'.
Exception

## getBasePath

public string getBasePath | ()

Output
string | the root directory for storing pages. Defaults to the 'pages' directory under the application base path.
Exception

## getDefaultPage

public string getDefaultPage | ()

Output
string | default page path to be served if no explicit page is request. Defaults to 'Home'.
Exception

## getDefaultPageUrl

public string getDefaultPageUrl | ()

Output
string | the URL for the default page
Exception

## getRequestedPage

public TPage getRequestedPage | ()

Output
TPage | the requested page
Exception

## getRequestedPagePath

public string getRequestedPagePath | ()

Output
string | the requested page path
Exception

## getTemplateManager

public TTemplateManager getTemplateManager | ()

Output
TTemplateManager | template manager
Exception

## getThemeManager

public TThemeManager getThemeManager | ()

Output
TThemeManager | theme manager
Exception

## init

public void init | (TXmlElement $config )

Initializes the service.

This method is required by IService interface and is invoked by application.

Input
TXmlElement | $config | service configuration
Output
Exception

## initPageContext

protected void initPageContext | (TPageConfiguration $pageConfig )

Initializes page context.

Page context includes path alias settings, namespace usages, parameter initialization, module loadings, page initial properties and authorization rules.

Input
TPageConfiguration | $pageConfig |
Output
Exception

## loadPageConfig

protected TPageConfiguration loadPageConfig | (TXmlElement $config )

Collects configuration for a page.

Input
TXmlElement | $config | additional configuration specified in the application configuration
Output
Exception

## run

public void run | ()

Runs the service.

This will create the requested page, initializes it with the property values specified in the configuration, and executes the page.

Output
Exception

## runPage

protected void runPage | (TPage $page , array $properties )

Executes a page.

Input
TPage | $page | the page instance to be run
array | $properties | list of initial page properties
Output
Exception

## setBasePageClass

public void setBasePageClass | (string $value )

Sets the base page class name (in namespace format).

If a page only has a template file without page class file, this base page class will be instantiated.

Input
string | $value | class name
Output
Exception

## setBasePath

public void setBasePath | (string $value )

Input
string | $value | root directory (in namespace form) storing pages
Output
Exception
throws | TInvalidOperationException if the service is initialized already or basepath is invalid

## setDefaultPage

public void setDefaultPage | (string $value )

Input
string | $value | default page path to be served if no explicit page is request
Output
Exception
throws | TInvalidOperationException if the page service is initialized

## setTemplateManager

public void setTemplateManager | (TTemplateManager $value )

Input
TTemplateManager | $value | template manager
Output
Exception

## setThemeManager

public void setThemeManager | (TThemeManager $value )

Input
TThemeManager | $value | theme manager
Output
Exception

Constant Details

### CONFIG_CACHE_PREFIX

Prefix of ID used for storing parsed configuration in cache

#### Type:

string

#### Value:

'prado:pageservice:'

### CONFIG_FILE

Configuration file name

#### Type:

string

#### Value:

'config.xml'

### DEFAULT_BASEPATH

Default base path

#### Type:

string

#### Value:

'pages'

### PAGE_FILE_EXT

Page template file extension

#### Type:

string

#### Value:

'.page'