19 require_once(BASE.
"wcmf/lib/core/class.WCMFException.php");
20 require_once(BASE.
"wcmf/lib/util/class.Log.php");
21 require_once(BASE.
"wcmf/lib/util/class.Message.php");
22 require_once(BASE.
"wcmf/lib/util/class.SessionData.php");
23 require_once(BASE.
"wcmf/lib/util/class.ObjectFactory.php");
24 require_once(BASE.
"wcmf/lib/presentation/class.Request.php");
25 require_once(BASE.
"wcmf/lib/presentation/class.Response.php");
26 require_once(BASE.
"wcmf/lib/presentation/class.WCMFInifileParser.php");
27 require_once(BASE.
"wcmf/lib/presentation/format/class.Formatter.php");
28 require_once(BASE.
"wcmf/lib/security/class.RightsManager.php");
29 require_once(BASE.
"wcmf/3rdparty/Bs_StopWatch.class.php");
50 static $instance = null;
52 if (!isset($instance))
70 $referrer = $request->getSender();
71 $context = $request->getContext();
72 $action = $request->getAction();
77 array_push($actionMapper->_lastControllers, $referrer);
82 $logExecutionTime = $parser->getValue(
'logExecuteTime',
'cms');
85 if (!$rightsManager->authorize($referrer, $context, $action))
87 $authUser = &$rightsManager->getAuthUser();
91 Log::error(
"The request was: ".$request->toString(), __CLASS__);
95 $login = $authUser->getName();
96 Log::error(
"Authorization failed for '".$actionKey.
"' user '".$login.
"'", __CLASS__);
103 $actionKey = $parser->getBestActionKey(
'actionmapping', $referrer, $context, $action);
107 Log::debug($referrer.
"?".$context.
"?".$action.
' -> '.$actionKey, __CLASS__);
109 if (strlen($actionKey) == 0)
112 $controllerClass = $actionMapper->_lastControllers[0];
113 Log::warn(
"No actionkey found for ".$referrer.
"?".$context.
"?".$action.
". Executing ".$controllerClass.
" ...", __CLASS__);
118 if (($controllerClass = $parser->getValue($actionKey,
'actionmapping')) ===
false)
124 if (strlen($controllerClass) == 0)
126 WCMFException::throwEx(
"No controller found for best action key ".$actionKey.
". Request was $referrer?$context?$action", __FILE__, __LINE__);
136 if ($actionMapper->_controllerDelegate == null)
138 if ($parser->getValue(
'ControllerDelegate',
'implementation') !==
false)
141 $actionMapper->_controllerDelegate = &$objectFactory->createInstanceFromConfig(
'implementation',
'ControllerDelegate');
146 if (($classFile = $parser->getValue($controllerClass,
'classmapping')) ===
false)
151 if (file_exists(BASE.$classFile))
153 require_once(BASE.$classFile);
154 $controllerObj =
new $controllerClass($actionMapper->_controllerDelegate);
158 WCMFException::throwEx(
"Definition of Controller ".$controllerClass.
" in '".$classFile.
"' not found.", __FILE__, __LINE__);
164 Log::debug(
"Request: ".$request->toString(), __CLASS__);
168 $response =
new Response($controllerClass, $context, $action, array());
169 $response->setFormat($request->getResponseFormat());
173 Log::debug(
"Execute ".$controllerClass.
" with request: ".$request->toString(), __CLASS__);
174 $controllerObj->initialize($request, $response);
177 if ($logExecutionTime)
179 $stopWatch =
new Bs_StopWatch();
182 $result = $controllerObj->execute();
185 Log::debug($controllerClass.
" execution time: ".$stopWatch->getTime().
" ms", __CLASS__);
187 if ($result ===
false)
192 else if ($result ===
true)
195 $nextRequest =
new Request($controllerClass, $response->getContext(), $response->getAction(), $response->getData());
201 WCMFException::throwEx(
"Controller::execute must return true or false. Executed controller was ".$controllerClass.
".", __FILE__, __LINE__);
213 $actionMapper->_lastControllers = array();
error($message, $category)
debug($message, $category)
get($message, $parameters=null, $domain='', $lang='')
warn($message, $category)
setResponseFormat($format)
& processAction(&$request)
Request holds the request values that are used as input to Controller instances. It is typically inst...
throwEx($message, $file='', $line='')
isDebugEnabled($category)
Response holds the response values that are used as output from Controller instances. It is typically instantiated by the ActionMapper instance and filled during Controller execution.
ActionMapper is the central class in our implementation of the mvc pattern. It calls the different Co...