[*] BO : Proposition : IMPROVEMENT Admin Modules Positions
You can see in action over there : http://www.youtube.com/watch?v=e7KXuCU3RIM
This commit is contained in:
@@ -49,38 +49,10 @@
|
|||||||
</select><sup> *</sup>
|
</select><sup> *</sup>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
//<![CDATA
|
|
||||||
function position_exception_add(shopID)
|
|
||||||
{
|
|
||||||
var listValue = $('#em_list_'+shopID).val();
|
|
||||||
var inputValue = $('#em_text_'+shopID).val();
|
|
||||||
var r = new RegExp('(^|,) *'+listValue+' *(,|$)');
|
|
||||||
if (!r.test(inputValue))
|
|
||||||
$('#em_text_'+shopID).val(inputValue + ((inputValue.trim()) ? ', ' : '') + listValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
function position_exception_remove(shopID)
|
|
||||||
{
|
|
||||||
var listValue = $('#em_list_'+shopID).val();
|
|
||||||
var inputValue = $('#em_text_'+shopID).val();
|
|
||||||
var r = new RegExp('(^|,) *'+listValue+' *(,|$)');
|
|
||||||
if (r.test(inputValue))
|
|
||||||
{
|
|
||||||
var rep = '';
|
|
||||||
if (new RegExp(', *'+listValue+' *,').test(inputValue))
|
|
||||||
$('#em_text_'+shopID).val(inputValue.replace(r, ','));
|
|
||||||
else if (new RegExp(listValue+' *,').test(inputValue))
|
|
||||||
$('#em_text_'+shopID).val(inputValue.replace(r, ''));
|
|
||||||
else
|
|
||||||
$('#em_text_'+shopID).val(inputValue.replace(r, ''));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//]]>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<label>{l s='Exceptions'} :</label>
|
<label>{l s='Exceptions'} :</label>
|
||||||
<div class="margin-form">
|
<div class="margin-form">
|
||||||
|
{l s='Please specify the files for which you do not want the module to be displayed.'}<br />
|
||||||
|
{l s='Please input each filename, separated by a comma.'}<br />
|
||||||
{if !$except_diff}
|
{if !$except_diff}
|
||||||
{$exception_list}
|
{$exception_list}
|
||||||
{else}
|
{else}
|
||||||
@@ -88,9 +60,6 @@
|
|||||||
{$value}
|
{$value}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
{/if}
|
{/if}
|
||||||
{l s='Please specify the files for which you do not want the module to be displayed.'}.<br />
|
|
||||||
{l s='Please input each filename, separated by a comma.'}.
|
|
||||||
<br /><br />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="margin-form">
|
<div class="margin-form">
|
||||||
@@ -102,4 +71,48 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="small"><sup>*</sup> {l s='Required field'}</div>
|
<div class="small"><sup>*</sup> {l s='Required field'}</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
<script type="text/javascript">
|
||||||
|
//<![CDATA
|
||||||
|
function position_exception_textchange(obj)
|
||||||
|
{
|
||||||
|
// TODO : Add & Remove automatically the "custom pages" in the "em_list_x"
|
||||||
|
var shopID = obj.attr('id').replace(/\D/g, '');
|
||||||
|
var list = obj.parent().find('#em_list_' + shopID);
|
||||||
|
var values = obj.val().split(',');
|
||||||
|
var len = values.length;
|
||||||
|
|
||||||
|
list.find('option').prop('selected', false);
|
||||||
|
for ( var i = 0; i < len; i++ )
|
||||||
|
{
|
||||||
|
list.find('option[value="' + $.trim(values[i]) + '"]').prop('selected', true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function position_exception_listchange(obj)
|
||||||
|
{
|
||||||
|
var shopID = obj.attr('id').replace(/\D/g, '');
|
||||||
|
var str = '';
|
||||||
|
obj.find('option:selected').each( function()
|
||||||
|
{
|
||||||
|
str += obj.val()+', ';
|
||||||
|
});
|
||||||
|
|
||||||
|
if (str.length > 2)
|
||||||
|
str = str.substr(0, str.length - 2);
|
||||||
|
obj.parent().find('#em_text_' + shopID).val(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function ()
|
||||||
|
{
|
||||||
|
$('form[id="hook_module_form"] input[id^="em_text_"]').each( function ()
|
||||||
|
{
|
||||||
|
$(this).change( position_exception_textchange($(this)) ).change();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('form[id="hook_module_form"] select[id^="em_list_"]').each( function ()
|
||||||
|
{
|
||||||
|
$(this).change( position_exception_listchange($(this)) );
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
|||||||
@@ -393,21 +393,35 @@ class AdminModulesPositionsControllerCore extends AdminController
|
|||||||
if (!is_array($file_list))
|
if (!is_array($file_list))
|
||||||
$file_list = ($file_list) ? array($file_list) : array();
|
$file_list = ($file_list) ? array($file_list) : array();
|
||||||
|
|
||||||
$content = '<input type="text" name="exceptions['.$shop_id.']" size="40" value="'.implode(', ', $file_list).'" id="em_text_'.$shop_id.'">';
|
$content = '<input type="text" name="exceptions['.$shop_id.']" size="40" value="'.implode(', ', $file_list).'" id="em_text_'.$shop_id.'" />';
|
||||||
if ($shop_id)
|
if ($shop_id)
|
||||||
{
|
{
|
||||||
$shop = new Shop($shop_id);
|
$shop = new Shop($shop_id);
|
||||||
$content .= ' ('.$shop->name.')';
|
$content .= ' ('.$shop->name.')';
|
||||||
}
|
}
|
||||||
$content .= '<br /><select id="em_list_'.$shop_id.'">';
|
$content .= '
|
||||||
|
<br />
|
||||||
|
<select id="em_list_'.$shop_id.'" size="45" multiple style="width:20em">
|
||||||
|
<option disabled="disabled">---- CUSTOM ----</option>';
|
||||||
|
|
||||||
// @todo do something better with controllers
|
// @todo do something better with controllers
|
||||||
$controllers = Dispatcher::getControllers(_PS_FRONT_CONTROLLER_DIR_);
|
$controllers = Dispatcher::getControllers(_PS_FRONT_CONTROLLER_DIR_);
|
||||||
ksort($controllers);
|
ksort($controllers);
|
||||||
|
|
||||||
|
foreach ($file_list as $k => $v)
|
||||||
|
if ( ! array_key_exists ($v, $controllers))
|
||||||
|
$content .= '
|
||||||
|
<option value="'.$v.'">'.$v.'</option>';
|
||||||
|
|
||||||
|
$content .= '
|
||||||
|
<option disabled="disabled">------ CORE ------</option>';
|
||||||
foreach ($controllers as $k => $v)
|
foreach ($controllers as $k => $v)
|
||||||
$content .= '<option value="'.$k.'">'.$k.'</option>';
|
$content .= '
|
||||||
$content .= '</select> <input type="button" class="button" value="'.$this->l('Add').'" onclick="position_exception_add('.$shop_id.')" />
|
<option value="'.$k.'">'.$k.'</option>';
|
||||||
<input type="button" class="button" value="'.$this->l('Remove').'" onclick="position_exception_remove('.$shop_id.')" /><br /><br />';
|
|
||||||
|
$content .= '
|
||||||
|
</select>
|
||||||
|
';
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user