ZenMagick 0.9.8


org.zenmagick.mvc.ZMRequest
\mvc\ZMRequest.php at line 34

Class ZMRequest

ZMObject
└─ZMRequest

public class ZMRequest
extends ZMObject

A request wrapper.

NOTE: For the time of transition between static and instance usage of request methods this will have a temp. name of ZMRequest.

Author:
DerManoMann
Version:
$Id: ZMRequest.php 2761 2009-12-18 01:31:02Z dermanomann $

Field Summary
final str

REQUEST_ID

Paramter name containing the request id.

final str

SESSION_TOKEN_NAME

Name of the session token form field and also the name in the session.

Fields inherited from org.zenmagick.core.ZMObject
properties_
Constructor Summary

ZMRequest(array parameter)

Create new instance.

Method Summary
string

getContext()

Get the URL context for this request.

ZMController

getController()

Get the controller for this request.

strng

getHostname()

Get the hostname for this request.

string

getMethod()

Get the request method.

mixed

getParameter(string name, mixed default, boolean sanitize)

Generic access method for request parameter.

array

getParameterMap(boolean sanitize)

Get the complete parameter map.

string

getQueryString()

Get the full query string.

string

getRequestId()

Get the request id.

ZMSession

getSession()

Get the current session.

string

getSticky(boolean clear)

Check if a sticky url exists that should be loaded (after a login).

string

getTemplatePath()

Get the template path.

ZMToolbox

getToolbox()

Get the toolbox for this request.

static void

instance()

Get instance.

boolean

isSecure()

Checks if the current request is secure or note.

void

markSticky()

Mark this request as the actually requested URL.

void

redirect(string url, int status)

Redirect to the given url.

void

setController(ZMController controller)

Set the current controller.

void

setMethod(string method)

Set the request method.

mixed

setParameter(string name, mixed value)

Allow programmatic manipulation of request parameters.

void

setParameterMap(array map)

Set the parameter map.

void

setRequestId(string requestId)

Set the request id.

void

setSession(ZMSession session)

Set the current session instance.

boolean

validateSessionToken()

Validate session token.

Methods inherited from org.zenmagick.core.ZMObject
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Field Detail

\mvc\ZMRequest.php at line 40

REQUEST_ID

public final str REQUEST_ID = 'zmid'

Paramter name containing the request id.

The request/page id determines the page being displayed.


\mvc\ZMRequest.php at line 44

SESSION_TOKEN_NAME

public final str SESSION_TOKEN_NAME = 'stoken'

Name of the session token form field and also the name in the session.


Constructor Detail

\mvc\ZMRequest.php at line 59

ZMRequest

public ZMRequest(array parameter)

Create new instance.

Parameters:
parameter - Optional request parameter; if null, $_GET and $_POST will be used.

Method Detail

\mvc\ZMRequest.php at line 311

getContext

public string getContext()

Get the URL context for this request.

Returns:
The URL context.

\mvc\ZMRequest.php at line 253

getController

public ZMController getController()

Get the controller for this request.

In case the controller is not explicitely set, the method will use the url mapper (ZMUrlManager::instance()->findController()) to determine a controller. This will then be either a configured controller or the default controller.

Returns:
The current controller.

\mvc\ZMRequest.php at line 138

getHostname

public strng getHostname()

Get the hostname for this request.

Returns:
The hostname.

\mvc\ZMRequest.php at line 98

getMethod

public string getMethod()

Get the request method.

Returns:
The (upper case) request method.

\mvc\ZMRequest.php at line 214

getParameter

public mixed getParameter(string name, mixed default, boolean sanitize)

Generic access method for request parameter.

This method is evaluating both GET and POST parameter.

There is a special case for when a parameter is not found, but _[name] is found. In this case false is returned. This allows to handle checkboxes same as any other form element by adding a hidden field _[name] with the original value.

Parameters:
name - The paramenter name.
default - An optional default parameter (if not provided, null is used).
sanitize - If true, sanitze value; default is true.
Returns:
The parameter value or the default value or null.

\mvc\ZMRequest.php at line 157

getParameterMap

public array getParameterMap(boolean sanitize)

Get the complete parameter map.

Parameters:
sanitize - If true, sanitze value; default is true.
Returns:
Map of all request parameters

\mvc\ZMRequest.php at line 147

getQueryString

public string getQueryString()

Get the full query string.

Returns:
The full query string for this request.

\mvc\ZMRequest.php at line 187

getRequestId

public string getRequestId()

Get the request id.

The request id is the main criteria for selecting the controller and view to process this request.

Returns:
The value of the self::REQUEST_ID query parameter.

\mvc\ZMRequest.php at line 116

getSession

public ZMSession getSession()

Get the current session.

Returns:
The session.

\mvc\ZMRequest.php at line 358

getSticky

public string getSticky(boolean clear)

Check if a sticky url exists that should be loaded (after a login).

Parameters:
clear - Optional flag to keep or clear the sticky url; default is true to clear.
Returns:
The url to go to or null.

\mvc\ZMRequest.php at line 321

getTemplatePath

public string getTemplatePath()

Get the template path.

Returns:
The path.

\mvc\ZMRequest.php at line 298

getToolbox

public ZMToolbox getToolbox()

Get the toolbox for this request.

Returns:
A toolbox instance.

\mvc\ZMRequest.php at line 89

instance

public static void instance()

Get instance.

A final straw to get the shared request instance if nothing else is available.


\mvc\ZMRequest.php at line 275

isSecure

public boolean isSecure()

Checks if the current request is secure or note.

Returns:
true if the current request is secure; eg. SSL, false if not.

\mvc\ZMRequest.php at line 348

markSticky

public void markSticky()

Mark this request as the actually requested URL.

Typically this happends when a request is received without valid authority. The URL will be forwarded to, once permissions is gained (user logged in).


\mvc\ZMRequest.php at line 285

redirect

public void redirect(string url, int status)

Redirect to the given url.

Parameters:
url - A fully qualified url.
status - Optional status; default is 302 - FOUND.

\mvc\ZMRequest.php at line 266

setController

public void setController(ZMController controller)

Set the current controller.

Parameters:
controller - The new controller.

\mvc\ZMRequest.php at line 107

setMethod

public void setMethod(string method)

Set the request method.

Parameters:
method - The request method.

\mvc\ZMRequest.php at line 235

setParameter

public mixed setParameter(string name, mixed value)

Allow programmatic manipulation of request parameters.

Parameters:
name - The paramenter name.
value - The value.
Returns:
The previous value or null.

\mvc\ZMRequest.php at line 175

setParameterMap

public void setParameterMap(array map)

Set the parameter map.

Parameters:
map - Map of all request parameters

\mvc\ZMRequest.php at line 196

setRequestId

public void setRequestId(string requestId)

Set the request id.

Parameters:
requestId - The new request id.

\mvc\ZMRequest.php at line 129

setSession

public void setSession(ZMSession session)

Set the current session instance.

Parameters:
session - The session.

\mvc\ZMRequest.php at line 330

validateSessionToken

public boolean validateSessionToken()

Validate session token.

Returns:
true in case the session token is valid.

ZenMagick 0.9.8