From eaa21cb2260e30451f7784cb64681de1b3da9f5c Mon Sep 17 00:00:00 2001 From: lLefevre Date: Wed, 5 Oct 2011 09:34:10 +0000 Subject: [PATCH] //Added AdminAliasesController --- admin-dev/themes/template/adminAliases.tpl | 53 ++++++++++++ .../admin/AdminAliasesController.php | 86 +++++++++++-------- 2 files changed, 101 insertions(+), 38 deletions(-) create mode 100644 admin-dev/themes/template/adminAliases.tpl rename admin-dev/tabs/AdminAliases.php => controllers/admin/AdminAliasesController.php (52%) diff --git a/admin-dev/themes/template/adminAliases.tpl b/admin-dev/themes/template/adminAliases.tpl new file mode 100644 index 000000000..2023e68d9 --- /dev/null +++ b/admin-dev/themes/template/adminAliases.tpl @@ -0,0 +1,53 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 8897 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + +{if isset($tab_form)} + + +
+ {if $tab_form['id']}{/if} +
+ {l s ='Aliases'} + +
+ * +

{l s ='Enter each alias separated by a comma (\',\')'}{l s ='(e.g., \'prestshop,preztashop,prestasohp\')'}
+ {l s ='Forbidden characters:'}<>;=#{}

+
+ +
+ * +

{l s ='Search this word instead.'}

+
+
+ +
+
* {l s ='Required field'}
+
+
+{/if} + +{$content} \ No newline at end of file diff --git a/admin-dev/tabs/AdminAliases.php b/controllers/admin/AdminAliasesController.php similarity index 52% rename from admin-dev/tabs/AdminAliases.php rename to controllers/admin/AdminAliasesController.php index e44f21342..d507786a7 100644 --- a/admin-dev/tabs/AdminAliases.php +++ b/controllers/admin/AdminAliasesController.php @@ -1,6 +1,6 @@ * @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 6844 $ +* @version Release: $Revision: 8971 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ -class AdminAliases extends AdminTab +class AdminAliasesControllerCore extends AdminController { - function __construct() + public function __construct() { $this->table = 'alias'; - $this->className = 'Alias'; + $this->className = 'Alias'; $this->edit = true; $this->delete = true; - + $this->lang = false; + $this->requiredDatabase = true; + + $this->context = Context::getContext(); + + if (!Tools::getValue('realedit')) + $this->deleted = false; + + $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); + $this->fieldsDisplay = array( 'alias' => array('title' => $this->l('Aliases'), 'width' => 160), 'search' => array('title' => $this->l('Search'), 'width' => 40), 'active' => array('title' => $this->l('Status'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false) ); + + $this->template = 'adminAliases.tpl'; + parent::__construct(); } @@ -47,21 +59,21 @@ class AdminAliases extends AdminTab if (isset($_POST['submitAdd'.$this->table])) { $search = strval(Tools::getValue('search')); - $string = strval(Tools::getValue('alias')); + $string = strval(Tools::getValue('alias')); $aliases = explode(',', $string); - if (empty($search) OR empty($string)) + if (empty($search) || empty($string)) $this->_errors[] = $this->l('aliases and result are both required'); if (!Validate::isValidSearch($search)) $this->_errors[] = $search.' '.$this->l('is not a valid result'); - foreach ($aliases AS $alias) + foreach ($aliases as $alias) if (!Validate::isValidSearch($alias)) $this->_errors[] = $alias.' '.$this->l('is not a valid alias'); - - if (!sizeof($this->_errors)) + + if (!count($this->_errors)) { - foreach ($aliases AS $alias) + foreach ($aliases as $alias) { - $obj = new Alias(NULL, trim($alias), trim($search)); + $obj = new Alias(null, trim($alias), trim($search)); $obj->save(); } } @@ -70,33 +82,31 @@ class AdminAliases extends AdminTab parent::postProcess(); } - public function displayForm($isMainTab = true) + public function displayForm($is_main_tab = true) { - parent::displayForm(); - + parent::displayForm($is_main_tab); + if (!($obj = $this->loadObject(true))) return; - echo ' -
- '.($obj->id ? '' : '').' -
'.$this->l('Aliases').' - -
- * -

'.$this->l('Enter each alias separated by a comma (\',\')').' '.$this->l('(e.g., \'prestshop,preztashop,prestasohp\')').'
- '.$this->l('Forbidden characters:').' <>;=#{}

-
- -
- * -

'.$this->l('Search this word instead.').'

-
-
- -
-
* '.$this->l('Required field').'
-
-
'; + $this->context->smarty->assign('tab_form', array( + 'current' => self::$currentIndex, + 'table' => $this->table, + 'token' => $this->token, + 'id' => $obj->id, + 'alias' => Tools::getValue('alias', $obj->getAliases()), + 'search' => $this->getFieldValue($obj, 'search') + )); } -} \ No newline at end of file + + public function initContent() + { + if ($this->display != 'edit') + $this->display = 'list'; + + parent::initContent(); + } + +} + +