// Multishop interface reworked

This commit is contained in:
rMalie
2012-05-09 15:05:39 +00:00
parent 7920dea947
commit d7337c4d4f
61 changed files with 6043 additions and 391 deletions
+92 -15
View File
@@ -112,6 +112,46 @@ class AdminMetaControllerCore extends AdminController
if (isset($robots_submit))
$robots_options['submit'] = $robots_submit;
// Options for shop URL if multishop is disabled
$shop_url_options = array(
'title' => $this->l('Set shop URL'),
'fields' => array(),
);
if (!Shop::isFeatureActive())
{
$this->url = ShopUrl::getShopUrls($this->context->shop->id)->where('main', '=', 1)->getFirst();
if ($this->url)
{
$shop_url_options['description'] = $this->l('You can set here the URL for your shop. If you migrate your shop to a new URL, remember to change the values bellow.');
$shop_url_options['fields'] = array(
'domain' => array(
'title' => $this->l('Shop domain'),
'validation' => 'isString',
'type' => 'text',
'size' => 70,
'defaultValue' => $this->url->domain,
),
'domain_ssl' => array(
'title' => $this->l('SSL domain'),
'validation' => 'isString',
'type' => 'text',
'size' => 70,
'defaultValue' => $this->url->domain_ssl,
),
'uri' => array(
'title' => $this->l('Base URI'),
'validation' => 'isString',
'type' => 'text',
'size' => 70,
'defaultValue' => $this->url->physical_uri,
),
);
}
}
else
$shop_url_options['description'] = $this->l('Multishop option is enabled, if you want to change the url of your shop you have to go in "Advanced parameters" -> "multishop" tab.');
// List of options
$this->fields_options = array(
'general' => array(
@@ -120,12 +160,13 @@ class AdminMetaControllerCore extends AdminController
'fields' => $general_fields,
'submit' => array()
),
'robots' => $robots_options,
'shop_url' => $shop_url_options,
'routes' => array(
'title' => $this->l('Schema of URLs'),
'description' => $this->l('Change the pattern of your links. There are some available keywords for each route listed below, keywords with * are required. To add a keyword in your URL use {keyword} syntax. You can add some text before or after the keyword IF the keyword is not empty with syntax {prepend:keyword:append}, for example {-hey-:meta_title} will add "-hey-my-title" in URL if meta title is set, or nothing. Friendly URL and rewriting Apache option must be activated on your web server to use this functionality.'),
'fields' => array(),
),
'robots' => $robots_options,
);
// Add display route options to options form
@@ -147,20 +188,20 @@ class AdminMetaControllerCore extends AdminController
$this->addJqueryUi('ui.widget');
$this->addJqueryPlugin('tagify');
}
public function addFieldRoute($routeID, $title)
public function addFieldRoute($route_id, $title)
{
$keywords = array();
foreach (Dispatcher::getInstance()->default_routes[$routeID]['keywords'] as $keyword => $data)
foreach (Dispatcher::getInstance()->default_routes[$route_id]['keywords'] as $keyword => $data)
$keywords[] = ((isset($data['param'])) ? '<span class="red">'.$keyword.'*</span>' : $keyword);
$this->fields_options['routes']['fields']['PS_ROUTE_'.$routeID] = array(
$this->fields_options['routes']['fields']['PS_ROUTE_'.$route_id] = array(
'title' => $title,
'desc' => sprintf($this->l('Keywords: %s'), implode(', ', $keywords)),
'validation' => 'isString',
'type' => 'text',
'size' => 70,
'defaultValue' => Dispatcher::getInstance()->default_routes[$routeID]['rule'],
'defaultValue' => Dispatcher::getInstance()->default_routes[$route_id]['rule'],
);
}
@@ -363,29 +404,29 @@ class AdminMetaControllerCore extends AdminController
/**
* Validate route syntax and save it in configuration
*
* @param string $routeID
* @param string $route_id
*/
public function checkAndUpdateRoute($routeID)
public function checkAndUpdateRoute($route_id)
{
$default_routes = Dispatcher::getInstance()->default_routes;
if (!isset($default_routes[$routeID]))
if (!isset($default_routes[$route_id]))
return;
$rule = Tools::getValue('PS_ROUTE_'.$routeID);
if (!$rule || $rule == $default_routes[$routeID]['rule'])
$rule = Tools::getValue('PS_ROUTE_'.$route_id);
if (!$rule || $rule == $default_routes[$route_id]['rule'])
{
Configuration::updateValue('PS_ROUTE_'.$routeID, '');
Configuration::updateValue('PS_ROUTE_'.$route_id, '');
return;
}
$errors = array();
if (!Dispatcher::getInstance()->validateRoute($routeID, $rule, $errors))
if (!Dispatcher::getInstance()->validateRoute($route_id, $rule, $errors))
{
foreach ($errors as $error)
$this->errors[] = sprintf('Keyword "{%1$s}" required for route "%2$s" (rule: "%3$s")', $error, $routeID, htmlspecialchars($rule));
$this->errors[] = sprintf('Keyword "{%1$s}" required for route "%2$s" (rule: "%3$s")', $error, $route_id, htmlspecialchars($rule));
}
else
Configuration::updateValue('PS_ROUTE_'.$routeID, $rule);
Configuration::updateValue('PS_ROUTE_'.$route_id, $rule);
}
/**
@@ -432,6 +473,42 @@ class AdminMetaControllerCore extends AdminController
$this->checkAndUpdateRoute('cms_category_rule');
}
/**
* Update shop domain (for mono shop)
*/
public function updateOptionDomain($value)
{
if (!Shop::isFeatureActive() && $this->url && $this->url->domain != $value)
{
$this->url->domain = $value;
$this->url->update();
}
}
/**
* Update shop SSL domain (for mono shop)
*/
public function updateOptionDomainSsl($value)
{
if (!Shop::isFeatureActive() && $this->url && $this->url->domain_ssl != $value)
{
$this->url->domain_ssl = $value;
$this->url->update();
}
}
/**
* Update shop physical uri for mono shop)
*/
public function updateOptionUri($value)
{
if (!Shop::isFeatureActive() && $this->url && $this->url->physical_uri != $value)
{
$this->url->physical_uri = $value;
$this->url->update();
}
}
/**
* Function used to render the options for this controller
*/
@@ -34,8 +34,6 @@ class AdminPreferencesControllerCore extends AdminController
$this->className = 'Configuration';
$this->table = 'configuration';
// Prevent classes which extend AdminPreferences to load useless data
if (get_class($this) == 'AdminPreferencesController')
{
@@ -88,6 +86,14 @@ class AdminPreferencesControllerCore extends AdminController
'cast' => 'intval',
'type' => 'bool'
),
'PS_MULTISHOP_FEATURE_ACTIVE' => array(
'title' => $this->l('Enable multishop'),
'desc' => $this->l('Multishop feature allows you to manage several shops with one back-office. If this feature is enabled, a tab "multishop" will be available in "advanced parameters" menu.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
'visibility' => Shop::CONTEXT_ALL
),
);
// No HTTPS activation if you haven't already.
@@ -110,4 +116,18 @@ class AdminPreferencesControllerCore extends AdminController
parent::__construct();
}
/**
* Enable / disable multishop menu if multishop feature is activated
*
* @param string $value
*/
public function updateOptionPsMultishopFeatureActive($value)
{
Configuration::updateValue('PS_MULTISHOP_FEATURE_ACTIVE', $value);
$tab = Tab::getInstanceFromClassName('AdminShopGroup');
$tab->active = (bool)Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE');
$tab->update();
}
}
+201 -51
View File
@@ -33,7 +33,8 @@ class AdminShopControllerCore extends AdminController
$this->context = Context::getContext();
$this->table = 'shop';
$this->className = 'Shop';
$this->multishop_context = Shop::CONTEXT_ALL | Shop::CONTEXT_GROUP;
$this->multishop_context = Shop::CONTEXT_ALL;
$this->id_shop_group = Tools::getValue('id_shop_group');
$this->fields_list = array(
'id_shop' => array(
@@ -53,7 +54,7 @@ class AdminShopControllerCore extends AdminController
'filter_key' => 'gs!name'
),
'category_name' => array(
'title' => $this->l('Category Root'),
'title' => $this->l('Category'),
'width' => 150,
'filter_key' => 'cl!name'
),
@@ -72,31 +73,20 @@ class AdminShopControllerCore extends AdminController
)
);
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'),'confirm' => $this->l('Delete selected items?')));
$this->fields_options = array(
'general' => array(
'title' => $this->l('Shops options'),
'fields' => array(
'PS_SHOP_DEFAULT' => array(
'title' => $this->l('Default shop:'),
'desc' => $this->l('The default shop'),
'cast' => 'intval',
'type' => 'select',
'identifier' => 'id_shop',
'list' => Shop::getShops(),
'visibility' => Shop::CONTEXT_ALL
)
),
'submit' => array()
)
);
parent::__construct();
}
public function initToolbar()
{
if (!$this->id_shop_group && $this->object && $this->object->id_shop_group)
$this->id_shop_group = $this->object->id_shop_url;
if (!$this->display && $this->id_shop_group)
$this->toolbar_btn['edit'] = array(
'desc' => $this->l('Edit this shop group'),
'href' => $this->context->link->getAdminLink('AdminShopGroup').'&amp;updateshop_group&amp;id_shop_group='.$this->id_shop_group,
);
if ($this->display == 'edit' || $this->display == 'add')
{
if ($shop = $this->loadObject(true))
@@ -111,21 +101,11 @@ class AdminShopControllerCore extends AdminController
'desc' => $this->l('Delete this shop'),
'confirm' => 1);
// adding button for preview this shop
if ($url_preview = $shop->getBaseURL())
$this->toolbar_btn['preview'] = array(
'href' => $url_preview,
'desc' => $this->l('Home page'),
'target' => true,
'class' => 'previewUrl'
);
$this->toolbar_btn['new-url'] = array(
'href' => $this->context->link->getAdminLink('AdminShopUrl').'&amp;id_shop='.$shop->id.'&amp;addshop_url',
'desc' => $this->l('Add URL'),
'class' => 'addShopUrl'
);
'href' => $this->context->link->getAdminLink('AdminShopUrl').'&amp;id_shop='.$shop->id.'&amp;addshop_url',
'desc' => $this->l('Add URL'),
'class' => 'addShopUrl'
);
}
if ($this->tabAccess['edit'])
@@ -147,6 +127,41 @@ class AdminShopControllerCore extends AdminController
parent::initToolbar();
$this->context->smarty->assign('toolbar_scroll', 1);
$this->show_toolbar = false;
if (isset($this->toolbar_btn['new']))
$this->toolbar_btn['new'] = array(
'desc' => $this->l('Add new shop'),
'href' => $this->context->link->getAdminLink('AdminShop').'&amp;add'.$this->table.'&amp;id_shop_group='.$this->id_shop_group,
);
if (isset($this->toolbar_btn['back']))
$this->toolbar_btn['back']['href'] .= '&amp;id_shop_group='.$this->id_shop_group;
}
public function initContent()
{
$this->list_simple_header = true;
parent::initContent();
$this->addJqueryPlugin('cookie');
$this->addJqueryPlugin('jstree');
$this->addCSS(_PS_JS_DIR_.'jquery/plugins/jstree/themes/classic/style.css');
if ($this->display == 'edit')
$this->toolbar_title[] = $this->object->name;
else if (!$this->display && $this->id_shop_group)
{
$group = new ShopGroup($this->id_shop_group);
$this->toolbar_title[] = $group->name;
}
$this->context->smarty->assign(array(
'toolbar_scroll' => 1,
'toolbar_btn' => $this->toolbar_btn,
'title' => $this->toolbar_title,
'selected_tree_id' => ($this->display == 'edit' ? 'tree-shop-'.$this->id_object : (Tools::getValue('id_shop_group') ? 'tree-group-'.Tools::getValue('id_shop_group') : '')),
));
}
public function renderList()
@@ -165,6 +180,9 @@ class AdminShopControllerCore extends AdminController
';
$this->_group = 'GROUP BY a.id_shop';
if ($id_shop_group = (int)Tools::getValue('id_shop_group'))
$this->_where = 'AND a.id_shop_group = '.$id_shop_group;
return parent::renderList();
}
@@ -204,7 +222,12 @@ class AdminShopControllerCore extends AdminController
if ($this->errors)
return false;
return parent::postProcess();
$result = parent::postProcess();
if ($this->redirect_after)
$this->redirect_after .= '&id_shop_group='.$this->id_shop_group;
return $result;
}
public function processDelete()
@@ -274,33 +297,37 @@ class AdminShopControllerCore extends AdminController
)
);
if (Shop::getTotalShops() > 1 && $obj->id)
$display_group_list = true;
if ($this->display == 'edit')
{
$shop_group = new ShopGroup($obj->id_shop_group);
$this->fields_form['input'][] = array(
'type' => 'hidden',
'name' => 'id_shop_group',
'default' => $shop_group->name
);
$this->fields_form['input'][] = array(
'type' => 'textShopGroup',
'label' => $this->l('Group Shop:'),
'name' => 'id_shop_group',
'value' => $shop_group->name
);
$group = new ShopGroup($obj->id_shop_group);
if ($group->share_customer || $group->share_order || $group->share_stock)
$display_group_list = false;
}
else
if (!$display_group_list)
{
$options = array();
foreach (ShopGroup::getShopGroups() as $group)
{
if ($this->display == 'edit' && ($group->share_customer || $group->share_order || $group->share_stock) && ShopGroup::hasDependency($group->id))
continue;
$options[] = array(
'id_shop_group' => $group->id,
'name' => $group->name,
);
}
if ($this->display == 'add')
$group_desc = $this->l('Warning: you won\'t be able to change the group of this shop if this shop belong to a group with one of these options "share customers" or "share quantities" or "share orders" activated.');
else
$group_desc = $this->l('You can only move your shop to a shop group with all "share" options disabled or to a shop group with no customers / orders.');
$this->fields_form['input'][] = array(
'type' => 'select',
'label' => $this->l('Group Shop:'),
'desc' => $group_desc,
'name' => 'id_shop_group',
'options' => array(
'query' => $options,
@@ -309,6 +336,22 @@ class AdminShopControllerCore extends AdminController
),
);
}
else
{
$this->fields_form['input'][] = array(
'type' => 'hidden',
'name' => 'id_shop_group',
'default' => $group->name
);
$this->fields_form['input'][] = array(
'type' => 'textShopGroup',
'label' => $this->l('Shop group:'),
'desc' => $this->l('You can\'t edit the shop group because the current shop belongs to a group with a "share" option enabled.'),
'name' => 'id_shop_group',
'value' => $group->name
);
}
$categories = Category::getRootCategories($this->context->language->id);
$this->fields_form['input'][] = array(
'type' => 'select',
@@ -558,4 +601,111 @@ class AdminShopControllerCore extends AdminController
$helper = new Helper();
return $helper->renderCategoryTree($root_category, $selected_cat, 'categoryBox', false, true);
}
public function ajaxProcessTree()
{
$tree = array();
$sql = 'SELECT g.id_shop_group, g.name as group_name, s.id_shop, s.name as shop_name, u.id_shop_url, u.domain, u.physical_uri, u.virtual_uri
FROM '._DB_PREFIX_.'shop_group g
LEFT JOIN '._DB_PREFIX_.'shop s ON g.id_shop_group = s.id_shop_group
LEFT JOIN '._DB_PREFIX_.'shop_url u ON u.id_shop = s.id_shop
ORDER BY g.name, s.name, u.main, u.domain';
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
foreach ($results as $row)
{
$id_shop_group = $row['id_shop_group'];
$id_shop = $row['id_shop'];
$id_shop_url = $row['id_shop_url'];
// Group list
if (!isset($tree[$id_shop_group]))
$tree[$id_shop_group] = array(
'data' => array(
'title' => '<b>'.$this->l('Group:').'</b> '.$row['group_name'],
'icon' => 'themes/'.$this->context->employee->bo_theme.'/img/tree-multishop-groups.png',
'attr' => array(
'href' => $this->context->link->getAdminLink('AdminShop').'&id_shop_group='.$id_shop_group,
'title' => sprintf($this->l('Click here to display shops of group %s'), $row['group_name']),
)
),
'attr' => array(
'id' => 'tree-group-'.$id_shop_group,
),
'children' => array(),
);
// Shop list
if (!$id_shop)
continue;
if (!isset($tree[$id_shop_group]['children'][$id_shop]))
$tree[$id_shop_group]['children'][$id_shop] = array(
'data' => array(
'title' => $row['shop_name'],
'icon' => 'themes/'.$this->context->employee->bo_theme.'/img/tree-multishop-shop.png',
'attr' => array(
'href' => $this->context->link->getAdminLink('AdminShopUrl').'&id_shop='.$id_shop,
'title' => sprintf($this->l('Click here to display URLs of shop %s'), $row['shop_name']),
)
),
'attr' => array(
'id' => 'tree-shop-'.$id_shop,
),
'children' => array(),
);
// Url list
if (!$id_shop_url)
continue;
if (!isset($tree[$id_shop_group]['children'][$id_shop]['children'][$id_shop_url]))
{
$url = $row['domain'].$row['physical_uri'].$row['virtual_uri'];
if (strlen($url) > 23)
$url = substr($url, 0, 23).'...';
$tree[$id_shop_group]['children'][$id_shop]['children'][$id_shop_url] = array(
'data' => array(
'title' => $url,
'icon' => 'themes/'.$this->context->employee->bo_theme.'/img/tree-multishop-url.png',
'attr' => array(
'href' => $this->context->link->getAdminLink('AdminShopUrl').'&updateshop_url&id_shop_url='.$id_shop_url,
'title' => $row['domain'].$row['physical_uri'].$row['virtual_uri'],
)
),
'attr' => array(
'id' => 'tree-url-'.$id_shop_url,
),
);
}
}
// jstree need to have children as array and not object, so we use sort to get clean keys
// DO NOT REMOVE this code, even if it seems really strange ;)
sort($tree);
foreach ($tree as &$groups)
{
sort($groups['children']);
foreach ($groups['children'] as &$shops)
sort($shops['children']);
}
$tree = array(array(
'data' => array(
'title' => '<b>'.$this->l('Shop groups list').'</b>',
'icon' => 'themes/'.$this->context->employee->bo_theme.'/img/tree-multishop-root.png',
'attr' => array(
'href' => $this->context->link->getAdminLink('AdminShopGroup'),
'title' => $this->l('Click here to display group shops list'),
)
),
'attr' => array(
'id' => 'tree-root',
),
'state' => 'open',
'children' => $tree,
));
die(Tools::jsonEncode($tree));
}
}
+51 -17
View File
@@ -36,9 +36,7 @@ class AdminShopGroupControllerCore extends AdminController
$this->multishop_context = Shop::CONTEXT_ALL;
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'),'confirm' => $this->l('Delete selected items?')));
$this->context = Context::getContext();
@@ -67,15 +65,62 @@ class AdminShopGroupControllerCore extends AdminController
),
);
$this->fields_options = array(
'general' => array(
'title' => $this->l('Multishop options'),
'fields' => array(
'PS_SHOP_DEFAULT' => array(
'title' => $this->l('Default shop:'),
'cast' => 'intval',
'type' => 'select',
'identifier' => 'id_shop',
'list' => Shop::getShops(),
'visibility' => Shop::CONTEXT_ALL
)
),
'submit' => array()
)
);
parent::__construct();
}
public function initToolbar()
{
parent::initToolbar();
$this->show_toolbar = false;
if (isset($this->toolbar_btn['new']))
$this->toolbar_btn['new']['desc'] = $this->l('Add new shop group');
}
public function initContent()
{
$this->list_simple_header = true;
parent::initContent();
$this->addJqueryPlugin('cookie');
$this->addJqueryPlugin('jstree');
$this->addCSS(_PS_JS_DIR_.'jquery/plugins/jstree/themes/classic/style.css');
if ($this->display == 'edit')
$this->toolbar_title[] = $this->object->name;
$this->context->smarty->assign(array(
'toolbar_scroll' => 1,
'toolbar_btn' => $this->toolbar_btn,
'title' => $this->toolbar_title,
'selected_tree_id' => ($this->display == 'edit') ? 'tree-group-'.$this->id_object : 'tree-root',
));
}
public function renderForm()
{
$this->fields_form = array(
'legend' => array(
'title' => $this->l('ShopGroup')
),
'description' => $this->l('Warning: it is not recommended to enable the "share customers" and "share orders" options, because once they are activated and customers or orders are created, you won\'t be able to disable these options anymore. If you need these options, try to first consider using several categories instead on several shops.'),
'input' => array(
array(
'type' => 'text',
@@ -90,6 +135,7 @@ class AdminShopGroupControllerCore extends AdminController
'required' => true,
'class' => 't',
'is_bool' => true,
'disabled' => ($this->display == 'edit' && ShopGroup::hasDependency($this->id_object, 'customer')) ? true : false,
'values' => array(
array(
'id' => 'share_customer_on',
@@ -102,7 +148,7 @@ class AdminShopGroupControllerCore extends AdminController
'label' => $this->l('Disabled')
)
),
'desc' => $this->l('Share customers between shops of this group')
'desc' => $this->l('Once the option is enabled, the shops in this group will share their customers: if a customer registers on one of this group\'s shops, the account will automatically be available on the others shops of this goup. Warning: you won\'t be able to disable this option once you have customers registered on at least one shop of this group.'),
),
array(
'type' => 'radio',
@@ -132,6 +178,7 @@ class AdminShopGroupControllerCore extends AdminController
'required' => true,
'class' => 't',
'is_bool' => true,
'disabled' => ($this->display == 'edit' && ShopGroup::hasDependency($this->id_object, 'order')) ? true : false,
'values' => array(
array(
'id' => 'share_order_on',
@@ -144,8 +191,7 @@ class AdminShopGroupControllerCore extends AdminController
'label' => $this->l('Disabled')
)
),
'desc' =>
$this->l('Share orders and carts between shops of this group (you can share orders only if you share customers and available quantities)')
'desc' => $this->l('Once this option is enabled (which is only possible if customers and available quantities are shared among shops), the customer\'s cart will be shared among all the shops in this group. This way, any purchase started on one of the shops in this group will be able to be finished in another shop from the same shop group. Warning: you won\'t be able to disable this option once you have orders on at least one shop of this group.')
),
array(
'type' => 'radio',
@@ -188,18 +234,6 @@ class AdminShopGroupControllerCore extends AdminController
else
$disabled = false;
$import_data = array(
'attribute_group' => $this->l('Attribute groups'),
'attribute' => $this->l('Attributes'),
//'customer_group' => $this->l('Customer groups'),
'feature' => $this->l('Features'),
'group' => $this->l('Groups'),
'manufacturer' => $this->l('Manufacturers'),
'supplier' => $this->l('Suppliers'),
'tax_rules_group' => $this->l('Tax rule groups'),
'zone' => $this->l('Zones'),
);
$default_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
$this->tpl_form_vars = array(
'disabled' => $disabled,
+182 -127
View File
@@ -34,6 +34,7 @@ class AdminShopUrlControllerCore extends AdminController
$this->lang = false;
$this->requiredDatabase = true;
$this->multishop_context = Shop::CONTEXT_ALL;
$this->id_shop = Tools::getValue('id_shop');
$this->context = Context::getContext();
@@ -51,20 +52,9 @@ class AdminShopUrlControllerCore extends AdminController
'width' => 150,
'filter_key' => 's!name'
),
'domain' => array(
'title' => $this->l('Domain'),
'width' => 'auto',
'filter_key' => 'domain'
),
'domain_ssl' => array(
'title' => $this->l('Domain SSL'),
'width' => 130,
'filter_key' => 'domain'
),
'uri' => array(
'title' => $this->l('URI'),
'width' => 200,
'filter_key' => 'uri',
'url' => array(
'title' => $this->l('URL'),
'filter_key' => 'url',
'havingFilter' => true
),
'main' => array(
@@ -86,7 +76,6 @@ class AdminShopUrlControllerCore extends AdminController
'width' => 50,
),
);
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
parent::__construct();
}
@@ -98,126 +87,143 @@ class AdminShopUrlControllerCore extends AdminController
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->_select = 's.name AS shop_name, CONCAT(a.physical_uri, a.virtual_uri) AS uri';
$this->_select = 's.name AS shop_name, CONCAT(\'http://\', a.domain, a.physical_uri, a.virtual_uri) AS url';
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'shop` s ON (s.id_shop = a.id_shop)';
if ($id_shop = (int)Tools::getValue('id_shop'))
$this->_where = 'AND a.id_shop = '.$id_shop;
return parent::renderList();
}
public function renderForm()
{
$this->multiple_fieldsets = true;
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Shop URL')
array(
'form' => array(
'legend' => array(
'title' => $this->l('URL options')
),
'input' => array(
array(
'type' => 'select',
'label' => $this->l('Shop:'),
'name' => 'id_shop',
'onchange' => 'checkMainUrlInfo(this.value);',
'options' => array(
'optiongroup' => array (
'query' => Shop::getTree(),
'label' => 'name'
),
'options' => array (
'query' => 'shops',
'id' => 'id_shop',
'name' => 'name'
)
)
),
array(
'type' => 'radio',
'label' => $this->l('Main URL:'),
'name' => 'main',
'class' => 't',
'values' => array(
array(
'id' => 'main_on',
'value' => 1,
'label' => '<img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" />'
),
array(
'id' => 'main_off',
'value' => 0,
'label' => '<img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" />'
)
),
'desc' => array(
$this->l('If you set this URL as the Main URL for the 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 the Main URL'),
'id' => 'mainUrlInfo'
),
array(
'text' => $this->l('The selected shop has already a Main URL, if you set this one as the Main URL, the older one will be set as the Normal URL.'),
'id' => 'mainUrlInfoExplain'
)
)
),
array(
'type' => 'radio',
'label' => $this->l('Status:'),
'name' => 'active',
'required' => false,
'class' => 't',
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => '<img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" />'
),
array(
'id' => 'active_off',
'value' => 0,
'label' => '<img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" />'
)
),
'desc' => $this->l('Enabled or disabled')
)
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'button'
),
),
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Domain:'),
'name' => 'domain',
'size' => 50,
),
array(
'type' => 'text',
'label' => $this->l('Domain SSL:'),
'name' => 'domain_ssl',
'size' => 50,
),
array(
'type' => 'text',
'label' => $this->l('Physical URI:'),
'name' => 'physical_uri',
'desc' => $this->l('Physical folder of your store on your server. Leave this field empty if your store is installed on the root path (e.g. if your store is available at www.my-prestashop.com/my-store/, you would set my-store/ in this field).'),
'size' => 50,
),
array(
'type' => 'text',
'label' => $this->l('Virtual URI:'),
'name' => 'virtual_uri',
'desc' => array(
$this->l('You can use this option if you want to create a store with an URI that doesn\'t exist on your server (e.g. if you want your store to be available with the URL www.my-prestashop.com/my-store/shoes/, you have to set shoes/ in this field, assuming that my-store/ is your Physical URI).'),
'<strong>'.$this->l('URL rewriting must be activated on your server to use this feature.').'</strong>'
array(
'form' => array(
'legend' => array(
'title' => $this->l('Shop URL')
),
'size' => 50,
),
array(
'type' => 'text',
'label' => $this->l('Your final URL will be:'),
'name' => 'final_url',
'size' => 76,
'readonly' => true
),
array(
'type' => 'select',
'label' => $this->l('Shop:'),
'name' => 'id_shop',
'onchange' => 'checkMainUrlInfo(this.value);',
'options' => array(
'optiongroup' => array (
'query' => Shop::getTree(),
'label' => 'name'
),
'options' => array (
'query' => 'shops',
'id' => 'id_shop',
'name' => 'name'
)
)
),
array(
'type' => 'radio',
'label' => $this->l('Main URL:'),
'name' => 'main',
'class' => 't',
'values' => array(
'input' => array(
array(
'id' => 'main_on',
'value' => 1,
'label' => '<img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" />'
'type' => 'text',
'label' => $this->l('Domain:'),
'name' => 'domain',
'size' => 50,
),
array(
'id' => 'main_off',
'value' => 0,
'label' => '<img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" />'
)
'type' => 'text',
'label' => $this->l('Domain SSL:'),
'name' => 'domain_ssl',
'size' => 50,
),
array(
'type' => 'text',
'label' => $this->l('Physical URI:'),
'name' => 'physical_uri',
'desc' => $this->l('Physical folder of your store on your server. Leave this field empty if your store is installed on the root path (e.g. if your store is available at www.my-prestashop.com/my-store/, you would set my-store/ in this field).'),
'size' => 50,
),
array(
'type' => 'text',
'label' => $this->l('Virtual URI:'),
'name' => 'virtual_uri',
'desc' => array(
$this->l('You can use this option if you want to create a store with an URI that doesn\'t exist on your server (e.g. if you want your store to be available with the URL www.my-prestashop.com/my-store/shoes/, you have to set shoes/ in this field, assuming that my-store/ is your Physical URI).'),
'<strong>'.$this->l('URL rewriting must be activated on your server to use this feature.').'</strong>'
),
'size' => 50,
),
array(
'type' => 'text',
'label' => $this->l('Your final URL will be:'),
'name' => 'final_url',
'size' => 76,
'readonly' => true
),
),
'desc' => array(
$this->l('If you set this URL as the Main URL for the 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 the Main URL'),
'id' => 'mainUrlInfo'
),
array(
'text' => $this->l('The selected shop has already a Main URL, if you set this one as the Main URL, the older one will be set as the Normal URL.'),
'id' => 'mainUrlInfoExplain'
)
)
),
array(
'type' => 'radio',
'label' => $this->l('Status:'),
'name' => 'active',
'required' => false,
'class' => 't',
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => '<img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" />'
),
array(
'id' => 'active_off',
'value' => 0,
'label' => '<img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" />'
)
),
'desc' => $this->l('Enabled or disabled')
)
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'button'
)
);
if (!($obj = $this->loadObject(true)))
@@ -242,10 +248,61 @@ class AdminShopUrlControllerCore extends AdminController
return parent::renderForm();
}
public function initToolbar()
{
if ($this->id_object)
$this->loadObject();
if (!$this->id_shop && $this->object && $this->object->id_shop)
$this->id_shop = $this->object->id_shop;
if (!$this->display && $this->id_shop)
$this->toolbar_btn['edit'] = array(
'desc' => $this->l('Edit this shop'),
'href' => $this->context->link->getAdminLink('AdminShop').'&amp;updateshop&amp;id_shop='.$this->id_shop,
);
parent::initToolbar();
$this->show_toolbar = false;
if (isset($this->toolbar_btn['new']))
$this->toolbar_btn['new'] = array(
'desc' => $this->l('Add new url'),
'href' => $this->context->link->getAdminLink('AdminShopUrl').'&amp;add'.$this->table.'&amp;id_shop='.$this->id_shop,
);
if (isset($this->toolbar_btn['back']))
$this->toolbar_btn['back']['href'] .= '&amp;id_shop='.$this->id_shop;
}
public function initContent()
{
$this->list_simple_header = true;
parent::initContent();
$this->addJqueryPlugin('cookie');
$this->addJqueryPlugin('jstree');
$this->addCSS(_PS_JS_DIR_.'jquery/plugins/jstree/themes/classic/style.css');
if (!$this->display && $this->id_shop)
{
$shop = new Shop($this->id_shop);
$this->toolbar_title[] = $shop->name;
}
$this->context->smarty->assign(array(
'toolbar_scroll' => 1,
'toolbar_btn' => $this->toolbar_btn,
'title' => $this->toolbar_title,
'selected_tree_id' => ($this->display == 'edit' ? 'tree-url-'.$this->id_object : (Tools::getValue('id_shop') ? 'tree-shop-'.Tools::getValue('id_shop') : '')),
));
}
public function postProcess()
{
$token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
$result = true;
if ((isset($_GET['status'.$this->table]) || isset($_GET['status'])) && Tools::getValue($this->identifier))
{
if ($this->tabAccess['edit'] === '1')
@@ -265,15 +322,13 @@ class AdminShopUrlControllerCore extends AdminController
else
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
}
else if (Tools::isSubmit('submitAdd'.$this->table) && $this->tabAccess['add'] === '1')
{
if (ShopUrl::urlExists(Tools::getValue('domain'), Tools::getValue('physical_uri'), Tools::getValue('virtual_uri'), Tools::getValue('id_shop')))
$this->errors[] = Tools::displayError('Virtual URI already used.');
else
return parent::postProcess();
}
else
return parent::postProcess();
$result = parent::postProcess();
if ($this->redirect_after)
$this->redirect_after .= '&id_shop='.$this->id_shop;
return $result;
}
public function processSave()
+1 -1
View File
@@ -551,7 +551,7 @@ class AdminThemesControllerCore extends AdminController
$this->uploadIco('PS_FAVICON', _PS_IMG_DIR_.'favicon.ico');
if ($this->uploadIco('PS_FAVICON', _PS_IMG_DIR_.'favicon-'.(int)$id_shop.'.ico'))
Configuration::updateValue('PS_FAVICON', 'favicon-'.(int)$id_shop.'.ico');
Configuration::updateGlobalValue('PS_FAVICON', 'favicon.ico');
}