Q_Request Class
Functions for dealing with a web server request
Item Index
Methods
- accepts static
- accepts static
- baseUrl static
- cacheTimestamp static
- callback static
- contentToEcho static
- filename static
- formFactor static
- getAppRootUrl static
- inferControllerUrl static
- isAjax static
- isAndroidStock static
- isCordova static
- isIE static
- isLoadExtras static
- isMobile static
- isTablet static
- isTouchscreen static
- isWebView static
- locale static
- method static
- platform static
- proxyBaseUrl static
- requireFields static
- requireValidNonce static
- slotNames static
- slotNames static
- special static
- special static
- tail static
- updateTimestamp static
- uri static
- url static
- version static
Properties
- $app_root_url static
- $base_url static
- $controller_present static
- $controller_url static
- $method_override static
- $slotNames_override static
- $uri static
- $url static
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:
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:
baseUrl
-
[$withPossibleController=false]
-
[$canonical=false]
Get the base URL, possibly with a controller script
Parameters:
-
[$withPossibleController=false]
Boolean optionalIf 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 optionalPass 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:
callback
()
String
static
The name of the callback that was specified, if any
Returns:
contentToEcho
()
Array
static
Returns:
filename
()
String
static
Returns:
formFactor
()
String
static
Returns the form factor based on the user agent
Returns:
can be either 'mobile', 'tablet', or 'desktop'
getAppRootUrl
()
String
protected
static
Gets the app root url
Returns:
inferControllerUrl
-
$script_name
Infers the base URL, with possible controller
Parameters:
-
$script_name
&string
Returns:
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:
The contents of Q.ajax
if it is present.
isAndroidStock
()
Boolean
static
Detects whether the request is coming from an Internet Explorer browser
Returns:
isCordova
()
String | Boolean
static
Detects whether the request is coming from a WebView enabled with Cordova
Returns:
The version of the cordova, or false if not cordova.
isIE
-
[$min_version=0]
-
[$max_version=0]
Detects whether the request is coming from an Internet Explorer browser
Parameters:
-
[$min_version=0]
Number optionaloptional 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 optionaloptional 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:
isLoadExtras
()
String
static
Use this to determine whether or not it the request is an "loadExtras" request, and is expecting responseExtras.
Returns:
The contents of Q.loadExtras
if it is present.
isMobile
()
Boolean
static
Detects whether the request is coming from a mobile browser
Returns:
isTablet
()
Boolean
static
Detects whether the request is coming from a tablet browser
Returns:
isTouchscreen
()
Boolean
static
Detects whether the request is coming from a browser which supports touch events
Returns:
isWebView
()
Boolean
static
Detects whether the request is coming from a WebView on a mobile browser
Returns:
locale
-
[$separator='_']
Gets the locale of the user agent in the form "en_GB" etc.
Parameters:
-
[$separator='_']
String optionalThe separator to use
Returns:
The locale
method
()
String
static
Use this to determine what method to treat the request as.
Returns:
platform
()
String
static
Returns a string identifying user browser's platform.
Returns:
proxyBaseUrl
-
[$withPossibleController=false]
Returns the base URL, run through a proxy
Parameters:
-
[$withPossibleController=false]
Boolean optionalIf 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]
Convenience method to apply certain criteria to an array. and call Q_Response::addError for each one.
Parameters:
-
$fields
ArrayArray of strings or arrays naming fields that are required
-
[$throwIfMissing=false]
Boolean optionalWhether to throw an exception if the field is missing
Returns:
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]
The names of slots that were requested, if any
Parameters:
-
[$returnDefaults=false]
Boolean optionalIf 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:
slotNames
-
$slotName
Returns whether a given slot name was requested.
Parameters:
-
$slotName
StringThe name of the slot
Returns:
special
-
name
-
$default
-
[$source=null]
Gets all the names of the fields with no value or equal
Parameters:
-
name
String | Array | ObjectThe 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
Mixedwhat to return if field is missing
-
[$source=null]
String optionaloptionally provide an array to use instead of $_REQUEST
Returns:
special
-
$fieldname
-
$default
-
[$source=null]
Gets a field passed in special a part of the request
Parameters:
-
$fieldname
Stringthe name of the field, which can be namespaced as "Module.fieldname"
-
$default
Mixedoptionally what to return if field is missing
-
[$source=null]
String optionaloptionally provide an array to use instead of $_REQUEST
Returns:
tail
-
[$url=Q_Request::url()]
Get just the part of the URL after the Q_Request::baseUrl() and slash
Parameters:
-
[$url=Q_Request::url()]
String optionalDefaults to the currently requested url
Returns:
updateTimestamp
()
Boolean
static
Used by the system to find out the last timestamp an update of urls was loaded by the client.
Returns:
url
-
[$queryFields=array()]
Get the URL that was requested, possibly with a querystring
Parameters:
-
[$queryFields=array()]
Mixed optionalIf 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:
Returns the URL that was requested, possibly with a querystring.
version
()
String
static
Returns a string identifying user platform version.
Returns:
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