RequestHandlerComponent Class Reference

Inheritance diagram for RequestHandlerComponent:

Object List of all members.

Public Member Functions

 __construct ()
 __initializeTypes ()
 accepts ($type=null)
 beforeRedirect (&$controller, $url)
 getAjaxVersion ()
 getClientIP ($safe=true)
 getReferrer ()
 initialize (&$controller)
 isAjax ()
 isAtom ()
 isDelete ()
 isFlash ()
 isGet ()
 isMobile ()
 isPost ()
 isPut ()
 isRss ()
 isSSL ()
 isWap ()
 isXml ()
 mapType ($ctype)
 prefers ($type=null)
 renderAs (&$controller, $type)
 requestedWith ($type=null)
 respondAs ($type, $options=array())
 responseType ()
 setContent ($name, $type=null)
 startup (&$controller)

Public Attributes

 $__acceptTypes = array()
 $__renderType = null
 $__requestContent
 $__responseTypeSet = null
 $__typesInitialized = false
 $ajaxLayout = 'ajax'
 $enabled = true
 $ext = null
 $params = array()

Detailed Description

Definition at line 39 of file request_handler.php.


Constructor & Destructor Documentation

RequestHandlerComponent::__construct (  ) 

Constructor. Parses the accepted content types accepted by the client using HTTP_ACCEPT

Reimplemented from Object.

Definition at line 144 of file request_handler.php.


Member Function Documentation

RequestHandlerComponent::__initializeTypes (  ) 

Initializes MIME types

Returns:
void private

Definition at line 726 of file request_handler.php.

RequestHandlerComponent::accepts ( type = null  ) 

Determines which content types the client accepts. Acceptance is based on the file extension parsed by the Router (if present), and by the HTTP_ACCEPT header.

Parameters:
mixed $type Can be null (or no parameter), a string type name, or an array of types
Returns:
mixed If null or no parameter is passed, returns an array of content types the client accepts. If a string is passed, returns true if the client accepts it. If an array is passed, returns true if the client accepts one or more elements in the array. public
See also:
RequestHandlerComponent::setContent()

Definition at line 438 of file request_handler.php.

RequestHandlerComponent::beforeRedirect ( &$  controller,
url 
)

Handles (fakes) redirects for Ajax requests using requestAction()

Parameters:
object $controller A reference to the controller
mixed $url A string or array containing the redirect location public

Definition at line 227 of file request_handler.php.

RequestHandlerComponent::getAjaxVersion (  ) 

Gets Prototype version if call is Ajax, otherwise empty string. The Prototype library sets a special "Prototype version" HTTP header.

Returns:
string Prototype version of component making Ajax call public

Definition at line 357 of file request_handler.php.

RequestHandlerComponent::getClientIP ( safe = true  ) 

Gets remote client IP

Returns:
string Client IP address public

Definition at line 404 of file request_handler.php.

RequestHandlerComponent::getReferrer (  ) 

Gets the server name from which this request was referred

Returns:
string Server address public

Definition at line 388 of file request_handler.php.

RequestHandlerComponent::initialize ( &$  controller  ) 

Initializes the component, gets a reference to Controller::$parameters, and checks to see if a file extension has been parsed by the Router. If yes, the corresponding content-type is pushed onto the list of accepted content-types as the first item.

Parameters:
object $controller A reference to the controller
Returns:
void
See also:
Router::parseExtensions() public

Definition at line 166 of file request_handler.php.

RequestHandlerComponent::isAjax (  ) 

Returns true if the current HTTP request is Ajax, false otherwise

Returns:
boolean True if call is Ajax public

Definition at line 243 of file request_handler.php.

RequestHandlerComponent::isAtom (  ) 

Returns true if the current call accepts an Atom response, false otherwise

Returns:
boolean True if client accepts an RSS response public

Definition at line 288 of file request_handler.php.

RequestHandlerComponent::isDelete (  ) 

Returns true if the current call a DELETE request

Returns:
boolean True if call is a DELETE public

Definition at line 347 of file request_handler.php.

RequestHandlerComponent::isFlash (  ) 

Returns true if the current HTTP request is coming from a Flash-based client

Returns:
boolean True if call is from Flash public

Definition at line 252 of file request_handler.php.

RequestHandlerComponent::isGet (  ) 

Returns true if the current call a GET request

Returns:
boolean True if call is a GET public

Definition at line 338 of file request_handler.php.

RequestHandlerComponent::isMobile (  ) 

Returns true if user agent string matches a mobile web browser, or if the client accepts WAP content.

Returns:
boolean True if user agent is a mobile web browser public

Definition at line 298 of file request_handler.php.

RequestHandlerComponent::isPost (  ) 

Returns true if the current call a POST request

Returns:
boolean True if call is a POST public

Definition at line 320 of file request_handler.php.

RequestHandlerComponent::isPut (  ) 

Returns true if the current call a PUT request

Returns:
boolean True if call is a PUT public

Definition at line 329 of file request_handler.php.

RequestHandlerComponent::isRss (  ) 

Returns true if the current call accepts an RSS response, false otherwise

Returns:
boolean True if client accepts an RSS response public

Definition at line 279 of file request_handler.php.

RequestHandlerComponent::isSSL (  ) 

Returns true if the current request is over HTTPS, false otherwise.

Returns:
bool True if call is over HTTPS public

Definition at line 261 of file request_handler.php.

RequestHandlerComponent::isWap (  ) 

Returns true if the client accepts WAP content

Returns:
bool public

Definition at line 311 of file request_handler.php.

RequestHandlerComponent::isXml (  ) 

Returns true if the current call accepts an XML response, false otherwise

