Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
PKPRouter Class Reference
Inheritance diagram for PKPRouter:
PKPComponentRouter PKPPageRouter PageRouter

Public Member Functions

 _authorizeInitializeAndCallRequest (&$serviceEndpoint, $request, &$args, $validate=true)
 _contextLevelToContextName ($contextLevel)
 _contextNameToContextLevel ($contextName)
 _urlCanonicalizeNewContext ($newContext)
 _urlFromParts ($baseUrl, $pathInfoArray=array(), $queryParametersArray=array(), $anchor= '', $escape=false)
 _urlGetAdditionalParameters ($request, $params=null, $escape=true)
 _urlGetBaseAndContext ($request, $newContext=array())
getApplication ()
 getCacheFilename ($request)
getContext ($request, $requestedContextLevel=1)
getContextByName ($request, $requestedContextName)
getDispatcher ()
 getIndexUrl ($request)
 getRequestedContextPath ($request, $requestedContextLevel=1)
 getRequestedContextPaths ($request)
 handleAuthorizationFailure ($request, $authorizationMessage)
 isCacheable ($request)
 PKPRouter ()
 route ($request)
 setApplication (&$application)
 setDispatcher ($dispatcher)
 supports ($request)
 url ($request, $newContext=null, $handler=null, $op=null, $path=null, $params=null, $anchor=null, $escape=false)

Public Attributes

 $_contextPaths = array()
 $_contexts = array()

Detailed Description

Basic router class that has functionality common to all routers.

See Also

NB: All handlers provide the common basic workflow. The router calls the following methods in the given order. 1) constructor: Handlers should establish a mapping of remote operations to roles that may access them. They do so by calling PKPHandler::addRoleAssignment(). 2) authorize(): Authorizes the request, among other things based on the result of the role assignment created during object instantiation. If authorization fails then die with a fatal error or execute the "call- on-deny" advice if one has been defined in the authorization policy that denied access. 3) validate(): Let the handler execute non-fatal data integrity checks (FIXME: currently only for component handlers). Please make sure that data integrity checks that can lead to denial of access are being executed in the authorize() step via authorization policies and not here. 4) initialize(): Let the handler initialize its internal state based on authorized and valid data. Authorization and integrity checks should be kept out of here to get a clear separation of concerns. 5) execution: Executes the requested handler operation. The mapping of requests to operations depends on the router implementation (see the class doc of specific router implementations for more details). 6) client response: Handlers should return a string value that will then be returned to the client as a response. Handler operations should not output the response directly to the client so that we can run filter operations on the output if required. Outputting text from handler operations to the client is possible but deprecated.

Definition at line 57 of file

Member Function Documentation

PKPRouter::_authorizeInitializeAndCallRequest ( $serviceEndpoint,
  $validate = true 

This is the method that implements the basic life-cycle of a handler request: 1) authorization 2) validation 3) initialization 4) execution 5) client response

$serviceEndpointcallable the handler operation
$validateboolean whether or not to execute the validation step.

Definition at line 371 of file

PKPRouter::_contextLevelToContextName (   $contextLevel)

Convert a context level to its corresponding context name.

string context name

Definition at line 613 of file

PKPRouter::_contextNameToContextLevel (   $contextName)

Convert a context name to its corresponding context level.

integer context level

Definition at line 623 of file

PKPRouter::_urlCanonicalizeNewContext (   $newContext)

Canonicalizes the new context.

A new context can be given as a scalar. In this case only the first context will be replaced. If the context depth of the current application is higher than one than the context can also be given as an array if more than the first context should be replaced. We therefore canonicalize the new context to an array.

When all entries are of the form 'contextName' => null or if $newContext == null then we'll return an empty array.

$newContextthe raw context array
array the canonicalized context array

Definition at line 426 of file

