Open Journal Systems  3.3.0
PKPRequest Class Reference
Inheritance diagram for PKPRequest:
Request

Public Member Functions

_delegateToRouter ($method)
 
 checkCSRF ()
 
 encodeBasePathFragment ($fragment)
 
 getBasePath ()
 
 getBaseUrl ($allowProtocolRelative=false)
 
 getCompleteUrl ()
 
getContext ()
 
 getCookieVar ($key)
 
getDispatcher ()
 
 getIfModifiedSince ()
 
 getIndexUrl ()
 
 getProtocol ()
 
 getQueryArray ()
 
 getQueryString ()
 
 getRemoteAddr ()
 
 getRemoteDomain ()
 
 getRequestedArgs ()
 
 getRequestedContextPath ($contextLevel=null)
 
 getRequestedOp ()
 
 getRequestedPage ()
 
 getRequestMethod ()
 
 getRequestPath ()
 
 getRequestUrl ()
 
getRouter ()
 
 getServerHost ($default=null, $includePort=true)
 
getSession ()
 
getSite ()
 
getUser ()
 
 getUserAgent ()
 
 getUserDateVar ($prefix, $defaultDay=null, $defaultMonth=null, $defaultYear=null, $defaultHour=0, $defaultMinute=0, $defaultSecond=0)
 
 getUserVar ($key)
 
getUserVars ()
 
 isBot ()
 
 isGet ()
 
 isPathInfoEnabled ()
 
 isPost ()
 
 isRestfulUrlsEnabled ()
 
 redirect ($context=null, $page=null, $op=null, $path=null, $params=null, $anchor=null)
 
 redirectNonSSL ()
 
 redirectSSL ()
 
 redirectUrl ($url)
 
 redirectUrlJson ($url)
 
 setCookieVar ($key, $value, $expire=0)
 
 setDispatcher ($dispatcher)
 
 setRouter ($router)
 
 url ($context=null, $page=null, $op=null, $path=null, $params=null, $anchor=null, $escape=false)
 

Data Fields

 $_basePath
 
 $_dispatcher = null
 
 $_isBot
 
 $_isPathInfoEnabled
 
 $_isRestfulUrlsEnabled
 
 $_protocol
 
 $_requestPath
 
 $_requestVars = null
 
 $_router = null
 
 $_serverHost
 
 $_userAgent
 

Detailed Description

Class providing operations associated with HTTP requests.

Definition at line 17 of file PKPRequest.inc.php.

Member Function Documentation

◆ _delegateToRouter()

& PKPRequest::_delegateToRouter (   $method)

This method exists to maintain backwards compatibility with calls to methods that have been factored into the Router implementations.

It delegates the call to the router and returns the result.

NB: This method is protected and may not be used by external classes. It should also only be used in legacy methods.

Returns
mixed depends on the called method

Definition at line 765 of file PKPRequest.inc.php.

References getRouter().

Referenced by Request\getContext(), getContext(), Request\getContextByName(), getIndexUrl(), Request\getJournal(), getRequestedArgs(), Request\getRequestedContextPath(), getRequestedContextPath(), Request\getRequestedJournalPath(), getRequestedOp(), getRequestedPage(), Request\redirectHome(), Request\url(), and url().

◆ checkCSRF()

PKPRequest::checkCSRF ( )

Determine whether a CSRF token is present and correct.

Returns
boolean

Definition at line 418 of file PKPRequest.inc.php.

References getSession(), and getUserVar().

◆ encodeBasePathFragment()

PKPRequest::encodeBasePathFragment (   $fragment)

Callback function for getBasePath() to correctly encode (or not encode) a basepath fragment.

Parameters
string$fragment
Returns
string

Definition at line 240 of file PKPRequest.inc.php.

◆ getBasePath()

PKPRequest::getBasePath ( )

Get the base path of the request (excluding trailing slash).

Returns
string

Definition at line 205 of file PKPRequest.inc.php.

References $_basePath, and HookRegistry\call().

Referenced by getBaseUrl(), getRequestPath(), and setCookieVar().

◆ getBaseUrl()

PKPRequest::getBaseUrl (   $allowProtocolRelative = false)

Get the base URL of the request (excluding script).

Parameters
$allowProtocolRelativeboolean True iff protocol-relative URLs are allowed
Returns
string

Definition at line 184 of file PKPRequest.inc.php.

References HookRegistry\call(), getBasePath(), getProtocol(), getServerHost(), and Config\getVar().

◆ getCompleteUrl()

PKPRequest::getCompleteUrl ( )

