KWeb  6.4
KWebRequest Class Reference

Web Request information. More...

Public Member Functions

 __destruct ()
 __clone ()
 isMain ()
 Returns true if this request is the main request.
 applyOptions (array $options)
 Applies options that change Requests's properties.
 setMethod ($method=null, $urlData=null, $data=null)
 Sets request method as Get or Post.
 setType ($type)
 setUrlData (array $data, $detectPathParams=true)
 Sets data passed with URL.
 copyRequest (KWebRequest $request)
 Copies parameters from another request.
 configureTypeHandling ()
 Sets up everything, for handling current type...
 getType ()
 getCategory ()
 getBaseCategory ()
 getData ($name=false, $default=null, $useUrlData=true)
 Returns data associated with this request (typically equivallent of $_GET or $_POST)
 getAllData ()
 Returns all data associated with this request.
 getResult ()
 getObject ($object=true)
 Returns object associated with this request, or False if no object is associated.
 setObject ($object)
 Sets object id/genre for this request.
 getTemplate ($returnValid=false)
 Returns template path.
 isFallback ()
 If objectId was specified, but the object wasn't found, fallback template is used...
 getView ()
 getLanguage ($returnActive=false)
 Returns language.
 getItemPath ($expand, $object=true)
 Zwraca ścieżkę otwarcia jako nazwa1/nazwa2/nazwa3 lub listę obiektów ...
 getUrlParams ($skip=null, $include=null)
 Returns all url data in a way, that will preserve params encoded in the path...
 getOptions ()
 getSignature ($domain=true, $language=true, $requestType=true, $userGroup=true, $user=false)
 Returns information that differentiates this request from others.
 isJSON ()
 isAJAX ()
 isHTML ()
 isXML ()
 isImage ()
 isIndex ()
 isEdit ()
 parseUrlPath (array $path, array $pathParams)
 Parses URL path, filling the request This function should be called when request is already prepared, filled with url, lang, urlData and so on.
 runRequest ()
 Runs the request, and prints the output.
 getUrl (array $data=null, $dataOverride=false, $lang=false, array $options=array())
 Returns url of this request modified with provided options.
 buildUrl ()
 Builds url for this request.
 buildUrlQuery ($params, &$pathQuery=null, array $pathParams=array(), $lang=false)
 Builds URL queries.
 pathUrlEncode ($value)
 pathUrlDecode ($value)
 getOpenedObjects ($asObject)
 Returns a list of currently opened object and it's parents (if it's KWebItem)
 setResult ($result)

Static Public Member Functions

static createNew ($type, $category=self::CATEGORY_DEFAULT)
 Creates new KWebRequest object.
static createNewFromOptions ($category, $params=null, $lang=false, array $options=array())
static createNewFromAnother (KWebRequest $request, $type=false)
static pushCurrent ($request)
static popCurrent ()
static get ($mainRequest=false)
 Return request object.
static getCurrent ()
static getMain ()
 Returns main request.
static getCurrentType ()
 Return current request's type safely.
static data ($name=false, $default=null, $useUrlData=true)
 Returns data associated with current request (typically equivallent of $_GET or $_POST)

Data Fields

const EVENT_BUILD_URL = "kweb.request.build_url"
const TYPE_HTML = 'html'
const TYPE_AJAX = 'ajax'
const TYPE_JSON = 'json'
const TYPE_XML = 'xml'
const TYPE_IMAGE = 'image'
const TYPE_CMDLINE = 'cmdline'
const TYPE_FRAME = 'frame'
const TYPE_EMPTY = 'empty'
const CATEGORY_DEFAULT = false
 Category is yet unknown.
const CATEGORY_OBJECT = 'object'
 Request for view of the object.
const CATEGORY_PAGE = 'page'
 Request for page (inc file)
 $type
 $data = array()
 Data passed in GET or POST.
 $urlData = array()
 Data passed in GET.
