Show:

Q_Request Class

Module: Q

Functions for dealing with a web server request

Item Index

Methods

Properties

Methods

accepts

() Array static

Used to find out what languages are accepted by the user agent, by analyzing the Accepts-Language header. May also get locale information.

Returns:

Array:

returns array of array("en", "US", 0.8) entries

accepts

() Boolean static

Used to find out whether a given mime type is accepted by the client

Returns:

Boolean:

baseUrl

(
  • [$withPossibleController=false]
  • [$canonical=false]
)
static

Get the base URL, possibly with a controller script

Parameters:

  • [$withPossibleController=false] Boolean optional

    If this is true, and if the URL contains the controller script, then the controller script is included in the return value. You can also pass a string here, which will then be simply appended as the controller.

  • [$canonical=false] Boolean optional

    Pass true here to just use the canonical info specified in the "Q"/"web" config.

cacheTimestamp

() Boolean static

Used by the system to find out the last timestamp a cache was generated, so it can be used instead of the actual files.

Returns:

Boolean:

callback

() String static

The name of the callback that was specified, if any

Returns:

String:

contentToEcho

() Array static

Returns:

Array:

filename

() String static

Returns:

String:

formFactor

() String static

Returns the form factor based on the user agent

Returns:

String:

can be either 'mobile', 'tablet', or 'desktop'

getAppRootUrl

() String protected static

Gets the app root url

Returns:

String:

inferControllerUrl

(
  • $script_name
)
String protected static

Infers the base URL, with possible controller

Parameters:

  • $script_name &string

Returns:

String:

isAjax

() String static

Use this to determine whether or not it the request is an "AJAX" request, and is not expecting a full document layout.

Returns:

String:

The contents of Q.ajax if it is present.

isAndroidStock

() Boolean static

Detects whether the request is coming from an Internet Explorer browser

Returns:

Boolean:

isCordova

() String | Boolean static

Detects whether the request is coming from a WebView enabled with Cordova

Returns:

String | Boolean:

The version of the cordova, or false if not cordova.

isIE

(
  • [$min_version=0]
  • [$max_version=0]
)
Boolean static

Detects whether the request is coming from an Internet Explorer browser

Parameters:

  • [$min_version=0] Number optional

    optional minimum version of IE to check (major number like 7, 8, 9 etc). If provided, the method will return true only if the browser is IE and the major version is greater or equal than $min_version.

  • [$max_version=0] Number optional

    optional maximum version of IE to check (major number like 7, 8, 9 etc). If provided, the method will return true only if the browser is IE and the major version is less or equal than $max_version.

Returns:

Boolean:

isLoadExtras

() String static

Use this to determine whether or not it the request is an "loadExtras" request, and is expecting responseExtras.

Returns:

String:

The contents of Q.loadExtras if it is present.

isMobile

() Boolean static

Detects whether the request is coming from a mobile browser

Returns:

Boolean:

isTablet

() Boolean static

Detects whether the request is coming from a tablet browser

Returns:

Boolean:

isTouchscreen

() Boolean static

Detects whether the request is coming from a browser which supports touch events

Returns:

Boolean:

isWebView

() Boolean static

Detects whether the request is coming from a WebView on a mobile browser

Returns:

Boolean:

locale

(
  • [$separator='_']
)
String static

Gets the locale of the user agent in the form "en_GB" etc.

Parameters:

  • [$separator='_'] String optional

    The separator to use

Returns:

String:

The locale

method

() String static

Use this to determine what method to treat the request as.

Returns:

String:

Returns an uppercase string such as "GET", "POST", "PUT", "DELETE"

See Request methods

platform

() String static

Returns a string identifying user browser's platform.

Returns:

String:

proxyBaseUrl

(
  • [$withPossibleController=false]
)
static

Returns the base URL, run through a proxy

Parameters:

  • [$withPossibleController=false] Boolean optional

    If this is true, and if the URL contains the controller script, then the controller script is included in the base url. You can also pass a string here, which will then be simply appended as the controller.

requireFields

(
  • $fields
  • [$throwIfMissing=false]
)
Array static

Convenience method to apply certain criteria to an array. and call Q_Response::addError for each one.

Parameters:

  • $fields Array

    Array of strings or arrays naming fields that are required

  • [$throwIfMissing=false] Boolean optional

    Whether to throw an exception if the field is missing

Returns:

Array:

The resulting list of exceptions

requireValidNonce

() static

Used called internally, by event handlers to see if the requested URI requires a valid nonce to be submitted, to prevent CSRF attacks.

slotNames

(
  • [$returnDefaults=false]
)
Array static

The names of slots that were requested, if any

Parameters:

  • [$returnDefaults=false] Boolean optional

    If set to true, returns the array of slot names set in config field named Q/response/$app/slotNames in the event that slotNames was not specified at all in the request.

Returns:

Array:

slotNames

(
  • $slotName
)
Boolean static

Returns whether a given slot name was requested.

Parameters:

  • $slotName String

    The name of the slot

Returns:

Boolean:

special

(
  • name
  • $default
  • [$source=null]
)
Mixed | Null static

Gets all the names of the fields with no value or equal

Parameters:

  • name String | Array | Object

    The name of the field. If it's an array, returns an object of {name: value} pairs. If it's an object, then they are added onto the querystring and the result is returned. If it's a string, it's the name of the field to get. And if it's an empty string, then we get the array of field names with no value, e.g. ?123&456&a=b returns array(123,456)

  • $default Mixed

    what to return if field is missing

  • [$source=null] String optional

    optionally provide an array to use instead of $_REQUEST

Returns:

Mixed | Null:

special

(
  • $fieldname
  • $default
  • [$source=null]
)
Mixed | Null static

Gets a field passed in special a part of the request

Parameters:

  • $fieldname String

    the name of the field, which can be namespaced as "Module.fieldname"

  • $default Mixed

    optionally what to return if field is missing

  • [$source=null] String optional

    optionally provide an array to use instead of $_REQUEST

Returns:

Mixed | Null:

tail

(
  • [$url=Q_Request::url()]
)
String static

Get just the part of the URL after the Q_Request::baseUrl() and slash

Parameters:

  • [$url=Q_Request::url()] String optional

    Defaults to the currently requested url

Returns:

String:

updateTimestamp

() Boolean static

Used by the system to find out the last timestamp an update of urls was loaded by the client.

Returns:

Boolean:

uri

() Q_Uri static

Get combination of module/action from URL

Returns:

url

(
  • [$queryFields=array()]
)
String static

Get the URL that was requested, possibly with a querystring

Parameters:

  • [$queryFields=array()] Mixed optional

    If true, includes the entire querystring as requested. If a string, appends the querystring correctly to the current URL. If an associative array, adds these fields, with their values to the existing querystring, while subtracting the fields corresponding to null values in $query. (For null values, the key is used as a regular expression that matches all the fields to subtract.) Then generates a querystring and includes it with the URL.

Returns:

String:

Returns the URL that was requested, possibly with a querystring.

version

() String static

Returns a string identifying user platform version.

Returns:

String:

Properties

$app_root_url

String static

$base_url

String static

$controller_present

String static

$controller_url

String static

$method_override

String static

$slotNames_override

String static

$uri

String static

$url

String static

Events

Q/request/accepts

Before

Event Payload:

  • mimeType String

Q/request/isAjax

Before

Q/request/isLoadExtras

Before

Q/request/isMobile

Before

Q/request/isTablet

Before

Q/request/isWebView

Before

Q/request/languages

Before

Q/request/method

Before