Get the complete URL to this page, including parameters.

Returns
string

Definition at line 268 of file PKPRequest.inc.php.

References HookRegistry\call(), getQueryString(), and getRequestUrl().

◆ getContext()

& PKPRequest::getContext ( )

Get the current "context" (press/journal/etc) object.

Returns
Context
See also
PKPPageRouter::getContext()

Definition at line 700 of file PKPRequest.inc.php.

References _delegateToRouter().

◆ getCookieVar()

PKPRequest::getCookieVar (   $key)

Get the value of a cookie variable.

Returns
mixed

Definition at line 658 of file PKPRequest.inc.php.

◆ getDispatcher()

& PKPRequest::getDispatcher ( )

Get the dispatcher

Returns
Dispatcher

Definition at line 116 of file PKPRequest.inc.php.

References $_dispatcher.

Referenced by redirect().

◆ getIfModifiedSince()

PKPRequest::getIfModifiedSince ( )

Get the IF_MODIFIED_SINCE date (as a numerical timestamp) if available

Returns
int

Definition at line 174 of file PKPRequest.inc.php.

◆ getIndexUrl()

PKPRequest::getIndexUrl ( )

Deprecated

See also
PKPPageRouter::getIndexUrl()

Definition at line 251 of file PKPRequest.inc.php.

References _delegateToRouter(), and HookRegistry\call().

◆ getProtocol()

PKPRequest::getProtocol ( )

Get the protocol used for the request (HTTP or HTTPS).

Returns
string

Definition at line 382 of file PKPRequest.inc.php.

References $_protocol, HookRegistry\call(), and strtolower_codesafe().

Referenced by getBaseUrl(), and getRequestUrl().

◆ getQueryArray()

PKPRequest::getQueryArray ( )

Get the complete set of URL parameters to the current request as an associative array. (Excludes reserved parameters, such as "path", which are used by disable_path_info mode.)

Returns
array

Definition at line 317 of file PKPRequest.inc.php.

References Application\getContextList(), and getQueryString().

◆ getQueryString()

PKPRequest::getQueryString ( )

Get the complete set of URL parameters to the current request.

Returns
string

Definition at line 300 of file PKPRequest.inc.php.

References HookRegistry\call().

Referenced by getCompleteUrl(), and getQueryArray().

◆ getRemoteAddr()

PKPRequest::getRemoteAddr ( )

Get the remote IP address of the current request.

Returns
string

Definition at line 427 of file PKPRequest.inc.php.

References HookRegistry\call(), Registry\get(), and Config\getVar().

Referenced by getRemoteDomain().

◆ getRemoteDomain()

PKPRequest::getRemoteDomain ( )

Get the remote domain of the current request

Returns
string

Definition at line 453 of file PKPRequest.inc.php.

References HookRegistry\call(), and getRemoteAddr().

◆ getRequestedArgs()

PKPRequest::getRequestedArgs ( )

Deprecated

See also
PKPPageRouter::getRequestedArgs()

Definition at line 738 of file PKPRequest.inc.php.

References _delegateToRouter().

◆ getRequestedContextPath()

PKPRequest::getRequestedContextPath (   $contextLevel = null)

Deprecated

See also
PKPPageRouter::getRequestedContextPath()

Reimplemented in Request.

Definition at line 708 of file PKPRequest.inc.php.

References _delegateToRouter().

◆ getRequestedOp()

PKPRequest::getRequestedOp ( )

Deprecated

See also
PKPPageRouter::getRequestedOp()

Definition at line 730 of file PKPRequest.inc.php.

References _delegateToRouter().

◆ getRequestedPage()

PKPRequest::getRequestedPage ( )

Deprecated

See also
PKPPageRouter::getRequestedPage()

Definition at line 722 of file PKPRequest.inc.php.

References _delegateToRouter().

◆ getRequestMethod()

PKPRequest::getRequestMethod ( )

Get the request method

Returns
string

Definition at line 394 of file PKPRequest.inc.php.

Referenced by isGet(), and isPost().

◆ getRequestPath()

PKPRequest::getRequestPath ( )

Get the completed path of the request.

Returns
string

Definition at line 337 of file PKPRequest.inc.php.

References $_requestPath, HookRegistry\call(), getBasePath(), isPathInfoEnabled(), and isRestfulUrlsEnabled().

Referenced by getRequestUrl().

◆ getRequestUrl()

PKPRequest::getRequestUrl ( )

Get the complete URL of the request.

Returns
string

Definition at line 285 of file PKPRequest.inc.php.

