예제 #1
0
    public function getContent()
    {
        if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) {
            $this->_html .= '<div id="pm_backoffice_wrapper" class="pm_bo_ps_' . substr(str_replace('.', '', _PS_VERSION_), 0, 2) . '">';
        }
        $this->_displayTitle($this->displayName);
        if ($this->_checkPermissions()) {
            if (Tools::getValue('makeUpdate')) {
                $this->checkIfModuleIsUpdate(true);
            }
            if (!$this->checkIfModuleIsUpdate(false)) {
                if (Configuration::get('PM_' . self::$_module_prefix . '_LAST_VERSION', false) !== false && version_compare(Configuration::get('PM_' . self::$_module_prefix . '_LAST_VERSION', false), '4.8', '>=') && version_compare(Configuration::get('PM_' . self::$_module_prefix . '_LAST_VERSION', false), '4.9.1', '<=')) {
                    $this->_html .= '
					<div class="warning warn clear">
						' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? '
						<p>' . $this->l('You have an old version of the module, this new version has a new approach for multishop features.') . '</p>
						<p>' . $this->l('Because of a lot of constraints, you will not be able to associate one search engine to multiple shops anymore.') . '</p>
						<p>' . $this->l('If it is your case at this time, we will only associate your search engine to one shop (from all the shops it was currently associated).') . '</p>
						' : '') . '
						<p>' . $this->l('We really recommand you to re-index all the search engines after this update. Thank you for your comprehension.') . '</p>
					</div><br />';
                }
                $this->_html .= '
					<div class="warning warn clear"><p>' . $this->l('We have detected that you installed a new version of the module on your shop') . '</p>
						<p style="text-align: center"><a href="' . $this->_base_config_url . '&makeUpdate=1" class="button">' . $this->l('Please click here in order to finish the installation process') . '</a></p>
					</div>';
                $this->_loadCssJsLibraries();
            } else {
                if (version_compare(_PS_VERSION_, '1.5.0.0', '>=') && Shop::getContext() != Shop::CONTEXT_SHOP) {
                    $this->_loadCssJsLibraries();
                    $this->_html .= '<div class="module_error alert error">' . $this->l('You must select a specific shop in order to continue, you can\'t create/edit a search engine from the "all shop" or "group shop" context.') . '</div>';
                } else {
                    $this->_preProcess();
                    $this->_loadCssJsLibraries();
                    $this->_postProcess();
                    $blocklayered_module = Module::getInstanceByName('blocklayered');
                    if (is_object($blocklayered_module) && isset($blocklayered_module->active) && $blocklayered_module->active == true) {
                        if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) {
                            $nbBlockLayeredFilters = (int) Db::getInstance()->getValue('SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'layered_filter` f JOIN `' . _DB_PREFIX_ . 'layered_filter_shop` fs ON (f.`id_layered_filter`= f.`id_layered_filter` AND fs.`id_shop`=' . $this->context->shop->id . ')');
                        } else {
                            $nbBlockLayeredFilters = (int) Db::getInstance()->getValue('SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'layered_filter`');
                        }
                        if ($nbBlockLayeredFilters) {
                            $this->_showWarning($this->l('Block Layered is not compatible with Advanced Search 4.') . '<br />' . $this->l('You must disable it first, or remove any filters in order to prevent unexpected behaviour on your shop.'));
                        }
                    }
                    $this->_showRating(true);
                    parent::getContent();
                    $this->_html .= '
					<script type="text/javascript">
						  var editTranlate = "' . $this->l('Edit') . '";
						  var reindexationInprogressMsg = "' . addcslashes($this->l('Another reindexing is in progress. Please wait.'), '"') . '";
						  var reindexingCriteriaMsg = "' . addcslashes($this->l('Reindexing criteria group'), '"') . '";
						  var reindexingCriteriaOfMsg = "' . addcslashes($this->l('of'), '"') . '";
						  $jqPm(document).ready(function() {
						  //Initialise the second table specifying a dragClass and an onDrop function that will display an alert
							$jqPm("#wrapConfigTab, #wrapAsTab").tabs({cache:false});
						 });
					  </script>';
                    $advanced_searchs = AdvancedSearchClass::getSearchs($this->_cookie->id_lang, false);
                    $this->_addButton(array('text' => $this->l('Add a new search'), 'href' => $this->_base_config_url . '&pm_load_function=displaySearchForm&class=AdvancedSearchClass&pm_js_callback=closeDialogIframe', 'icon_class' => 'ui-icon ui-icon-circle-plus', 'class' => 'open_on_dialog_iframe', 'rel' => '950_530_1'));
                    $this->_html .= '<br /><br /><div id="wrapAsTab">
										<ul id="asTab">';
                    if ($advanced_searchs && sizeof($advanced_searchs)) {
                        foreach ($advanced_searchs as $k => $advanced_search) {
                            $this->_html .= '<li id="TabSearchAdminPanel' . (int) $advanced_search['id_search'] . '"><a href="' . $this->_base_config_url . '&pm_load_function=displaySearchAdminPanel&id_search=' . $advanced_search['id_search'] . '"><span>' . $advanced_search['internal_name'] . '</span></a></li>';
                        }
                    }
                    $this->_html .= '</ul>';
                    $this->_html .= '</div><br />';
                    $this->_html .= '<div id="msgNoResults" style="' . ($advanced_searchs && sizeof($advanced_searchs) ? 'display:none;' : '') . '">';
                    $this->_showInfo($this->l('You do not have added a search engine yet. Please click on the click "Add a new search" in order to start.'));
                    $this->_html .= '<br /></div>';
                    $this->_html .= '<div id="wrapConfigTab">
										<ul id="configTab">
										  <li><a href="#config-2"><span><img src="' . $this->_path . 'img/document-code.png" /> ' . $this->l('Advanced styles') . '</span></a></li>
										  <li><a href="#config-3"><span><img src="' . $this->_path . 'img/clock.png" /> ' . $this->l('Crontab') . '</span></a></li>
										  <li><a href="#config-4"><span><img src="' . $this->_path . 'img/drill.png" /> ' . $this->l('Maintenance') . '</span></a></li>
										</ul>';
                    $this->_html .= '<div id="config-2">';
                    $this->displayAdvancedConfig();
                    $this->_html .= '</div>';
                    $this->_html .= '<div id="config-3">';
                    $this->_html .= '<br /><div class="conf confirm">' . $this->l('Use this URL for CRON Tasks (reindexation)') . '<br />' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? $this->context->shop->getBaseURL() : Tools::getHttpHost(true, true) . __PS_BASE_URI__) . 'modules/pm_advancedsearch4/cron.php?secure_key=' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? Configuration::getGlobalValue('PM_AS4_SECURE_KEY') : Configuration::get('PM_AS4_SECURE_KEY')) . '</div>';
                    $this->_html .= '</div>';
                    $this->_html .= '<div id="config-4">';
                    $this->displayMaintenance();
                    $this->_html .= '</div>';
                    $this->_html .= '</div>';
                }
            }
        } else {
            $this->_loadCssJsLibraries();
        }
        $this->_displaySupport();
        $this->_html .= '</div>';
        return $this->_html;
    }