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:

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: $Id: TPageService.php 1490 2006-11-04 03:33:00Z xue $
  • 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 = true], [boolean $encodeGetItems = true])
string getBasePageClass ()
string getBasePath ()
string getDefaultPage ()
void init (TXmlElement $config)
void initPageContext (TPageConfiguration $pageConfig)
TPageConfiguration loadPageConfig (string $pagePath, [TXmlElement $config = null])
void run ()
void setBasePageClass (string $value)
void setBasePath (string $value)
void setDefaultPage (string $value)
void setTemplateManager (TTemplateManager $value)
void setThemeManager (TThemeManager $value)
Methods
Constructor __construct (line 135)

Constructor.

Sets default service ID to 'page'.

  • access: public
TPageService __construct ()
constructUrl (line 469)

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 = true], [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 true.
  • boolean $encodeGetItems: whether to encode the GET parameters (their names and values), defaults to true.
determineRequestedPagePath (line 215)

Determines the requested page path.

  • return: page path requested
  • access: protected
string determineRequestedPagePath ()
getBasePageClass (line 418)
  • return: base page class name in namespace format. Defaults to 'TPage'.
  • access: public
string getBasePageClass ()
getBasePath (line 380)
  • return: the root directory for storing pages. Defaults to the 'pages' directory under the application base path.
  • access: public
string getBasePath ()
getDefaultPage (line 360)
  • return: default page path to be served if no explicit page is request. Defaults to 'Home'.
  • access: public
string getDefaultPage ()
getRequestedPage (line 352)
  • return: the requested page
  • access: public
TPage getRequestedPage ()
getRequestedPagePath (line 338)
  • return: the requested page path
  • access: public
string getRequestedPagePath ()
getTemplateManager (line 296)
  • return: template manager
  • access: public
TTemplateManager getTemplateManager ()
getThemeManager (line 317)
  • return: theme manager
  • access: public
TThemeManager getThemeManager ()
init (line 145)

Initializes the service.

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

  • access: public
void init (TXmlElement $config)

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

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)
loadPageConfig (line 229)

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 428)

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.
setBasePageClass (line 410)

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.

  • access: public
void setBasePageClass (string $value)
  • string $value: class name
setBasePath (line 395)
  • 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 369)
  • 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 309)
  • access: public
void setTemplateManager (TTemplateManager $value)
setThemeManager (line 330)
  • access: public
void setThemeManager (TThemeManager $value)

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::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()
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, 14 Jan 2007 21:43:47 -0500 by phpDocumentor 1.3.0RC4