[*] BO #PSFV-94 : update of the displayform method by helperForm in AdminShopUrlController
This commit is contained in:
@@ -1,142 +0,0 @@
|
||||
{*
|
||||
* 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: 8897 $
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
|
||||
{if isset($tab_form)}
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function fillShopUrl()
|
||||
{
|
||||
var domain = $('#domain').val();
|
||||
var physical = $('#physical_uri').val();
|
||||
var virtual = $('#virtual_uri').val();
|
||||
url = ((domain) ? domain : '???');
|
||||
if (physical)
|
||||
url += '/'+physical;
|
||||
if (virtual)
|
||||
url += '/'+virtual;
|
||||
url = url.replace(/\/+/g, "/");
|
||||
$('#final_url').val('http://'+url);
|
||||
};
|
||||
|
||||
var shopUrl = {$tab_form['jsShopUrl']};
|
||||
|
||||
function checkMainUrlInfo(shopID)
|
||||
{
|
||||
if (!shopID)
|
||||
shopID = $('#id_shop').val();
|
||||
|
||||
if (!shopUrl[shopID])
|
||||
{
|
||||
$('#main_off').attr('disabled', true);
|
||||
$('#main_on').attr('checked', true);
|
||||
$('#mainUrlInfo').css('display', 'block');
|
||||
$('#mainUrlInfoExplain').css('display', 'none');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#main_off').attr('disabled', false);
|
||||
$('#mainUrlInfo').css('display', 'none');
|
||||
$('#mainUrlInfoExplain').css('display', 'block');
|
||||
}
|
||||
}
|
||||
|
||||
$().ready(function()
|
||||
{
|
||||
fillShopUrl();
|
||||
checkMainUrlInfo();
|
||||
$('#domain, #physical_uri, #virtual_uri').keyup(fillShopUrl);
|
||||
});
|
||||
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<form action="{$tab_form['current']}&submitAdd{$tab_form['table']}=1&token={$tab_form['token']}" method="post">
|
||||
{if $tab_form['id']}<input type="hidden" name="id_{$tab_form['table']}" value="{$tab_form['id']}" />{/if}
|
||||
<fieldset>
|
||||
<legend>{l s ='Shop Url'}</legend>
|
||||
<label for="domain">{l s ='Domain'}</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" name="domain" id="domain" value="{$tab_form['domain']}" />
|
||||
</div>
|
||||
<label for="domain">{l s ='Domain SSL'}</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" name="domain_ssl" id="domain_ssl" value="{$tab_form['domain_ssl']}" />
|
||||
</div>
|
||||
<label for="physical_uri">{l s ='Physical URI'}</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" name="physical_uri" id="physical_uri" value="{$tab_form['physical_uri']}" />
|
||||
<p>{l s ='Physical folder of your store on your server. Leave this field empty if your store is installed on root path.'}</p>
|
||||
</div>
|
||||
<label for="virtual_uri">{l s ='Virtual URI'}</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" name="virtual_uri" id="virtual_uri" value="{$tab_form['virtual_uri']}" />
|
||||
<p>{l s ='This virtual folder must not exist on your server and is used to associate an URI to a shop.'}<br /><b>{l s ='URL rewriting must be activated on your server to use this feature.'}</b></p>
|
||||
</div>
|
||||
<label>{l s ='Your final URL will be'}</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" readonly="readonly" id="final_url" style="width: 400px" />
|
||||
</div>
|
||||
<label for="id_shop">{l s ='Shop'}</label>
|
||||
<div class="margin-form">
|
||||
<select name="id_shop" id="id_shop" onchange="checkMainUrlInfo(this.value)">
|
||||
{foreach $tab_form['getTree'] AS $gID => $gData}
|
||||
<optgroup label="{$gData['name']}">
|
||||
{foreach $gData['shops'] as $sID => $sData}
|
||||
<option value="{$sID}" {if {$tab_form['id_shop']} == $sID} selected="selected"{/if}>{$sData['name']}</option>
|
||||
{/foreach}
|
||||
</optgroup>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
<label>{l s ='Main URL:'}</label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="main" id="main_on" value="1" {if $tab_form['main']} checked="checked"{/if}/>
|
||||
<label class="t" for="main_on"><img src="../img/admin/enabled.gif" alt="{l s ='Enabled'}" title="{l s ='Enabled'}" /></label>
|
||||
<input type="radio" name="main" id="main_off" value="0" {if !$tab_form['main']} checked="checked"{/if} />
|
||||
<label class="t" for="main_off"><img src="../img/admin/disabled.gif" alt="{l s ='Disabled'}" title="{l s ='Disabled'}" /></label>
|
||||
<p>{l s ='If you set this url as main url for selected shop, all urls set to this shop will be redirected to this url (you can only have one main url per shop).'}</p>
|
||||
<p id="mainUrlInfo">{l s ='Since the selected shop has no main url, you have to set this url as main'}</p>
|
||||
<p id="mainUrlInfoExplain">{l s ='The selected shop has already a main url, if you set this one as main url, the older one will be set as normal url'}</p>
|
||||
</div>
|
||||
<label>{l s ='Status:'} </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="active" id="active_on" value="1" {if $tab_form['active']} checked="checked"{/if} />
|
||||
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="{l s ='Enabled'}" title="{l s ='Enabled'}" /></label>
|
||||
<input type="radio" name="active" id="active_off" value="0" {if !$tab_form['active']} checked="checked"{/if} />
|
||||
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="{l s ='Disabled'}" title="{l s ='Disabled'}" /></label>
|
||||
<p>{l s ='Enable or disable URL'}</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="{l s =' Save '}" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> {l s ='Required field'}</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
{/if}
|
||||
|
||||
{$content}
|
||||
@@ -51,9 +51,6 @@
|
||||
}
|
||||
{/literal}
|
||||
{rdelim});
|
||||
{if isset($script)}
|
||||
{$script}
|
||||
{/if}
|
||||
</script>
|
||||
<script type="text/javascript" src="../js/form.js"></script>
|
||||
{/if}
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
{*
|
||||
* 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: 8897 $
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
{*
|
||||
* 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
|
||||
*}
|
||||
|
||||
{if $firstCall}
|
||||
<script type="text/javascript">
|
||||
var vat_number = {$vat_number};
|
||||
var module_dir = '{$module_dir}';
|
||||
|
||||
$(document).ready(function() {ldelim}
|
||||
var id_language = {$defaultFormLanguage};
|
||||
var languages = new Array();
|
||||
{foreach $languages as $k => $language}
|
||||
languages[{$k}] = {ldelim}
|
||||
id_lang: {$language.id_lang},
|
||||
iso_code: '{$language.iso_code}',
|
||||
name: '{$language.name}'
|
||||
{rdelim};
|
||||
{/foreach}
|
||||
displayFlags(languages, id_language, {$allowEmployeeFormLang});
|
||||
|
||||
{literal}
|
||||
if ($('#id_country'))
|
||||
{
|
||||
ajaxStates();
|
||||
$('#id_country').change(function() {
|
||||
ajaxStates();
|
||||
});
|
||||
}
|
||||
{/literal}
|
||||
fillShopUrl();
|
||||
checkMainUrlInfo();
|
||||
$('#domain, #physical_uri, #virtual_uri').keyup(fillShopUrl);
|
||||
{rdelim});
|
||||
|
||||
var shopUrl = {$jsShopUrl};
|
||||
|
||||
{literal}
|
||||
function fillShopUrl()
|
||||
{
|
||||
var domain = $('#domain').val();
|
||||
var physical = $('#physical_uri').val();
|
||||
var virtual = $('#virtual_uri').val();
|
||||
url = ((domain) ? domain : '???');
|
||||
if (physical)
|
||||
url += '/'+physical;
|
||||
if (virtual)
|
||||
url += '/'+virtual;
|
||||
url = url.replace(/\/+/g, "/");
|
||||
$('#final_url').val('http://'+url);
|
||||
};
|
||||
|
||||
function checkMainUrlInfo(shopID)
|
||||
{
|
||||
if (!shopID)
|
||||
shopID = $('#id_shop').val();
|
||||
|
||||
if (!shopUrl[shopID])
|
||||
{
|
||||
$('#main_off').attr('disabled', true);
|
||||
$('#main_on').attr('checked', true);
|
||||
$('#mainUrlInfo').css('display', 'block');
|
||||
$('#mainUrlInfoExplain').css('display', 'none');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#main_off').attr('disabled', false);
|
||||
$('#mainUrlInfo').css('display', 'none');
|
||||
$('#mainUrlInfoExplain').css('display', 'block');
|
||||
}
|
||||
}
|
||||
{/literal}
|
||||
</script>
|
||||
<script type="text/javascript" src="../js/form.js"></script>
|
||||
{/if}
|
||||
|
||||
<form action="{$current}&submitAdd{$table}=1&token={$token}" method="post">
|
||||
{if $form_id}
|
||||
<input type="hidden" name="id_{$table}" value="{$form_id}" />
|
||||
{/if}
|
||||
<fieldset>
|
||||
{foreach $fields as $key => $field}
|
||||
{if $key == 'legend'}
|
||||
<legend>
|
||||
{if isset($field.image)}<img src="{$field.image}" alt="{$field.title}" />{/if}
|
||||
{$field.title}
|
||||
</legend>
|
||||
{elseif $key == 'input'}
|
||||
{foreach $field as $input}
|
||||
{if $input.name == 'id_state'}
|
||||
<div id="contains_states" {if $contains_states}style="display:none;"{/if}>
|
||||
{/if}
|
||||
<label>{$input.label} </label>
|
||||
<div class="margin-form">
|
||||
{if $input.type == 'text'}
|
||||
<input type="text"
|
||||
name="{$input.name}"
|
||||
id="{$input.name}"
|
||||
value="{$fields_value[$input.name]}"
|
||||
{if isset($input.size)}size="{$input.size}"{/if}
|
||||
{if isset($input.class)}class="{$input.class}"{/if}
|
||||
{if isset($input.readonly) && $input.readonly}readonly="readonly"{/if} />
|
||||
{elseif $input.type == 'select'}
|
||||
<select name="{$input.name}" id="{$input.name}" {if isset($input.onchange)}onchange="{$input.onchange}"{/if}>
|
||||
{if isset($input.options.optiongroup)}
|
||||
{foreach $input.options.optiongroup.query AS $optiongroup}
|
||||
<optgroup label="{$optiongroup[$input.options.optiongroup.label]}">
|
||||
{foreach $optiongroup[$input.options.options.query] as $option}
|
||||
<option value="{$option[$input.options.options.id]}"
|
||||
{if $fields_value[$input.name] == $option[$input.options.options.id]}selected="selected"{/if}>{$option[$input.options.options.name]}</option>
|
||||
{/foreach}
|
||||
</optgroup>
|
||||
{/foreach}
|
||||
{else}
|
||||
{foreach $input.options.query AS $option}
|
||||
<option value="{$option[$input.options.id]}"
|
||||
{if $fields_value[$input.name] == $option[$input.options.id]}selected="selected"{/if}>{$option[$input.options.name]}</option>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</select>
|
||||
{elseif $input.type == 'radio'}
|
||||
{foreach $input.values as $value}
|
||||
<input type="radio"
|
||||
name="{$input.name}"
|
||||
id="{$value.id}"
|
||||
value="{$value.value}"
|
||||
{if $fields_value[$input.name] == $value.value}checked="checked"{/if} />
|
||||
<label {if isset($input.class)}class="{$input.class}"{/if} for="{$value.id}"> {$value.label}</label>
|
||||
{/foreach}
|
||||
{elseif $input.type == 'textarea'}
|
||||
<textarea name="{$input.name}" id="{$input.name}" cols="{$input.cols}" rows="{$input.rows}">{$fields_value[$input.name]}</textarea>
|
||||
{elseif $input.type == 'checkbox'}
|
||||
|
||||
{/if}
|
||||
{if isset($input.required) && $input.required} <sup>*</sup>{/if}
|
||||
{if isset($input.p)}
|
||||
<p class="clear">
|
||||
{if is_array($input.p)}
|
||||
{foreach $input.p as $p}
|
||||
{if is_array($p)}
|
||||
<span id="{$p.id}">{$p.text}</span><br />
|
||||
{else}
|
||||
{$p}<br />
|
||||
{/if}
|
||||
{/foreach}
|
||||
{else}
|
||||
{$input.p}
|
||||
{/if}
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
{if $input.name == 'id_state'}
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
{elseif $key == 'submit'}
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="{$field.title}" name="submitAdd{$table}" {if isset($field.class)}class="{$field.class}"{/if} />
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
{if $requiredFields}
|
||||
<div class="small"><sup>*</sup> {l s ='Required field'}</div>
|
||||
{/if}
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<br /><br />
|
||||
{if $firstCall}
|
||||
{if $back}
|
||||
<a href="{$back}"><img src="../img/admin/arrow2.gif" />{l s='Back'}</a>
|
||||
{else}
|
||||
<a href="{$current}&token={$token}"><img src="../img/admin/arrow2.gif" />{l s='Back to list'}</a>
|
||||
{/if}
|
||||
<br />
|
||||
{/if}
|
||||
+17
-15
@@ -58,28 +58,29 @@ class HelperFormCore extends Helper
|
||||
|
||||
public function displayForm()
|
||||
{
|
||||
$allowEmployeeFormLang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
|
||||
if ($allowEmployeeFormLang && !$this->context->cookie->employee_form_lang)
|
||||
$this->context->cookie->employee_form_lang = (int)(Configuration::get('PS_LANG_DEFAULT'));
|
||||
$useLangFromCookie = false;
|
||||
$cookie = $this->context->cookie;
|
||||
$allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
|
||||
if ($allow_employee_form_lang && !$cookie->employee_form_lang)
|
||||
$cookie->employee_form_lang = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||
$use_lang_from_cookie = false;
|
||||
$languages = Language::getLanguages(false);
|
||||
if ($allowEmployeeFormLang)
|
||||
if ($allow_employee_form_lang)
|
||||
foreach ($languages as $lang)
|
||||
if ($this->context->cookie->employee_form_lang == $lang['id_lang'])
|
||||
$useLangFromCookie = true;
|
||||
if (!$useLangFromCookie)
|
||||
$defaultFormLanguage = (int)(Configuration::get('PS_LANG_DEFAULT'));
|
||||
if ($cookie->employee_form_lang == $lang['id_lang'])
|
||||
$use_lang_from_cookie = true;
|
||||
if (!$use_lang_from_cookie)
|
||||
$default_form_language = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||
else
|
||||
$defaultFormLanguage = (int)($this->context->cookie->employee_form_lang);
|
||||
$default_form_language = (int)$cookie->employee_form_lang;
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'firstCall' => $this->first_call,
|
||||
'current' => self::$currentIndex,
|
||||
'token' => $this->token,
|
||||
'table' => $this->table,
|
||||
'defaultFormLanguage' => $defaultFormLanguage,
|
||||
'defaultFormLanguage' => $default_form_language,
|
||||
'languages' => $languages,
|
||||
'allowEmployeeFormLang' => $allowEmployeeFormLang,
|
||||
'allowEmployeeFormLang' => $allow_employee_form_lang,
|
||||
'form_id' => $this->id,
|
||||
'back' => Tools::getValue('back'),
|
||||
'fields' => $this->fields_form,
|
||||
@@ -95,9 +96,10 @@ class HelperFormCore extends Helper
|
||||
|
||||
public function getFieldsRequired()
|
||||
{
|
||||
foreach ($this->fields_form['input'] as $input)
|
||||
if (array_key_exists('required', $input) && $input['required'])
|
||||
return true;
|
||||
if (isset($this->fields_form['input']))
|
||||
foreach ($this->fields_form['input'] as $input)
|
||||
if (array_key_exists('required', $input) && $input['required'])
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -234,9 +234,7 @@ class AdminShopUrlControllerCore extends AdminController
|
||||
foreach (Shop::getShops(false, null, true) as $id)
|
||||
$list_shop_with_url[$id] = (bool)count(ShopUrl::getShopUrls($id));
|
||||
|
||||
$smarty = $this->context->smarty;
|
||||
$smarty->assign('jsShopUrl', Tools::jsonEncode($list_shop_with_url));
|
||||
$smarty->assign('script', $smarty->fetch($smarty->template_dir.'/'.$this->tpl_folder.'script.tpl'));
|
||||
$this->context->smarty->assign('jsShopUrl', Tools::jsonEncode($list_shop_with_url));
|
||||
|
||||
$this->fields_value = array(
|
||||
'domain' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'domain') : $current_shop->domain,
|
||||
|
||||
Reference in New Issue
Block a user