PKPRouter::_urlFromParts (   $baseUrl,
  $pathInfoArray = array(),
  $queryParametersArray = array(),
  $anchor = '',
  $escape = false 

Creates a valid URL from parts.

$baseUrlstring the protocol, domain and initial path/parameters, no anchors allowed here
$pathInfoArrayarray strings to be concatenated as path info
$queryParametersArrayarray strings to be concatenated as query string
$anchorstring an additional anchor
$escapeboolean whether to escape ampersands
string the URL

Definition at line 556 of file

PKPRouter::_urlGetAdditionalParameters (   $request,
  $params = null,
  $escape = true 

Build the additional parameters part of the URL.

$requestPKPRequest the request to be routed
$paramsarray (optional) the parameter list to be transformed to a url part.
$escapeboolean (optional) Whether or not to escape structural elements
array the encoded parameters or an empty array if no parameters were given.

Definition at line 529 of file

PKPRouter::_urlGetBaseAndContext (   $request,
  $newContext = array() 

Build the base URL and add the context part of the URL.

The new URL will be based on the current request's context if no new context is given.

The base URL for a given primary context can be overridden in the config file using the 'base_url[context]' syntax in the config file's 'general' section.

$requestPKPRequest the request to be routed
$newContextmixed (optional) context that differs from the current request's context
array An array consisting of the base url as the first entry and the context as the remaining entries.

Definition at line 461 of file

& PKPRouter::getApplication ( )

get the application


Definition at line 109 of file

PKPRouter::getCacheFilename (   $request)

Determine the filename to use for a local cache file.


Definition at line 309 of file

& PKPRouter::getContext (   $request,
  $requestedContextLevel = 1 

A Generic call to a context defining object (e.g. a Press, a Conference, or a SchedConf)

$requestPKPRequest the request to be routed
$requestedContextLevelint (optional) the desired context level

Definition at line 228 of file

& PKPRouter::getContextByName (   $request,

Get the object that represents the desired context (e.g. Conference or Press)

$requestPKPRequest the request to be routed
$requestedContextNamestring page context

Definition at line 267 of file

References HookRegistry\call().

& PKPRouter::getDispatcher ( )

get the dispatcher


Definition at line 131 of file

PKPRouter::getIndexUrl (   $request)

Get the URL to the index script.

$requestPKPRequest the request to be routed

Definition at line 287 of file

PKPRouter::getRequestedContextPath (   $request,
  $requestedContextLevel = 1 

A generic method to return a single context path (e.g. a Press or a SchedConf path)

$requestPKPRequest the request to be routed
$requestedContextLevelint (optional) the context level to return

Definition at line 208 of file

PKPRouter::getRequestedContextPaths (   $request)

A generic method to return an array of context paths (e.g. a Press or a Conference/SchedConf paths)

$requestPKPRequest the request to be routed
$requestedContextLevelint (optional) the context level to return in the path
array of string (each element the path to one context element)

Definition at line 170 of file

PKPRouter::handleAuthorizationFailure (   $request,

Handle an authorization failure.

$authorizationMessagestring a translation key with the authorization failure message.

Definition at line 347 of file

PKPRouter::isCacheable (   $request)

Determine whether or not this request is cacheable


Definition at line 159 of file

PKPRouter::PKPRouter ( )


Definition at line 102 of file

PKPRouter::route (   $request)

Routes a given request to a handler operation


Definition at line 318 of file

PKPRouter::setApplication ( $application)

set the application


Definition at line 118 of file

PKPRouter::setDispatcher (   $dispatcher)

set the dispatcher


Definition at line 140 of file

PKPRouter::supports (   $request)

Determines whether this router can route the given request.

boolean true, if the router supports this request, otherwise false

Definition at line 149 of file

PKPRouter::url (   $request,
  $newContext = null,
  $handler = null,
  $op = null,
  $path = null,
  $params = null,
  $anchor = null,
  $escape = false 

Build a handler request URL into PKPApplication.

$requestPKPRequest the request to be routed
$newContextmixed Optional contextual paths
$handlerstring Optional name of the handler to invoke
$opstring Optional name of operation to invoke
$pathmixed Optional string or array of args to pass to handler
$paramsarray Optional set of name => value pairs to pass as user parameters
$anchorstring Optional name of anchor to add to URL
$escapeboolean Whether or not to escape ampersands, square brackets, etc. for this URL; default false.
string the URL

Definition at line 335 of file

Member Data Documentation

integer PKPRouter::$_contextDepth

context depth

Definition at line 77 of file

integer PKPRouter::$_contextList

context list

Definition at line 82 of file

integer PKPRouter::$_contextPaths = array()

context paths

Definition at line 92 of file

integer PKPRouter::$_contexts = array()


Definition at line 97 of file

integer PKPRouter::$_flippedContextList

context list with keys and values flipped

Definition at line 87 of file

The documentation for this class was generated from the following file: