From b58fb34c97a422f71b4c836a240f1ea243a5116b Mon Sep 17 00:00:00 2001
From: lLefevre
Date: Fri, 14 Oct 2011 08:57:52 +0000
Subject: [PATCH] [*] BO #PSFV-94 : update of the displayform method by
helperForm in AdminQuickAccessesController
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9355 b9a71923-0436-4b27-9f14-aed3839534dd
---
admin-dev/tabs/AdminQuickAccesses.php | 91 ------------
admin-dev/themes/template/form.tpl | 4 +-
classes/OrderMessage.php | 45 +++---
classes/QuickAccess.php | 42 +++---
.../admin/AdminOrderMessageController.php | 4 +-
.../admin/AdminQuickAccessesController.php | 132 ++++++++++++++++++
install-dev/sql/db_settings_lite.sql | 2 +-
7 files changed, 181 insertions(+), 139 deletions(-)
delete mode 100644 admin-dev/tabs/AdminQuickAccesses.php
create mode 100644 controllers/admin/AdminQuickAccessesController.php
diff --git a/admin-dev/tabs/AdminQuickAccesses.php b/admin-dev/tabs/AdminQuickAccesses.php
deleted file mode 100644
index 2945b69ae..000000000
--- a/admin-dev/tabs/AdminQuickAccesses.php
+++ /dev/null
@@ -1,91 +0,0 @@
-
-* @copyright 2007-2011 PrestaShop SA
-* @version Release: $Revision: 6844 $
-* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-class AdminQuickAccesses extends AdminTab
-{
- public function __construct()
- {
- $this->table = 'quick_access';
- $this->className = 'QuickAccess';
- $this->lang = true;
- $this->edit = true;
- $this->delete = true;
-
- $this->fieldsDisplay = array(
- 'id_quick_access' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
- 'name' => array('title' => $this->l('Name'), 'width' => 200),
- 'link' => array('title' => $this->l('Link'), 'width' => 300),
- 'new_window' => array('title' => $this->l('New window'), 'align' => 'center', 'type' => 'bool', 'activeVisu' => 'new_window'));
-
- parent::__construct();
- }
-
- public function displayForm($isMainTab = true)
- {
- parent::displayForm();
-
- if (!($obj = $this->loadObject(true)))
- return;
- $new_window = $this->getFieldValue($obj, 'new_window');
-
- echo '
- ';
- }
-}
-
-
diff --git a/admin-dev/themes/template/form.tpl b/admin-dev/themes/template/form.tpl
index beb1a08b5..9dd6361bc 100644
--- a/admin-dev/themes/template/form.tpl
+++ b/admin-dev/themes/template/form.tpl
@@ -83,6 +83,7 @@
{if isset($input.size)}size="{$input.size}"{/if}
{if isset($input.class)}class="{$input.class}"{/if}
{if isset($input.readonly) && $input.readonly}readonly="readonly"{/if} />
+ {if isset($input.hint)}{$input.hint} {/if}
{/foreach}
{if count($languages) > 1}
@@ -111,6 +112,7 @@
{if isset($input.size)}size="{$input.size}"{/if}
{if isset($input.class)}class="{$input.class}"{/if}
{if isset($input.readonly) && $input.readonly}readonly="readonly"{/if} />
+ {if isset($input.hint)}{$input.hint} {/if}
{/if}
{elseif $input.type == 'select'}
{/if}
+ {if isset($languages)}
diff --git a/classes/OrderMessage.php b/classes/OrderMessage.php
index 96b0e9389..bef437bd9 100644
--- a/classes/OrderMessage.php
+++ b/classes/OrderMessage.php
@@ -1,6 +1,6 @@
128, 'message' => 1200);
- protected $fieldsValidateLang = array('name' => 'isGenericName', 'message' => 'isMessage');
-
- protected $table = 'order_message';
- protected $identifier = 'id_order_message';
-
- protected $webserviceParameters = array(
+ /** @var string message content */
+ public $message;
+
+ /** @var string Object creation date */
+ public $date_add;
+
+ protected $fieldsRequired = array();
+ protected $fieldsValidate = array();
+ protected $fieldsSize = array();
+
+ protected $fieldsRequiredLang = array('name', 'message');
+ protected $fieldsSizeLang = array('name' => 128, 'message' => 1200);
+ protected $fieldsValidateLang = array('name' => 'isGenericName', 'message' => 'isMessage');
+
+ protected $table = 'order_message';
+ protected $identifier = 'id_order_message';
+
+ protected $webserviceParameters = array(
'fields' => array(
'id' => array('sqlId' => 'id_discount_type', 'xlink_resource' => 'order_message_lang'),
'date_add' => array('sqlId' => 'date_add')
)
);
-
-
+
public function getFields()
{
$this->validateFields();
@@ -73,7 +72,7 @@ class OrderMessageCore extends ObjectModel
SELECT om.id_order_message, oml.name, oml.message
FROM '._DB_PREFIX_.'order_message om
LEFT JOIN '._DB_PREFIX_.'order_message_lang oml ON (oml.id_order_message = om.id_order_message)
- WHERE oml.id_lang = '.(int)($id_lang).'
+ WHERE oml.id_lang = '.(int)$id_lang.'
ORDER BY name ASC');
}
}
diff --git a/classes/QuickAccess.php b/classes/QuickAccess.php
index e91295418..12bca3114 100644
--- a/classes/QuickAccess.php
+++ b/classes/QuickAccess.php
@@ -28,32 +28,32 @@
class QuickAccessCore extends ObjectModel
{
/** @var string Name */
- public $name;
-
- /** @var string Link */
- public $link;
-
- /** @var boolean New windows or not */
- public $new_window;
-
- protected $fieldsRequired = array('link', 'new_window');
- protected $fieldsSize = array('link' => 128);
- protected $fieldsValidate = array('link' => 'isUrl', 'new_window' => 'isBool');
- protected $fieldsRequiredLang = array('name');
- protected $fieldsSizeLang = array('name' => 32);
- protected $fieldsValidateLang = array('name' => 'isGenericName');
+ public $name;
+
+ /** @var string Link */
+ public $link;
+
+ /** @var boolean New windows or not */
+ public $new_window;
+
+ protected $fieldsRequired = array('link', 'new_window');
+ protected $fieldsSize = array('link' => 128);
+ protected $fieldsValidate = array('link' => 'isUrl', 'new_window' => 'isBool');
+ protected $fieldsRequiredLang = array('name');
+ protected $fieldsSizeLang = array('name' => 32);
+ protected $fieldsValidateLang = array('name' => 'isGenericName');
+
+ protected $table = 'quick_access';
+ protected $identifier = 'id_quick_access';
- protected $table = 'quick_access';
- protected $identifier = 'id_quick_access';
-
public function getFields()
{
$this->validateFields();
$fields['link'] = pSQL($this->link);
- $fields['new_window'] = (int)($this->new_window);
+ $fields['new_window'] = (int)$this->new_window;
return $fields;
}
-
+
/**
* Check then return multilingual fields for database interaction
*
@@ -64,7 +64,7 @@ class QuickAccessCore extends ObjectModel
$this->validateFieldsLang();
return $this->getTranslationsFields(array('name'));
}
-
+
/**
* Get all available quick_accesses
*
@@ -75,7 +75,7 @@ class QuickAccessCore extends ObjectModel
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT *
FROM `'._DB_PREFIX_.'quick_access` qa
- LEFT JOIN `'._DB_PREFIX_.'quick_access_lang` qal ON (qa.`id_quick_access` = qal.`id_quick_access` AND qal.`id_lang` = '.(int)($id_lang).')
+ LEFT JOIN `'._DB_PREFIX_.'quick_access_lang` qal ON (qa.`id_quick_access` = qal.`id_quick_access` AND qal.`id_lang` = '.(int)$id_lang.')
ORDER BY `name` ASC');
}
}
diff --git a/controllers/admin/AdminOrderMessageController.php b/controllers/admin/AdminOrderMessageController.php
index cc63effd4..6f89e7553 100644
--- a/controllers/admin/AdminOrderMessageController.php
+++ b/controllers/admin/AdminOrderMessageController.php
@@ -30,7 +30,7 @@ class AdminOrderMessageController extends AdminController
public function __construct()
{
$this->table = 'order_message';
- $this->className = 'OrderMessage';
+ $this->className = 'OrderMessage';
$this->lang = true;
$this->edit = true;
$this->delete = true;
@@ -48,7 +48,7 @@ class AdminOrderMessageController extends AdminController
'title' => $this->l('ID'),
'align' => 'center',
'width' => 25
- ),
+ ),
'name' => array(
'title' => $this->l('Name'),
'width' => 140
diff --git a/controllers/admin/AdminQuickAccessesController.php b/controllers/admin/AdminQuickAccessesController.php
new file mode 100644
index 000000000..94200d882
--- /dev/null
+++ b/controllers/admin/AdminQuickAccessesController.php
@@ -0,0 +1,132 @@
+
+* @copyright 2007-2011 PrestaShop SA
+* @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 AdminQuickAccessesController extends AdminController
+{
+ public function __construct()
+ {
+ $this->table = 'quick_access';
+ $this->className = 'QuickAccess';
+ $this->lang = true;
+ $this->edit = true;
+ $this->delete = true;
+ $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(
+ 'id_quick_access' => array(
+ 'title' => $this->l('ID'),
+ 'align' => 'center',
+ 'width' => 25
+ ),
+ 'name' => array(
+ 'title' => $this->l('Name'),
+ 'width' => 200
+ ),
+ 'link' => array(
+ 'title' => $this->l('Link'),
+ 'width' => 300
+ ),
+ 'new_window' => array(
+ 'title' => $this->l('New window'),
+ 'align' => 'center',
+ 'type' => 'bool',
+ 'activeVisu' => 'new_window'
+ )
+ );
+
+ $this->fields_form = array(
+ 'legend' => array(
+ 'title' => $this->l('Quick Access menu'),
+ 'image' => '../img/admin/quick.gif'
+ ),
+ 'input' => array(
+ array(
+ 'type' => 'text',
+ 'label' => $this->l('Name:'),
+ 'name' => 'name',
+ 'lang' => true,
+ 'attributeLang' => 'name',
+ 'size' => 33,
+ 'maxlength' => 32,
+ 'required' => true,
+ 'hint' => $this->l('Forbidden characters:').' <>;=#{}'
+ ),
+ array(
+ 'type' => 'text',
+ 'label' => $this->l('URL:'),
+ 'name' => 'link',
+ 'size' => 60,
+ 'maxlength' => 128,
+ 'required' => true
+ ),
+ array(
+ 'type' => 'radio',
+ 'label' => $this->l('Open in new window:'),
+ 'name' => 'new_window',
+ 'required' => false,
+ 'class' => 't',
+ 'values' => array(
+ array(
+ 'id' => 'new_window_on',
+ 'value' => 1,
+ 'label' => '

'
+ ),
+ array(
+ 'id' => 'new_window_off',
+ 'value' => 0,
+ 'label' => '

'
+ )
+ )
+ )
+ ),
+ 'submit' => array(
+ 'title' => $this->l(' Save '),
+ 'class' => 'button'
+ )
+ );
+
+ parent::__construct();
+ }
+
+ public function initContent()
+ {
+ if ($this->display != 'edit' && $this->display != 'add')
+ $this->display = 'list';
+
+ parent::initContent();
+ }
+
+}
+
+
diff --git a/install-dev/sql/db_settings_lite.sql b/install-dev/sql/db_settings_lite.sql
index b25ca86b8..24f2b40f8 100644
--- a/install-dev/sql/db_settings_lite.sql
+++ b/install-dev/sql/db_settings_lite.sql
@@ -973,7 +973,7 @@ INSERT IGNORE INTO `PREFIX_tab_lang` (`id_tab`, `id_lang`, `name`)
FROM `PREFIX_lang` CROSS JOIN `PREFIX_tab`);
INSERT INTO `PREFIX_quick_access` (`id_quick_access`, `link`, `new_window`) VALUES
-(1, 'index.php', 0),(2, '../', 1),(3, 'index.php?tab=AdminCatalog&addcategory', 0),(4, 'index.php?tab=AdminCatalog&addproduct', 0),(5, 'index.php?tab=AdminDiscounts&adddiscount', 0);
+(1, 'index.php', 0),(2, '../', 1),(3, 'index.php?controller=AdminCatalog&addcategory', 0),(4, 'index.php?controller=AdminCatalog&addproduct', 0),(5, 'index.php?controller=AdminDiscounts&adddiscount', 0);
INSERT INTO `PREFIX_quick_access_lang` (`id_quick_access`, `id_lang`, `name`) VALUES
(1, 1, 'Home'),(1, 2, 'Accueil'),(1, 3, 'Inicio'),(1, 4, 'Start'),(1, 5, 'Home page'),