// AdminControllers cleanup

This commit is contained in:
tDidierjean committed 2011-11-28 16:32:33 +00:00
1 parent 770ea11835
commit fda491a781
6 files changed
+9 -68

No files matched your search

+3 -1
View File
@@ -24,4 +24,6 @@
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*} *}
{$content} {if isset($content)}
{$content}
{/if}
-23
View File
@@ -233,10 +233,7 @@ class AdminControllerCore extends Controller
public function __construct() public function __construct()
{ {
// retro-compatibility : className for admin without controller
// This can be overriden in controllers (like for AdminCategories or AdminProducts
$controller = get_class($this); $controller = get_class($this);
// temporary fix for Token retrocompatibility // temporary fix for Token retrocompatibility
// This has to be done when url is built instead of here) // This has to be done when url is built instead of here)
if (strpos($controller, 'Controller')) if (strpos($controller, 'Controller'))
@@ -389,8 +386,6 @@ class AdminControllerCore extends Controller
// set token // set token
$token = Tools::getValue('token') ? Tools::getValue('token') : $this->token; $token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
// Sub included tab postProcessing
$this->includeSubTab('postProcess', array('status', 'submitAdd1', 'submitDel', 'delete', 'submitFilter', 'submitReset'));
if (!empty($this->action) && method_exists($this, 'process'.ucfirst(Tools::toCamelCase($this->action)))) if (!empty($this->action) && method_exists($this, 'process'.ucfirst(Tools::toCamelCase($this->action))))
return $this->{'process'.Tools::toCamelCase($this->action)}($token); return $this->{'process'.Tools::toCamelCase($this->action)}($token);
else if (method_exists($this, $this->action)) else if (method_exists($this, $this->action))
@@ -964,7 +959,6 @@ class AdminControllerCore extends Controller
return false; return false;
} }
$this->content = $this->displayErrors();
return $this->object; return $this->object;
} }
@@ -990,13 +984,6 @@ class AdminControllerCore extends Controller
return true; return true;
} }
/**
* @TODO
*/
public function includeSubTab($methodname, $actions = array())
{
}
protected function filterToField($key, $filter) protected function filterToField($key, $filter)
{ {
foreach ($this->fieldsDisplay as $field) foreach ($this->fieldsDisplay as $field)
@@ -1823,16 +1810,6 @@ class AdminControllerCore extends Controller
)); ));
} }
/**
* Display errors
*/
public function displayErrors()
{
// @TODO includesubtab
$content = $this->includeSubTab('displayErrors');
return $content;
}
/** /**
* Get the current objects' list form the database * Get the current objects' list form the database
* *
+2 -2
View File
@@ -244,7 +244,7 @@ class AdminCartsController extends AdminController
if (!$this->context->cart->id) if (!$this->context->cart->id)
return; return;
if ($this->context->cart->OrderExists()) if ($this->context->cart->OrderExists())
$errors[] = Tools::displayErrors('An order already placed with this cart'); $errors[] = Tools::displayError('An order already placed with this cart');
elseif (!($id_product = (int)Tools::getValue('id_product')) OR !($product = new Product((int)$id_product, true, $this->context->language->id))) elseif (!($id_product = (int)Tools::getValue('id_product')) OR !($product = new Product((int)$id_product, true, $this->context->language->id)))
$errors[] = Tools::displayError('Invalid product'); $errors[] = Tools::displayError('Invalid product');
elseif (!($qty = Tools::getValue('qty')) || $qty == 0) elseif (!($qty = Tools::getValue('qty')) || $qty == 0)
@@ -326,7 +326,7 @@ class AdminCartsController extends AdminController
{ {
$errors = array(); $errors = array();
if (!$id_order = Tools::getValue('id_order')) if (!$id_order = Tools::getValue('id_order'))
$errors[] = Tools::displayErrors('Invalid order'); $errors[] = Tools::displayError('Invalid order');
$cart = Cart::getCartByOrderId($id_order); $cart = Cart::getCartByOrderId($id_order);
$new_cart = $cart->duplicate(); $new_cart = $cart->duplicate();
if (!$new_cart || !Validate::isLoadedObject($new_cart['cart'])) if (!$new_cart || !Validate::isLoadedObject($new_cart['cart']))
+4 -15
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2011 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -115,18 +115,7 @@ class AdminCatalogController extends AdminController
$this->adminProducts->ajaxProcess(); $this->adminProducts->ajaxProcess();
if (Tools::getValue('deleteImage')) if (Tools::getValue('deleteImage'))
$this->adminProducts->ajaxProcess(); $this->adminProducts->ajaxProcess();
}
public function displayErrors()
{
parent::displayErrors();
$this->adminProducts->displayErrors();
$this->adminCategories->displayErrors();
if (Validate::isLoadedObject($this->attributeGenerator))
$this->attributeGenerator->displayErrors();
if (Validate::isLoadedObject($this->imageResize))
$this->imageResize->displayErrors();
} }
public function initContent() public function initContent()
@@ -154,12 +143,12 @@ class AdminCatalogController extends AdminController
// Cleaning links // Cleaning links
$catBarIndex = self::$currentIndex; $catBarIndex = self::$currentIndex;
foreach ($catalog_tabs AS $tab) foreach ($catalog_tabs AS $tab)
if (Tools::getValue($tab.'Orderby') && Tools::getValue($tab.'Orderway')) if (Tools::getValue($tab.'Orderby') && Tools::getValue($tab.'Orderway'))
$catBarIndex = preg_replace('/&'.$tab.'Orderby=([a-z _]*)&'.$tab.'Orderway=([a-z]*)/i', '', self::$currentIndex); $catBarIndex = preg_replace('/&'.$tab.'Orderby=([a-z _]*)&'.$tab.'Orderway=([a-z]*)/i', '', self::$currentIndex);
$this->context->smarty->assign('cat_bar',getPath($catBarIndex, $id_category, '', '', 'catalog', $home)); $this->context->smarty->assign('cat_bar',getPath($catBarIndex, $id_category, '', '', 'catalog', $home));
} }
$this->content = ''; $this->content = '';
parent::initContent(); parent::initContent();
} }
} }
@@ -69,14 +69,6 @@ class AdminCmsContentControllerCore extends AdminController
return $result; return $result;
} }
public function displayErrors()
{
parent::displayErrors();
$this->adminCMS->displayErrors();
$this->adminCMSCategories->displayErrors();
}
public function initContent() public function initContent()
{ {
$this->adminCMSCategories->token = $this->token; $this->adminCMSCategories->token = $this->token;
@@ -1773,24 +1773,6 @@ class AdminProductsControllerCore extends AdminController
return $content; return $content;
} }
public function displayErrors()
{
if ($this->includeSubTab('displayErrors'))
;
else if ($nbErrors = sizeof($this->_errors))
{
$this->content .= '<div class="error">
<img src="../img/admin/error2.png" />
'.$nbErrors.' '.($nbErrors > 1 ? $this->l('errors') : $this->l('error')).'
<ol>';
foreach ($this->_errors as $error)
$this->content .= '<li>'.$error.'</li>';
$this->content .= '
</ol>
</div>';
}
}
private function _displayDraftWarning($active) private function _displayDraftWarning($active)
{ {
$content = '<div class="warn draft" style="'.($active ? 'display:none' : '').'"> $content = '<div class="warn draft" style="'.($active ? 'display:none' : '').'">
@@ -3539,7 +3521,6 @@ class AdminProductsControllerCore extends AdminController
else else
$this->_errors[] = Tools::displayError('Object cannot be loaded (identifier missing or invalid)'); $this->_errors[] = Tools::displayError('Object cannot be loaded (identifier missing or invalid)');
$this->displayErrors();
return $this->object; return $this->object;
} }