// fix Update the call of JavaScript and CSS files in the class of HelperForm and controller templates (PSFV-94)

This commit is contained in:
lLefevre
2011-11-14 14:21:26 +00:00
parent 74ef17ca79
commit 5bde977d1f
7 changed files with 87 additions and 47 deletions
+22 -30
View File
@@ -65,7 +65,6 @@
}); });
{block name="script"}{/block} {block name="script"}{/block}
</script> </script>
<script type="text/javascript" src="../js/form.js"></script>
{/if} {/if}
{if $show_toolbar} {if $show_toolbar}
@@ -244,7 +243,7 @@
</div><br /> </div><br />
{/if} {/if}
{/if} {/if}
<input type="file" name="{$input.name}" /> <input type="file" name="{$input.name}" {if isset($input.id)}id="{$input.id}"{/if} />
{elseif $input.type == 'password'} {elseif $input.type == 'password'}
<input type="password" <input type="password"
name="{$input.name}" name="{$input.name}"
@@ -275,7 +274,6 @@
{elseif $input.type == 'asso_shop' && isset($asso_shop) && $asso_shop} {elseif $input.type == 'asso_shop' && isset($asso_shop) && $asso_shop}
{$asso_shop} {$asso_shop}
{elseif $input.type == 'color'} {elseif $input.type == 'color'}
<script type="text/javascript" src="../js/jquery/jquery-colorpicker.js"></script>
<input type="color" <input type="color"
size="{$input.size}" size="{$input.size}"
data-hex="true" data-hex="true"
@@ -284,7 +282,6 @@
name="{$input.name}" name="{$input.name}"
value="{$fields_value[$input.name]}" /> value="{$fields_value[$input.name]}" />
{elseif $input.type == 'date'} {elseif $input.type == 'date'}
<script type="text/javascript" src="../js/jquery/jquery-colorpicker.js"></script>
<input type="text" <input type="text"
size="{$input.size}" size="{$input.size}"
data-hex="true" data-hex="true"
@@ -347,15 +344,6 @@
{if $required_fields} {if $required_fields}
<div class="small"><sup>*</sup> {l s ='Required field'}</div> <div class="small"><sup>*</sup> {l s ='Required field'}</div>
{/if} {/if}
{if isset($fields.tinymce) && $fields.tinymce}
<script type="text/javascript">
var iso = '{$iso}';
var pathCSS = '{$path_css}';
var ad = '{$ad}';
</script>
<script type="text/javascript" src="../js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="../js/tinymce.inc.js"></script>
{/if}
</fieldset> </fieldset>
{block name="other_fieldsets"}{/block} {block name="other_fieldsets"}{/block}
{if isset($fields[$f+1])}<br class="clear" />{/if} {if isset($fields[$f+1])}<br class="clear" />{/if}
@@ -364,23 +352,27 @@
{/block} {/block}
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){
$(document).ready(function(){
tinySetup();
});
{block name="autoload_tinyMCE"} var iso = '{$iso}';
$(".autoload_rte").click(function(e){ var pathCSS = '{$path_css}';
tinySetup({ var ad = '{$ad}';
mode :"exact",
editor_selector :"autoload_rte", $(document).ready(function(){
elements : $(this).attr("id"),
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull|cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,undo,redo", tinySetup();
theme_advanced_buttons2 : "link,unlink,anchor,image,cleanup,code,|,forecolor,backcolor,|,hr,removeformat,visualaid,|,charmap,media,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons3 : "", {block name="autoload_tinyMCE"}
theme_advanced_buttons4 : "", $(".autoload_rte").click(function(e){
}); tinySetup({
}) mode :"exact",
{/block} editor_selector :"autoload_rte",
elements : $(this).attr("id"),
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull|cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,undo,redo",
theme_advanced_buttons2 : "link,unlink,anchor,image,cleanup,code,|,forecolor,backcolor,|,hr,removeformat,visualaid,|,charmap,media,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons3 : "",
theme_advanced_buttons4 : "",
});
})
{/block}
}); });
</script> </script>
@@ -24,11 +24,6 @@
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*} *}
{if count($categories) && isset($categories)} {if count($categories) && isset($categories)}
<script src="../js/jquery/plugins/treeview/jquery.treeview.js" type="text/javascript"></script>
<script src="../js/jquery/plugins/treeview/jquery.treeview.async.js" type="text/javascript"></script>
<script src="../js/jquery/plugins/treeview/jquery.treeview.edit.js" type="text/javascript"></script>
<script src="../js/admin-categories-tree.js" type="text/javascript"></script>
{if isset($categories.use_search) && $categories.use_search}<script src="../js/jquery/plugins/autocomplete/jquery.autocomplete.js" type="text/javascript"></script>{/if}
<script type="text/javascript"> <script type="text/javascript">
var inputName = '{$categories.input_name}'; var inputName = '{$categories.input_name}';
var use_radio = {if $categories.use_radio}1{else}0{/if}; var use_radio = {if $categories.use_radio}1{else}0{/if};
@@ -37,7 +32,6 @@
var home = '{$categories.trads.Home}'; var home = '{$categories.trads.Home}';
var use_radio = {if $categories.use_radio}1{else}0{/if}; var use_radio = {if $categories.use_radio}1{else}0{/if};
</script> </script>
<link type="text/css" rel="stylesheet" href="../css/jquery.treeview.css" />
<div style="background-color:#F4E6C9; width:99%;padding:5px 0 5px 5px;"> <div style="background-color:#F4E6C9; width:99%;padding:5px 0 5px 5px;">
<a href="#" id="collapse_all" >{$categories.trads['Collapse All']}</a> <a href="#" id="collapse_all" >{$categories.trads['Collapse All']}</a>
@@ -27,7 +27,6 @@
{extends file="helper/view/view.tpl"} {extends file="helper/view/view.tpl"}
{block name="override_tpl"} {block name="override_tpl"}
<script src="../js/adminImport.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var errorEmpty = "{l s='Please enter a name to save.'}" var errorEmpty = "{l s='Please enter a name to save.'}"
</script> </script>
+63 -3
View File
@@ -69,12 +69,72 @@ class HelperFormCore extends Helper
if ($this->submit_action == '') if ($this->submit_action == '')
$this->submit_action = 'submitAdd'.$this->table; $this->submit_action = 'submitAdd'.$this->table;
if (isset($this->fields_form['asso_shop']) && Shop::isFeatureActive()) /* TODO : replace call method displayAssoShop() by form_shop.tpl */
if ($this->fields_form['asso_shop'] == 'group') if (isset($this->fields_form[0]['form']['asso_shop']) && Shop::isFeatureActive())
if ($this->fields_form[0]['asso_shop'] == 'group')
$asso_shop = $this->displayAssoShop('group_shop'); $asso_shop = $this->displayAssoShop('group_shop');
else if ($this->fields_form['asso_shop'] == 'shop') else if ($this->fields_form[0]['form']['asso_shop'] == 'shop')
$asso_shop = $this->displayAssoShop(); $asso_shop = $this->displayAssoShop();
$this->context->controller->addJS(_PS_JS_DIR_.'form.js');
$categories = true;
$color = true;
$date = true;
$tinymce = true;
foreach ($this->fields_form as $fieldset)
if (isset($fieldset['form']['input']))
foreach ($fieldset['form']['input'] as $key => $params)
{
switch ($params['type'])
{
case 'categories':
if ($categories)
{
// Added Jquery plugin treeview (css and js files)
$this->context->controller->addJqueryPlugin('treeview');
// Added JS files
$this->context->controller->addJS(_PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.async.js');
$this->context->controller->addJS(_PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.edit.js');
$this->context->controller->addJS(_PS_JS_DIR_.'admin-categories-tree.js');
if (isset($params['use_search']) && $params['use_search'])
$this->context->controller->addJS(_PS_JS_DIR_.'jquery/plugins/autocomplete/jquery.autocomplete.js');
$categories = false;
}
break;
case 'color':
if ($color)
{
// Added JS file
$this->context->controller->addJS(_PS_JS_DIR_.'jquery/plugins/jquery.colorpicker.js');
$color = false;
}
break;
case 'date':
if ($date)
{
$this->context->controller->addJqueryUI('ui.datepicker');
$date = false;
}
break;
case 'textarea':
if ($tinymce)
{
$iso = $this->context->language->iso_code;
$this->tpl_vars['iso'] = file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en';
$this->tpl_vars['theme_path_css'] = _THEME_CSS_DIR_;
$this->tpl_vars['ad'] = dirname($_SERVER['PHP_SELF']);
$this->context->controller->addJS(_PS_JS_DIR_.'tiny_mce/tiny_mce.js');
$this->context->controller->addJS(_PS_JS_DIR_.'tinymce.inc.js');
$tinymce = false;
}
break;
}
}
$iso = $this->context->language->iso_code; $iso = $this->context->language->iso_code;
$this->tpl->assign(array( $this->tpl->assign(array(
'submit_action' => $this->submit_action, 'submit_action' => $this->submit_action,
@@ -294,13 +294,6 @@ class AdminCategoriesControllerCore extends AdminController
'size' => $image ? filesize(_PS_CAT_IMG_DIR_.'/'.$obj->id.'.jpg') / 1000 : false 'size' => $image ? filesize(_PS_CAT_IMG_DIR_.'/'.$obj->id.'.jpg') / 1000 : false
); );
$iso = $this->context->language->iso_code;
$this->context->smarty->assign(array(
'iso' => file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en',
'theme_path_css' => _THEME_CSS_DIR_,
'ad' => dirname($_SERVER["PHP_SELF"])
));
// Added values of object Group // Added values of object Group
$carrier_groups = $obj->getGroups(); $carrier_groups = $obj->getGroups();
$carrier_groups_ids = array(); $carrier_groups_ids = array();
@@ -393,6 +393,8 @@ class AdminImportController extends AdminController
) )
); );
$this->addJS(_PS_JS_DIR_.'adminImport.js');
$glue = Tools::getValue('separator', ';'); $glue = Tools::getValue('separator', ';');
$handle = $this->openCsvFile(); $handle = $this->openCsvFile();
$nb_column = $this->getNbrColumn($handle, $glue); $nb_column = $this->getNbrColumn($handle, $glue);