diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php index b18dcdf5d..7cbb3b684 100644 --- a/modules/blocklayered/blocklayered.php +++ b/modules/blocklayered/blocklayered.php @@ -1495,36 +1495,64 @@ class BlockLayered extends Module $this->context->smarty->assign('asso_shops', $helper->renderAssoShop()); } - $tree_categories_helper = new HelperTreeCategories('categories-treeview'); - $tree_categories_helper->setRootCategory((Shop::getContext() == Shop::CONTEXT_SHOP ? Category::getRootCategory()->id_category : 0)) - ->setUseCheckBox(true); + if (version_compare(_PS_VERSION_, '1.6.0', '>=') === TRUE) + { + $tree_categories_helper = new HelperTreeCategories('categories-treeview'); + $tree_categories_helper->setRootCategory((Shop::getContext() == Shop::CONTEXT_SHOP ? Category::getRootCategory()->id_category : 0)) + ->setUseCheckBox(true); + } + else + { + if (Shop::getContext() == Shop::CONTEXT_SHOP) + { + $root_category = Category::getRootCategory(); + $root_category = array('id_category' => $root_category->id_category, 'name' => $root_category->name); + } + else + $root_category = array('id_category' => '0', 'name' => $this->l('Root')); + + $tree_categories_helper = new Helper(); + } $module_url = Tools::getProtocol(Tools::usingSecureMode()).$_SERVER['HTTP_HOST'].$this->getPathUri(); if (method_exists($this->context->controller, 'addJquery')) { $this->context->controller->addJS($this->_path.'js/blocklayered_admin.js'); - $this->context->controller->addJS(_PS_JS_DIR_.'vendor/jquery.sortable.js'); + + if (version_compare(_PS_VERSION_, '1.6.0', '>=') === TRUE) + $this->context->controller->addJS(_PS_JS_DIR_.'vendor/jquery.sortable.js'); + else + $this->context->controller->addJS($this->_path.'js/jquery.sortable.js'); } if (version_compare(_PS_VERSION_, '1.6.0', '>=') === TRUE) - $this->context->controller->addCSS($this->_path.'css/blocklayered_admin_bt.css'); - /*else - $this->context->controller->addCSS($this->_path.'css/blocklayered_admin.css');*/ + $this->context->controller->addCSS($this->_path.'css/blocklayered_admin_1.6.css'); + else + $this->context->controller->addCSS($this->_path.'css/blocklayered_admin.css'); if (Tools::getValue('add_new_filters_template')) { $this->context->smarty->assign(array( 'current_url' => $this->context->link->getAdminLink('AdminModules').'&configure=blocklayered&tab_module=front_office_features&module_name=blocklayered', + 'uri' => $this->getPathUri(), 'id_layered_filter' => 0, 'template_name' => sprintf($this->l('My template - %s'), date('Y-m-d')), 'attribute_groups' => $attribute_groups, 'features' => $features, - 'total_filters' => 6+count($attribute_groups)+count($features), - 'categories_tree' => $tree_categories_helper->render(), + 'total_filters' => 6+count($attribute_groups)+count($features) )); - return $this->display(__FILE__, 'views/templates/admin/add.tpl'); + if (version_compare(_PS_VERSION_, '1.6.0', '>=') === TRUE) + $this->context->smarty->assign('categories_tree', $tree_categories_helper->render()); + else + $this->context->smarty->assign('categories_tree', $tree_categories_helper->renderCategoryTree( + $root_category, array(), 'categoryBox', false, false, array(), true)); + + if (version_compare(_PS_VERSION_, '1.6.0', '>=') === TRUE) + return $this->display(__FILE__, 'views/templates/admin/add_1.6.tpl'); + else + return $this->display(__FILE__, 'views/templates/admin/add.tpl'); } else if (Tools::getValue('edit_filters_template')) { @@ -1535,28 +1563,41 @@ class BlockLayered extends Module ); $filters = unserialize($template['filters']); - $tree_categories_helper->setSelectedCategories($filters['categories']); + + if (version_compare(_PS_VERSION_, '1.6.0', '>=') === TRUE) + { + $tree_categories_helper->setSelectedCategories($filters['categories']); + $this->context->smarty->assign('categories_tree', $tree_categories_helper->render()); + } + else + $this->context->smarty->assign('categories_tree',$tree_categories_helper->renderCategoryTree( + $root_category, $filters['categories'], 'categoryBox', false, false, array(), true)); + $select_shops = $filters['shop_list']; unset($filters['categories']); unset($filters['shop_list']); $this->context->smarty->assign(array( 'current_url' => $this->context->link->getAdminLink('AdminModules').'&configure=blocklayered&tab_module=front_office_features&module_name=blocklayered', + 'uri' => $this->getPathUri(), 'id_layered_filter' => (int)Tools::getValue('id_layered_filter'), 'template_name' => $template['name'], 'attribute_groups' => $attribute_groups, 'features' => $features, 'filters' => Tools::jsonEncode($filters), - 'total_filters' => 6+count($attribute_groups)+count($features), - 'categories_tree' => $tree_categories_helper->render(), + 'total_filters' => 6+count($attribute_groups)+count($features) )); - return $this->display(__FILE__, 'views/templates/admin/add.tpl'); + if (version_compare(_PS_VERSION_, '1.6.0', '>=') === TRUE) + return $this->display(__FILE__, 'views/templates/admin/add_1.6.tpl'); + else + return $this->display(__FILE__, 'views/templates/admin/add.tpl'); } else { $this->context->smarty->assign(array( 'message' => $message, + 'uri' => $this->getPathUri(), 'PS_LAYERED_INDEXED' => Configuration::getGlobalValue('PS_LAYERED_INDEXED'), 'current_url' => Tools::safeOutput(preg_replace('/&deleteFilterTemplate=[0-9]*&id_layered_filter=[0-9]*/', '', $_SERVER['REQUEST_URI'])), 'id_lang' => Context::getContext()->cookie->id_lang, @@ -1577,8 +1618,11 @@ class BlockLayered extends Module 'index_mnf' => Configuration::get('PS_LAYERED_FILTER_INDEX_MNF'), 'index_cat' => Configuration::get('PS_LAYERED_FILTER_INDEX_CAT') )); - - return $this->display(__FILE__, 'views/templates/admin/view.tpl'); + + if (version_compare(_PS_VERSION_, '1.6.0', '>=') === TRUE) + return $this->display(__FILE__, 'views/templates/admin/view_1.6.tpl'); + else + return $this->display(__FILE__, 'views/templates/admin/view.tpl'); } } @@ -3174,4 +3218,4 @@ class BlockLayered extends Module if ($values) Db::getInstance()->execute(rtrim($sql_to_insert, ',')); } -} +} \ No newline at end of file diff --git a/modules/blocklayered/css/blocklayered_admin.css b/modules/blocklayered/css/blocklayered_admin.css index e2636eb21..67b33d991 100644 --- a/modules/blocklayered/css/blocklayered_admin.css +++ b/modules/blocklayered/css/blocklayered_admin.css @@ -1,21 +1,53 @@ -#error-filter-name { display: none; } -#layered_container_left ul, #layered_container_right ul { list-style-type: none; padding-left: 0px; } -.ui-effects-transfer { border: 1px solid #CCC; } -.ui-state-highlight { height: 1.5em; line-height: 1.2em; } -ul#selected_filters, #layered_container_right ul { list-style-type: none; margin: 0; padding: 0; } -ul#selected_filters li, #layered_container_right ul li { width: 326px; font-size: 11px; padding: 8px 9px 7px 20px; height: 14px; margin-bottom: 5px; } -ul#selected_filters li span.ui-icon { position: absolute; margin-top: -2px; margin-left: -18px; } -#layered_container_right ul li span { display: none; } -#layered_container_right ul li { padding-left: 8px; position: relative; } -#layered_container_left ul li { cursor: move; position: relative; } -#layered-cat-counter { display: none; } -#layered-step-2, #layered-step-3 { display: none; } -#layered-step-2 h3 { margin-top: 0; } -#table-filter-templates tr th, #table-filter-templates tr td { text-align: center; } -.filter_type { width: 70px; position: absolute; right: 53px; top: 5px;} -.filter_show_limit { position: absolute; width: 40px; right: 5px; top: 5px; } -#layered-step-3 .alert { width: auto; } -#fancybox-content { - height: 400px !important; - overflow: auto !important; +.table-filter-templates, .table-configurations { + width: 100%; +} + +.table-configurations td { + padding: 10px; +} + +.table-configurations .label { + text-align: right; + font-weight: bold; + width: 30%; + vertical-align: top; +} + +.help-block { + font-weight: normal; + font-style: italic; + font-size: 11px; +} + +.text-right { + text-align: right; +} + +.text-left { + text-align: left; +} + +.filter_panel header { + margin-bottom: 10px; + font-weight: bold; +} + +.filter_list { + background-color: #fff; + padding-top: 1px; + padding-bottom: 1px; +} + +.filter_list_item { + background-color: #E9E9E9; + margin: 5px; +} + +.filter_list_item td { + white-space: nowrap; +} + +.filter_list_item .filter-title { + font-weight: bold; + width: 100%; } \ No newline at end of file diff --git a/modules/blocklayered/css/blocklayered_admin_bt.css b/modules/blocklayered/css/blocklayered_admin_1.6.css similarity index 100% rename from modules/blocklayered/css/blocklayered_admin_bt.css rename to modules/blocklayered/css/blocklayered_admin_1.6.css diff --git a/modules/blocklayered/img/cogs.gif b/modules/blocklayered/img/cogs.gif new file mode 100644 index 000000000..659aace81 Binary files /dev/null and b/modules/blocklayered/img/cogs.gif differ diff --git a/modules/blocklayered/img/cross.png b/modules/blocklayered/img/cross.png new file mode 100644 index 000000000..33a383748 Binary files /dev/null and b/modules/blocklayered/img/cross.png differ diff --git a/modules/blocklayered/img/edit.gif b/modules/blocklayered/img/edit.gif new file mode 100644 index 000000000..7934bbc8c Binary files /dev/null and b/modules/blocklayered/img/edit.gif differ diff --git a/modules/blocklayered/js/blocklayered_admin.js b/modules/blocklayered/js/blocklayered_admin.js index d23a9ee3e..0631cdc3a 100644 --- a/modules/blocklayered/js/blocklayered_admin.js +++ b/modules/blocklayered/js/blocklayered_admin.js @@ -58,7 +58,7 @@ $(document).ready( if (this.running == true) return false; - $('.ajax-message').hide(); + $('.ajax-message').hide(); this.running = true; if (typeof(this.restartAllowed) == 'undefined' || this.restartAllowed) diff --git a/modules/blocklayered/js/jquery.sortable.js b/modules/blocklayered/js/jquery.sortable.js new file mode 100644 index 000000000..a0023ef96 --- /dev/null +++ b/modules/blocklayered/js/jquery.sortable.js @@ -0,0 +1,85 @@ +/* + * HTML5 Sortable jQuery Plugin + * http://farhadi.ir/projects/html5sortable + * + * Copyright 2012, Ali Farhadi + * Released under the MIT license. + */ +(function($) { +var dragging, placeholders = $(); +$.fn.sortable = function(options) { + var method = String(options); + options = $.extend({ + connectWith: false + }, options); + return this.each(function() { + if (/^enable|disable|destroy$/.test(method)) { + var items = $(this).children($(this).data('items')).attr('draggable', method == 'enable'); + if (method == 'destroy') { + items.add(this).removeData('connectWith items') + .off('dragstart.h5s dragend.h5s selectstart.h5s dragover.h5s dragenter.h5s drop.h5s'); + } + return; + } + var isHandle, index, items = $(this).children(options.items); + var placeholder = $('<' + (/^ul|ol$/i.test(this.tagName) ? 'li' : 'div') + ' class="sortable-placeholder">'); + items.find(options.handle).mousedown(function() { + isHandle = true; + }).mouseup(function() { + isHandle = false; + }); + $(this).data('items', options.items) + placeholders = placeholders.add(placeholder); + if (options.connectWith) { + $(options.connectWith).add(this).data('connectWith', options.connectWith); + } + items.attr('draggable', 'true').on('dragstart.h5s', function(e) { + if (options.handle && !isHandle) { + return false; + } + isHandle = false; + var dt = e.originalEvent.dataTransfer; + dt.effectAllowed = 'move'; + dt.setData('Text', 'dummy'); + index = (dragging = $(this)).addClass('sortable-dragging').index(); + }).on('dragend.h5s', function() { + if (!dragging) { + return; + } + dragging.removeClass('sortable-dragging').show(); + placeholders.detach(); + if (index != dragging.index()) { + dragging.parent().trigger('sortupdate', {item: dragging, start_index: index, end_index: dragging.index()}); + } + dragging = null; + }).not('a[href], img').on('selectstart.h5s', function() { + this.dragDrop && this.dragDrop(); + return false; + }).end().add([this, placeholder]).on('dragover.h5s dragenter.h5s drop.h5s', function(e) { + if (!items.is(dragging) && options.connectWith !== $(dragging).parent().data('connectWith')) { + return true; + } + if (e.type == 'drop') { + e.stopPropagation(); + placeholders.filter(':visible').after(dragging); + dragging.trigger('dragend.h5s'); + return false; + } + e.preventDefault(); + e.originalEvent.dataTransfer.dropEffect = 'move'; + if (items.is(this)) { + if (options.forcePlaceholderSize) { + placeholder.height(dragging.outerHeight()); + } + dragging.hide(); + $(this)[placeholder.index() < $(this).index() ? 'after' : 'before'](placeholder); + placeholders.not(placeholder).detach(); + } else if (!placeholders.is(this) && !$(this).children(options.items).length) { + placeholders.detach(); + $(this).append(placeholder); + } + return false; + }); + }); +}; +})(jQuery); diff --git a/modules/blocklayered/views/templates/admin/add.tpl b/modules/blocklayered/views/templates/admin/add.tpl index 077cef31d..2f0900d81 100644 --- a/modules/blocklayered/views/templates/admin/add.tpl +++ b/modules/blocklayered/views/templates/admin/add.tpl @@ -1,373 +1,310 @@ {if isset($message)}{$message}{/if} -