// AdminControllers cleanup

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10716 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
tDidierjean
2011-11-28 16:32:33 +00:00
parent d3cf49aaef
commit e474dc01b5
6 changed files with 9 additions and 68 deletions
+3 -1
View File
@@ -24,4 +24,6 @@
* 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()
{
// retro-compatibility : className for admin without controller
// This can be overriden in controllers (like for AdminCategories or AdminProducts
$controller = get_class($this);
// temporary fix for Token retrocompatibility
// This has to be done when url is built instead of here)
if (strpos($controller, 'Controller'))
@@ -389,8 +386,6 @@ class AdminControllerCore extends Controller
// set 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))))
return $this->{'process'.Tools::toCamelCase($this->action)}($token);
else if (method_exists($this, $this->action))
@@ -964,7 +959,6 @@ class AdminControllerCore extends Controller
return false;
}
$this->content = $this->displayErrors();
return $this->object;
}
@@ -990,13 +984,6 @@ class AdminControllerCore extends Controller
return true;
}
/**
* @TODO
*/
public function includeSubTab($methodname, $actions = array())
{
}
protected function filterToField($key, $filter)
{
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
*
+2 -2
View File
@@ -244,7 +244,7 @@ class AdminCartsController extends AdminController
if (!$this->context->cart->id)
return;
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)))
$errors[] = Tools::displayError('Invalid product');
elseif (!($qty = Tools::getValue('qty')) || $qty == 0)
@@ -326,7 +326,7 @@ class AdminCartsController extends AdminController
{
$errors = array();
if (!$id_order = Tools::getValue('id_order'))
$errors[] = Tools::displayErrors('Invalid order');
$errors[] = Tools::displayError('Invalid order');
$cart = Cart::getCartByOrderId($id_order);
$new_cart = $cart->duplicate();
if (!$new_cart || !Validate::isLoadedObject($new_cart['cart']))
+4 -15
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -115,18 +115,7 @@ class AdminCatalogController extends AdminController
$this->adminProducts->ajaxProcess();
if (Tools::getValue('deleteImage'))
$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()
@@ -154,12 +143,12 @@ class AdminCatalogController extends AdminController
// Cleaning links
$catBarIndex = self::$currentIndex;
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);
$this->context->smarty->assign('cat_bar',getPath($catBarIndex, $id_category, '', '', 'catalog', $home));
}
$this->content = '';
$this->content = '';
parent::initContent();
}
}
@@ -69,14 +69,6 @@ class AdminCmsContentControllerCore extends AdminController
return $result;
}
public function displayErrors()
{
parent::displayErrors();
$this->adminCMS->displayErrors();
$this->adminCMSCategories->displayErrors();
}
public function initContent()
{
$this->adminCMSCategories->token = $this->token;
@@ -1773,24 +1773,6 @@ class AdminProductsControllerCore extends AdminController
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)
{
$content = '<div class="warn draft" style="'.($active ? 'display:none' : '').'">
@@ -3539,7 +3521,6 @@ class AdminProductsControllerCore extends AdminController
else
$this->_errors[] = Tools::displayError('Object cannot be loaded (identifier missing or invalid)');
$this->displayErrors();
return $this->object;
}