References HookRegistry\call(), getProtocol(), getRequestPath(), and getServerHost().

Referenced by getCompleteUrl().

◆ getRouter()

& PKPRequest::getRouter ( )

get the router instance

Returns
PKPRouter

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

References $_router.

Referenced by _delegateToRouter(), getUser(), and getUserVar().

◆ getServerHost()

PKPRequest::getServerHost (   $default = null,
  $includePort = true 
)

Get the server hostname in the request.

Parameters
$defaultstring Default hostname (defaults to localhost)
$includePortboolean Whether to include non-standard port number; default true
Returns
string

Definition at line 359 of file PKPRequest.inc.php.

References $_serverHost, and HookRegistry\call().

Referenced by getBaseUrl(), getRequestUrl(), redirectNonSSL(), and redirectSSL().

◆ getSession()

& PKPRequest::getSession ( )

Get the user session associated with the current request.

Returns
Session

Definition at line 535 of file PKPRequest.inc.php.

References Registry\get(), and SessionManager\getManager().

Referenced by checkCSRF().

◆ getSite()

& PKPRequest::getSite ( )

Get site data.

Returns
Site

Definition at line 519 of file PKPRequest.inc.php.

References Registry\get(), DAORegistry\getDAO(), and Registry\set().

◆ getUser()

& PKPRequest::getUser ( )

Get the user associated with the current request.

Returns
User

Definition at line 550 of file PKPRequest.inc.php.

References Registry\get(), DAORegistry\getDAO(), SessionManager\getManager(), and getRouter().

◆ getUserAgent()

PKPRequest::getUserAgent ( )

Get the user agent of the current request.

Returns
string

Definition at line 467 of file PKPRequest.inc.php.

References $_userAgent, and HookRegistry\call().

Referenced by isBot().

◆ getUserDateVar()

PKPRequest::getUserDateVar (   $prefix,
  $defaultDay = null,
  $defaultMonth = null,
  $defaultYear = null,
  $defaultHour = 0,
  $defaultMinute = 0,
  $defaultSecond = 0 
)

Get the value of a GET/POST variable generated using the Smarty html_select_date and/or html_select_time function.

Parameters
$prefixstring
$defaultDayint
$defaultMonthint
$defaultYearint
$defaultHourint
$defaultMinuteint
$defaultSecondint
Returns
Date

Definition at line 625 of file PKPRequest.inc.php.

References getUserVar().

◆ getUserVar()

PKPRequest::getUserVar (   $key)

Get the value of a GET/POST variable.

Returns
mixed

Definition at line 578 of file PKPRequest.inc.php.

References getRouter(), and getUserVars().

Referenced by checkCSRF(), and getUserDateVar().

◆ getUserVars()

& PKPRequest::getUserVars ( )

Get all GET/POST variables as an array

Returns
array

Definition at line 603 of file PKPRequest.inc.php.

References $_requestVars.

Referenced by getUserVar().

◆ isBot()

PKPRequest::isBot ( )

Determine whether the user agent is a bot or not.

Returns
boolean

Definition at line 487 of file PKPRequest.inc.php.

References $_isBot, getUserAgent(), and Core\isUserAgentBot().

◆ isGet()

PKPRequest::isGet ( )

Determine whether the request is a GET request

Returns
boolean

Definition at line 410 of file PKPRequest.inc.php.

References getRequestMethod().

◆ isPathInfoEnabled()

PKPRequest::isPathInfoEnabled ( )

Return true if PATH_INFO is enabled.

Definition at line 498 of file PKPRequest.inc.php.

References $_isPathInfoEnabled, and Config\getVar().

Referenced by getRequestPath().

◆ isPost()

PKPRequest::isPost ( )

Determine whether the request is a POST request

Returns
boolean

Reimplemented in Request.

Definition at line 402 of file PKPRequest.inc.php.

References getRequestMethod().

◆ isRestfulUrlsEnabled()

PKPRequest::isRestfulUrlsEnabled ( )

Return true if RESTFUL_URLS is enabled.

Definition at line 508 of file PKPRequest.inc.php.

References $_isRestfulUrlsEnabled, and Config\getVar().

Referenced by getRequestPath().

◆ redirect()

PKPRequest::redirect (   $context = null,
  $page = null,
  $op = null,
  $path = null,
  $params = null,
  $anchor = null 
)

Redirect to the specified page within a PKP Application. Shorthand for a common call to $request->redirect($dispatcher->url($request, ROUTE_PAGE, ...)).

