## Class TPageService

Description

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
- version: $Revision: $ $Date: $
- author: Qiang Xue <qiang.xue@gmail.com>

Located in /Web/Services/TPageService.php (line 76)

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

Class Constant Summary
CONFIG_CACHE_PREFIX = 'prado:pageservice:'
CONFIG_FILE = 'config.xml'
DEFAULT_BASEPATH = 'pages'
PAGE_FILE_EXT = '.page'
Method Summary
TPageService __construct ()
string constructUrl (string $pagePath, [array $getParams = null], [boolean $encodeAmpersand = false], [boolean $encodeGetItems = true])
string determineRequestedPagePath ()
string getBasePath ()
string getDefaultPage ()
TPage getRequestedPage ()
string getRequestedPagePath ()
TTemplateManager getTemplateManager ()
TThemeManager getThemeManager ()
void init (TXmlElement $config)
void initPageContext (TPageConfiguration $pageConfig)
TPageConfiguration loadPageConfig (string $pagePath, [TXmlElement $config = null])
void run ()
void setBasePath (string $value)
void setDefaultPage (string $value)
void setTemplateManager (TTemplateManager $value)
void setThemeManager (TThemeManager $value)
Methods
Constructor __construct (line 131)

Constructor.

Sets default service ID to 'page'.

- access: public

TPageService __construct ()
constructUrl (line 446)

Constructs a URL with specified page path and GET parameters.

- return: URL for the page and GET parameters
- access: public

string constructUrl (string $pagePath, [array $getParams = null], [boolean $encodeAmpersand = false], [boolean $encodeGetItems = true])

- 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 false.
- boolean $encodeGetItems: whether to encode the GET parameters (their names and values), defaults to true.

determineRequestedPagePath (line 211)

Determines the requested page path.

- return: page path requested
- access: protected

string determineRequestedPagePath ()
getBasePath (line 376)

- return: root directory (in namespace form) storing pages. Defaults to 'pages' directory under application base path.
- access: public

string getBasePath ()
getDefaultPage (line 356)

- return: default page path to be served if no explicit page is request. Defaults to 'Home'.
- access: public

string getDefaultPage ()
getRequestedPage (line 348)

- return: the requested page
- access: public

TPage getRequestedPage ()
getRequestedPagePath (line 334)

- return: the requested page path
- access: public

string getRequestedPagePath ()
getTemplateManager (line 292)

- return: template manager
- access: public

TTemplateManager getTemplateManager ()
getThemeManager (line 313)

- return: theme manager
- access: public

TThemeManager getThemeManager ()
init (line 141)

Initializes the service.

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

- access: public

void init (TXmlElement $config)

- TXmlElement $config: service configuration

Redefinition of:

TService::init()
  Initializes the service and attaches run to the RunService event of application.

initPageContext (line 161)

Initializes page context.

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

- access: protected

void initPageContext (TPageConfiguration $pageConfig)

- TPageConfiguration $pageConfig

loadPageConfig (line 225)

Collects configuration for a page.

- access: protected

TPageConfiguration loadPageConfig (string $pagePath, [TXmlElement $config = null])

- string $pagePath: page path in the format of Path.To.Page
- TXmlElement $config: additional configuration

run (line 405)

Runs the service.

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

- access: public

void run ()

Redefinition of:

TService::run()
  Runs the service.

setBasePath (line 391)

- access: public
- throws: TInvalidOperationException if the service is initialized already or basepath is invalid

void setBasePath (string $value)

- string $value: root directory (in namespace form) storing pages

setDefaultPage (line 365)

- access: public
- throws: TInvalidOperationException if the page service is initialized

void setDefaultPage (string $value)

- string $value: default page path to be served if no explicit page is request

setTemplateManager (line 305)

- access: public

void setTemplateManager (TTemplateManager $value)

- TTemplateManager $value: template manager

setThemeManager (line 326)

- access: public

void setThemeManager (TThemeManager $value)

- TThemeManager $value: theme manager

#### Inherited Methods

Inherited From TService

> TService::getID()
> TService::init()
> TService::run()
> TService::setID()

Inherited From TApplicationComponent

> TApplicationComponent::getApplication()
> TApplicationComponent::getRequest()
> TApplicationComponent::getResponse()
> TApplicationComponent::getService()
> TApplicationComponent::getSession()
> TApplicationComponent::getUser()
> TApplicationComponent::publishAsset()
> TApplicationComponent::publishFilePath()

Inherited From TComponent

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

Class Constants
CONFIG_CACHE_PREFIX = 'prado:pageservice:' (line 89)

Prefix of ID used for storing parsed configuration in cache

CONFIG_FILE = 'config.xml' (line 81)

Configuration file name

DEFAULT_BASEPATH = 'pages' (line 85)

Default base path

PAGE_FILE_EXT = '.page' (line 93)

Page template file extension

Documentation generated on Sun, 04 Jun 2006 19:00:02 -0400 by phpDocumentor 1.3.0RC4