diff --git a/admin-dev/themes/template/shop_url/form.tpl b/admin-dev/themes/template/shop_url/form.tpl index a0c8639af..d29f8bf42 100644 --- a/admin-dev/themes/template/shop_url/form.tpl +++ b/admin-dev/themes/template/shop_url/form.tpl @@ -1,224 +1,70 @@ -{* -* 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 -* @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 -* @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} - - -{/if} - -
- {if $form_id} - - {/if} -
- {foreach $fields as $key => $field} - {if $key == 'legend'} - - {if isset($field.image)}{$field.title}{/if} - {$field.title} - - {elseif $key == 'input'} - {foreach $field as $input} - {if $input.name == 'id_state'} -
- {/if} - -
- {if $input.type == 'text'} - - {elseif $input.type == 'select'} - - {elseif $input.type == 'radio'} - {foreach $input.values as $value} - - - {/foreach} - {elseif $input.type == 'textarea'} - - {elseif $input.type == 'checkbox'} - - {/if} - {if isset($input.required) && $input.required} *{/if} - {if isset($input.p)} -

- {if is_array($input.p)} - {foreach $input.p as $p} - {if is_array($p)} - {$p.text}
- {else} - {$p}
- {/if} - {/foreach} - {else} - {$input.p} - {/if} -

- {/if} -
- {if $input.name == 'id_state'} -
- {/if} - {/foreach} - {elseif $key == 'submit'} -
- -
- {/if} - {/foreach} - {if $required_fields} -
* {l s ='Required field'}
- {/if} -
-
- -

-{if $firstCall} - {if $back} - {l s='Back'} - {else} - {l s='Back to list'} - {/if} -
-{/if} \ No newline at end of file +{* +* 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 +* @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=script} + $(document).ready(function(){ + fillShopUrl(); + checkMainUrlInfo(); + $('#domain, #physical_uri, #virtual_uri').keyup(fillShopUrl); + }); + + var shopUrl = {$js_shop_url}; + + 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'); + } + } +{/block} diff --git a/admin-dev/themes/template/shop_url/script.tpl b/admin-dev/themes/template/shop_url/script.tpl deleted file mode 100644 index 156fe5fe1..000000000 --- a/admin-dev/themes/template/shop_url/script.tpl +++ /dev/null @@ -1,67 +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 -* @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 -*} -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 = {$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); -}); \ No newline at end of file diff --git a/controllers/admin/AdminShopUrlController.php b/controllers/admin/AdminShopUrlController.php index 046790946..2c3a41d33 100644 --- a/controllers/admin/AdminShopUrlController.php +++ b/controllers/admin/AdminShopUrlController.php @@ -33,18 +33,12 @@ class AdminShopUrlControllerCore extends AdminController $this->className = 'ShopUrl'; $this->lang = false; $this->requiredDatabase = true; - $this->addRowActionSkipList('delete', array(1)); - - $this->addRowAction('edit'); - $this->addRowAction('delete'); $this->context = Context::getContext(); if (!Tools::getValue('realedit')) $this->deleted = false; - $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); - $this->fieldsDisplay = array( 'id_shop_url' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'domain' => array('title' => $this->l('Domain'), 'width' => 130, 'filter_key' => 'domain'), @@ -60,6 +54,12 @@ class AdminShopUrlControllerCore extends AdminController public function initList() { + $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); + $this->addRowActionSkipList('delete', array(1)); + + $this->addRowAction('edit'); + $this->addRowAction('delete'); + $this->_select = 's.name AS shop_name, CONCAT(a.physical_uri, a.virtual_uri) AS uri'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'shop` s ON (s.id_shop = a.id_shop)'; @@ -140,7 +140,8 @@ class AdminShopUrlControllerCore extends AdminController ) ), 'p' => array( - $this->l('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).'), + $this->l('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).'), array( 'text' => $this->l('Since the selected shop has no main url, you have to set this url as main'), 'id' => 'mainUrlInfo' @@ -186,7 +187,9 @@ class AdminShopUrlControllerCore extends AdminController foreach (Shop::getShops(false, null, true) as $id) $list_shop_with_url[$id] = (bool)count(ShopUrl::getShopUrls($id)); - $this->context->smarty->assign('jsShopUrl', Tools::jsonEncode($list_shop_with_url)); + $this->tpl_form_vars = array( + 'js_shop_url' => Tools::jsonEncode($list_shop_with_url) + ); $this->fields_value = array( 'domain' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'domain') : $current_shop->domain,