ZenMagick 0.9.6


org.zenmagick.rp.ZMRequest

Class ZMRequest

ZMObject
|
+--ZMRequest

public class ZMRequest
extends ZMObject

A central place for all request/session stuff.

Author:
DerManoMann
Version:
$Id: ZMRequest.php 2244 2009-05-27 04:20:23Z DerManoMann $

Fields inherited from org.zenmagick.ZMObject
properties_
Constructor Summary

ZMRequest(array parameter)

Create new instance.

Method Summary
static ZMAccount

getAccount()

Get the account.

static int

getAccountId()

Get the account id.

static int

getCategoryId()

Get the current category id.

static string

getCategoryPath()

Get the current category path.

static array

getCategoryPathArray()

Get the category path arry.

static ZMController

getController()

Get the controller for this request.

static string

getCurrencyCode()

Get the currency code.

static strng

getHostname()

Get the hostname for this request.

static string

getLanguageCode()

Get the language code.

static int

getManufacturerId()

Get the manufacturer id.

static string

getMethod()

Get the request method.

static string

getModel()

Get the request model number.

static int

getOrderId()

Get the current order id.

static string

getPageBase()

Get the page base url.

static int

getPageIndex()

Get the current page index (if available).

static string

getPageName()

Get the current page name; ie the ZM_PAGE_KEY value.

static mixed

getParameter(string name, mixed default, boolean sanitize)

Generic access method for request parameter.

static array

getParameterMap(boolean sanitize)

Get the complete parameter map.

static int

getProductId()

Get the product id.

static string

getQueryString()

Get the full query string.

static int

getReviewId()

Get the current review id.

static ZMSession

getSession()

Get the current session.

static ZMShoppingCart

getShoppingCart()

Get the current shopping cart.

static string

getSortId()

Get the current sort id.

static strin

getSubPageName()

Get the sub page name; this is the contents name for static pages.

protected static void

instance()

Get instance.

static boolean

isAdmin()

Check if we are running as admin.

static boolean

isAnonymous()

Returns true if the user is not logged in at all.

static boolean

isCheckout(boolean includeCart)

Checks, if the current page is a checkout page.

static boolean

isGuest()

Returns true if the user is a guest user.

static boolean

isRegistered()

Returns true if the user is fully registered and logged in.

static boolean

isSecure()

Checks if the current request is secure or note.

static boolean

isValidSession()

Check for a valid session.

static void

redirect(string url, int status)

Redirect to the given url.

static void

setCategoryPathArray(array cPath)

Set the category path arry.

static void

setController(ZMController controller)

Set the current controller.

static mixed

setParameter(string name, mixed value)

Allow programmatic manipulation of request parameters.

static void

setParameterMap(array map)

Set the parameter map.

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

Constructor Detail

ZMRequest

public ZMRequest(array parameter)

Create new instance.

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

Method Detail

getAccount

public static ZMAccount getAccount()

Get the account.

Returns:
The account or null.

getAccountId

public static int getAccountId()

Get the account id.

Returns:
The account id for the currently logged in user or 0.

getCategoryId

public static int getCategoryId()

Get the current category id.

Returns:
The current category id or 0.

getCategoryPath

public static string getCategoryPath()

Get the current category path.

Returns:
The category path value (cPath) or null.

getCategoryPathArray

public static array getCategoryPathArray()

Get the category path arry.

Returns:
The current category path broken into an array of category ids.

getController

public static ZMController getController()

Get the controller for this request.

Returns:
The current controller or a default controller instance.

getCurrencyCode

public static string getCurrencyCode()

Get the currency code.

NOTE: This will return the currency code as found in the request. If not set, the session currency code will be returned instead. To access the session currency code directly, use ZMRequest::getSession()->getCurrencyCode().

Returns:
The currency code or null.

getHostname

public static strng getHostname()

Get the hostname for this request.

Returns:
The hostname.

getLanguageCode

public static string getLanguageCode()

Get the language code.

NOTE: This will return only the language code as found in the request. If you want to find out the session language (ie the language for the current request), use ZMRuntime::getLanguageId() or ZMRuntime::getLanguage().

Returns:
The language code or null.

getManufacturerId

public static int getManufacturerId()

Get the manufacturer id.

Returns:
The manufacturer id or 0.

getMethod

public static string getMethod()

Get the request method.

Returns:
The upper case request method.

getModel

public static string getModel()

Get the request model number.

Returns:
The model numner or null.

getOrderId

public static int getOrderId()

Get the current order id.

Returns:
The current order id or 0.

getPageBase

public static string getPageBase()

Get the page base url.

Returns:
A base URL for the current request.

getPageIndex

public static int getPageIndex()

Get the current page index (if available).

Returns:
The current page index (default is 1).

getPageName

public static string getPageName()

Get the current page name; ie the ZM_PAGE_KEY value.

Returns:
The value of the ZM_PAGE_KEY query parameter.

getParameter

public static 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.

getParameterMap

public static array getParameterMap(boolean sanitize)

Get the complete parameter map.

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

getProductId

public static int getProductId()

Get the product id.

Returns:
The request product id or 0.

getQueryString

public static string getQueryString()

Get the full query string.

Returns:
The full query string for this request.

getReviewId

public static int getReviewId()

Get the current review id.

Returns:
The current review id or 0.

getSession

public static ZMSession getSession()

Get the current session.

Returns:
The session.

getShoppingCart

public static ZMShoppingCart getShoppingCart()

Get the current shopping cart.

Returns:
The current shopping cart (may be empty).

getSortId

public static string getSortId()

Get the current sort id.

Returns:
The current sort id.

getSubPageName

public static strin getSubPageName()

Get the sub page name; this is the contents name for static pages.

Returns:
The static page contents id.

instance

protected static void instance()

Get instance. /


isAdmin

public static boolean isAdmin()

Check if we are running as admin.

Returns:
true if code execution is in the context of an admin page, * false if not.

isAnonymous

public static boolean isAnonymous()

Returns true if the user is not logged in at all.

Returns:
true if the current user is guest, false if not.

isCheckout

public static boolean isCheckout(boolean includeCart)

Checks, if the current page is a checkout page.

Parameters:
includeCart - If true, the shopping cart is considered a checkout page, too; (defaults to true)
Returns:
true if the current page is a checkout page.

isGuest

public static boolean isGuest()

Returns true if the user is a guest user.

Returns:
true if the current user is guest, false if not.

isRegistered

public static boolean isRegistered()

Returns true if the user is fully registered and logged in.

Returns:
true if the current user is fully registered and logged in, false if not.

isSecure

public static boolean isSecure()

Checks if the current request is secure or note.

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

isValidSession

public static boolean isValidSession()

Check for a valid session.

Returns:
true if a valid session exists, false if not.

redirect

public static void redirect(string url, int status)

Redirect to the given url.

This method wil also persist existing messages in the session in order to be able to display them after the redirect.

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

setCategoryPathArray

public static void setCategoryPathArray(array cPath)

Set the category path arry.

Parameters:
cPath - The category path as array.

setController

public static void setController(ZMController controller)

Set the current controller.

Parameters:
controller - The new controller.

setParameter

public static 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.

setParameterMap

public static void setParameterMap(array map)

Set the parameter map.

Parameters:
map - Map of all request parameters

ZenMagick 0.9.6