示例#1
0
    protected function displaySearchForm($params)
    {
        if ($params['obj']->id) {
            $categoriesAssociation = AdvancedSearchClass::getCategoriesAssociation($params['obj']->id, $this->_cookie->id_lang);
            $cmsAssociation = AdvancedSearchClass::getCMSAssociation($params['obj']->id, $this->_cookie->id_lang);
            $manufacturersAssociation = AdvancedSearchClass::getManufacturersAssociation($params['obj']->id);
            $suppliersAssociation = AdvancedSearchClass::getSuppliersAssociation($params['obj']->id);
            $productsAssociation = AdvancedSearchClass::getProductsAssociation($params['obj']->id, $this->_cookie->id_lang);
            $specialPagesAssociation = AdvancedSearchClass::getSpecialPagesAssociation($params['obj']->id, true, $this->_cookie->id_lang);
        } else {
            $categoriesAssociation = array();
            $cmsAssociation = array();
            $manufacturersAssociation = array();
            $suppliersAssociation = array();
            $productsAssociation = array();
            $specialPagesAssociation = array();
        }
        $this->_startForm(array('id' => 'searchForm', 'obj' => $params['obj'], 'params' => $params));
        $this->_displayTitle(isset($params['obj']) && Validate::isLoadedObject($params['obj']) ? $this->l('Edit Search') : $this->l('Add Search'));
        $this->_startFieldset(false, false, false);
        $this->_displayInputText(array('obj' => $params['obj'], 'key' => 'internal_name', 'label' => $this->l('Internal name')));
        $this->_endFieldset();
        $this->_startFieldset($this->l('Display'), $this->_path . 'img/eye.png', false);
        $this->_displayInputTextLang(array('obj' => $params['obj'], 'key' => 'title', 'label' => $this->l('Public title')));
        $this->_displayRichTextareaLang(array('obj' => $params['obj'], 'key' => 'description', 'label' => $this->l('Description')));
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'activestatus', 'key_db' => 'active', 'label' => $this->l('Active')));
        $hooks = array();
        if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) {
            $valid_hooks = AdvancedSearchClass::$_valid_hooks_1_5;
        } else {
            $valid_hooks = AdvancedSearchClass::$_valid_hooks;
        }
        foreach ($valid_hooks as $k => $hook_name) {
            $id_hook = self::_getHookIdByName($hook_name);
            if (!$id_hook) {
                continue;
            }
            $hooks[$id_hook] = $hook_name;
        }
        $hooks[-1] = $this->l('Custom (advanced user only)');
        $configOptions = array('obj' => $params['obj'], 'label' => $this->l('Transplant to hook'), 'key' => 'id_hook', 'options' => $hooks, 'defaultvalue' => $this->l('Do not show'), 'onchange' => 'updateHookOptions($jqPm(this));');
        $this->_displaySelect($configOptions);
        $this->_html .= '<div class="hookOptions hookOption-displayTop hookOption-top hookOption-displayHome hookOption-home" style="display:none;"><br />' . $this->l('The transplantation on hook top and home are experimental. No support will be made ​​on these option.') . '</div>';
        $this->_html .= '<div class="hookOptions hookOption-1" style="display:none;">';
        $this->_displayInputText(array('obj' => $params['obj'], 'key' => 'smarty_var_name', 'label' => $this->l('Smarty var name'), 'defaultvalue' => 'as4_' . uniqid()));
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'insert_in_center_column', 'key_db' => 'insert_in_center_column', 'label' => $this->l('Do you want to insert your search engine in your center column?')));
        $this->_showInfo($this->l('Please insert the following code in your template at the line where you want the search engine to appear:') . '<br /><div id="custom_content_results" onclick="selectText(\'custom_content_results\')"><p id="smarty_var_name_picker"></p><div ' . ($params['obj'] && $params['obj']->insert_in_center_column ? '' : 'style="display:none;"') . ' id="custom_content_area_results">&lt;div id="as_custom_content_results"&gt;&lt;/div&gt;</div></div>');
        $this->_html .= '<script type="text/javascript">';
        $this->_html .= '$jqPm("input[name=insert_in_center_column]").unbind("click").bind("click",function() {
				if (parseInt($jqPm(this).val())) {
					$jqPm("#custom_content_area_results").show();
					$jqPm("#blc_search_results_selector").hide();
					$jqPm("#search_results_selector").val("#as_custom_content_results");
				}else {
					$jqPm("#custom_content_area_results").hide();
					$jqPm("#blc_search_results_selector").show();
					$jqPm("#search_results_selector").val("#center_column");
				}
			});';
        $this->_html .= '$jqPm("#smarty_var_name").unbind("keyup").bind("keyup",function() {
				updateSmartyVarNamPicker();
			});
			updateSmartyVarNamPicker();';
        $this->_html .= '</script>';
        $this->_html .= '</div>';
        $this->_html .= '<div id="blc_search_results_selector" style="' . ($params['obj'] && $params['obj']->id_hook && ($params['obj']->id_hook == 8 || $params['obj']->insert_in_center_column) ? 'display:none;' : '') . '">';
        $this->_html .= '<hr class="pm_hr" />';
        $this->_html .= '<p><span style="float: left; margin-right: .3em;" class="ui-icon ui-icon-alert"></span>' . $this->l('Set here the ID of your center column. (If you are not sure do not change this value)') . '</p>';
        $this->_displayInputText(array('obj' => $params['obj'], 'key' => 'search_results_selector', 'label' => $this->l('Search results area'), 'defaultvalue' => '#center_column'));
        $this->_html .= '<hr class="pm_hr" />';
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'unique_search', 'key_db' => 'unique_search', 'label' => $this->l('Unique search'), 'tips' => $this->l('Only search to be displayed. If several searches have the unique option activated, they will all be displayed on your page.')));
        $this->_html .= '</div>';
        $this->_html .= '<div class="hookOptions hookOption-displayTop hookOption-top hookOption-displayHome hookOption-home hookOption-1" style="display:none;">';
        $this->_displayInputText(array('obj' => $params['obj'], 'key' => 'width', 'label' => $this->l('Width')));
        $this->_displayInputText(array('obj' => $params['obj'], 'key' => 'height', 'label' => $this->l('Height')));
        $this->_html .= '</div>';
        $this->_endFieldset();
        $this->_startFieldset($this->l('Behaviour'), $this->_path . 'img/clapperboard.png', true);
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'keep_category_information', 'key_db' => 'keep_category_information', 'label' => $this->l('Keep category information while searching')));
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'display_nb_result_on_blc', 'key_db' => 'display_nb_result_on_blc', 'label' => $this->l('Display number of results on search block')));
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'display_nb_result_criterion', 'key_db' => 'display_nb_result_criterion', 'label' => $this->l('Display number of results per criteria')));
        $configOptions = array('obj' => $params['obj'], 'label' => $this->l('Display a remind of selection'), 'key' => 'remind_selection', 'options' => $this->options_remind_selection, 'size' => '400px');
        $this->_displaySelect($configOptions);
        $configOptions = array('obj' => $params['obj'], 'label' => $this->l('Method to display hidden criteria'), 'key' => 'show_hide_crit_method', 'options' => $this->options_show_hide_crit_method);
        $this->_displaySelect($configOptions);
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'step_search', 'key_db' => 'step_search', 'label' => $this->l('Search by steps'), 'onclick' => 'toogleDisplayCriteriaOptions(); showRelatedOptions($jqPm(this))'));
        $this->_html .= '<div class="collapse">';
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'collapsable_criterias', 'key_db' => 'collapsable_criterias', 'label' => $this->l('Allow criterias to be collapsed')));
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'reset_group', 'key_db' => 'reset_group', 'label' => $this->l('Display an option to reset user choices'), 'defaultvalue' => true));
        $this->_html .= '</div>';
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'filter_by_emplacement', 'key_db' => 'filter_by_emplacement', 'label' => $this->l('Show available criteria only for displayed products'), 'defaultvalue' => true, 'onclick' => 'toogleDisplayCategoryRootOption()'));
        $categorySelect = array(0 => $this->l('-- User-context category --'));
        foreach (Category::getCategories($this->_cookie->id_lang) as $shopCategory) {
            foreach ($shopCategory as $idCategory => $categoryInformations) {
                if (version_compare(_PS_VERSION_, '1.5.0.0', '>=') && Configuration::get('PS_ROOT_CATEGORY') == $idCategory) {
                    continue;
                }
                $categorySelect[$idCategory] = str_repeat('&#150 ', version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? $categoryInformations['infos']['level_depth'] - 1 : $categoryInformations['infos']['level_depth']) . $categoryInformations['infos']['name'];
            }
        }
        $this->_html .= '<div class="id_category_root_container">';
        $configOptions = array('obj' => $params['obj'], 'label' => $this->l('Set the root category for your search (default is user-context category)'), 'key' => 'id_category_root', 'options' => $categorySelect, 'size' => '500px');
        $this->_displaySelect($configOptions);
        $this->_html .= '</div>';
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'recursing_indexing', 'key_db' => 'recursing_indexing', 'label' => $this->l('Recursive indexing of categories'), 'defaultvalue' => true));
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'share', 'key_db' => 'share', 'label' => $this->l('Display share block under search results'), 'defaultvalue' => true));
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'search_on_stock', 'key_db' => 'search_on_stock', 'label' => $this->l('Search only products in stock'), 'defaultvalue' => false));
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'display_empty_criteria', 'key_db' => 'display_empty_criteria', 'label' => $this->l('Display empty criteria'), 'defaultvalue' => false, 'onclick' => 'toogleDisplayCriteriaOptions()'));
        $this->_html .= '<div id="criteriaOptions">';
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'hide_empty_crit_group', 'key_db' => 'hide_empty_crit_group', 'label' => $this->l('Hide empty criteria groups'), 'defaultvalue' => false));
        $this->_html .= '</div>';
        $this->_html .= '<div class="displaySaveSelection">';
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'save_selection', 'key_db' => 'save_selection', 'label' => $this->l('Save selection during navigation'), 'onclick' => 'toogleDisplayCriteriaOptions()'));
        $this->_html .= '</div>';
        $configOptions = array('obj' => $params['obj'], 'label' => $this->l('Submit search method'), 'key' => 'search_method', 'options' => $this->options_launch_search_method, 'onchange' => 'display_search_method_options();');
        $this->_displaySelect($configOptions);
        $this->_html .= '<script type="text/javascript">
					     $jqPm(document).ready($jqPm(".collapse").' . ($params['obj'] && (int) $params['obj']->step_search ? 'hide' : 'show') . '("fast"));
					      </script>';
        $this->_html .= '<div class="search_method_options_1" ' . ((Tools::getIsset('search_method') && Tools::getValue('search_method') == 2 or $params['obj'] && $params['obj']->search_method == 2) ? '' : ' style="display:none"') . '>';
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'dynamic_criterion', 'key_db' => 'dynamic_criterion', 'label' => $this->l('Dynamic criteria'), 'defaultvalue' => true));
        $this->_html .= '</div>';
        $this->_html .= '<div class="search_method_options_2" ' . ((isset($_POST['search_method']) && Tools::getValue('search_method') == 2 or $params['obj'] && $params['obj']->search_method == 2) ? '' : ' style="display:none"') . '>';
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'redirect_one_product', 'key_db' => 'redirect_one_product', 'label' => $this->l('Redirect to product sheet if only one product found'), 'defaultvalue' => true));
        $this->_html .= '</div>';
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'priority_on_combination_image', 'key_db' => 'priority_on_combination_image', 'label' => $this->l('Display combination image on priority'), 'defaultvalue' => true));
        if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) {
            $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'add_anchor_to_url', 'key_db' => 'add_anchor_to_url', 'label' => $this->l('Pre-select product\'s combination for product page'), 'defaultvalue' => false));
        } else {
            $this->_html .= '<input name="add_anchor_to_url" value="0" type="hidden" />';
        }
        $this->_displayInputText(array('obj' => $params['obj'], 'key' => 'products_per_page', 'label' => $this->l('Number of products per page'), 'defaultvalue' => Configuration::get('PS_PRODUCTS_PER_PAGE')));
        $configOptions = array('obj' => $params['obj'], 'label' => $this->l('Default order by'), 'key' => 'products_order_by', 'options' => $this->options_defaut_order_by, 'size' => '500px');
        $this->_displaySelect($configOptions);
        $configOptions = array('obj' => $params['obj'], 'label' => $this->l('Default order way'), 'key' => 'products_order_way', 'options' => $this->options_defaut_order_way);
        $this->_displaySelect($configOptions);
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'scrolltop_active', 'key_db' => 'scrolltop_active', 'label' => $this->l('Activate auto scrolling effect'), 'defaultvalue' => true));
        $this->_endFieldset();
        $this->_startFieldset($this->l('Appearance'), $this->_path . 'img/color-swatch.png', true);
        $this->_html .= '<div class="hookOptions hookOption-displayTop hookOption-top hookOption-displayHome hookOption-home hookOption-1" style="display:none;">';
        $this->_displayInputGradient(array('obj' => $params['obj'], 'key' => 'background_color', 'label' => $this->l('Background'), 'defaultvalue' => '#ffffff-#ebebeb'));
        $this->_displayInputSlider(array('obj' => $params['obj'], 'key' => 'border_radius', 'label' => $this->l('Border radius'), 'minvalue' => '0', 'maxvalue' => '100', 'defaultvalue' => '30', 'suffix' => 'px'));
        $this->_displayInput4size(array('obj' => $params['obj'], 'key' => 'border_size', 'label' => $this->l('Border size'), 'defaultvalue' => '1px 1px 1px 1px'));
        $this->_displayInputColor(array('obj' => $params['obj'], 'key' => 'border_color', 'label' => $this->l('Border color'), 'defaultvalue' => '#b6b7ba'));
        $this->_displayInputSlider(array('obj' => $params['obj'], 'key' => 'font_size_title', 'label' => $this->l('Font size title search'), 'minvalue' => '8', 'maxvalue' => '30', 'defaultvalue' => '12', 'suffix' => 'px'));
        $this->_html .= '</div>';
        $this->_displayInputColor(array('obj' => $params['obj'], 'key' => 'color_group_title', 'label' => $this->l('Criteria group color title'), 'defaultvalue' => '#333333'));
        $this->_displayInputSlider(array('obj' => $params['obj'], 'key' => 'font_size_group_title', 'label' => $this->l('Criteria group title font size'), 'minvalue' => '8', 'maxvalue' => '30', 'defaultvalue' => '12', 'suffix' => 'px'));
        $this->_endFieldset();
        $this->_startFieldset($this->l('Associations'));
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'bool_cat', 'key_db' => 'bool_cat', 'label' => $this->l('Apply this rule to some categories'), 'defaultvalue' => $categoriesAssociation && self::_isFilledArray($categoriesAssociation) ? 1 : 0, 'onclick' => 'display_cat_picker();'));
        $this->_html .= '<div id="category_picker">';
        $this->_displayCategoryTree(array('label' => $this->l('Categories'), 'input_name' => 'categories_association', 'selected_cat' => $categoriesAssociation && self::_isFilledArray($categoriesAssociation) ? $categoriesAssociation : array(0), 'category_root_id' => version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? Category::getRootCategory()->id : 1));
        $this->_html .= '</div>';
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'bool_prod', 'key_db' => 'bool_prod', 'label' => $this->l('Apply this rule to some products'), 'defaultvalue' => $productsAssociation && self::_isFilledArray($productsAssociation) ? 1 : 0, 'onclick' => 'display_prod_picker();'));
        $this->_html .= '<div id="product_picker">';
        $this->_displayAjaxSelectMultiple(array('selectedoptions' => $productsAssociation && self::_isFilledArray($productsAssociation) ? $productsAssociation : false, 'key' => 'products_association', 'label' => $this->l('Products'), 'remoteurl' => $this->_base_config_url . '&getItem=1&itemType=product', 'limit' => 50, 'limitincrement' => 20, 'remoteparams' => false, 'idcolumn' => 'id_product', 'namecolumn' => 'name', 'triggeronliclick' => true, 'displaymore' => true));
        $this->_html .= '</div>';
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'bool_manu', 'key_db' => 'bool_manu', 'label' => $this->l('Apply this rule to some manufacturers'), 'defaultvalue' => $manufacturersAssociation && self::_isFilledArray($manufacturersAssociation) ? 1 : 0, 'onclick' => 'display_manu_picker();'));
        $this->_html .= '<div id="manu_picker">';
        $this->_displayAjaxSelectMultiple(array('selectedoptions' => $manufacturersAssociation && self::_isFilledArray($manufacturersAssociation) ? $manufacturersAssociation : false, 'key' => 'manufacturers_association', 'label' => $this->l('Manufacturers'), 'remoteurl' => $this->_base_config_url . '&getItem=1&itemType=manufacturer', 'limit' => 50, 'limitincrement' => 20, 'remoteparams' => false, 'idcolumn' => 'id_manufacturer', 'namecolumn' => 'name', 'triggeronliclick' => true, 'displaymore' => true));
        $this->_html .= '</div>';
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'bool_supp', 'key_db' => 'bool_supp', 'label' => $this->l('Apply this rule to some suppliers'), 'defaultvalue' => $suppliersAssociation && self::_isFilledArray($suppliersAssociation) ? true : false, 'onclick' => 'display_supp_picker();'));
        $this->_html .= '<div id="supp_picker">';
        $this->_displayAjaxSelectMultiple(array('selectedoptions' => $suppliersAssociation && self::_isFilledArray($suppliersAssociation) ? $suppliersAssociation : false, 'key' => 'suppliers_association', 'label' => $this->l('Suppliers'), 'remoteurl' => $this->_base_config_url . '&getItem=1&itemType=supplier', 'limit' => 50, 'limitincrement' => 20, 'remoteparams' => false, 'idcolumn' => 'id_supplier', 'namecolumn' => 'name', 'triggeronliclick' => true, 'displaymore' => true));
        $this->_html .= '</div>';
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'bool_cms', 'key_db' => 'bool_cms', 'label' => $this->l('Apply this rule to some CMS pages'), 'defaultvalue' => self::_isFilledArray($cmsAssociation) ? true : false, 'onclick' => 'display_cms_picker();'));
        $this->_html .= '<div id="cms_picker">';
        $this->_displayAjaxSelectMultiple(array('selectedoptions' => $cmsAssociation && self::_isFilledArray($cmsAssociation) ? $cmsAssociation : false, 'key' => 'cms_association', 'label' => $this->l('CMS Pages'), 'remoteurl' => $this->_base_config_url . '&getItem=1&itemType=cms', 'limit' => 50, 'limitincrement' => 20, 'remoteparams' => false, 'idcolumn' => 'id_cms', 'namecolumn' => 'meta_title', 'triggeronliclick' => true, 'displaymore' => true));
        $this->_html .= '</div>';
        $this->_displayInputActive(array('obj' => $params['obj'], 'key_active' => 'bool_spe', 'key_db' => 'bool_spe', 'label' => $this->l('Apply this rule to some special pages'), 'defaultvalue' => $specialPagesAssociation && self::_isFilledArray($specialPagesAssociation) ? true : false, 'onclick' => 'display_spe_picker();'));
        $this->_html .= '<div id="special_pages">';
        $this->_html .= '<div id="controller_picker">';
        $this->_displayAjaxSelectMultiple(array('selectedoptions' => $specialPagesAssociation && self::_isFilledArray($specialPagesAssociation) ? $specialPagesAssociation : false, 'key' => 'special_pages_association', 'label' => $this->l('Select the controller where you want the search engine to be shown'), 'remoteurl' => $this->_base_config_url . '&getItem=1&itemType=controller', 'limit' => 50, 'limitincrement' => 20, 'remoteparams' => false, 'idcolumn' => 'page', 'namecolumn' => 'title', 'triggeronliclick' => true, 'displaymore' => true));
        $this->_html .= '</div>';
        $this->_html .= '</div>';
        $this->_html .= '
		<script type="text/javascript">
			display_cms_picker();
			display_spe_picker();
			display_cat_picker();
			display_prod_picker();
			display_manu_picker();
			display_supp_picker();
			toogleDisplayCriteriaOptions();
			toogleDisplayCategoryRootOption();
		</script>';
        $this->_endFieldset();
        $this->_displaySubmit($this->l('   Save   '), 'submitSearch');
        $this->_html .= '<br /><br />';
        $this->_html .= '<script type="text/javascript">
		updateHookOptions($jqPm("#id_hook"));
		</script>';
        $this->_endForm(array('id' => 'searchForm'));
        return;
    }