const METHOD_GET = 'get'
const METHOD_POST = 'post'
 $method = 'get'
 $url
 $urlView
 view passed in URL
 $urlPath
 path passed in URL (without language and control segments)
 $urlLang
 lang passed in URL
 $urlPathParams = array()
 data parameters passed in URL's path
 $urlSpecialData = array()
 special data used during url building
 $urlExtension
 $urlHash
 $view
 object view
 $lang
 language
 $objectId
 object id
 $objectGenre
 object genre
 $template
 template - shouldn't be used if objectId is not empty, may be used as a failsafe if objectId is set, but object doesn't exist
 $itemPath
 active item's path
 $callback
 function to run this request function(KWebRequest $request)
 $options = array()
 Additional request options (e.g.
 $result = null
 Result of this request...

Static Public Attributes

static $current = null
static $main = null
static $stack = array()

Protected Member Functions

 __construct ($type, $category)
 parseUrlData (array $pathParams)
 buildRequestUri ()
 buildPageUri ($inc, $lang)
 Builds URI (not URL!) for pages.
 buildObjectUri ($genre, $itemId, $view, $lang)

Protected Attributes

 $category
 $object = false
 $itemPathExpanded

Detailed Description

Web Request information.

Author:
rafal.lindemann

Constructor & Destructor Documentation

KWebRequest::__construct ( type,
category 
) [protected]
KWebRequest::__destruct ( )

Member Function Documentation

KWebRequest::__clone ( )
KWebRequest::applyOptions ( array $  options)

Applies options that change Requests's properties.

KWebRequest::buildObjectUri ( genre,
itemId,
view,
lang 
) [protected]
KWebRequest::buildPageUri ( inc,
lang 
) [protected]

Builds URI (not URL!) for pages.

KWebRequest::buildRequestUri ( ) [protected]
Returns:
string - Uri of the request (path in the url)
KWebRequest::buildUrl ( )

Builds url for this request.

Warning:
This function may modify the request! If the request is not a fresh object (or clone), than use getUrl();
KWebRequest::buildUrlQuery ( params,
&$  pathQuery = null,
array $  pathParams = array(),
lang = false 
)

Builds URL queries.

Parameters:
$params- list of parameters as key => value. If key is prefixed with '/' then it's put into $pathQuery
$pathQuery- reference to string to write pathQuery into (query encoded in path like: "index,name-value.html")
$pathParams- list of parameter values which should be put into $pathQuery
Returns:
query string
KWebRequest::configureTypeHandling ( )

Sets up everything, for handling current type...

Types are configured using template files in _config/request_TYPENAME.inc Typical template discovery rules do apply, allowing for different configurations for different sections of the website.

KWebRequest::copyRequest ( KWebRequest request)

Copies parameters from another request.

static KWebRequest::createNew ( type,
category = self::CATEGORY_DEFAULT 
) [static]

Creates new KWebRequest object.

Parameters:
string$typeType of the request/response ie. TYPE_HTML, TYPE_AJAX
string$categoryCategory of the request. Class is discovered using category. Using FALSE will assume default request (object or page)
Returns:
KWebRequest
static KWebRequest::createNewFromAnother ( KWebRequest request,
type = false 
) [static]
Returns:
KWebRequest
static KWebRequest::createNewFromOptions ( category,
params = null,
lang = false,
array $  options = array() 
) [static]
Returns:
KWebRequest
static KWebRequest::data ( name = false,
default = null,
useUrlData = true 
) [static]

Returns data associated with current request (typically equivallent of $_GET or $_POST)

Parameters:
$name
$default
static KWebRequest::get ( mainRequest = false) [static]

Return request object.

Returns:
KWebRequest
KWebRequest::getAllData ( )

Returns all data associated with this request.

KWebRequest::getBaseCategory ( )
Returns:
string Returns base request's category - for example CATEGORY_OBJECT instead of object's genre
KWebRequest::getCategory ( )
Returns:
string Returns request's category. Be aware, that for object requests, it will be object's genre!
static KWebRequest::getCurrent ( ) [static]
Returns:
KWebRequest
static KWebRequest::getCurrentType ( ) [static]

Return current request's type safely.

Returns:
string
KWebRequest::getData ( name = false,
default = null,
useUrlData = true 
)

Returns data associated with this request (typically equivallent of $_GET or $_POST)

Parameters:
$name
$default
$useUrlData- TRUE - return from urlData if data is unavailable
KWebRequest::getItemPath ( expand,
object = true 
)

Zwraca ścieżkę otwarcia jako nazwa1/nazwa2/nazwa3 lub listę obiektów ...

Parameters:
$expandbool Jeżeli jest true, zwraca pełną listę obiektów (razem z rodzicami pierwszego elementu ścieżki)
KWebRequest::getLanguage ( returnActive = false)

Returns language.

Parameters:
$returnActive- TRUE - Returns language, FALSE - return language only if it was passed to url
static KWebRequest::getMain ( ) [static]

Returns main request.

Returns:
KWebRequest
KWebRequest::getObject ( object = true)

Returns object associated with this request, or False if no object is associated.

If objectId is set, but object doesn't exist, null is returned.

Returns:
KWebObject
KWebRequest::getOpenedObjects ( asObject)

Returns a list of currently opened object and it's parents (if it's KWebItem)

Parameters:
$asObject
Returns:
Array
KWebRequest::getOptions ( )
KWebRequest::getResult ( )
KWebRequest::getSignature ( domain = true,
language = true,
requestType = true,
userGroup = true,
user = false 
)

Returns information that differentiates this request from others.

To be used with CacheBlock, or anywhere where unique signature of a request is needed...

The returned value DOESN't contain current URI, GET/POST/COOKIE values, view or item ids.

Parameters:
$domain
$language
$requestType
$userGroup
$user
Returns:
string
KWebRequest::getTemplate ( returnValid = false)

Returns template path.

Controller should always set some fallback template path, even if request seems to be an object.

