KWeb  6.4
KWebController Class Reference

Controller class used to translate urls to actions/views/objects and back. More...

Public Member Functions

 onTemplateFinished ($e)
 checkCron ()
 getDomainSettings ($domainNameOrId)
 setupDomain ($domainName=false, $obeyHostForce=true)
 Domain specific setup.
 buildRequestFromUrl ($url, $mainRequest=false, $requestMethod=null)
 URLe.
 getRequestTypeFromExtension ($extension, $url, $checkHeaders=true)
 Returns request type for specified extension and url.
 handleRequest ($request)
 Handles the request.
 openURI ($uri)
 buildUrl ($uri='', $params=null, $lang=false, array $options=array())
 buildObjectUrl ($genre, $itemId, $view=null, $params=null, $lang=false, array $options=array())
 buildIncUrl ($inc, $params=null, $lang=false, array $options=array())
 rebuildUrl ($href, &$request=null)
 Rebuilds url, guessing the item, view and all parematers.
 pushRequestType ($type)
 popRequestType ()
 getCurrentRequestType ()
 rootUrlPush ($url=true)
 Overrides current root url.
 rootUrlPop ()
 isFullUrlEnabled ()
 getRootUrl ($alwaysReturn=true)
 getReservedControlWords ($lang=false)
 checkReservedControlWord ($word, $lang=false)
 translateUrlPart ($part, $value, $lang=false, $returnOriginal=true)
 Translates url part from internal name to url-ready.
 untranslateUrlPart ($part, $value, $lang=false, $returnOriginal=true)
 Translates url part from url to internal name.

Static Public Member Functions

static instance ($create=true)

Data Fields

const FILTER_PARSE_URL = 'kweb.controller.parse_url'
 Filters the url passed to buildRequestFromUrl.
const FILTER_REQUEST = 'kweb.controller.request'
 Filters the request passed to handleRequest.
const EVENT_BUILD_REQUEST = 'kweb.controller.build_request'
 Allows to build the request object, right after parsing the most basic url parts (language and path params).
const EVENT_EXTENSION_TO_REQUEST = 'kweb.controller.extension_to_request'
 Maps extension to request type.
const PART_GENRE = 'genre'
 Object's genre (/GENRE/id.html or /id,GENRE.html)
const PART_VIEW = 'view'
 View or template (/VIEW/id.html or /page/VIEW.html)
const PART_PARAM = 'param'
 URL Parameter (/id,PARAM-123.html or /id.html?PARAM-123)
const PART_CONTROL = 'control'
 Control word like "view", "edit" (/object/view/print/id.html)
const PART_CATEGORY = 'category'
 Request category like "object", "page" (/CATEGORY/id.html or /CATEGORY/template.html)
 $translateUrlParts = array()
 array(part => array(lang => array(k=>v)))
 $reservedControlWords = array()
 array(lang => array(word, word)

Static Public Attributes

static $inst

Protected Member Functions

 __construct ()
 prepareUrlTranslations ()

Protected Attributes

 $rootUrlStack = array()
 $requestTypeStack = array()

Detailed Description

Controller class used to translate urls to actions/views/objects and back.

In KWeb URLs consist of several parts. Optional elements are in brackets, required are in parentheses, options are delimited with pipe ('|')

1) Server path, main script and prefixes... (KWebSetting::$inst->server_path|/)[KWebSetting::$inst->main_script][/][KWebSetting::$inst->url_prefix] '/' or '/blog/' .... 'index.php/'

2) Language, request category or genre [language/][category_translation/|object_genre_translation/] 'pl/' 'page/' or 'comment/' or 'strona/' or 'komentarz/'

The rest depends on the request category. KWebRequest's subclass is created based on category and this class parses the rest of an URL. Default request:

3) View and object's pathname or id, or path to the page's inc file [([(edit/|view/)path_to_view/]object/path[,object_genre])|(path/to/inc)]

4) Path parameters - GET parameters encoded into the path, for SEO, or readability reasons [,name][,-reserved-name][,name-value][,name-value.20url.20encoded]

5) Request type as extension [.(html|ajax|json|xml|jpg|frame|...)]

6) Typical request parameters (GET) [?name=value]

Additionally, some GET parameters have special meaning and are reserved! They can be both encoded in the path (like ,view-user-authorize), or in a query (?view=user-authorize):

  • view - path to the view for this object
  • itempath - path to use for this item
  • lang - language to use for this request

Constructor & Destructor Documentation

KWebController::__construct ( ) [protected]

Member Function Documentation

