|
PntHttpRequest |
PntRequestHandler |
PntSite |
PntStringConverter |
|
getRequestHandler |
__construct |
__toString |
checkAlphaNumeric |
forwardRequest |
getBaseUrl |
getContextHref |
getController |
getConverter |
getDebugMode |
getDir |
getDomainDir |
getEventualItemNotFoundMessage |
getFormTextPaths |
getFormTexts |
getGlobalFilters |
getHandlersTriedString |
getIncludesDir |
getInformation |
getLabel |
getMarkedItemsCollector |
getName |
getReqParam |
getRequestParam |
getRequestedObject |
getScout |
getThisPntHandlerName |
getTryUseClassTryParams |
getType |
getTypeClassDescriptor |
getTypeLabel |
htOut |
initForHandleRequest |
queryStringFrom |
redirectRequest |
setFormTexts |
setInformation |
setRequestedObject |
startSession |
toString |
tryUseClass |
tryUseHandlerClass |
useClass |
|
/** @return PntRequestHandler appropriate to handle a request.
* First a class named <pntType><pntHandler> is tried.
* If it can not be included, Object<pntHandler> will be used.
* If pntHandler param is missing in $requestData a default will be used, see implementation fo this method.
* A special case is if pntHandler=(MtoN)PropertyPage: then <pntType>Property<pntProperty>Page is tried first,
* @param array $requestData associative, of string like $_REQUEST,
* used to decide which class to include and instantiate,
* and passed to the PntRequestHandler as the request data.
* @param string $dir appears to be ignored. $thisfunction (->() will be used.
* For each class name inclusion is first tried from $this->(),
* If the class is not found, a class from the classes root folder is tried
* @throws PntValidationException is no class could be included
*/
function getRequestHandler($requestData, $dir=null) {
if (!$dir) $dir = $this->();
$id = isSet($requestData["id"]) ? $requestData["id"] : null;
$specifiedHandler = $handler = isSet($requestData["pntHandler"])
? $requestData["pntHandler"] : null;
$property = ucFirst(isSet($requestData["pntProperty"]) ? $requestData["pntProperty"] : '');
$type = isSet($requestData["pntType"]) ? $requestData["pntType"] : null;
if ($handler=='PropertyPage' || $handler=='MtoNPropertyPage')
$handler = "Property$property".'Page';
elseif (!$handler) { //no pntHandler param, use default:
if ($property == 'pntList')
$handler = 'IndexPage';
elseif ($id !== null)
$handler = 'EditDetailsPage';
else
$handler = 'IndexPage';
$specifiedHandler = $handler;
}
$attempted = array();
$info = null;
$handlerClass = $type
? $this->("$type$handler", $attempted)
: null;
if (!$handlerClass && $property) {
//there is no specific handler for this type and property, try type-handler
$handler = $specifiedHandler;
$handlerClass = $this->("$type$handler", $attempted);
}
if (!$handlerClass)
//there is no specific handler for this type, try generic handler from same dir
$handlerClass = $this->controller->($this, $requestData, $handler, $attempted);
if (!$handlerClass) {
$name = $this->();
$errorMessage = "$name - handler not found: $handler, tried: <BR>\n";
$errorMessage .= $this->($attempted);
throw new PntValidationException($errorMessage);
}
// print "<BR>Handler: $handlerClass $included";
if (!is_subclassOr($handlerClass, 'PntRequestHandler'))
throw new PntValidationException($handlerClass. ' does not inherit from PntRequestHandler');
$result = new $handlerClass($this, $requestData);
if ($this->() == 'verbose') {
$info = 'Handlers tried<BR>(one of last two succeeded): ';
$info .= $this->($attempted);
$result->($info);
}
return $result;
}
|
Copyright (c) MetaClass, 2003-
This code is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
Click here for a copy of the license or see http://www.gnu.org/licenses/ .
|
|