Open Journal Systems  2.4.3
 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)
 
 route (&$request)
 
 setApplication (&$application)
 
 setDispatcher (&$dispatcher)
 
 supports (&$request)
 
 url (&$request, $newContext=null, $handler=null, $op=null, $path=null, $params=null, $anchor=null, $escape=false)
 

Detailed Description

Basic router class that has functionality common to all routers.

See Also
PKPPageRouter
PKPComponentRouter

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 PKPRouter.inc.php.

Member Function Documentation

PKPRouter::_authorizeInitializeAndCallRequest ( $serviceEndpoint,
$request,
$args,
  $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

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

Definition at line 345 of file PKPRouter.inc.php.

References getDispatcher(), and handleAuthorizationFailure().

Referenced by PKPPageRouter\route(), and PKPComponentRouter\route().

PKPRouter::_contextLevelToContextName (   $contextLevel)

Convert a context level to its corresponding context name.

Parameters
$contextLevelinteger
Returns
string context name

Definition at line 564 of file PKPRouter.inc.php.

Referenced by getContext().

PKPRouter::_contextNameToContextLevel (   $contextName)

Convert a context name to its corresponding context level.

Parameters
$contextNamestring
Returns
integer context level

Definition at line 574 of file PKPRouter.inc.php.

Referenced by getContextByName().

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.

Parameters
$newContextthe raw context array
Returns
array the canonicalized context array

Definition at line 395 of file PKPRouter.inc.php.

Referenced by PKPPageRouter\url(), and PKPComponentRouter\url().

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

Creates a valid URL from parts.

Parameters
$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
Returns
string the URL

Definition at line 517 of file PKPRouter.inc.php.

Referenced by PKPPageRouter\url(), and PKPComponentRouter\url().

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

Build the additional parameters part of the URL.

Parameters
$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
Returns
array the encoded parameters or an empty array if no parameters were given.

Definition at line 490 of file PKPRouter.inc.php.

Referenced by PKPPageRouter\url(), and PKPComponentRouter\url().

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.

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

Definition at line 430 of file PKPRouter.inc.php.

References getContextByName(), getIndexUrl(), and Config\getVar().

Referenced by PKPPageRouter\url(), and PKPComponentRouter\url().

& PKPRouter::getApplication ( )
PKPRouter::getCacheFilename ( $request)

Determine the filename to use for a local cache file.

Parameters
$requestPKPRequest
Returns
string

Definition at line 283 of file PKPRouter.inc.php.

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

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

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

Definition at line 202 of file PKPRouter.inc.php.

References _contextLevelToContextName(), DAORegistry\getDAO(), and getRequestedContextPath().

Referenced by getContextByName(), and PageRouter\redirectHome().

& PKPRouter::getContextByName ( $request,
  $requestedContextName 
)

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

Parameters
$requestPKPRequest the request to be routed
$requestedContextNamestring page context
Returns
object

Definition at line 241 of file PKPRouter.inc.php.

References _contextNameToContextLevel(), and getContext().

Referenced by _urlGetBaseAndContext().

& PKPRouter::getDispatcher ( )

get the dispatcher

Returns
Dispatcher

Definition at line 105 of file PKPRouter.inc.php.

Referenced by _authorizeInitializeAndCallRequest(), and PKPPageRouter\route().

PKPRouter::getIndexUrl ( $request)

Get the URL to the index script.

Parameters
$requestPKPRequest the request to be routed
Returns
string

Definition at line 261 of file PKPRouter.inc.php.

References HookRegistry\call().

Referenced by _urlGetBaseAndContext().

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

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

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

Definition at line 182 of file PKPRouter.inc.php.

References getRequestedContextPaths().

Referenced by getContext().

PKPRouter::getRequestedContextPaths ( $request)

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

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

Definition at line 144 of file PKPRouter.inc.php.

References HookRegistry\call(), and Core\getContextPaths().

Referenced by getRequestedContextPath().

PKPRouter::handleAuthorizationFailure (   $request,
  $authorizationMessage 
)

Handle an authorization failure.

Parameters
$requestRequest
$authorizationMessagestring a translation key with the authorization failure message.

Definition at line 321 of file PKPRouter.inc.php.

Referenced by _authorizeInitializeAndCallRequest().

PKPRouter::isCacheable ( $request)

Determine whether or not this request is cacheable

Parameters
$requestPKPRequest
Returns
boolean

Definition at line 133 of file PKPRouter.inc.php.

PKPRouter::route ( $request)

Routes a given request to a handler operation

Parameters
$requestPKPRequest

Definition at line 292 of file PKPRouter.inc.php.

PKPRouter::setApplication ( $application)

set the application

Parameters
$applicationPKPApplication

Definition at line 92 of file PKPRouter.inc.php.

PKPRouter::setDispatcher ( $dispatcher)

set the dispatcher

Parameters
$dispatcherPKPDispatcher

Definition at line 114 of file PKPRouter.inc.php.

PKPRouter::supports ( $request)

Determines whether this router can route the given request.

Parameters
$requestPKPRequest
Returns
boolean true, if the router supports this request, otherwise false

Definition at line 123 of file PKPRouter.inc.php.

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

Build a handler request URL into PKPApplication.

Parameters
$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.
Returns
string the URL

Definition at line 309 of file PKPRouter.inc.php.


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