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.

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

TComponent
   |
   --TApplicationComponent
      |
      --TService
         |
         --TPageService
Class Constant Summary
 CONFIG_CACHE_PREFIX = 'prado:pageservice:'
 CONFIG_FILE_PHP = 'config.php'
 CONFIG_FILE_XML = 'config.xml'
 DEFAULT_BASEPATH = 'Pages'
 FALLBACK_BASEPATH = 'pages'
 PAGE_FILE_EXT = '.page'
Method Summary
string constructUrl (string $pagePath, [array $getParams = null], [boolean $encodeAmpersand = true], [boolean $encodeGetItems = true])
TPage createPage (string $pagePath)
string getBasePageClass ()
string getBasePath ()
string getDefaultPage ()
string getDefaultPageUrl ()
void init (TXmlElement $config)
void initPageContext (TPageConfiguration $pageConfig)
void run ()
void runPage (TPage $page, array $properties)
void setBasePageClass (string $value)
void setBasePath (string $value)
void setClientScriptManagerClass (string $value)
void setDefaultPage (string $value)
void setTemplateManager ( $value)
void setThemeManager ( $value)
Methods
applyConfiguration (line 181)

Applies a page configuration.

  • access: protected
void applyConfiguration (TPageConfiguration $config)
constructUrl (line 535)

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.
createPage (line 480)

Creates a page instance based on requested page path.

  • return: the requested page instance
  • throws: TConfigurationException if the page class cannot be found
  • throws: THttpException if requested page path is invalid
  • access: protected
TPage createPage (string $pagePath)
  • string $pagePath: requested page path
determineRequestedPagePath (line 209)

Determines the requested page path.

  • return: page path requested
  • access: protected
string determineRequestedPagePath ()
getBasePageClass (line 437)
  • return: base page class name in namespace format. Defaults to 'TPage'.
  • access: public
string getBasePageClass ()
getBasePath (line 395)
  • return: the root directory for storing pages. Defaults to the 'pages' directory under the application base path.
  • access: public
string getBasePath ()
getClientScriptManagerClass (line 456)
  • return: clientscript manager class in namespace format. Defaults to 'System.Web.UI.TClientScriptManager'.
  • since: 3.1.7
  • access: public
string getClientScriptManagerClass ()
getDefaultPage (line 367)
  • return: default page path to be served if no explicit page is request. Defaults to 'Home'.
  • access: public
string getDefaultPage ()
getDefaultPageUrl (line 387)
  • return: the URL for the default page
  • access: public
string getDefaultPageUrl ()
getRequestedPage (line 359)
  • return: the requested page
  • access: public
TPage getRequestedPage ()
getRequestedPagePath (line 345)
  • return: the requested page path
  • access: public
string getRequestedPagePath ()
getTemplateManager (line 303)
  • return: template manager
  • access: public
TTemplateManager getTemplateManager ()
getThemeManager (line 324)
  • return: theme manager
  • access: public
TThemeManager getThemeManager ()
init (line 150)

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

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

Collects configuration for a page.

  • access: protected
TPageConfiguration loadPageConfig (TXmlElement $config)
  • TXmlElement $config: additional configuration specified in the application configuration
run (line 466)

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.
runPage (line 520)

Executes a page.

  • access: protected
void runPage (TPage $page, array $properties)
  • TPage $page: the page instance to be run
  • array $properties: list of initial page properties
setBasePageClass (line 429)

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 414)
  • throws: TInvalidOperationException if the service is initialized already or basepath is invalid
  • access: public
void setBasePath (string $value)
  • string $value: root directory (in namespace form) storing pages
setClientScriptManagerClass (line 447)

Sets the clientscript manager class (in namespace format).

  • since: 3.1.7
  • access: public
void setClientScriptManagerClass (string $value)
  • string $value: class name
setDefaultPage (line 376)
  • throws: TInvalidOperationException if the page service is initialized
  • access: public
void setDefaultPage (string $value)
  • string $value: default page path to be served if no explicit page is request
setTemplateManager (line 316)
  • access: public
void setTemplateManager ( $value)
setThemeManager (line 337)
  • access: public
void setThemeManager ( $value)

Inherited Methods

Inherited From TService

TService::getEnabled()
TService::getID()
TService::init()
TService::run()
TService::setEnabled()
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::__call()
TComponent::__get()
TComponent::__set()
TComponent::__sleep()
TComponent::__wakeup()
Class Constants
CONFIG_CACHE_PREFIX = 'prado:pageservice:' (line 98)

Prefix of ID used for storing parsed configuration in cache

CONFIG_FILE_PHP = 'config.php' (line 86)

Configuration file name

CONFIG_FILE_XML = 'config.xml' (line 82)

Configuration file name

DEFAULT_BASEPATH = 'Pages' (line 90)

Default base path

FALLBACK_BASEPATH = 'pages' (line 94)

Fallback base path - used to be the default up to Prado < 3.2

PAGE_FILE_EXT = '.page' (line 102)

Page template file extension

Documentation generated on Mon, 25 Jun 2012 14:38:51 +0200 by phpDocumentor 1.4.3