KWeb
6.4
|
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() |
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):
KWebController::__construct | ( | ) | [protected] |
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.
$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 |
KWebController::buildUrl | ( | $ | uri = '' , |
$ | params = null , |
||
$ | lang = false , |
||
array $ | options = array() |
||
) |
$params | array 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 |
||
) |
KWebController::getCurrentRequestType | ( | ) |
KWebController::getDomainSettings | ( | $ | domainNameOrId | ) |
KWebController::getRequestTypeFromExtension | ( | $ | extension, |
$ | url, | ||
$ | checkHeaders = true |
||
) |
Returns request type for specified extension and url.
$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.
KWebRequest | $request |
static KWebController::instance | ( | $ | create = true | ) | [static] |
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.
$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.
$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.
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.
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)