class_WebLoginAreaCommand.php
Go to the documentation of this file.00001 <?php
00024 class WebLoginAreaCommand extends BaseCommand implements Commandable {
00028 private $actionName = "";
00029
00035 protected function __construct () {
00036
00037 parent::__construct(__CLASS__);
00038 }
00039
00046 public final static function createWebLoginAreaCommand (CommandResolver $resolverInstance) {
00047
00048 $commandInstance = new WebLoginAreaCommand();
00049
00050
00051 $commandInstance->setResolverInstance($resolverInstance);
00052
00053
00054 $commandInstance->prepareCommand();
00055
00056
00057 return $commandInstance;
00058 }
00059
00066 protected function prepareCommand () {
00067 }
00068
00076 public function execute (Requestable $requestInstance, Responseable $responseInstance) {
00077
00078 $actionInstance = Registry::getRegistry()->getInstance('action');
00079
00080
00081 if ($actionInstance instanceof PerformableAction) {
00082
00083 $actionInstance->execute($requestInstance, $responseInstance);
00084 }
00085
00086
00087 $appInstance = $this->getResolverInstance()->getApplicationInstance();
00088
00089
00090 $templateInstance = $this->prepareTemplateInstance($appInstance);
00091
00092
00093 $templateInstance->assignConfigVariable('base_url');
00094
00095
00096 $templateInstance->assignApplicationData($appInstance);
00097
00098
00099 $masterTemplate = $appInstance->getMasterTemplate();
00100
00101
00102 $templateInstance->loadCodeTemplate('header');
00103
00104
00105 $templateInstance->compileTemplate();
00106 $templateInstance->assignTemplateWithVariable('header', 'header');
00107
00108
00109 $templateInstance->loadCodeTemplate('footer');
00110
00111
00112 $templateInstance->compileTemplate();
00113 $templateInstance->assignTemplateWithVariable('footer', 'footer');
00114
00115
00116 $templateInstance->loadCodeTemplate('action_' . $this->actionName);
00117
00118
00119 $templateInstance->compileTemplate();
00120 $templateInstance->assignTemplateWithVariable('action_' . $this->actionName, 'login_content');
00121
00122
00123 $templateInstance->loadCodeTemplate('login_main');
00124
00125
00126 $templateInstance->compileTemplate();
00127 $templateInstance->assignTemplateWithVariable('login_main', 'content');
00128
00129
00130 $templateInstance->loadCodeTemplate($masterTemplate);
00131
00132
00133 $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage($this->actionName . '_title'));
00134
00135
00136
00137
00138 $templateInstance->compileVariables();
00139
00140
00141 $templateInstance->transferToResponse($responseInstance);
00142 }
00143
00151 public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
00152
00153 $actionInstance = null;
00154
00155
00156 $registryInstance = Registry::getRegistry();
00157
00158
00159 $appInstance = $registryInstance->getInstance('application');
00160
00161
00162 $this->actionName = sprintf("%s_login_%s",
00163 str_replace("-", "_", $appInstance->getAppShortName()),
00164 $this->getConfigInstance()->readConfig('login_default_action')
00165 );
00166
00167
00168 $actReq = $requestInstance->getRequestElement('action');
00169
00170
00171 if ((is_string($actReq)) && (!empty($actReq))) {
00172
00173 $this->actionName = sprintf("%s_login_%s",
00174 str_replace("-", "_", $appInstance->getAppShortName()),
00175 $actReq
00176 );
00177 }
00178
00179
00180 $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
00181
00182
00183 $actionResolver = WebActionResolver::createWebActionResolver($this->actionName, $applicationInstance);
00184
00185
00186 $actionInstance = $actionResolver->resolveAction();
00187
00188
00189 $actionInstance->addExtraFilters($controllerInstance, $requestInstance);
00190
00191
00192 Registry::getRegistry()->addInstance('action', $actionInstance);
00193 }
00194 }
00195
00196
00197 ?>