19 require_once(BASE.
"wcmf/lib/core/class.WCMFException.php");
20 require_once(BASE.
"wcmf/lib/util/class.ObjectFactory.php");
21 require_once(BASE.
"wcmf/lib/util/class.Message.php");
22 require_once(BASE.
"wcmf/lib/util/class.FormUtil.php");
23 require_once(BASE.
"wcmf/lib/util/class.FileUtil.php");
24 require_once(BASE.
"wcmf/lib/presentation/class.View.php");
25 require_once(BASE.
"wcmf/lib/presentation/format/class.Formatter.php");
26 require_once(BASE.
"wcmf/lib/presentation/class.WCMFInifileParser.php");
27 require_once(BASE.
"wcmf/lib/model/class.NodeUtil.php");
28 require_once(BASE.
"wcmf/lib/i18n/class.Localization.php");
29 require_once(BASE.
"wcmf/lib/security/class.RightsManager.php");
30 require_once(BASE.
"wcmf/lib/util/class.Obfuscator.php");
31 require_once(BASE.
"wcmf/lib/util/class.Log.php");
69 $this->_request =
new Request(null, null, null, array());
70 $this->_response =
new Response(null, null, null, array());
71 $this->_delegate = &$delegate;
89 $this->_request = &$request;
90 $this->_response = &$response;
95 if ($this->_delegate !== null)
96 $this->_delegate->postInitialize($this);
106 if ($this->_delegate !== null)
107 return $this->_delegate->validate($this);
120 WCMFException::throwEx(
"hasView() must be implemented by derived class: ".get_class($this), __FILE__, __LINE__);
130 Log::debug(
'Executing: '.get_class($this), __CLASS__);
131 Log::debug(
'Request: '.$this->_request->toString(), __CLASS__);
138 if ($this->_delegate !== null)
139 $this->_delegate->preExecute($this);
143 $this->_response->setValue(
'sid', $session->getID());
144 $this->_response->setValue(
'controller', get_class($this));
151 $this->_response->appendValue(
'errorMsg', $this->
getErrorMsg());
158 $viewTpl = $this->
getViewTemplate($this->_response->getSender(), $this->_request->getContext(), $this->_request->getAction());
160 WCMFException::throwEx(
"View definition missing for ".get_class($this).
". Action key: ".$actionKey, __FILE__, __LINE__);
163 $this->_view = &$objectFactory->createInstanceFromConfig(
'implementation',
'View');
164 if ($this->_view === null) {
169 $this->_view->setup();
170 $this->_response->setView($this->_view);
175 if ($this->_delegate !== null)
176 $result = $this->_delegate->postExecute($this, $result);
180 $this->_response->setValue(
'success',
false);
182 $this->_response->setValue(
'success',
true);
190 $viewTpl = realpath(BASE.$this->getViewTemplate($this->_response->getSender(), $this->_request->getContext(), $this->_request->getAction()));
191 if ($this->_view->caching && ($cacheId = $this->getCacheId()) !== null)
193 $this->_view->display($viewTpl, $cacheId);
196 $this->_view->display($viewTpl);
201 Log::debug(
'Response: '.$this->_response->toString(), __CLASS__);
213 WCMFException::throwEx(
"executeKernel() must be implemented by derived class: ".get_class($this), __FILE__, __LINE__);
229 $this->_errorMsg = $msg;
237 if (preg_match(
"/".$msg.
"$/", $this->_errorMsg))
240 if (strlen($this->_errorMsg) > 0)
241 $this->_errorMsg .=
"\n";
242 $this->_errorMsg .= $msg;
288 $actionKey = $parser->getBestActionKey(
'views', $controller, $context, $action);
290 Log::debug(
'Controller::getViewTemplate: '.$controller.
"?".$context.
"?".$action.
' -> '.$actionKey, __CLASS__);
293 $view = $parser->getValue($actionKey,
'views',
false);
317 $authUser = &$rightsManager->getAuthUser();
320 $view->assign(
'_controller', $this->_response->getSender());
321 $view->assign(
'_context', $this->_response->getContext());
322 $view->assign(
'_action', $this->_response->getAction());
323 $view->assign(
'_responseFormat', $this->_response->getFormat());
324 $view->assign(
'messageObj',
new Message());
325 $view->assign(
'formUtil',
new FormUtil());
326 $view->assign(
'nodeUtil',
new NodeUtil());
328 $view->assign(
'applicationTitle', $parser->getValue(
'applicationTitle',
'cms'));
329 if ($authUser != null)
330 $view->assign_by_ref(
'authUser', $authUser);
332 if ($this->_delegate !== null)
333 $this->_delegate->assignAdditionalViewValues($this);
343 if ($this->_request->hasValue(
'language') &&
344 $this->_request->getValue(
'language') != $localization->getDefaultLanguage()) {
initialize(&$request, &$response)
debug($message, $category)
get($message, $parameters=null, $domain='', $lang='')
NodeUtil provides services for the Node class. All methods are static.
Request holds the request values that are used as input to Controller instances. It is typically inst...
throwEx($message, $file='', $line='')
Controller is the base class of all controllers. If a Controller has a view it is expected to reside ...
assignViewDefaults(&$view)
isDebugEnabled($category)
Use the Message class to output messages. You need not instantiate a Message object because the metho...
getViewTemplate($controller, $context, $action)
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.