core/model/modx/modrequest.class.php
MODX Revolution
Copyright 2006-2012 by MODX, LLC. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Package
- modx
\modRequest
Encapsulates the interaction of MODX with an HTTP request.
This class represents the functional portion of the MODX {@link http://www.martinfowler.com/eaaCatalog/frontController.html front- controller}, and is responsible for sanitizing, interpretting, and dispatching a web request to the appropriate MODX {@link modResource Web Resource}.
- Children
- \modManagerRequest
Properties
Methods
__construct(
\modX $modx
)
:
void
Name | Type | Description |
---|---|---|
$modx | \modX | A reference to the modX object |
_cleanResourceIdentifier(
string $identifier
)
:
string | integer
Cleans the resource identifier from the request params.
Name | Type | Description |
---|---|---|
$identifier | string | The raw identifier. |
Type | Description |
---|---|
string | integer | The cleansed identifier. |
getActionIDs(
array $actions
=
array(), string $namespace
=
'core'
)
:
array
Get the IDs for a collection of string action keys
Name | Type | Description |
---|---|---|
$actions | array | |
$namespace | string |
Type | Description |
---|---|
array |
getAllActionIDs(
string $namespace
=
''
)
:
array
Get a list of all modAction IDs
Name | Type | Description |
---|---|---|
$namespace | string |
Type | Description |
---|---|
array |
getClientIp(
)
:
array
Get the true client IP. Returns an array of values:
- ip - The real, true client IP
- suspected - The suspected IP, if not alike to REMOTE_ADDR
- network - The client's network IP
Type | Description |
---|---|
array |
- Access
- public
getHeaders(
boolean $ucKeys
=
false
)
:
array
Return the HTTP headers sent through the request
Name | Type | Description |
---|---|---|
$ucKeys | boolean | if true, upper-case all keys for the headers |
Type | Description |
---|---|
array |
getParameters(
string | array $keys
=
array(), string $type
=
'GET'
)
:
mixed
Get a GPC/REQUEST variable value or an array of values from the request.
Name | Type | Description |
---|---|---|
$keys | string | array | A key or array of keys to retrieve from the GPC variable. An empty array means get all keys of the variable. |
$type | string | The type of GPC variable, GET by default (GET, POST, COOKIE or REQUEST). |
Type | Description |
---|---|
mixed |
getResource(
string $method, string | integer $identifier, array $options
=
array()
)
:
\modResource
Gets a requested resource and all required data.
Name | Type | Description |
---|---|---|
$method | string | The method, 'id', or 'alias', by which to perform the resource lookup. |
$identifier | string | integer | The identifier with which to search. |
$options | array | An array of options for the resource fetching |
Type | Description |
---|---|
\modResource | The requested modResource instance or request is forwarded to the error page, or unauthorized page. |
getResourceIdentifier(
string $method
)
:
string
Gets the idetifier used to request a resource.
Name | Type | Description |
---|---|---|
$method | string | 'alias' or 'id'. |
Type | Description |
---|---|
string | The identifier for the requested resource. |
getResourceMethod(
)
:
string
Gets the method used to request a resource.
Type | Description |
---|---|
string | 'alias', 'id', or an empty string. |
handleRequest(
)
:
boolean
The primary MODX request handler (a.k.a. controller).
Type | Description |
---|---|
boolean | True if a request is handled without interruption. |
loadErrorHandler(
string $class
=
'modError'
)
:
void
Loads the error handling class for the request.
Name | Type | Description |
---|---|---|
$class | string | The class to use as the error handler. |
prepareResponse(
array $options
=
array()
)
:
boolean
Prepares the MODX response to a web request that is being handled.
Name | Type | Description |
---|---|---|
$options | array | An array of options |
Type | Description |
---|---|
boolean | True if the response is properly prepared. |
preserveRequest(
string $key
=
'referrer'
)
:
void
Preserves the $_REQUEST superglobal to the $_SESSION.
Name | Type | Description |
---|---|---|
$key | string | A key to save the $_REQUEST as; default is 'referrer'. |
registerLogging(
array $options
=
array()
)
:
void
Provides an easy way to initiate register logging.
Through an array of options, you can have all calls to modX::log() recorded in a topic of a modRegister instance. The options include:
- register: the name of the register (required)
- topic: the topic to record to (required)
- register_class: the modRegister class (defaults to modFileRegister)
- log_level: the logging level (defaults to MODX_LOG_LEVEL_INFO)
Name | Type | Description |
---|---|---|
$options | array | An array containing all the options required to initiate and configure logging to a modRegister instance. |
retrieveRequest(
string $key
=
'referrer'
)
:
string
Retrieve a preserved $_REQUEST from $_SESSION.
Name | Type | Description |
---|---|---|
$key | string | A key to identify a specific $_REQUEST; default is 'referrer'. |
Type | Description |
---|---|
string |