// change to Controller workflow

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8813 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
tDidierjean committed 2011-09-27 15:20:30 +00:00
1 parent 86f18ce106
commit 3192ddb27d
3 files changed
+50 -46

No files matched your search

+13 -26
View File
@@ -111,37 +111,30 @@ class AdminControllerCore extends Controller
return (!empty($token) AND $token === $this->token); return (!empty($token) AND $token === $this->token);
} }
public function action() public function postProcess()
{ {
if (!$this->ajax) if ($this->ajax)
{
$this->postProcess();
$this->setMedia();
$this->initHeader();
$this->initFooter();
//$adminObj->displayConf();
//$adminObj->displayErrors();
}
else
{ {
// from ajax-tab.php // from ajax-tab.php
if(method_exists($this,'ajaxPreprocess')) if (method_exists($this, 'ajaxPreprocess'))
$this->ajaxPreProcess(); $this->ajaxPreProcess();
$action = Tools::getValue('action'); $action = Tools::getValue('action');
// no need to use displayConf() here // no need to use displayConf() here
if (!empty($action) AND method_exists($this, 'ajaxProcess'.Tools::toCamelCase($action)) ) if (!empty($action) && method_exists($this, 'ajaxProcess'.Tools::toCamelCase($action)))
$this->{'ajaxProcess'.Tools::toCamelCase($action)}(); $this->{'ajaxProcess'.Tools::toCamelCase($action)}();
else else
$this->ajaxProcess(); $this->ajaxProcess();
// @TODO We should use a displayAjaxError // @TODO We should use a displayAjaxError
$this->displayErrors(); /*$this->displayErrors();
if (!empty($action) AND method_exists($this, 'displayAjax'.Tools::toCamelCase($action)) ) if (!empty($action) && method_exists($this, 'displayAjax'.Tools::toCamelCase($action)))
$this->{'displayAjax'.$action}(); $this->{'displayAjax'.$action}();
else else
$this->displayAjax(); $this->displayAjax(); */
}
else
{
} }
} }
@@ -549,10 +542,4 @@ class AdminControllerCore extends Controller
{ {
p($this->_errors); p($this->_errors);
} }
public function postProcess()
{
}
} }
+25 -4
View File
@@ -73,7 +73,7 @@ abstract class ControllerCore
/** /**
* Do the page treatment : post process, ajax process, etc. * Do the page treatment : post process, ajax process, etc.
*/ */
abstract public function action(); abstract public function postProcess();
/** /**
* Display page view * Display page view
@@ -111,12 +111,18 @@ abstract class ControllerCore
public function run() public function run()
{ {
$this->init(); $this->init();
$this->action(); $this->postProcess();
if ($this->displayHeader)
{
$this->setMedia();
$this->initHeader();
}
$this->initContent();
if ($this->displayFooter)
$this->initFooter();
if ($this->ajax) if ($this->ajax)
{
$this->displayAjax(); $this->displayAjax();
}
else else
$this->display(); $this->display();
} }
@@ -135,7 +141,22 @@ abstract class ControllerCore
{ {
$this->template = $template; $this->template = $template;
} }
/**
* Assign smarty variables for the page header
*/
abstract public function initHeader();
/**
* Assign smarty variables for the page main content
*/
abstract public function initContent();
/**
* Assign smarty variables for the page footer
*/
abstract public function initFooter();
/** /**
* Add a new stylesheet in page header. * Add a new stylesheet in page header.
* *
+12 -16
View File
@@ -87,6 +87,12 @@ class FrontControllerCore extends Controller
exit(); exit();
} }
if ($this->ajax)
{
$this->displayHeader(false);
$this->displayFooter(false);
}
ob_start(); ob_start();
// Switch language if needed and init cookie language // Switch language if needed and init cookie language
@@ -335,7 +341,7 @@ class FrontControllerCore extends Controller
$this->context->controller = $this; $this->context->controller = $this;
} }
public function action() public function postProcess()
{ {
/*// For retrocompatibility with versions before 1.5, preProcess support will be removed on next release /*// For retrocompatibility with versions before 1.5, preProcess support will be removed on next release
if (method_exists(get_class($this), 'preProcess')) if (method_exists(get_class($this), 'preProcess'))
@@ -347,25 +353,15 @@ class FrontControllerCore extends Controller
$this->preProcess(); $this->preProcess();
} }
}*/ }*/
if ($this->ajax) //$this->preProcess();
{
$this->displayHeader(false);
$this->displayFooter(false);
}
$this->preProcess();
// Prepare generation of page display
$this->processHeader();
$this->process();
$this->processFooter();
} }
public function preProcess() public function preProcess()
{ {
} }
public function process() public function initContent()
{ {
} }
@@ -508,7 +504,7 @@ class FrontControllerCore extends Controller
$this->addCSS(_THEME_CSS_DIR_.'rtl.css'); $this->addCSS(_THEME_CSS_DIR_.'rtl.css');
} }
public function processHeader() public function initHeader()
{ {
// P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies) // P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies)
header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"'); header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');
@@ -548,7 +544,7 @@ class FrontControllerCore extends Controller
$this->context->smarty->assign('js_files', array_unique($this->js_files)); $this->context->smarty->assign('js_files', array_unique($this->js_files));
} }
public function processFooter() public function initFooter()
{ {
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn', array('cart' => $this->context->cart)), 'HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn', array('cart' => $this->context->cart)),