[*] BO #PSFV-94 : Added AdminFeatureController
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10137 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
1 parent
6b502937dd
commit
764ccc45a3
13 files changed
+835
-604
No files matched your search
@@ -1,297 +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: 7331 $
|
|
||||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
|
||||||
*/
|
|
||||||
|
|
||||||
include_once(_PS_ADMIN_DIR_.'/tabs/AdminFeaturesValues.php');
|
|
||||||
|
|
||||||
class AdminFeatures extends AdminTab
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->adminFeaturesValues = new AdminFeaturesValues();
|
|
||||||
$this->table = 'feature';
|
|
||||||
$this->className = 'Feature';
|
|
||||||
$this->lang = true;
|
|
||||||
$this->edit = true;
|
|
||||||
$this->delete = true;
|
|
||||||
|
|
||||||
$this->fieldsDisplay = array(
|
|
||||||
'name' => array('title' => $this->l('Name'), 'width' => 128, 'filter_key' => 'b!name'),
|
|
||||||
'value' => array('title' => $this->l('Values'), 'width' => 255, 'orderby' => false, 'search' => false),
|
|
||||||
'position' => array('title' => $this->l('Position'), 'width' => 40,'filter_key' => 'cp!position', 'align' => 'center', 'position' => 'position'));
|
|
||||||
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function display()
|
|
||||||
{
|
|
||||||
if (Feature::isFeatureActive())
|
|
||||||
{
|
|
||||||
if ((isset($_POST['submitAddfeature_value']) AND sizeof($this->adminFeaturesValues->_errors))
|
|
||||||
OR isset($_GET['updatefeature_value']) OR isset($_GET['addfeature_value']))
|
|
||||||
{
|
|
||||||
$this->adminFeaturesValues->displayForm($this->token);
|
|
||||||
echo '<br /><br /><a href="'.self::$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" alt="" /> '.$this->l('Back to the features list').'</a><br />';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
parent::display();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').' <a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.$this->l('Performances').'</a>');
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Report to AdminTab::displayList() for more details */
|
|
||||||
public function displayList()
|
|
||||||
{
|
|
||||||
echo '<br />
|
|
||||||
<a href="'.self::$currentIndex.'&add'.$this->table.'&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> <b>'.$this->l('Add a new feature').'</b></a><br />
|
|
||||||
<a href="'.self::$currentIndex.'&addfeature_value&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add a new feature value').'</a><br /><br />
|
|
||||||
'.$this->l('Click on a feature name to view its values and then click again if you want to hide them.').'<br /><br />';
|
|
||||||
|
|
||||||
$this->displayListHeader();
|
|
||||||
echo '<input type="hidden" name="groupid" value="0">';
|
|
||||||
|
|
||||||
if (!sizeof($this->_list))
|
|
||||||
echo '<tr><td class="center" colspan="'.sizeof($this->_list).'">'.$this->l('No features found.').'</td></tr>';
|
|
||||||
|
|
||||||
|
|
||||||
echo '
|
|
||||||
<script type="text/javascript" src="../js/jquery/jquery.tablednd_0_5.js"></script>
|
|
||||||
<script type="text/javascript">
|
|
||||||
var token = \''.$this->token.'\';
|
|
||||||
var come_from = \''.$this->table.'\';
|
|
||||||
var alternate = \''.($this->_orderWay == 'DESC' ? '1' : '0' ).'\';
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="../js/admin-dnd.js"></script>
|
|
||||||
';
|
|
||||||
|
|
||||||
$irow = 0;
|
|
||||||
if ($this->_list AND isset($this->fieldsDisplay['position']))
|
|
||||||
{
|
|
||||||
$positions = array_map(create_function('$elem', 'return (int)$elem[\'position\'];'), $this->_list);
|
|
||||||
sort($positions);
|
|
||||||
}
|
|
||||||
foreach ($this->_list AS $tr)
|
|
||||||
{
|
|
||||||
$id = (int)($tr['id_'.$this->table]);
|
|
||||||
echo '
|
|
||||||
<tr'.($irow++ % 2 ? ' class="alt_row"' : '').' id="tr_'.$tr['id_feature'].'_'.$tr['position'].'">
|
|
||||||
<td style="vertical-align: top; padding: 4px 0 4px 0" class="center"><input type="checkbox" name="'.$this->table.'Box[]" value="'.$id.'" class="noborder" /></td>
|
|
||||||
<td style="width: 140px; vertical-align: top; padding: 4px 0 4px 0; cursor: pointer" onclick="$(\'#features_values_'.$id.'\').slideToggle();">'.$tr['name'].'</td>
|
|
||||||
<td style="vertical-align: top; padding: 4px 0 4px 0; width: 340px">
|
|
||||||
<div id="features_values_'.$id.'" style="display: none">
|
|
||||||
<table class="table" cellpadding="0" cellspacing="0">
|
|
||||||
<tr>
|
|
||||||
<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'feature_value'.$id.'Box[]\', this.checked)" /></th>
|
|
||||||
<th width="100%">'.$this->l('Value').'</th>
|
|
||||||
<th>'.$this->l('Actions').'</th>
|
|
||||||
</tr>';
|
|
||||||
$features = FeatureValue::getFeatureValuesWithLang((int)(Configuration::get('PS_LANG_DEFAULT')), $id);
|
|
||||||
foreach ($features AS $feature)
|
|
||||||
{
|
|
||||||
echo '
|
|
||||||
<tr>
|
|
||||||
<td class="center"><input type="checkbox" name="feature_value'.$id.'Box[]" value="'.$feature['id_feature_value'].'" class="noborder" /></td>
|
|
||||||
<td>'.$feature['value'].'</td>
|
|
||||||
<td class="center">
|
|
||||||
<a href="'.self::$currentIndex.'&id_feature_value='.$feature['id_feature_value'].'&updatefeature_value&token='.$this->token.'">
|
|
||||||
<img src="../img/admin/edit.gif" border="0" alt="'.$this->l('Edit').'" title="'.$this->l('Edit').'" /></a>
|
|
||||||
<a href="'.self::$currentIndex.'&id_feature_value='.$feature['id_feature_value'].'&deletefeature_value&token='.$this->token.'"
|
|
||||||
onclick="return confirm(\''.$this->l('Delete value', __CLASS__, true, false).' #'.$feature['id_feature_value'].'?\');">
|
|
||||||
<img src="../img/admin/delete.gif" border="0" alt="'.$this->l('Delete').'" title="'.$this->l('Delete').'" /></a>
|
|
||||||
</td>
|
|
||||||
</tr>';
|
|
||||||
}
|
|
||||||
if (!sizeof($features))
|
|
||||||
echo '
|
|
||||||
<tr><td colspan="3" style="text-align:center">'.$this->l('No values defined').'</td></tr>';
|
|
||||||
echo '
|
|
||||||
</table>
|
|
||||||
<p><input type="Submit" class="button" name="submitDelfeature_value" value="'.$this->l('Delete selection').'"
|
|
||||||
onclick="changeFormParam(this.form, \'?tab=AdminFeatures\', '.$id.'); return confirm(\''.$this->l('Delete selected items?', __CLASS__, true, false).'\');" /></p>
|
|
||||||
</div>
|
|
||||||
</td>';
|
|
||||||
|
|
||||||
echo '
|
|
||||||
<td style="width: 140px; vertical-align: top; padding: 4px 0 4px 0; cursor: pointer" class="dragHandle">';
|
|
||||||
|
|
||||||
if ($this->_orderBy == 'position' AND $this->_orderWay != 'DESC')
|
|
||||||
{
|
|
||||||
echo '<a'.(!($tr['position'] != $positions[sizeof($positions) - 1]) ? ' style="display: none;"' : '').' href="'.self::$currentIndex.
|
|
||||||
'&'.$this->identifiersDnd[$this->identifier].'='.$id.'
|
|
||||||
&way=1&position='.((int)$tr['position'] + 1).'&token='.$this->token.'">
|
|
||||||
<img src="../img/admin/'.($this->_orderWay == 'ASC' ? 'down' : 'up').'.gif"
|
|
||||||
alt="'.$this->l('Down').'" title="'.$this->l('Down').'" /></a>';
|
|
||||||
|
|
||||||
echo '<a'.(!($tr['position'] != $positions[0]) ? ' style="display: none;"' : '').' href="'.self::$currentIndex.
|
|
||||||
'&'.$this->identifiersDnd[$this->identifier].'='.$id.'
|
|
||||||
&way=0&position='.((int)$tr['position'] - 1).'&token='.$this->token.'">
|
|
||||||
<img src="../img/admin/'.($this->_orderWay == 'ASC' ? 'up' : 'down').'.gif"
|
|
||||||
alt="'.$this->l('Up').'" title="'.$this->l('Up').'" /></a>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
echo (int)($tr['position'] + 1);
|
|
||||||
|
|
||||||
|
|
||||||
echo '
|
|
||||||
<td style="vertical-align: top; padding: 4px 0 4px 0" class="center">
|
|
||||||
<a href="'.self::$currentIndex.'&id_'.$this->table.'='.$id.'&update'.$this->table.'&token='.$this->token.'">
|
|
||||||
<img src="../img/admin/edit.gif" border="0" alt="'.$this->l('Edit').'" title="'.$this->l('Edit').'" /></a>
|
|
||||||
<a href="'.self::$currentIndex.'&id_'.$this->table.'='.$id.'&delete'.$this->table.'&token='.$this->token.'" onclick="return confirm(\''.$this->l('Delete item', __CLASS__, true, false).' #'.$id.'?\');">
|
|
||||||
<img src="../img/admin/delete.gif" border="0" alt="'.$this->l('Delete').'" title="'.$this->l('Delete').'" /></a>
|
|
||||||
</td>
|
|
||||||
</tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->displayListFooter();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayForm($isMainTab = true)
|
|
||||||
{
|
|
||||||
if (!Feature::isFeatureActive())
|
|
||||||
{
|
|
||||||
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').'<a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.$this->l('Performances').'</a>');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
parent::displayForm();
|
|
||||||
|
|
||||||
if (!($obj = $this->loadObject(true)))
|
|
||||||
return;
|
|
||||||
|
|
||||||
echo '
|
|
||||||
<h2>'.$this->l('Add a new feature').'</h2>
|
|
||||||
<form action="'.self::$currentIndex.'&token='.$this->token.'"" method="post">
|
|
||||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
|
||||||
<fieldset class="width2">
|
|
||||||
<legend><img src="../img/t/AdminFeatures.gif" />'.$this->l('Add a new feature').'</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('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
var flag_fields = \'name\';
|
|
||||||
</script>';
|
|
||||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'flag_fields', 'name', false, true);
|
|
||||||
echo '
|
|
||||||
<div class="clear"></div>
|
|
||||||
</div>';
|
|
||||||
if (Shop::isFeatureActive())
|
|
||||||
{
|
|
||||||
echo '<label>'.$this->l('GroupShop association:').'</label><div class="margin-form">';
|
|
||||||
$this->displayAssoShop('group_shop');
|
|
||||||
echo '</div>';
|
|
||||||
}
|
|
||||||
echo '
|
|
||||||
'.Hook::exec('featureForm', array('id_feature' => $obj->id)).'
|
|
||||||
<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>';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayErrors()
|
|
||||||
{
|
|
||||||
$this->adminFeaturesValues->displayErrors();
|
|
||||||
parent::displayErrors();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function postProcess()
|
|
||||||
{
|
|
||||||
if (!Feature::isFeatureActive())
|
|
||||||
return ;
|
|
||||||
|
|
||||||
$this->adminFeaturesValues->tabAccess = Profile::getProfileAccess($this->context->employee->id_profile, $this->id);
|
|
||||||
|
|
||||||
if (Tools::isSubmit('submitAddfeature_value') || Tools::isSubmit('submitDelfeature_value'))
|
|
||||||
$this->adminFeaturesValues->postProcess($this->token);
|
|
||||||
|
|
||||||
Hook::exec('postProcessFeature',
|
|
||||||
array('errors' => &$this->_errors)); // send _errors as reference to allow postProcessFeature to stop saving process
|
|
||||||
|
|
||||||
if(Tools::getValue('submitDel'.$this->table))
|
|
||||||
{
|
|
||||||
if ($this->tabAccess['delete'] === '1')
|
|
||||||
{
|
|
||||||
if (isset($_POST[$this->table.'Box']))
|
|
||||||
{
|
|
||||||
$object = new $this->className();
|
|
||||||
if ($object->deleteSelection($_POST[$this->table.'Box']))
|
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&conf=2'.'&token='.$this->token);
|
|
||||||
$this->_errors[] = Tools::displayError('An error occurred while deleting selection.');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$this->_errors[] = Tools::displayError('You must select at least one element to delete.');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
|
||||||
}
|
|
||||||
else if (Tools::isSubmit('submitAdd'.$this->table))
|
|
||||||
{
|
|
||||||
if ($this->tabAccess['add'] === '1')
|
|
||||||
{
|
|
||||||
$id_feature = (int)Tools::getValue('id_feature');
|
|
||||||
// Adding last position to the feature if not exist
|
|
||||||
if ($id_feature <= 0)
|
|
||||||
{
|
|
||||||
$sql = 'SELECT `position`+1
|
|
||||||
FROM `'._DB_PREFIX_.'feature`
|
|
||||||
ORDER BY position DESC';
|
|
||||||
// set the position of the new feature in $_POST for postProcess() method
|
|
||||||
$_POST['position'] = DB::getInstance()->getValue($sql);
|
|
||||||
}
|
|
||||||
// clean \n\r characters
|
|
||||||
foreach ($_POST as $key => $value)
|
|
||||||
if (preg_match('/^name_/Ui', $key))
|
|
||||||
$_POST[$key] = str_replace ('\n', '', str_replace('\r', '', $value));
|
|
||||||
parent::postProcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
parent::postProcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Modifying initial getList method to display position feature (drag and drop)
|
|
||||||
*/
|
|
||||||
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
|
|
||||||
{
|
|
||||||
if ($order_by && $this->context->cookie->__get($this->table.'Orderby'))
|
|
||||||
$order_by = $this->context->cookie->__get($this->table.'Orderby');
|
|
||||||
else
|
|
||||||
$order_by = 'position';
|
|
||||||
|
|
||||||
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,124 +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 AdminFeaturesValues extends AdminTab
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->table = 'feature_value';
|
|
||||||
$this->className = 'FeatureValue';
|
|
||||||
$this->lang = true;
|
|
||||||
$this->edit = true;
|
|
||||||
$this->delete = true;
|
|
||||||
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display form
|
|
||||||
*/
|
|
||||||
public function displayForm($isMainTab = true)
|
|
||||||
{
|
|
||||||
if (!Feature::isFeatureActive())
|
|
||||||
{
|
|
||||||
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').' <a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.$this->l('Performances').'</a>');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
parent::displayForm();
|
|
||||||
|
|
||||||
if (!($obj = $this->loadObject(true)))
|
|
||||||
return;
|
|
||||||
|
|
||||||
echo '
|
|
||||||
<h2>'.$this->l('Add a new feature value').'</h2>
|
|
||||||
<form action="'.self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.Tools::getValue('token').'" method="post">
|
|
||||||
'.($obj->id ? '<input type="hidden" name="id_feature_value" value="'.$obj->id.'" />' : '').'
|
|
||||||
<fieldset class="width2">
|
|
||||||
<legend><img src="../img/t/AdminFeatures.gif" />'.$this->l('Add a new feature value').'</legend>
|
|
||||||
<label>'.$this->l('Value:').' </label>
|
|
||||||
<div class="margin-form">';
|
|
||||||
foreach ($this->_languages as $language)
|
|
||||||
echo '
|
|
||||||
<div id="value_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
|
||||||
<input size="33" type="text" name="value_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'value', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
|
|
||||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
var flag_fields = \'value\';
|
|
||||||
</script>';
|
|
||||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'flag_fields', 'value', false, true);
|
|
||||||
echo '
|
|
||||||
<div class="clear"></div>
|
|
||||||
</div>
|
|
||||||
<label>'.$this->l('Feature:').' </label>
|
|
||||||
<div class="margin-form">
|
|
||||||
<select name="id_feature">';
|
|
||||||
$features = Feature::getFeatures($this->_defaultFormLanguage);
|
|
||||||
foreach ($features AS $feature)
|
|
||||||
echo '<option value="'.$feature['id_feature'].'"'.($this->getFieldValue($obj, 'id_feature') == $feature['id_feature']? ' selected="selected"' : '').'>'.$feature['name'].'</option>';
|
|
||||||
echo '
|
|
||||||
</select><sup> *</sup>
|
|
||||||
</div>
|
|
||||||
'.Hook::exec('featureValueForm', array('id_feature_value' => $obj->id)).'
|
|
||||||
<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>';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Manage page processing
|
|
||||||
*/
|
|
||||||
public function postProcess($token = NULL)
|
|
||||||
{
|
|
||||||
Hook::exec('postProcessFeatureValue',
|
|
||||||
array('errors' => &$this->_errors)); // send _errors as reference to allow postProcessFeatureValue to stop saving process
|
|
||||||
|
|
||||||
if(Tools::getValue('submitDel'.$this->table))
|
|
||||||
{
|
|
||||||
if ($this->tabAccess['delete'] === '1')
|
|
||||||
{
|
|
||||||
if (isset($_POST[$this->table.$_POST['groupid'].'Box']))
|
|
||||||
{
|
|
||||||
$object = new $this->className();
|
|
||||||
if ($object->deleteSelection($_POST[$this->table.$_POST['groupid'].'Box']))
|
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&conf=2'.'&token='.($token ? $token : $this->token));
|
|
||||||
$this->_errors[] = Tools::displayError('An error occurred while deleting selection.');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$this->_errors[] = Tools::displayError('You must select at least one element to delete.');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
parent::postProcess();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
{*
|
||||||
|
* 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 <contact@prestashop.com>
|
||||||
|
* @copyright 2007-2011 PrestaShop SA
|
||||||
|
* @version Release: $Revision: 8971 $
|
||||||
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
|
*}
|
||||||
|
{extends file="helper/form/form.tpl"}
|
||||||
|
|
||||||
|
{block name="end_field_block"}
|
||||||
|
</div>
|
||||||
|
{if $input.name == 'id_feature'}
|
||||||
|
{if isset($hook)}{$hook}{/if}
|
||||||
|
{/if}
|
||||||
|
{/block}
|
||||||
@@ -1863,6 +1863,13 @@ class AdminControllerCore extends Controller
|
|||||||
return $this->_languages;
|
return $this->_languages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the list of fields value
|
||||||
|
*
|
||||||
|
* @param object $obj Object
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getFieldsValue($obj)
|
public function getFieldsValue($obj)
|
||||||
{
|
{
|
||||||
foreach ($this->fields_form as $fieldset)
|
foreach ($this->fields_form as $fieldset)
|
||||||
@@ -1873,11 +1880,12 @@ class AdminControllerCore extends Controller
|
|||||||
{
|
{
|
||||||
if ($obj->id)
|
if ($obj->id)
|
||||||
{
|
{
|
||||||
$assos = array();
|
if ($input['type'] == 'group_shop')
|
||||||
$sql = 'SELECT `id_'.$input['type'].'`, `'.pSQL($this->identifier).'`
|
$result = GroupShop::getGroupShopById((int)$obj->id, $this->identifier, $this->table);
|
||||||
FROM `'._DB_PREFIX_.pSQL($this->table).'_'.$input['type'].'`
|
else
|
||||||
WHERE `'.pSQL($this->identifier).'` = '.(int)$obj->id;
|
$result = Shop::getShopById((int)$obj->id, $this->identifier, $this->table);
|
||||||
foreach (Db::getInstance()->executeS($sql) as $row)
|
|
||||||
|
foreach ($result as $row)
|
||||||
$this->fields_value['shop'][$row['id_'.$input['type']]][] = $row[$this->identifier];
|
$this->fields_value['shop'][$row['id_'.$input['type']]][] = $row[$this->identifier];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+67
-42
@@ -28,17 +28,20 @@
|
|||||||
class FeatureCore extends ObjectModel
|
class FeatureCore extends ObjectModel
|
||||||
{
|
{
|
||||||
/** @var string Name */
|
/** @var string Name */
|
||||||
public $name;
|
public $name;
|
||||||
public $position;
|
public $position;
|
||||||
|
|
||||||
protected $fieldsRequiredLang = array('name');
|
protected $fieldsRequiredLang = array('name');
|
||||||
protected $fieldsSizeLang = array('name' => 128);
|
protected $fieldsSizeLang = array('name' => 128);
|
||||||
protected $fieldsValidateLang = array('name' => 'isGenericName', 'position' => 'isInt');
|
protected $fieldsValidateLang = array(
|
||||||
|
'name' => 'isGenericName',
|
||||||
|
'position' => 'isInt'
|
||||||
|
);
|
||||||
|
|
||||||
protected $table = 'feature';
|
protected $table = 'feature';
|
||||||
protected $identifier = 'id_feature';
|
protected $identifier = 'id_feature';
|
||||||
|
|
||||||
protected $webserviceParameters = array(
|
protected $webserviceParameters = array(
|
||||||
'objectsNodeName' => 'product_features',
|
'objectsNodeName' => 'product_features',
|
||||||
'objectNodeName' => 'product_feature',
|
'objectNodeName' => 'product_feature',
|
||||||
'fields' => array(),
|
'fields' => array(),
|
||||||
@@ -46,7 +49,7 @@ class FeatureCore extends ObjectModel
|
|||||||
|
|
||||||
public function getFields()
|
public function getFields()
|
||||||
{
|
{
|
||||||
return array('id_feature' => NULL, 'position' => (int)$this->position);
|
return array('id_feature' => null, 'position' => (int)$this->position);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,10 +74,12 @@ class FeatureCore extends ObjectModel
|
|||||||
public static function getFeature($id_lang, $id_feature)
|
public static function getFeature($id_lang, $id_feature)
|
||||||
{
|
{
|
||||||
return Db::getInstance()->getRow('
|
return Db::getInstance()->getRow('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `'._DB_PREFIX_.'feature` f
|
FROM `'._DB_PREFIX_.'feature` f
|
||||||
LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl ON ( f.`id_feature` = fl.`id_feature` AND fl.`id_lang` = '.(int)($id_lang).')
|
LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl
|
||||||
WHERE f.`id_feature` = '.(int)($id_feature));
|
ON ( f.`id_feature` = fl.`id_feature` AND fl.`id_lang` = '.(int)$id_lang.')
|
||||||
|
WHERE f.`id_feature` = '.(int)$id_feature
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,10 +92,12 @@ class FeatureCore extends ObjectModel
|
|||||||
public static function getFeatures($id_lang)
|
public static function getFeatures($id_lang)
|
||||||
{
|
{
|
||||||
return Db::getInstance()->executeS('
|
return Db::getInstance()->executeS('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `'._DB_PREFIX_.'feature` f
|
FROM `'._DB_PREFIX_.'feature` f
|
||||||
LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl ON (f.`id_feature` = fl.`id_feature` AND fl.`id_lang` = '.(int)($id_lang).')
|
LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl
|
||||||
ORDER BY f.`position` ASC');
|
ON (f.`id_feature` = fl.`id_feature` AND fl.`id_lang` = '.(int)$id_lang.')
|
||||||
|
ORDER BY f.`position` ASC
|
||||||
|
');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,7 +109,8 @@ class FeatureCore extends ObjectModel
|
|||||||
public function deleteSelection($selection)
|
public function deleteSelection($selection)
|
||||||
{
|
{
|
||||||
/* Also delete Attributes */
|
/* Also delete Attributes */
|
||||||
foreach ($selection AS $value) {
|
foreach ($selection as $value)
|
||||||
|
{
|
||||||
$obj = new Feature($value);
|
$obj = new Feature($value);
|
||||||
if (!$obj->delete())
|
if (!$obj->delete())
|
||||||
return false;
|
return false;
|
||||||
@@ -123,13 +131,22 @@ class FeatureCore extends ObjectModel
|
|||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
/* Also delete related attributes */
|
/* Also delete related attributes */
|
||||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'feature_value_lang` WHERE `id_feature_value` IN (SELECT id_feature_value FROM `'._DB_PREFIX_.'feature_value` WHERE `id_feature` = '.(int)($this->id).')');
|
Db::getInstance()->execute('
|
||||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'feature_value` WHERE `id_feature` = '.(int)($this->id));
|
DELETE FROM `'._DB_PREFIX_.'feature_value_lang`
|
||||||
|
WHERE `id_feature_value` IN (SELECT id_feature_value FROM `'._DB_PREFIX_.'feature_value` WHERE `id_feature` = '.(int)$this->id.')
|
||||||
|
');
|
||||||
|
Db::getInstance()->execute('
|
||||||
|
DELETE FROM `'._DB_PREFIX_.'feature_value`
|
||||||
|
WHERE `id_feature` = '.(int)$this->id
|
||||||
|
);
|
||||||
/* Also delete related products */
|
/* Also delete related products */
|
||||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'feature_product` WHERE `id_feature` = '.(int)($this->id));
|
Db::getInstance()->execute('
|
||||||
|
DELETE FROM `'._DB_PREFIX_.'feature_product`
|
||||||
|
WHERE `id_feature` = '.(int)$this->id
|
||||||
|
);
|
||||||
|
|
||||||
$return = parent::delete();
|
$return = parent::delete();
|
||||||
if($return)
|
if ($return)
|
||||||
Hook::exec('afterDeleteFeature', array('id_feature' => $this->id));
|
Hook::exec('afterDeleteFeature', array('id_feature' => $this->id));
|
||||||
|
|
||||||
/* Reinitializing position */
|
/* Reinitializing position */
|
||||||
@@ -174,7 +191,7 @@ class FeatureCore extends ObjectModel
|
|||||||
$result = Db::getInstance()->getRow('
|
$result = Db::getInstance()->getRow('
|
||||||
SELECT COUNT(ag.`id_feature`) as nb
|
SELECT COUNT(ag.`id_feature`) as nb
|
||||||
FROM `'._DB_PREFIX_.'feature` ag
|
FROM `'._DB_PREFIX_.'feature` ag
|
||||||
LEFT JOIN `'._DB_PREFIX_.'feature_lang` agl ON (ag.`id_feature` = agl.`id_feature` AND `id_lang` = '.(int)($id_lang).')
|
LEFT JOIN `'._DB_PREFIX_.'feature_lang` agl ON (ag.`id_feature` = agl.`id_feature` AND `id_lang` = '.(int)$id_lang.')
|
||||||
ORDER BY `name` ASC');
|
ORDER BY `name` ASC');
|
||||||
return ($result['nb']);
|
return ($result['nb']);
|
||||||
}
|
}
|
||||||
@@ -188,9 +205,14 @@ class FeatureCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public static function addFeatureImport($name, $position = false)
|
public static function addFeatureImport($name, $position = false)
|
||||||
{
|
{
|
||||||
$rq = Db::getInstance()->getRow('SELECT `id_feature` FROM '._DB_PREFIX_.'feature_lang WHERE `name` = \''.pSQL($name).'\' GROUP BY `id_feature`');
|
$rq = Db::getInstance()->getRow('
|
||||||
|
SELECT `id_feature`
|
||||||
|
FROM '._DB_PREFIX_.'feature_lang
|
||||||
|
WHERE `name` = \''.pSQL($name).'\'
|
||||||
|
GROUP BY `id_feature`
|
||||||
|
');
|
||||||
if (!empty($rq))
|
if (!empty($rq))
|
||||||
return (int)($rq['id_feature']);
|
return (int)$rq['id_feature'];
|
||||||
// Feature doesn't exist, create it
|
// Feature doesn't exist, create it
|
||||||
$feature = new Feature();
|
$feature = new Feature();
|
||||||
$languages = Language::getLanguages();
|
$languages = Language::getLanguages();
|
||||||
@@ -210,8 +232,8 @@ class FeatureCore extends ObjectModel
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
$ids = '';
|
$ids = '';
|
||||||
foreach($list_ids_product as $id)
|
foreach ($list_ids_product as $id)
|
||||||
$ids .= (int)($id).',';
|
$ids .= (int)$id.',';
|
||||||
|
|
||||||
$ids = rtrim($ids, ',');
|
$ids = rtrim($ids, ',');
|
||||||
|
|
||||||
@@ -219,14 +241,17 @@ class FeatureCore extends ObjectModel
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
return Db::getInstance()->executeS('
|
return Db::getInstance()->executeS('
|
||||||
SELECT * , COUNT(*) as nb
|
SELECT * , COUNT(*) as nb
|
||||||
FROM `'._DB_PREFIX_.'feature` f
|
FROM `'._DB_PREFIX_.'feature` f
|
||||||
LEFT JOIN `'._DB_PREFIX_.'feature_product` fp ON f.`id_feature` = fp.`id_feature`
|
LEFT JOIN `'._DB_PREFIX_.'feature_product` fp
|
||||||
LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl ON f.`id_feature` = fl.`id_feature`
|
ON f.`id_feature` = fp.`id_feature`
|
||||||
WHERE fp.`id_product` IN ('.$ids.')
|
LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl
|
||||||
AND `id_lang` = '.(int)($id_lang).'
|
ON f.`id_feature` = fl.`id_feature`
|
||||||
GROUP BY f.`id_feature`
|
WHERE fp.`id_product` IN ('.$ids.')
|
||||||
ORDER BY nb DESC');
|
AND `id_lang` = '.(int)$id_lang.'
|
||||||
|
GROUP BY f.`id_feature`
|
||||||
|
ORDER BY nb DESC
|
||||||
|
');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -255,11 +280,11 @@ class FeatureCore extends ObjectModel
|
|||||||
))
|
))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
foreach ($res AS $feature)
|
foreach ($res as $feature)
|
||||||
if ((int)$feature['id_feature'] == (int)$this->id)
|
if ((int)$feature['id_feature'] == (int)$this->id)
|
||||||
$movedFeature = $feature;
|
$moved_feature = $feature;
|
||||||
|
|
||||||
if (!isset($movedFeature) || !isset($position))
|
if (!isset($moved_feature) || !isset($position))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// < and > statements rather than BETWEEN operator
|
// < and > statements rather than BETWEEN operator
|
||||||
@@ -269,12 +294,12 @@ class FeatureCore extends ObjectModel
|
|||||||
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
|
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
|
||||||
WHERE `position`
|
WHERE `position`
|
||||||
'.($way
|
'.($way
|
||||||
? '> '.(int)$movedFeature['position'].' AND `position` <= '.(int)$position
|
? '> '.(int)$moved_feature['position'].' AND `position` <= '.(int)$position
|
||||||
: '< '.(int)$movedFeature['position'].' AND `position` >= '.(int)$position))
|
: '< '.(int)$moved_feature['position'].' AND `position` >= '.(int)$position))
|
||||||
AND Db::getInstance()->execute('
|
&& Db::getInstance()->execute('
|
||||||
UPDATE `'._DB_PREFIX_.'feature`
|
UPDATE `'._DB_PREFIX_.'feature`
|
||||||
SET `position` = '.(int)$position.'
|
SET `position` = '.(int)$position.'
|
||||||
WHERE `id_feature`='.(int)$movedFeature['id_feature']));
|
WHERE `id_feature`='.(int)$moved_feature['id_feature']));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+65
-51
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* 2007-2011 PrestaShop
|
* 2007-2011 PrestaShop
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* NOTICE OF LICENSE
|
||||||
*
|
*
|
||||||
@@ -28,23 +28,27 @@
|
|||||||
class FeatureValueCore extends ObjectModel
|
class FeatureValueCore extends ObjectModel
|
||||||
{
|
{
|
||||||
/** @var integer Group id which attribute belongs */
|
/** @var integer Group id which attribute belongs */
|
||||||
public $id_feature;
|
public $id_feature;
|
||||||
|
|
||||||
/** @var string Name */
|
/** @var string Name */
|
||||||
public $value;
|
public $value;
|
||||||
|
|
||||||
/** @var boolean Custom */
|
/** @var boolean Custom */
|
||||||
public $custom = 0;
|
public $custom = 0;
|
||||||
|
|
||||||
protected $fieldsRequired = array('id_feature');
|
protected $fieldsRequired = array('id_feature');
|
||||||
protected $fieldsValidate = array('id_feature' => 'isUnsignedId', 'custom' => 'isBool');
|
protected $fieldsValidate = array(
|
||||||
protected $fieldsRequiredLang = array('value');
|
'id_feature' => 'isUnsignedId',
|
||||||
protected $fieldsSizeLang = array('value' => 255);
|
'custom' => 'isBool'
|
||||||
protected $fieldsValidateLang = array('value' => 'isGenericName');
|
);
|
||||||
|
|
||||||
protected $table = 'feature_value';
|
protected $fieldsRequiredLang = array('value');
|
||||||
protected $identifier = 'id_feature_value';
|
protected $fieldsSizeLang = array('value' => 255);
|
||||||
|
protected $fieldsValidateLang = array('value' => 'isGenericName');
|
||||||
|
|
||||||
|
protected $table = 'feature_value';
|
||||||
|
protected $identifier = 'id_feature_value';
|
||||||
|
|
||||||
protected $webserviceParameters = array(
|
protected $webserviceParameters = array(
|
||||||
'objectsNodeName' => 'product_feature_values',
|
'objectsNodeName' => 'product_feature_values',
|
||||||
'objectNodeName' => 'product_feature_value',
|
'objectNodeName' => 'product_feature_value',
|
||||||
@@ -62,7 +66,7 @@ class FeatureValueCore extends ObjectModel
|
|||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check then return multilingual fields for database interaction
|
* Check then return multilingual fields for database interaction
|
||||||
*
|
*
|
||||||
@@ -73,7 +77,7 @@ class FeatureValueCore extends ObjectModel
|
|||||||
$this->validateFieldsLang();
|
$this->validateFieldsLang();
|
||||||
return $this->getTranslationsFields(array('value'));
|
return $this->getTranslationsFields(array('value'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all values for a given feature
|
* Get all values for a given feature
|
||||||
*
|
*
|
||||||
@@ -84,11 +88,12 @@ class FeatureValueCore extends ObjectModel
|
|||||||
public static function getFeatureValues($id_feature)
|
public static function getFeatureValues($id_feature)
|
||||||
{
|
{
|
||||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `'._DB_PREFIX_.'feature_value`
|
FROM `'._DB_PREFIX_.'feature_value`
|
||||||
WHERE `id_feature` = '.(int)$id_feature);
|
WHERE `id_feature` = '.(int)$id_feature
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all values for a given feature and language
|
* Get all values for a given feature and language
|
||||||
*
|
*
|
||||||
@@ -100,11 +105,14 @@ class FeatureValueCore extends ObjectModel
|
|||||||
public static function getFeatureValuesWithLang($id_lang, $id_feature)
|
public static function getFeatureValuesWithLang($id_lang, $id_feature)
|
||||||
{
|
{
|
||||||
return Db::getInstance()->executeS('
|
return Db::getInstance()->executeS('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `'._DB_PREFIX_.'feature_value` v
|
FROM `'._DB_PREFIX_.'feature_value` v
|
||||||
LEFT JOIN `'._DB_PREFIX_.'feature_value_lang` vl ON (v.`id_feature_value` = vl.`id_feature_value` AND vl.`id_lang` = '.(int)$id_lang.')
|
LEFT JOIN `'._DB_PREFIX_.'feature_value_lang` vl
|
||||||
WHERE v.`id_feature` = '.(int)$id_feature.' AND (v.`custom` IS NULL OR v.`custom` = 0)
|
ON (v.`id_feature_value` = vl.`id_feature_value` AND vl.`id_lang` = '.(int)$id_lang.')
|
||||||
ORDER BY vl.`value` ASC');
|
WHERE v.`id_feature` = '.(int)$id_feature.'
|
||||||
|
AND (v.`custom` IS NULL OR v.`custom` = 0)
|
||||||
|
ORDER BY vl.`value` ASC
|
||||||
|
');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,12 +125,13 @@ class FeatureValueCore extends ObjectModel
|
|||||||
public static function getFeatureValueLang($id_feature_value)
|
public static function getFeatureValueLang($id_feature_value)
|
||||||
{
|
{
|
||||||
return Db::getInstance()->executeS('
|
return Db::getInstance()->executeS('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `'._DB_PREFIX_.'feature_value_lang`
|
FROM `'._DB_PREFIX_.'feature_value_lang`
|
||||||
WHERE `id_feature_value` = '.(int)$id_feature_value.'
|
WHERE `id_feature_value` = '.(int)$id_feature_value.'
|
||||||
ORDER BY `id_lang`');
|
ORDER BY `id_lang`
|
||||||
|
');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select the good lang in tab
|
* Select the good lang in tab
|
||||||
*
|
*
|
||||||
@@ -137,32 +146,34 @@ class FeatureValueCore extends ObjectModel
|
|||||||
if ($tab['id_lang'] == $id_lang)
|
if ($tab['id_lang'] == $id_lang)
|
||||||
return $tab['value'];
|
return $tab['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function addFeatureValueImport($id_feature, $name)
|
public static function addFeatureValueImport($id_feature, $name)
|
||||||
{
|
{
|
||||||
$rq = Db::getInstance()->executeS('
|
$rq = Db::getInstance()->executeS('
|
||||||
SELECT fv.`id_feature_value`
|
SELECT fv.`id_feature_value`
|
||||||
FROM '._DB_PREFIX_.'feature_value fv
|
FROM '._DB_PREFIX_.'feature_value fv
|
||||||
LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.`id_feature_value` = fv.`id_feature_value`)
|
LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl
|
||||||
WHERE `value` = \''.pSQL($name).'\'
|
ON (fvl.`id_feature_value` = fv.`id_feature_value`)
|
||||||
AND fv.`id_feature` = '.(int)$id_feature.'
|
WHERE `value` = \''.pSQL($name).'\'
|
||||||
AND fv.`custom` = 0
|
AND fv.`id_feature` = '.(int)$id_feature.'
|
||||||
GROUP BY fv.`id_feature_value` LIMIT 1');
|
AND fv.`custom` = 0
|
||||||
|
GROUP BY fv.`id_feature_value` LIMIT 1
|
||||||
|
');
|
||||||
|
|
||||||
if (!isset($rq[0]['id_feature_value']) OR !$id_feature_value = (int)$rq[0]['id_feature_value'])
|
if (!isset($rq[0]['id_feature_value']) || !$id_feature_value = (int)$rq[0]['id_feature_value'])
|
||||||
{
|
{
|
||||||
// Feature doesn't exist, create it
|
// Feature doesn't exist, create it
|
||||||
$featureValue = new FeatureValue();
|
$feature_value = new FeatureValue();
|
||||||
|
|
||||||
$languages = Language::getLanguages();
|
$languages = Language::getLanguages();
|
||||||
foreach ($languages AS $language)
|
foreach ($languages as $language)
|
||||||
$featureValue->value[$language['id_lang']] = strval($name);
|
$feature_value->value[$language['id_lang']] = strval($name);
|
||||||
|
|
||||||
$featureValue->id_feature = (int)$id_feature;
|
$feature_value->id_feature = (int)$id_feature;
|
||||||
$featureValue->custom = 1;
|
$feature_value->custom = 1;
|
||||||
$featureValue->add();
|
$feature_value->add();
|
||||||
|
|
||||||
return (int)$featureValue->id;
|
return (int)$feature_value->id;
|
||||||
}
|
}
|
||||||
return (int)$id_feature_value;
|
return (int)$id_feature_value;
|
||||||
}
|
}
|
||||||
@@ -178,9 +189,12 @@ class FeatureValueCore extends ObjectModel
|
|||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
/* Also delete related products */
|
/* Also delete related products */
|
||||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'feature_product` WHERE `id_feature_value` = '.(int)$this->id);
|
Db::getInstance()->execute('
|
||||||
|
DELETE FROM `'._DB_PREFIX_.'feature_product`
|
||||||
|
WHERE `id_feature_value` = '.(int)$this->id
|
||||||
|
);
|
||||||
$return = parent::delete();
|
$return = parent::delete();
|
||||||
|
|
||||||
if ($return)
|
if ($return)
|
||||||
Hook::exec('afterDeleteFeatureValue', array('id_feature_value' => $this->id));
|
Hook::exec('afterDeleteFeatureValue', array('id_feature_value' => $this->id));
|
||||||
return $return;
|
return $return;
|
||||||
|
|||||||
+18
-15
@@ -48,6 +48,9 @@ class HelperListCore extends Helper
|
|||||||
/** @var string Default ORDER BY clause when $orderBy is not defined */
|
/** @var string Default ORDER BY clause when $orderBy is not defined */
|
||||||
public $_defaultOrderBy = false;
|
public $_defaultOrderBy = false;
|
||||||
|
|
||||||
|
/** @var array : list of vars for button delete*/
|
||||||
|
public $tpl_delete_link_vars = array();
|
||||||
|
|
||||||
/** @var string Order way (ASC, DESC) determined by arrows in list header */
|
/** @var string Order way (ASC, DESC) determined by arrows in list header */
|
||||||
public $orderWay;
|
public $orderWay;
|
||||||
|
|
||||||
@@ -100,7 +103,8 @@ class HelperListCore extends Helper
|
|||||||
'id_attribute' => 'id_attribute',
|
'id_attribute' => 'id_attribute',
|
||||||
'id_attribute_group' => 'id_attribute_group',
|
'id_attribute_group' => 'id_attribute_group',
|
||||||
'id_carrier' => 'id_carrier',
|
'id_carrier' => 'id_carrier',
|
||||||
'id_tab' => 'id_tab'
|
'id_tab' => 'id_tab',
|
||||||
|
'id_feature' => 'id_feature'
|
||||||
);
|
);
|
||||||
|
|
||||||
/** @var if not null, a title will be added on that list */
|
/** @var if not null, a title will be added on that list */
|
||||||
@@ -219,7 +223,7 @@ class HelperListCore extends Helper
|
|||||||
|
|
||||||
if (method_exists($this->context->controller, $method_name))
|
if (method_exists($this->context->controller, $method_name))
|
||||||
$this->_list[$index][$action] = $this->context->controller->$method_name($token, $id);
|
$this->_list[$index][$action] = $this->context->controller->$method_name($token, $id);
|
||||||
elseif (method_exists($this, $method_name))
|
else if (method_exists($this, $method_name))
|
||||||
$this->_list[$index][$action] = $this->$method_name($token, $id);
|
$this->_list[$index][$action] = $this->$method_name($token, $id);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -248,9 +252,9 @@ class HelperListCore extends Helper
|
|||||||
Tools::getValue('id_product')
|
Tools::getValue('id_product')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
elseif (isset($params['activeVisu']))
|
else if (isset($params['activeVisu']))
|
||||||
$this->_list[$index][$key] = (bool)$tr[$key];
|
$this->_list[$index][$key] = (bool)$tr[$key];
|
||||||
elseif (isset($params['position']))
|
else if (isset($params['position']))
|
||||||
{
|
{
|
||||||
$this->_list[$index][$key] = array(
|
$this->_list[$index][$key] = array(
|
||||||
'position' => $tr[$key],
|
'position' => $tr[$key],
|
||||||
@@ -262,7 +266,7 @@ class HelperListCore extends Helper
|
|||||||
'&way=0&position='.((int)$tr['position'] - 1).'&token='.$this->token
|
'&way=0&position='.((int)$tr['position'] - 1).'&token='.$this->token
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
elseif (isset($params['image']))
|
else if (isset($params['image']))
|
||||||
{
|
{
|
||||||
// item_id is the product id in a product image context, else it is the image id.
|
// item_id is the product id in a product image context, else it is the image id.
|
||||||
$item_id = isset($params['image_id']) ? $tr[$params['image_id']] : $id;
|
$item_id = isset($params['image_id']) ? $tr[$params['image_id']] : $id;
|
||||||
@@ -276,24 +280,24 @@ class HelperListCore extends Helper
|
|||||||
|
|
||||||
$this->_list[$index][$key] = cacheImage($path_to_image, $this->table.'_mini_'.$item_id.'.'.$this->imageType, 45, $this->imageType);
|
$this->_list[$index][$key] = cacheImage($path_to_image, $this->table.'_mini_'.$item_id.'.'.$this->imageType, 45, $this->imageType);
|
||||||
}
|
}
|
||||||
elseif (isset($params['icon']) && (isset($params['icon'][$tr[$key]]) || isset($params['icon']['default'])))
|
else if (isset($params['icon']) && (isset($params['icon'][$tr[$key]]) || isset($params['icon']['default'])))
|
||||||
$this->_list[$index][$key] = isset($params['icon'][$tr[$key]]) ? $params['icon'][$tr[$key]] : $params['icon']['default'];
|
$this->_list[$index][$key] = isset($params['icon'][$tr[$key]]) ? $params['icon'][$tr[$key]] : $params['icon']['default'];
|
||||||
elseif (isset($params['float']))
|
else if (isset($params['float']))
|
||||||
$this->_list[$index][$key] = rtrim(rtrim($tr[$key], '0'), '.');
|
$this->_list[$index][$key] = rtrim(rtrim($tr[$key], '0'), '.');
|
||||||
elseif (isset($params['type']) && $params['type'] == 'price')
|
else if (isset($params['type']) && $params['type'] == 'price')
|
||||||
{
|
{
|
||||||
$currency = isset($params['currency']) ? Currency::getCurrencyInstance($tr['id_currency']) : $this->context->currency;
|
$currency = isset($params['currency']) ? Currency::getCurrencyInstance($tr['id_currency']) : $this->context->currency;
|
||||||
$this->_list[$index][$key] = Tools::displayPrice($tr[$key], $currency, false);
|
$this->_list[$index][$key] = Tools::displayPrice($tr[$key], $currency, false);
|
||||||
}
|
}
|
||||||
elseif (isset($params['type']) && $params['type'] == 'date')
|
else if (isset($params['type']) && $params['type'] == 'date')
|
||||||
$this->_list[$index][$key] = Tools::displayDate($tr[$key], $this->context->language->id);
|
$this->_list[$index][$key] = Tools::displayDate($tr[$key], $this->context->language->id);
|
||||||
elseif (isset($params['type']) && $params['type'] == 'datetime')
|
else if (isset($params['type']) && $params['type'] == 'datetime')
|
||||||
$this->_list[$index][$key] = Tools::displayDate($tr[$key], $this->context->language->id, true);
|
$this->_list[$index][$key] = Tools::displayDate($tr[$key], $this->context->language->id, true);
|
||||||
elseif (isset($tr[$key]))
|
else if (isset($tr[$key]))
|
||||||
{
|
{
|
||||||
if ($key == 'price')
|
if ($key == 'price')
|
||||||
$echo = round($tr[$key], 2);
|
$echo = round($tr[$key], 2);
|
||||||
elseif (isset($params['maxlength']) && Tools::strlen($tr[$key]) > $params['maxlength'])
|
else if (isset($params['maxlength']) && Tools::strlen($tr[$key]) > $params['maxlength'])
|
||||||
$echo = '<span title="'.$tr[$key].'">'.Tools::substr($tr[$key], 0, $params['maxlength']).'...</span>';
|
$echo = '<span title="'.$tr[$key].'">'.Tools::substr($tr[$key], 0, $params['maxlength']).'...</span>';
|
||||||
else
|
else
|
||||||
$echo = $tr[$key];
|
$echo = $tr[$key];
|
||||||
@@ -393,7 +397,7 @@ class HelperListCore extends Helper
|
|||||||
$tpl->assign(array(
|
$tpl->assign(array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'controller' => str_replace('Controller', '', get_class($this->context->controller)),
|
'controller' => str_replace('Controller', '', get_class($this->context->controller)),
|
||||||
'token' => $this->token,
|
'token' => $token != null ? $token : $this->token,
|
||||||
'action' => self::$cache_lang['Details'],
|
'action' => self::$cache_lang['Details'],
|
||||||
'params' => $this->ajax_params
|
'params' => $this->ajax_params
|
||||||
));
|
));
|
||||||
@@ -496,7 +500,7 @@ class HelperListCore extends Helper
|
|||||||
isset($this->context->cookie->{$this->table.'_pagination'}) ? $this->context->cookie->{$this->table.'_pagination'} : null
|
isset($this->context->cookie->{$this->table.'_pagination'}) ? $this->context->cookie->{$this->table.'_pagination'} : null
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->is_dnd_identifier = array_key_exists($this->identifier,$this->identifiersDnd);
|
$this->is_dnd_identifier = array_key_exists($this->identifier, $this->identifiersDnd);
|
||||||
/*
|
/*
|
||||||
if ($is_dnd_identifier)
|
if ($is_dnd_identifier)
|
||||||
{
|
{
|
||||||
@@ -605,7 +609,6 @@ class HelperListCore extends Helper
|
|||||||
'current' => $this->currentIndex,
|
'current' => $this->currentIndex,
|
||||||
'simple_header' => $this->simple_header,
|
'simple_header' => $this->simple_header,
|
||||||
'bulk_actions' => $this->bulk_actions,
|
'bulk_actions' => $this->bulk_actions,
|
||||||
|
|
||||||
'back' => Tools::getValue('back'),
|
'back' => Tools::getValue('back'),
|
||||||
'no_back' => $this->no_back,
|
'no_back' => $this->no_back,
|
||||||
)));
|
)));
|
||||||
|
|||||||
+45
-24
@@ -30,31 +30,31 @@
|
|||||||
*/
|
*/
|
||||||
class GroupShopCore extends ObjectModel
|
class GroupShopCore extends ObjectModel
|
||||||
{
|
{
|
||||||
public $name;
|
public $name;
|
||||||
public $active;
|
public $active;
|
||||||
public $share_customer;
|
public $share_customer;
|
||||||
public $share_order;
|
public $share_order;
|
||||||
public $deleted;
|
public $deleted;
|
||||||
|
|
||||||
protected $fieldsSize = array('name' => 64);
|
protected $fieldsSize = array('name' => 64);
|
||||||
protected $fieldsValidate = array(
|
protected $fieldsValidate = array(
|
||||||
'active' => 'isBool',
|
'active' => 'isBool',
|
||||||
'share_customer' => 'isBool',
|
'share_customer' => 'isBool',
|
||||||
'share_order' => 'isBool',
|
'share_order' => 'isBool',
|
||||||
'name' => 'isGenericName',
|
'name' => 'isGenericName',
|
||||||
);
|
);
|
||||||
protected $table = 'group_shop';
|
protected $table = 'group_shop';
|
||||||
protected $identifier = 'id_group_shop';
|
protected $identifier = 'id_group_shop';
|
||||||
|
|
||||||
private static $assoTables = array(
|
private static $assoTables = array(
|
||||||
'attribute_group' => array('type' => 'group_shop'),
|
'attribute_group' => array('type' => 'group_shop'),
|
||||||
'attribute' => array('type' => 'group_shop'),
|
'attribute' => array('type' => 'group_shop'),
|
||||||
'feature' => array('type' => 'group_shop'),
|
'feature' => array('type' => 'group_shop'),
|
||||||
'group' => array('type' => 'group_shop'),
|
'group' => array('type' => 'group_shop'),
|
||||||
'manufacturer' => array('type' => 'group_shop'),
|
'manufacturer' => array('type' => 'group_shop'),
|
||||||
'supplier' => array('type' => 'group_shop'),
|
'supplier' => array('type' => 'group_shop'),
|
||||||
'zone' => array('type' => 'shop'),
|
'zone' => array('type' => 'shop'),
|
||||||
'tax_rules_group' => array('type' => 'group_shop'),
|
'tax_rules_group' => array('type' => 'group_shop'),
|
||||||
);
|
);
|
||||||
|
|
||||||
public function getFields()
|
public function getFields()
|
||||||
@@ -71,9 +71,11 @@ class GroupShopCore extends ObjectModel
|
|||||||
|
|
||||||
public static function getGroupShops($active = true)
|
public static function getGroupShops($active = true)
|
||||||
{
|
{
|
||||||
return Db::getInstance()->executeS('SELECT *
|
return Db::getInstance()->executeS('
|
||||||
FROM '._DB_PREFIX_.'group_shop
|
SELECT *
|
||||||
WHERE `deleted`= 0 AND `active`='.(int)$active);
|
FROM '._DB_PREFIX_.'group_shop
|
||||||
|
WHERE `deleted`= 0 AND `active`='.(int)$active
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete()
|
public function delete()
|
||||||
@@ -81,7 +83,7 @@ class GroupShopCore extends ObjectModel
|
|||||||
if (!$res = parent::delete())
|
if (!$res = parent::delete())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
foreach (Shop::getAssoTables() AS $table_name => $row)
|
foreach (Shop::getAssoTables() as $table_name => $row)
|
||||||
{
|
{
|
||||||
$id = 'id_'.$row['type'];
|
$id = 'id_'.$row['type'];
|
||||||
if ($row['type'] == 'fk_group_shop')
|
if ($row['type'] == 'fk_group_shop')
|
||||||
@@ -96,7 +98,7 @@ class GroupShopCore extends ObjectModel
|
|||||||
|
|
||||||
public static function getAssoTables()
|
public static function getAssoTables()
|
||||||
{
|
{
|
||||||
return self::$assoTables;
|
return self::$assoTables;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +106,7 @@ class GroupShopCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public static function getTotalGroupShops($active = true)
|
public static function getTotalGroupShops($active = true)
|
||||||
{
|
{
|
||||||
return sizeof(GroupShop::getGroupShops($active));
|
return count(GroupShop::getGroupShops($active));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function haveShops()
|
public function haveShops()
|
||||||
@@ -134,9 +136,28 @@ class GroupShopCore extends ObjectModel
|
|||||||
return (int)Db::getInstance()->getValue($sql);
|
return (int)Db::getInstance()->getValue($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the list of group shop by id
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param string $identifier
|
||||||
|
* @param string $table
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getGroupShopById($id, $identifier, $table)
|
||||||
|
{
|
||||||
|
$sql = sprintf('
|
||||||
|
SELECT `id_group_shop`, `%s`
|
||||||
|
FROM `'._DB_PREFIX_.'%s_group_shop`
|
||||||
|
WHERE `%s` = %d'
|
||||||
|
, $identifier, $table, $identifier, $id);
|
||||||
|
|
||||||
|
return Db::getInstance()->executeS($sql);
|
||||||
|
}
|
||||||
|
|
||||||
public function copyGroupShopData($old_id, $tables_import = false, $deleted = false)
|
public function copyGroupShopData($old_id, $tables_import = false, $deleted = false)
|
||||||
{
|
{
|
||||||
foreach (GroupShop::getAssoTables() AS $table_name => $row)
|
foreach (GroupShop::getAssoTables() as $table_name => $row)
|
||||||
{
|
{
|
||||||
if ($tables_import && !isset($tables_import[$table_name]))
|
if ($tables_import && !isset($tables_import[$table_name]))
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
+35
-5
@@ -167,7 +167,10 @@ class ShopCore extends ObjectModel
|
|||||||
$id = 'id_shop';
|
$id = 'id_shop';
|
||||||
else
|
else
|
||||||
$table_name .= '_'.$row['type'];
|
$table_name .= '_'.$row['type'];
|
||||||
$res &= Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.$table_name.'` WHERE `'.$id.'`='.(int)$this->id);
|
$res &= Db::getInstance()->execute('
|
||||||
|
DELETE FROM `'._DB_PREFIX_.$table_name.'`
|
||||||
|
WHERE `'.$id.'`='.(int)$this->id
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Shop::cacheShops(true);
|
Shop::cacheShops(true);
|
||||||
@@ -183,13 +186,21 @@ class ShopCore extends ObjectModel
|
|||||||
public static function has_dependency($id_shop)
|
public static function has_dependency($id_shop)
|
||||||
{
|
{
|
||||||
$has_dependency = false;
|
$has_dependency = false;
|
||||||
$nbr_customer = (int)Db::getInstance()->getValue('SELECT `id_customer` FROM `'._DB_PREFIX_.'customer` WHERE `id_shop`='.(int)$id_shop);
|
$nbr_customer = (int)Db::getInstance()->getValue('
|
||||||
if($nbr_customer)
|
SELECT `id_customer`
|
||||||
|
FROM `'._DB_PREFIX_.'customer`
|
||||||
|
WHERE `id_shop`='.(int)$id_shop
|
||||||
|
);
|
||||||
|
if ($nbr_customer)
|
||||||
$has_dependency = true;
|
$has_dependency = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$nbr_order= (int)Db::getInstance()->getValue('SELECT `id_order` FROM `'._DB_PREFIX_.'orders` WHERE `id_shop`='.(int)$id_shop);
|
$nbr_order = (int)Db::getInstance()->getValue('
|
||||||
if($nbr_order)
|
SELECT `id_order`
|
||||||
|
FROM `'._DB_PREFIX_.'orders`
|
||||||
|
WHERE `id_shop`='.(int)$id_shop
|
||||||
|
);
|
||||||
|
if ($nbr_order)
|
||||||
$has_dependency = true;
|
$has_dependency = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,6 +620,25 @@ class ShopCore extends ObjectModel
|
|||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the list of shop by id
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param string $identifier
|
||||||
|
* @param string $table
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getShopById($id, $identifier, $table)
|
||||||
|
{
|
||||||
|
$sql = sprintf('
|
||||||
|
SELECT `id_shop`, `%s`
|
||||||
|
FROM `'._DB_PREFIX_.'%s_shop`
|
||||||
|
WHERE `%s` = %d'
|
||||||
|
, $identifier, $table, $identifier, $id);
|
||||||
|
|
||||||
|
return Db::getInstance()->executeS($sql);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the current shop context in FO or BO
|
* Retrieve the current shop context in FO or BO
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,466 @@
|
|||||||
|
<?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: 7331 $
|
||||||
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||||
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
|
*/
|
||||||
|
class AdminFeaturesControllerCore extends AdminController
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->table = 'feature';
|
||||||
|
$this->className = 'Feature';
|
||||||
|
$this->lang = true;
|
||||||
|
|
||||||
|
$this->fieldsDisplay = array(
|
||||||
|
'id_feature' => array(
|
||||||
|
'title' => $this->l('ID'),
|
||||||
|
'width' => 25
|
||||||
|
),
|
||||||
|
'name' => array(
|
||||||
|
'title' => $this->l('Name'),
|
||||||
|
'width' => 128,
|
||||||
|
'filter_key' => 'b!name'
|
||||||
|
),
|
||||||
|
'value' => array(
|
||||||
|
'title' => $this->l('Values'),
|
||||||
|
'width' => 255,
|
||||||
|
'orderby' => false,
|
||||||
|
'search' => false
|
||||||
|
),
|
||||||
|
'position' => array(
|
||||||
|
'title' => $this->l('Position'),
|
||||||
|
'width' => 40,
|
||||||
|
'filter_key' => 'cp!position',
|
||||||
|
'align' => 'center',
|
||||||
|
'position' => 'position'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AdminController::initList() override
|
||||||
|
* @see AdminController::initList()
|
||||||
|
*/
|
||||||
|
public function initList()
|
||||||
|
{
|
||||||
|
$this->addRowAction('edit');
|
||||||
|
$this->addRowAction('delete');
|
||||||
|
$this->addRowAction('details');
|
||||||
|
|
||||||
|
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
|
||||||
|
|
||||||
|
// Added specific button in toolbar
|
||||||
|
$this->toolbar_btn['newAttributes'] = array(
|
||||||
|
'href' => self::$currentIndex.'&addfeature_value&token='.$this->token,
|
||||||
|
'desc' => $this->l('Add new feature value')
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->toolbar_btn['new'] = array(
|
||||||
|
'href' => self::$currentIndex.'&addfeature&token='.$this->token,
|
||||||
|
'desc' => $this->l('Add new feature')
|
||||||
|
);
|
||||||
|
|
||||||
|
return parent::initList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* method call when ajax request is made with the details row action
|
||||||
|
* @see AdminController::postProcess()
|
||||||
|
*/
|
||||||
|
public function ajaxProcess()
|
||||||
|
{
|
||||||
|
// test if an id is submit
|
||||||
|
if (($id = Tools::getValue('id')) && Tools::isSubmit('id'))
|
||||||
|
{
|
||||||
|
$this->table = 'feature_value';
|
||||||
|
$this->className = 'FeatureValue';
|
||||||
|
$this->identifier = 'id_feature_value';
|
||||||
|
$this->lang = true;
|
||||||
|
|
||||||
|
// override attributes
|
||||||
|
$this->display = 'list';
|
||||||
|
|
||||||
|
// Action for list
|
||||||
|
$this->addRowAction('edit');
|
||||||
|
$this->addRowAction('delete');
|
||||||
|
|
||||||
|
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
|
||||||
|
|
||||||
|
if (!Validate::isLoadedObject($obj = new FeatureValue((int)$id)))
|
||||||
|
$this->_errors[] = Tools::displayError('An error occurred while updating status for object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||||
|
|
||||||
|
$this->fieldsDisplay = array(
|
||||||
|
'id_feature_value' => array(
|
||||||
|
'title' => $this->l('ID'),
|
||||||
|
'width' => 25
|
||||||
|
),
|
||||||
|
'value' => array(
|
||||||
|
'title' => $this->l('Value'),
|
||||||
|
'width' => 100
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->_where = sprintf('AND `id_feature` = %d', (int)$id);
|
||||||
|
|
||||||
|
// get list and force no limit clause in the request
|
||||||
|
$this->getList($this->context->language->id, null);
|
||||||
|
|
||||||
|
// Render list
|
||||||
|
$helper = new HelperList();
|
||||||
|
$helper->actions = $this->actions;
|
||||||
|
$helper->no_link = true;
|
||||||
|
$helper->shopLinkType = '';
|
||||||
|
$helper->identifier = $this->identifier;
|
||||||
|
$helper->toolbar_fix = false;
|
||||||
|
$helper->orderBy = 'position';
|
||||||
|
$helper->orderWay = 'ASC';
|
||||||
|
$helper->currentIndex = self::$currentIndex;
|
||||||
|
$helper->token = $this->token;
|
||||||
|
$helper->table = $this->table;
|
||||||
|
$helper->simple_header = true;
|
||||||
|
$helper->show_toolbar = false;
|
||||||
|
$helper->bulk_actions = $this->bulk_actions;
|
||||||
|
$content = $helper->generateList($this->_list, $this->fieldsDisplay);
|
||||||
|
|
||||||
|
$this->content = Tools::jsonEncode(array('use_parent_structure' => false, 'data' => $content));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modifying initial getList method to display position feature (drag and drop)
|
||||||
|
*/
|
||||||
|
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
|
||||||
|
{
|
||||||
|
if ($order_by && $this->context->cookie->__get($this->table.'Orderby'))
|
||||||
|
$order_by = $this->context->cookie->__get($this->table.'Orderby');
|
||||||
|
else if (!is_null($order_by))
|
||||||
|
$order_by = 'position';
|
||||||
|
|
||||||
|
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AdminController::initForm() override
|
||||||
|
* @see AdminController::initForm()
|
||||||
|
*/
|
||||||
|
public function initForm()
|
||||||
|
{
|
||||||
|
$this->toolbar_title = $this->l('Add a new feature');
|
||||||
|
$this->fields_form = array(
|
||||||
|
'legend' => array(
|
||||||
|
'title' => $this->l('Feature'),
|
||||||
|
'image' => '../img/t/AdminFeatures.gif'
|
||||||
|
),
|
||||||
|
'input' => array(
|
||||||
|
array(
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => $this->l('Name:'),
|
||||||
|
'name' => 'name',
|
||||||
|
'lang' => true,
|
||||||
|
'size' => 33,
|
||||||
|
'hint' => $this->l('Invalid characters:').' <>;=#{}',
|
||||||
|
'required' => true
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Shop::isFeatureActive())
|
||||||
|
{
|
||||||
|
$this->fields_form['input'][] = array(
|
||||||
|
'type' => 'group_shop',
|
||||||
|
'label' => $this->l('GroupShop association:'),
|
||||||
|
'name' => 'checkBoxShopAsso',
|
||||||
|
'values' => Shop::getTree()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->fields_form['submit'] = array(
|
||||||
|
'title' => $this->l(' Save '),
|
||||||
|
'class' => 'button'
|
||||||
|
);
|
||||||
|
|
||||||
|
return parent::initForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AdminController::initToolbar() override
|
||||||
|
* @see AdminController::initToolbar()
|
||||||
|
*/
|
||||||
|
public function initToolbar()
|
||||||
|
{
|
||||||
|
switch ($this->display)
|
||||||
|
{
|
||||||
|
case 'editFeatureValue':
|
||||||
|
$this->toolbar_btn['save'] = array(
|
||||||
|
'href' => '#',
|
||||||
|
'desc' => $this->l('Save')
|
||||||
|
);
|
||||||
|
|
||||||
|
// Default cancel button - like old back link
|
||||||
|
if (!isset($this->no_back) || $this->no_back == false)
|
||||||
|
{
|
||||||
|
$back = Tools::safeOutput(Tools::getValue('back', ''));
|
||||||
|
if (empty($back))
|
||||||
|
$back = self::$currentIndex.'&token='.$this->token;
|
||||||
|
|
||||||
|
$this->toolbar_btn['cancel'] = array(
|
||||||
|
'href' => $back,
|
||||||
|
'desc' => $this->l('Cancel')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
parent::initToolbar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AdminController::initForm() override
|
||||||
|
* @see AdminController::initForm()
|
||||||
|
*/
|
||||||
|
public function initFormFeatureValue()
|
||||||
|
{
|
||||||
|
$this->fields_form[0]['form'] = array(
|
||||||
|
'legend' => array(
|
||||||
|
'title' => $this->l('Feature value'),
|
||||||
|
'image' => '../img/t/AdminFeatures.gif'
|
||||||
|
),
|
||||||
|
'input' => array(
|
||||||
|
array(
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => $this->l('Value:'),
|
||||||
|
'name' => 'value',
|
||||||
|
'lang' => true,
|
||||||
|
'size' => 33,
|
||||||
|
'hint' => $this->l('Invalid characters:').' <>;=#{}',
|
||||||
|
'required' => true
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'select',
|
||||||
|
'label' => $this->l('Feature:'),
|
||||||
|
'name' => 'id_feature',
|
||||||
|
'options' => array(
|
||||||
|
'query' => Feature::getFeatures($this->context->language->id),
|
||||||
|
'id' => 'id_feature',
|
||||||
|
'name' => 'name'
|
||||||
|
),
|
||||||
|
'required' => true
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'submit' => array(
|
||||||
|
'title' => $this->l(' Save '),
|
||||||
|
'class' => 'button'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create Object FeatureValue
|
||||||
|
$feature_value = new FeatureValue(Tools::getValue('id_feature_value'));
|
||||||
|
|
||||||
|
$this->tpl_vars = array(
|
||||||
|
'hook' => Hook::exec('featureValueForm', array('id_feature_value' => $feature_value->id))
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->getlanguages();
|
||||||
|
$helper = new HelperForm();
|
||||||
|
$helper->currentIndex = self::$currentIndex;
|
||||||
|
$helper->token = $this->token;
|
||||||
|
$helper->table = 'feature_value';
|
||||||
|
$helper->identifier = 'id_feature_value';
|
||||||
|
$helper->override_folder = 'feature_value/';
|
||||||
|
$helper->id = $feature_value->id;
|
||||||
|
$helper->toolbar_fix = false;
|
||||||
|
$helper->tpl_vars = $this->tpl_vars;
|
||||||
|
$helper->languages = $this->_languages;
|
||||||
|
$helper->default_form_language = $this->default_form_language;
|
||||||
|
$helper->allow_employee_form_lang = $this->allow_employee_form_lang;
|
||||||
|
$helper->fields_value = $this->getFieldsValue($feature_value);
|
||||||
|
$helper->toolbar_btn = $this->toolbar_btn;
|
||||||
|
$helper->title = $this->l('Add a new feature value');
|
||||||
|
$this->content .= $helper->generateForm($this->fields_form);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AdminController::init() override
|
||||||
|
* @see AdminController::init()
|
||||||
|
*/
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
if (isset($_POST['submitAddfeature_value']) || isset($_GET['updatefeature_value']) || isset($_GET['addfeature_value']))
|
||||||
|
$this->display = 'editFeatureValue';
|
||||||
|
|
||||||
|
parent::init();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AdminController::initContent() override
|
||||||
|
* @see AdminController::initContent()
|
||||||
|
*/
|
||||||
|
public function initContent()
|
||||||
|
{
|
||||||
|
if (Feature::isFeatureActive())
|
||||||
|
{
|
||||||
|
// toolbar (save, cancel, new, ..)
|
||||||
|
$this->initToolbar();
|
||||||
|
if ($this->display == 'edit' || $this->display == 'add')
|
||||||
|
{
|
||||||
|
if (!$this->loadObject(true))
|
||||||
|
return;
|
||||||
|
$this->content .= $this->initForm();
|
||||||
|
}
|
||||||
|
else if ($this->display == 'view')
|
||||||
|
{
|
||||||
|
// Some controllers use the view action without an object
|
||||||
|
if ($this->className)
|
||||||
|
$this->loadObject(true);
|
||||||
|
$this->content .= $this->initView();
|
||||||
|
}
|
||||||
|
else if ($this->display == 'editFeatureValue')
|
||||||
|
{
|
||||||
|
if (!$this->object = new FeatureValue((int)Tools::getValue('id_feature_value')))
|
||||||
|
return;
|
||||||
|
|
||||||
|
$this->content .= $this->initFormFeatureValue();
|
||||||
|
}
|
||||||
|
else if (!$this->ajax)
|
||||||
|
{
|
||||||
|
$this->content .= $this->initList();
|
||||||
|
$this->content .= $this->initOptions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').'<a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.$this->l('Performances').'</a>');
|
||||||
|
|
||||||
|
$this->context->smarty->assign(array(
|
||||||
|
'content' => $this->content,
|
||||||
|
'url_post' => self::$currentIndex.'&token='.$this->token,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function postProcess()
|
||||||
|
{
|
||||||
|
if (!Feature::isFeatureActive())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Tools::isSubmit('deletefeature_value') || Tools::isSubmit('submitAddfeature_value'))
|
||||||
|
{
|
||||||
|
Hook::exec('postProcessFeatureValue',
|
||||||
|
array('errors' => &$this->_errors)); // send _errors as reference to allow postProcessFeatureValue to stop saving process
|
||||||
|
|
||||||
|
if (Tools::isSubmit('deletefeature_value'))
|
||||||
|
{
|
||||||
|
if ($this->tabAccess['delete'] === '1')
|
||||||
|
{
|
||||||
|
if (Tools::getValue('id_feature_value'))
|
||||||
|
{
|
||||||
|
$object = new FeatureValue((int)Tools::getValue('id_feature_value'));
|
||||||
|
if ($object->delete())
|
||||||
|
Tools::redirectAdmin(self::$currentIndex.'&conf=2'.'&token='.$this->token);
|
||||||
|
else
|
||||||
|
$this->_errors[] = Tools::displayError('An error occurred during deletion.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||||
|
}
|
||||||
|
else if (Tools::isSubmit('submitAddfeature_value'))
|
||||||
|
{
|
||||||
|
$id = (int)Tools::getValue('id_feature_value');
|
||||||
|
$feature_value = new FeatureValue($id);
|
||||||
|
$feature_value->value = array();
|
||||||
|
$languages = Language::getLanguages(false);
|
||||||
|
foreach ($languages as $language)
|
||||||
|
$feature_value->value[$language['id_lang']] = Tools::getValue('value_'.$language['id_lang']);
|
||||||
|
$feature_value->id_feature = Tools::getValue('id_feature');
|
||||||
|
|
||||||
|
if (isset($id) && !empty($id))
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
if (!$feature_value->update())
|
||||||
|
$this->_errors[] = Tools::displayError('An error has occured: Can\'t save the current feature value');
|
||||||
|
else
|
||||||
|
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Create
|
||||||
|
if (!$feature_value->add())
|
||||||
|
$this->_errors[] = Tools::displayError('An error has occured: Can\'t save the current feature value');
|
||||||
|
else
|
||||||
|
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
parent::postProcess();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Hook::exec('postProcessFeature',
|
||||||
|
array('errors' => &$this->_errors)); // send _errors as reference to allow postProcessFeature to stop saving process
|
||||||
|
|
||||||
|
if (Tools::getValue('submitDel'.$this->table))
|
||||||
|
{
|
||||||
|
if ($this->tabAccess['delete'] === '1')
|
||||||
|
{
|
||||||
|
if (isset($_POST[$this->table.'Box']))
|
||||||
|
{
|
||||||
|
$object = new $this->className();
|
||||||
|
if ($object->deleteSelection($_POST[$this->table.'Box']))
|
||||||
|
Tools::redirectAdmin(self::$currentIndex.'&conf=2'.'&token='.$this->token);
|
||||||
|
$this->_errors[] = Tools::displayError('An error occurred while deleting selection.');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$this->_errors[] = Tools::displayError('You must select at least one element to delete.');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||||
|
}
|
||||||
|
else if (Tools::isSubmit('submitAdd'.$this->table))
|
||||||
|
{
|
||||||
|
if ($this->tabAccess['add'] === '1')
|
||||||
|
{
|
||||||
|
$id_feature = (int)Tools::getValue('id_feature');
|
||||||
|
// Adding last position to the feature if not exist
|
||||||
|
if ($id_feature <= 0)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT `position`+1
|
||||||
|
FROM `'._DB_PREFIX_.'feature`
|
||||||
|
ORDER BY position DESC';
|
||||||
|
// set the position of the new feature in $_POST for postProcess() method
|
||||||
|
$_POST['position'] = DB::getInstance()->getValue($sql);
|
||||||
|
}
|
||||||
|
// clean \n\r characters
|
||||||
|
foreach ($_POST as $key => $value)
|
||||||
|
if (preg_match('/^name_/Ui', $key))
|
||||||
|
$_POST[$key] = str_replace ('\n', '', str_replace('\r', '', $value));
|
||||||
|
parent::postProcess();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
parent::postProcess();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -372,7 +372,7 @@ class AdminManufacturersControllerCore extends AdminController
|
|||||||
// Create Object Address
|
// Create Object Address
|
||||||
$address = new Address($id_address);
|
$address = new Address($id_address);
|
||||||
|
|
||||||
$this->fields_form = array(
|
$form = array(
|
||||||
'legend' => array(
|
'legend' => array(
|
||||||
'title' => $this->l('Addresses'),
|
'title' => $this->l('Addresses'),
|
||||||
'image' => '../img/admin/contact.gif'
|
'image' => '../img/admin/contact.gif'
|
||||||
@@ -380,7 +380,7 @@ class AdminManufacturersControllerCore extends AdminController
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!$address->id_manufacturer || !Manufacturer::manufacturerExists($address->id_manufacturer))
|
if (!$address->id_manufacturer || !Manufacturer::manufacturerExists($address->id_manufacturer))
|
||||||
$this->fields_form['input'][] = array(
|
$form['input'][] = array(
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'label' => $this->l('Choose the manufacturer:'),
|
'label' => $this->l('Choose the manufacturer:'),
|
||||||
'name' => 'id_manufacturer',
|
'name' => 'id_manufacturer',
|
||||||
@@ -392,24 +392,24 @@ class AdminManufacturersControllerCore extends AdminController
|
|||||||
);
|
);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->fields_form['input'][] = array(
|
$form['input'][] = array(
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'label' => $this->l('Manufacturer:'),
|
'label' => $this->l('Manufacturer:'),
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
'disabled' => true,
|
'disabled' => true,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->fields_form['input'][] = array(
|
$form['input'][] = array(
|
||||||
'type' => 'hidden',
|
'type' => 'hidden',
|
||||||
'name' => 'id_manufacturer'
|
'name' => 'id_manufacturer'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->fields_form['input'][] = array(
|
$form['input'][] = array(
|
||||||
'type' => 'hidden',
|
'type' => 'hidden',
|
||||||
'name' => 'alias',
|
'name' => 'alias',
|
||||||
);
|
);
|
||||||
$this->fields_form['input'][] = array(
|
$form['input'][] = array(
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'label' => $this->l('Last name:'),
|
'label' => $this->l('Last name:'),
|
||||||
'name' => 'lastname',
|
'name' => 'lastname',
|
||||||
@@ -417,7 +417,7 @@ class AdminManufacturersControllerCore extends AdminController
|
|||||||
'required' => true,
|
'required' => true,
|
||||||
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:'
|
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:'
|
||||||
);
|
);
|
||||||
$this->fields_form['input'][] = array(
|
$form['input'][] = array(
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'label' => $this->l('First name:'),
|
'label' => $this->l('First name:'),
|
||||||
'name' => 'firstname',
|
'name' => 'firstname',
|
||||||
@@ -425,35 +425,35 @@ class AdminManufacturersControllerCore extends AdminController
|
|||||||
'required' => true,
|
'required' => true,
|
||||||
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:'
|
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:'
|
||||||
);
|
);
|
||||||
$this->fields_form['input'][] = array(
|
$form['input'][] = array(
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'label' => $this->l('Address:'),
|
'label' => $this->l('Address:'),
|
||||||
'name' => 'address1',
|
'name' => 'address1',
|
||||||
'size' => 33,
|
'size' => 33,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
);
|
);
|
||||||
$this->fields_form['input'][] = array(
|
$form['input'][] = array(
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'label' => $this->l('Address (2):'),
|
'label' => $this->l('Address (2):'),
|
||||||
'name' => 'address2',
|
'name' => 'address2',
|
||||||
'size' => 33,
|
'size' => 33,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
);
|
);
|
||||||
$this->fields_form['input'][] = array(
|
$form['input'][] = array(
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'label' => $this->l('Postcode / Zip Code:'),
|
'label' => $this->l('Postcode / Zip Code:'),
|
||||||
'name' => 'postcode',
|
'name' => 'postcode',
|
||||||
'size' => 33,
|
'size' => 33,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
);
|
);
|
||||||
$this->fields_form['input'][] = array(
|
$form['input'][] = array(
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'label' => $this->l('City:'),
|
'label' => $this->l('City:'),
|
||||||
'name' => 'city',
|
'name' => 'city',
|
||||||
'size' => 33,
|
'size' => 33,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
);
|
);
|
||||||
$this->fields_form['input'][] = array(
|
$form['input'][] = array(
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'label' => $this->l('Country:'),
|
'label' => $this->l('Country:'),
|
||||||
'name' => 'id_country',
|
'name' => 'id_country',
|
||||||
@@ -464,7 +464,7 @@ class AdminManufacturersControllerCore extends AdminController
|
|||||||
'name' => 'name'
|
'name' => 'name'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->fields_form['input'][] = array(
|
$form['input'][] = array(
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'label' => $this->l('State:'),
|
'label' => $this->l('State:'),
|
||||||
'name' => 'id_state',
|
'name' => 'id_state',
|
||||||
@@ -475,21 +475,21 @@ class AdminManufacturersControllerCore extends AdminController
|
|||||||
'name' => 'name'
|
'name' => 'name'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->fields_form['input'][] = array(
|
$form['input'][] = array(
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'label' => $this->l('Home phone:'),
|
'label' => $this->l('Home phone:'),
|
||||||
'name' => 'phone',
|
'name' => 'phone',
|
||||||
'size' => 33,
|
'size' => 33,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
);
|
);
|
||||||
$this->fields_form['input'][] = array(
|
$form['input'][] = array(
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'label' => $this->l('Mobile phone:'),
|
'label' => $this->l('Mobile phone:'),
|
||||||
'name' => 'phone_mobile',
|
'name' => 'phone_mobile',
|
||||||
'size' => 33,
|
'size' => 33,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
);
|
);
|
||||||
$this->fields_form['input'][] = array(
|
$form['input'][] = array(
|
||||||
'type' => 'textarea',
|
'type' => 'textarea',
|
||||||
'label' => $this->l('Other:'),
|
'label' => $this->l('Other:'),
|
||||||
'name' => 'other',
|
'name' => 'other',
|
||||||
@@ -498,7 +498,7 @@ class AdminManufacturersControllerCore extends AdminController
|
|||||||
'required' => false,
|
'required' => false,
|
||||||
'hint' => $this->l('Forbidden characters:').' <>;=#{}'
|
'hint' => $this->l('Forbidden characters:').' <>;=#{}'
|
||||||
);
|
);
|
||||||
$this->fields_form['submit'] = array(
|
$form['submit'] = array(
|
||||||
'title' => $this->l(' Save '),
|
'title' => $this->l(' Save '),
|
||||||
'class' => 'button'
|
'class' => 'button'
|
||||||
);
|
);
|
||||||
@@ -508,22 +508,15 @@ class AdminManufacturersControllerCore extends AdminController
|
|||||||
'alias' => 'manufacturer'
|
'alias' => 'manufacturer'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->toolbar_btn = array(
|
$this->initToolbar();
|
||||||
'save' => array(
|
$this->fields_form[0]['form'] = $form;
|
||||||
'href' => '#',
|
|
||||||
'desc' => $this->l('Save')
|
|
||||||
),
|
|
||||||
'cancel' => array(
|
|
||||||
'href' => self::$currentIndex.'&token='.$this->token,
|
|
||||||
'desc' => $this->l('Cancel')
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$this->getlanguages();
|
$this->getlanguages();
|
||||||
$helper = new HelperForm();
|
$helper = new HelperForm();
|
||||||
$helper->currentIndex = self::$currentIndex;
|
$helper->currentIndex = self::$currentIndex;
|
||||||
$helper->token = $this->token;
|
$helper->token = $this->token;
|
||||||
$helper->table = $this->table;
|
$helper->table = $this->table;
|
||||||
$helper->identifier = $this->identifier;
|
$helper->identifier = $this->identifier;
|
||||||
|
$helper->title = $this->l('Edit Addresses');
|
||||||
$helper->id = $address->id;
|
$helper->id = $address->id;
|
||||||
$helper->toolbar_fix = true;
|
$helper->toolbar_fix = true;
|
||||||
$helper->languages = $this->_languages;
|
$helper->languages = $this->_languages;
|
||||||
@@ -534,6 +527,41 @@ class AdminManufacturersControllerCore extends AdminController
|
|||||||
$this->content .= $helper->generateForm($this->fields_form);
|
$this->content .= $helper->generateForm($this->fields_form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AdminController::initToolbar() override
|
||||||
|
* @see AdminController::initToolbar()
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function initToolbar()
|
||||||
|
{
|
||||||
|
switch ($this->display)
|
||||||
|
{
|
||||||
|
case 'editaddresses':
|
||||||
|
case 'addaddress':
|
||||||
|
$this->toolbar_btn['save'] = array(
|
||||||
|
'href' => '#',
|
||||||
|
'desc' => $this->l('Save')
|
||||||
|
);
|
||||||
|
|
||||||
|
// Default cancel button - like old back link
|
||||||
|
if (!isset($this->no_back) || $this->no_back == false)
|
||||||
|
{
|
||||||
|
$back = Tools::safeOutput(Tools::getValue('back', ''));
|
||||||
|
if (empty($back))
|
||||||
|
$back = self::$currentIndex.'&token='.$this->token;
|
||||||
|
|
||||||
|
$this->toolbar_btn['cancel'] = array(
|
||||||
|
'href' => $back,
|
||||||
|
'desc' => $this->l('Cancel')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
parent::initToolbar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function initView()
|
public function initView()
|
||||||
{
|
{
|
||||||
if (!($manufacturer = $this->loadObject()))
|
if (!($manufacturer = $this->loadObject()))
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ class AdminStatusesControllerCore extends AdminController
|
|||||||
// Create Object OrderReturnState
|
// Create Object OrderReturnState
|
||||||
$order_return_state = new OrderReturnState($id_order_return_state);
|
$order_return_state = new OrderReturnState($id_order_return_state);
|
||||||
|
|
||||||
$this->fields_form = array(
|
$this->fields_form[0]['form'] = array(
|
||||||
'tinymce' => true,
|
'tinymce' => true,
|
||||||
'legend' => array(
|
'legend' => array(
|
||||||
'title' => $this->l('Order statuses'),
|
'title' => $this->l('Order statuses'),
|
||||||
@@ -351,18 +351,7 @@ class AdminStatusesControllerCore extends AdminController
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->initToolbar();
|
||||||
$this->toolbar_btn = array(
|
|
||||||
'save' => array(
|
|
||||||
'href' => '#',
|
|
||||||
'desc' => $this->l('Save')
|
|
||||||
),
|
|
||||||
'cancel' => array(
|
|
||||||
'href' => self::$currentIndex.'&token='.$this->token,
|
|
||||||
'desc' => $this->l('Cancel')
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->getlanguages();
|
$this->getlanguages();
|
||||||
$helper = new HelperForm();
|
$helper = new HelperForm();
|
||||||
$helper->currentIndex = self::$currentIndex;
|
$helper->currentIndex = self::$currentIndex;
|
||||||
@@ -376,9 +365,44 @@ class AdminStatusesControllerCore extends AdminController
|
|||||||
$helper->allow_employee_form_lang = $this->allow_employee_form_lang;
|
$helper->allow_employee_form_lang = $this->allow_employee_form_lang;
|
||||||
$helper->fields_value = $this->getFieldsValue($order_return_state);
|
$helper->fields_value = $this->getFieldsValue($order_return_state);
|
||||||
$helper->toolbar_btn = $this->toolbar_btn;
|
$helper->toolbar_btn = $this->toolbar_btn;
|
||||||
|
$helper->title = $this->l('Edit Order Statuses');
|
||||||
$this->content .= $helper->generateForm($this->fields_form);
|
$this->content .= $helper->generateForm($this->fields_form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AdminController::initToolbar() override
|
||||||
|
* @see AdminController::initToolbar()
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function initToolbar()
|
||||||
|
{
|
||||||
|
switch ($this->display)
|
||||||
|
{
|
||||||
|
case 'editstatus':
|
||||||
|
$this->toolbar_btn['save'] = array(
|
||||||
|
'href' => '#',
|
||||||
|
'desc' => $this->l('Save')
|
||||||
|
);
|
||||||
|
|
||||||
|
// Default cancel button - like old back link
|
||||||
|
if (!isset($this->no_back) || $this->no_back == false)
|
||||||
|
{
|
||||||
|
$back = Tools::safeOutput(Tools::getValue('back', ''));
|
||||||
|
if (empty($back))
|
||||||
|
$back = self::$currentIndex.'&token='.$this->token;
|
||||||
|
|
||||||
|
$this->toolbar_btn['cancel'] = array(
|
||||||
|
'href' => $back,
|
||||||
|
'desc' => $this->l('Cancel')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
parent::initToolbar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function getTemplates($iso_code)
|
private function getTemplates($iso_code)
|
||||||
{
|
{
|
||||||
$array = array();
|
$array = array();
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ class AdminTaxRulesGroupControllerCore extends AdminController
|
|||||||
|
|
||||||
public function initRuleForm()
|
public function initRuleForm()
|
||||||
{
|
{
|
||||||
$this->fields_form = array(
|
$this->fields_form[0]['form'] = array(
|
||||||
'legend' => array(
|
'legend' => array(
|
||||||
'title' => $this->l('New tax rule'),
|
'title' => $this->l('New tax rule'),
|
||||||
'image' => '../img/admin/dollar.gif'
|
'image' => '../img/admin/dollar.gif'
|
||||||
|
|||||||
Reference in new issue
Block a user