KWebController::buildIncUrl ( inc,
params = null,
lang = false,
array $  options = array() 
)
KWebController::buildObjectUrl ( genre,
itemId,
view = null,
params = null,
lang = false,
array $  options = array() 
)
KWebController::buildRequestFromUrl ( url,
mainRequest = false,
requestMethod = null 
)

URLe.

Parameters:
$url- URL address without domain
$mainRequest- TRUE - request will be handled as the main one. Current GET/POST data will be set, plus special parameters will be set on global $_GET
Returns:
KWebRequest
KWebController::buildUrl ( uri = '',
params = null,
lang = false,
array $  options = array() 
)
Parameters:
$paramsarray Parametry do dołączenia do adresu. Parametry zaczynające się od / zostaną dopisane do adresu ścieżki (jako index,nazwa-wartosc.html.
KWebController::checkCron ( )
KWebController::checkReservedControlWord ( word,
lang = false 
)
Returns:
TRUE if word is safe to use at the beginning of the url
KWebController::getCurrentRequestType ( )
KWebController::getDomainSettings ( domainNameOrId)
KWebController::getRequestTypeFromExtension ( extension,
url,
checkHeaders = true 
)

Returns request type for specified extension and url.

Parameters:
$checkHeaders- if TRUE, headers will be checked for automatic extension matching
KWebController::getReservedControlWords ( lang = false)
KWebController::getRootUrl ( alwaysReturn = true)
KWebController::handleRequest ( request)

Handles the request.

Parameters:
KWebRequest$request
static KWebController::instance ( create = true) [static]
Returns:
KWebController
KWebController::isFullUrlEnabled ( )
KWebController::onTemplateFinished ( e)
KWebController::openURI ( uri)
KWebController::popRequestType ( )
KWebController::prepareUrlTranslations ( ) [protected]
KWebController::pushRequestType ( type)
KWebController::rebuildUrl ( href,
&$  request = null 
)

Rebuilds url, guessing the item, view and all parematers.

Parameters:
$href
$request- returns KWebRequest if one is found for the url
KWebController::rootUrlPop ( )
KWebController::rootUrlPush ( url = true)

Overrides current root url.

Root URL should contain "http://" and shouldn't be suffixed with "/"

You can pass FALSE to disable full url requirement, or TRUE to use default ROOT URL and enable full url requirement

KWebController::setupDomain ( domainName = false,
obeyHostForce = true 
)

Domain specific setup.

Parameters:
$domainName- name of domain to setup
$obeyHostForce- TRUE - will make a redirect if $domainName is different then matched domain name and host_force setting is TRUE
KWebController::translateUrlPart ( part,
value,
lang = false,
returnOriginal = true 
)

Translates url part from internal name to url-ready.

KWebController::untranslateUrlPart ( part,
value,
lang = false,
returnOriginal = true 
)

Translates url part from url to internal name.


Field Documentation

KWebController::$inst [static]
KWebController::$requestTypeStack = array() [protected]
KWebController::$reservedControlWords = array()

array(lang => array(word, word)

KWebController::$rootUrlStack = array() [protected]
KWebController::$translateUrlParts = array()

array(part => array(lang => array(k=>v)))

const KWebController::EVENT_BUILD_REQUEST = 'kweb.controller.build_request'

Allows to build the request object, right after parsing the most basic url parts (language and path params).

New request object should be set as request attribute. Attributes 'path' and 'pathParams' may be altered.

Use $event->setProcessed(true) after successfull handling

const KWebController::EVENT_EXTENSION_TO_REQUEST = 'kweb.controller.extension_to_request'

Maps extension to request type.

See also:
getRequestFromExtension Parameters: extension url checkHeaders
const KWebController::FILTER_PARSE_URL = 'kweb.controller.parse_url'

Filters the url passed to buildRequestFromUrl.

Should return modified url. It's possible to set the new request as the event's attribute. If FALSE is returned, the new request will be returned, otherwise the controller will use provided request object.

const KWebController::FILTER_REQUEST = 'kweb.controller.request'

Filters the request passed to handleRequest.

Allow for changes in the request, or it's substitution

const KWebController::PART_CATEGORY = 'category'

Request category like "object", "page" (/CATEGORY/id.html or /CATEGORY/template.html)

const KWebController::PART_CONTROL = 'control'

Control word like "view", "edit" (/object/view/print/id.html)

const KWebController::PART_GENRE = 'genre'

Object's genre (/GENRE/id.html or /id,GENRE.html)

const KWebController::PART_PARAM = 'param'

URL Parameter (/id,PARAM-123.html or /id.html?PARAM-123)

const KWebController::PART_VIEW = 'view'

View or template (/VIEW/id.html or /page/VIEW.html)


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