Parameters
$contextArray The optional contextual paths
$pagestring The name of the op to redirect to.
$opstring optional The name of the op to redirect to.
$pathmixed string or array containing path info for redirect.
$paramsarray Map of name => value pairs for additional parameters
$anchorstring Name of desired anchor on the target page

Definition at line 690 of file PKPRequest.inc.php.

References $op, getDispatcher(), and redirectUrl().

◆ redirectNonSSL()

PKPRequest::redirectNonSSL ( )

Redirect to the current URL, forcing the HTTP protocol to be used.

Definition at line 161 of file PKPRequest.inc.php.

References getServerHost(), and redirectUrl().

◆ redirectSSL()

PKPRequest::redirectSSL ( )

Redirect to the current URL, forcing the HTTPS protocol to be used.

Definition at line 149 of file PKPRequest.inc.php.

References getServerHost(), and redirectUrl().

◆ redirectUrl()

PKPRequest::redirectUrl (   $url)

Perform an HTTP redirect to an absolute or relative (to base system URL) URL.

Parameters
$urlstring (exclude protocol for local redirects)

Definition at line 125 of file PKPRequest.inc.php.

References HookRegistry\call().

Referenced by redirect(), redirectNonSSL(), and redirectSSL().

◆ redirectUrlJson()

PKPRequest::redirectUrlJson (   $url)

Request an HTTP redirect via JSON to be used from components.

Parameters
$urlstring
Returns
JSONMessage

Definition at line 139 of file PKPRequest.inc.php.

◆ setCookieVar()

PKPRequest::setCookieVar (   $key,
  $value,
  $expire = 0 
)

Set a cookie variable.

Parameters
$keystring
$valuemixed
$expireint (optional)

Definition at line 672 of file PKPRequest.inc.php.

References getBasePath().

◆ setDispatcher()

PKPRequest::setDispatcher (   $dispatcher)

Set the dispatcher

Parameters
$dispatcherDispatcher

Definition at line 108 of file PKPRequest.inc.php.

◆ setRouter()

PKPRequest::setRouter (   $router)

set the router instance

Parameters
$routerinstance PKPRouter

Definition at line 100 of file PKPRequest.inc.php.

◆ url()

PKPRequest::url (   $context = null,
  $page = null,
  $op = null,
  $path = null,
  $params = null,
  $anchor = null,
  $escape = false 
)

Deprecated

See also
PKPPageRouter::url()

Reimplemented in Request.

Definition at line 746 of file PKPRequest.inc.php.

References $op, and _delegateToRouter().

Field Documentation

◆ $_basePath

string PKPRequest::$_basePath

request base path

Definition at line 43 of file PKPRequest.inc.php.

Referenced by getBasePath().

◆ $_dispatcher

Dispatcher PKPRequest::$_dispatcher = null

dispatcher instance used to dispatch this request

Definition at line 31 of file PKPRequest.inc.php.

Referenced by getDispatcher().

◆ $_isBot

boolean PKPRequest::$_isBot

bot flag

Definition at line 79 of file PKPRequest.inc.php.

Referenced by isBot().

◆ $_isPathInfoEnabled

boolean PKPRequest::$_isPathInfoEnabled

true if path info is enabled for this server

Definition at line 61 of file PKPRequest.inc.php.

Referenced by isPathInfoEnabled().

◆ $_isRestfulUrlsEnabled

boolean PKPRequest::$_isRestfulUrlsEnabled

true if restful URLs are enabled in the config

Definition at line 55 of file PKPRequest.inc.php.

Referenced by isRestfulUrlsEnabled().

◆ $_protocol

string PKPRequest::$_protocol

request protocol

Definition at line 73 of file PKPRequest.inc.php.

Referenced by getProtocol().

◆ $_requestPath

string PKPRequest::$_requestPath

request path

Definition at line 49 of file PKPRequest.inc.php.

Referenced by getRequestPath().

◆ $_requestVars

array PKPRequest::$_requestVars = null

the request variables cache (GET/POST)

Definition at line 37 of file PKPRequest.inc.php.

Referenced by getUserVars().

◆ $_router

PKPRouter PKPRequest::$_router = null

router instance used to route this request

Definition at line 25 of file PKPRequest.inc.php.

Referenced by getRouter().

◆ $_serverHost

string PKPRequest::$_serverHost

server host

Definition at line 67 of file PKPRequest.inc.php.

Referenced by getServerHost().

◆ $_userAgent

string PKPRequest::$_userAgent

user agent

Definition at line 85 of file PKPRequest.inc.php.

Referenced by getUserAgent().


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