Parameters:
$returnValid- returns only valid template paths
KWebRequest::getType ( )
KWebRequest::getUrl ( array $  data = null,
dataOverride = false,
lang = false,
array $  options = array() 
)

Returns url of this request modified with provided options.

Always operates on the clone of this request object!

KWebRequest::getUrlParams ( skip = null,
include = null 
)

Returns all url data in a way, that will preserve params encoded in the path...

Parameters:
$skipParameters to skip or null
$includeParameters to include, null, or TRUE to include only urlPathParams
KWebRequest::getView ( )
KWebRequest::isAJAX ( )
KWebRequest::isEdit ( )
Returns:
boolean - True if it's editing request
KWebRequest::isFallback ( )

If objectId was specified, but the object wasn't found, fallback template is used...

KWebRequest::isHTML ( )
KWebRequest::isImage ( )
KWebRequest::isIndex ( )
KWebRequest::isJSON ( )
KWebRequest::isMain ( )

Returns true if this request is the main request.

KWebRequest::isXML ( )
KWebRequest::parseUrlData ( array $  pathParams) [protected]
KWebRequest::parseUrlPath ( array $  path,
array $  pathParams 
)

Parses URL path, filling the request This function should be called when request is already prepared, filled with url, lang, urlData and so on.

This function can use self::$url instead of relying on $path and $pathParams.

Parameters:
$pathFiltered Array of path segments (delimited with '/')
$pathParamsArray of path parameters (delimited with ',')
See also:
Controller::buildRequestFromUrl()
KWebRequest::pathUrlDecode ( value)
KWebRequest::pathUrlEncode ( value)
static KWebRequest::popCurrent ( ) [static]
static KWebRequest::pushCurrent ( request) [static]
KWebRequest::runRequest ( )

Runs the request, and prints the output.

Warning:
This function doesn't setup the environment. Controller:handleRequest is meant for that!
KWebRequest::setMethod ( method = null,
urlData = null,
data = null 
)

Sets request method as Get or Post.

Parameters:
$method- GET or POST. If NULL the method will be read from $_SERVER['REQUEST_METHOD']
$urlData- data passed in GET parameters as array or string. If NULL current request's data will be set.
$data- data passed in GET or POST depending on request method as array or string. If NULL current request's data will be set.
KWebRequest::setObject ( object)

Sets object id/genre for this request.

Parameters:
$objectYou may pass KWebObject, UID, or FALSE
KWebRequest::setResult ( result)
KWebRequest::setType ( type)
KWebRequest::setUrlData ( array $  data,
detectPathParams = true 
)

Sets data passed with URL.

Parameters:
$dataas array(key => value)

Field Documentation

KWebRequest::$callback

function to run this request function(KWebRequest $request)

KWebRequest::$category [protected]
KWebRequest::$current = null [static]
KWebRequest::$data = array()

Data passed in GET or POST.

KWebRequest::$itemPath

active item's path

KWebRequest::$itemPathExpanded [protected]
KWebRequest::$lang

language

KWebRequest::$main = null [static]
KWebRequest::$method = 'get'
KWebRequest::$object = false [protected]
KWebRequest::$objectGenre

object genre

KWebRequest::$objectId

object id

KWebRequest::$options = array()

Additional request options (e.g.

KWeb::URL_*).

KWebRequest::$result = null

Result of this request...

KWebRequest::$stack = array() [static]
KWebRequest::$template

template - shouldn't be used if objectId is not empty, may be used as a failsafe if objectId is set, but object doesn't exist

KWebRequest::$type
KWebRequest::$url
KWebRequest::$urlData = array()

Data passed in GET.

KWebRequest::$urlExtension
KWebRequest::$urlHash
KWebRequest::$urlLang

lang passed in URL

KWebRequest::$urlPath

path passed in URL (without language and control segments)

KWebRequest::$urlPathParams = array()

data parameters passed in URL's path

KWebRequest::$urlSpecialData = array()

special data used during url building

KWebRequest::$urlView

view passed in URL

KWebRequest::$view

object view

Category is yet unknown.

const KWebRequest::CATEGORY_OBJECT = 'object'

Request for view of the object.

Request for page (inc file)

const KWebRequest::EVENT_BUILD_URL = "kweb.request.build_url"
const KWebRequest::METHOD_GET = 'get'
const KWebRequest::METHOD_POST = 'post'
const KWebRequest::TYPE_AJAX = 'ajax'
const KWebRequest::TYPE_CMDLINE = 'cmdline'
const KWebRequest::TYPE_EMPTY = 'empty'
const KWebRequest::TYPE_FRAME = 'frame'
const KWebRequest::TYPE_HTML = 'html'
const KWebRequest::TYPE_IMAGE = 'image'
const KWebRequest::TYPE_JSON = 'json'
const KWebRequest::TYPE_XML = 'xml'

The documentation for this class was generated from the following file: