[*] BO #PSFV-94 : update of the displayform method by helperForm in AdminQuickAccessesController

This commit is contained in:
lLefevre
2011-10-14 08:57:52 +00:00
parent d79fcf00fb
commit 4b55e21167
7 changed files with 181 additions and 139 deletions
-91
View File
@@ -1,91 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
* @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 '
<form action="'.self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
<fieldset><legend><img src="../img/admin/quick.gif" />'.$this->l('Quick Access menu').'</legend>
<label>'.$this->l('Name:').' </label>
<div class="margin-form">';
foreach ($this->_languages as $language)
echo '
<div id="name_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
<input size="33" type="text" name="name_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name');
echo '
<div class="clear"></div>
</div>
<label>'.$this->l('URL:').' </label>
<div class="margin-form">
<input type="text" size="60" maxlength="128" name="link" value="'.htmlentities($this->getFieldValue($obj, 'link'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
</div>
<label>'.$this->l('Open in new window:').' </label>
<div class="margin-form">
<input type="radio" name="new_window" id="new_window_on" value="1" '.($new_window ? 'checked="checked" ' : '').'/>
<label class="t" for="new_window_on"><img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Yes').'" /></label>
<input type="radio" name="new_window" id="new_window_off" value="0" '.(!$new_window ? 'checked="checked" ' : '').'/>
<label class="t" for="new_window_off"><img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('No').'" /></label>
</div>
<div class="margin-form">
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
</div>
<div class="small"><sup>*</sup> '.$this->l('required field').'</div>
</fieldset>
</form>';
}
}
+3 -1
View File
@@ -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)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer">&nbsp;</span></span>{/if}
</div>
{/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)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer">&nbsp;</span></span>{/if}
{/if}
{elseif $input.type == 'select'}
<select name="{$input.name}" id="{$input.name}" {if isset($input.onchange)}onchange="{$input.onchange}"{/if}>
@@ -187,11 +189,11 @@
{/if}
</p>
{/if}
{if isset($languages)}<div class="clear"></div>{/if}
</div>
{if $input.name == 'id_state'}
</div>
{/if}
<div class="clear"></div>
{/foreach}
{elseif $key == 'submit'}
<div class="margin-form">
+22 -23
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -28,33 +28,32 @@
class OrderMessageCore extends ObjectModel
{
/** @var string name name */
public $name;
/** @var string message content */
public $message;
/** @var string Object creation date */
public $date_add;
protected $fieldsRequired = array();
protected $fieldsValidate = array();
protected $fieldsSize = array();
public $name;
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(
/** @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');
}
}
+21 -21
View File
@@ -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');
}
}
@@ -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
@@ -0,0 +1,132 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
* @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' => '<img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" />'
),
array(
'id' => 'new_window_off',
'value' => 0,
'label' => '<img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" />'
)
)
)
),
'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();
}
}
+1 -1
View File
@@ -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'),