Returns:
boolean True if client accepts an XML response public

Definition at line 270 of file request_handler.php.

RequestHandlerComponent::mapType ( ctype  ) 

Maps a content-type back to an alias

Parameters:
mixed $type Content type
Returns:
mixed Alias public

Definition at line 696 of file request_handler.php.

RequestHandlerComponent::prefers ( type = null  ) 

Determines which content-types the client prefers. If no parameters are given, the content-type that the client most likely prefers is returned. If $type is an array, the first item in the array that the client accepts is returned. Preference is determined primarily by the file extension parsed by the Router if provided, and secondarily by the list of content-types provided in HTTP_ACCEPT.

Parameters:
mixed $type An optional array of 'friendly' content-type names, i.e. 'html', 'xml', 'js', etc.
Returns:
mixed If $type is null or not provided, the first content-type in the list, based on preference, is returned. public
See also:
RequestHandlerComponent::setContent()

Definition at line 513 of file request_handler.php.

RequestHandlerComponent::renderAs ( &$  controller,
type 
)

Sets the layout and template paths for the content type defined by $type.

Parameters:
object $controller A reference to a controller object
string $type Type of response to send (e.g: 'ajax')
Returns:
void public
See also:
RequestHandlerComponent::setContent()

RequestHandlerComponent::respondAs()

Definition at line 571 of file request_handler.php.

RequestHandlerComponent::requestedWith ( type = null  ) 

Determines the content type of the data the client has sent (i.e. in a POST request)

Parameters:
mixed $type Can be null (or no parameter), a string type name, or an array of types
Returns:
mixed public

Definition at line 479 of file request_handler.php.

RequestHandlerComponent::respondAs ( type,
options = array() 
)

Sets the response header based on type map index name. If DEBUG is greater than 2, the header is not set.

Parameters:
mixed $type Friendly type name, i.e. 'html' or 'xml', or a full content-type, like 'application/x-shockwave'.
array $options If $type is a friendly type name that is associated with more than one type of content, $index is used to select which content-type to use.
Returns:
boolean Returns false if the friendly type name given in $type does not exist in the type map, or if the Content-type header has already been set by this method. public
See also:
RequestHandlerComponent::setContent()

Definition at line 625 of file request_handler.php.

RequestHandlerComponent::responseType (  ) 

Returns the current response type (Content-type header), or null if none has been set

Returns:
mixed A string content type alias, or raw content type if no alias map exists, otherwise null public

Definition at line 683 of file request_handler.php.

RequestHandlerComponent::setContent ( name,
type = null 
)

Adds/sets the Content-type(s) for the given name. This method allows content-types to be mapped to friendly aliases (or extensions), which allows RequestHandler to automatically respond to requests of that type in the startup method.

Parameters:
string $name The name of the Content-type, i.e. "html", "xml", "css"
mixed $type The Content-type or array of Content-types assigned to the name, i.e. "text/html", or "application/xml"
Returns:
void public

Definition at line 375 of file request_handler.php.

RequestHandlerComponent::startup ( &$  controller  ) 

The startup method of the RequestHandler enables several automatic behaviors related to the detection of certain properties of the HTTP request, including:

Parameters:
object $controller A reference to the controller
Returns:
void public

Definition at line 189 of file request_handler.php.


Member Data Documentation

RequestHandlerComponent::$__acceptTypes = array()

Definition at line 116 of file request_handler.php.

RequestHandlerComponent::$__renderType = null

Definition at line 123 of file request_handler.php.

RequestHandlerComponent::$__requestContent

Initial value:

 array(
        'javascript'    => 'text/javascript',
        'js'            => 'text/javascript',
        'json'          => 'application/json',
        'css'           => 'text/css',
        'html'          => array('text/html', '*/*'),
        'text'          => 'text/plain',
        'txt'           => 'text/plain',
        'csv'           => array('application/vnd.ms-excel', 'text/plain'),
        'form'          => 'application/x-www-form-urlencoded',
        'file'          => 'multipart/form-data',
        'xhtml'         => array('application/xhtml+xml', 'application/xhtml', 'text/xhtml'),
        'xhtml-mobile'  => 'application/vnd.wap.xhtml+xml',
        'xml'           => array('application/xml', 'text/xml'),
        'rss'           => 'application/rss+xml',
        'atom'          => 'application/atom+xml',
        'amf'           => 'application/x-amf',
        'wap'           => array(
            'text/vnd.wap.wml',
            'text/vnd.wap.wmlscript',
            'image/vnd.wap.wbmp'
        ),
        'wml'           => 'text/vnd.wap.wml',
        'wmlscript'     => 'text/vnd.wap.wmlscript',
        'wbmp'          => 'image/vnd.wap.wbmp',
        'pdf'           => 'application/pdf',
        'zip'           => 'application/x-zip',
        'tar'           => 'application/x-tar'
    )

Definition at line 78 of file request_handler.php.

RequestHandlerComponent::$__responseTypeSet = null

Definition at line 62 of file request_handler.php.

RequestHandlerComponent::$__typesInitialized = false

Definition at line 139 of file request_handler.php.

RequestHandlerComponent::$ajaxLayout = 'ajax'

Definition at line 47 of file request_handler.php.

RequestHandlerComponent::$enabled = true

Definition at line 54 of file request_handler.php.

RequestHandlerComponent::$ext = null

Definition at line 131 of file request_handler.php.

RequestHandlerComponent::$params = array()

Definition at line 69 of file request_handler.php.


The documentation for this class was generated from the following file:
Generated on Sun Nov 22 00:30:56 2009 for CakePHP 1.2.x.x (v1.2.4.8284) by doxygen 1.4.7