Пример #1
0
 private function _postProcessSearch()
 {
     $id_search = Tools::getValue('id_search', false);
     $ObjAdvancedSearchClass = new AdvancedSearchClass($id_search);
     $reindexing_categories = false;
     $index_filter_by_emplacement = false;
     $desindex_filter_by_emplacement = false;
     $this->_cleanOutput(true);
     if (!Tools::getValue('bool_cat')) {
         $_POST['categories_association'] = array();
     }
     if (!Tools::getValue('bool_prod')) {
         $_POST['products_association'] = array();
     }
     if (!Tools::getValue('bool_manu')) {
         $_POST['manufacturers_association'] = array();
     }
     if (!Tools::getValue('bool_supp')) {
         $_POST['suppliers_association'] = array();
     }
     if (!Tools::getValue('bool_spe')) {
         $_POST['special_pages_association'] = array();
     }
     $this->errors = self::_retroValidateController($ObjAdvancedSearchClass);
     $_POST['background_color'] = $this->_getGradientFromArray('background_color');
     $_POST['border_size'] = $this->_getBorderSizeFromArray(Tools::getValue('border_size'));
     if ($id_search && Tools::getValue('recursing_indexing') != $ObjAdvancedSearchClass->recursing_indexing) {
         $reindexing_categories = true;
     }
     if (Tools::getValue('filter_by_emplacement') && !$ObjAdvancedSearchClass->filter_by_emplacement) {
         $index_filter_by_emplacement = true;
     } elseif (!Tools::getValue('filter_by_emplacement') && $ObjAdvancedSearchClass->filter_by_emplacement) {
         $desindex_filter_by_emplacement = true;
     }
     if (!sizeof($this->errors)) {
         $this->copyFromPost($ObjAdvancedSearchClass);
         if (!$ObjAdvancedSearchClass->save()) {
             $this->errors[] = $this->l('Error while saving');
         }
         if (!sizeof($this->errors)) {
             if (!$id_search && !$this->installDBCache($ObjAdvancedSearchClass->id)) {
                 $this->errors[] = $this->l('Error while making cache table');
             } elseif (!$id_search && !$ObjAdvancedSearchClass->addCacheProduct()) {
                 $this->errors[] = $this->l('Error while creating products index');
             } elseif ($id_search && !$ObjAdvancedSearchClass->updateCacheProduct()) {
                 $this->errors[] = $this->l('Error while creating products index');
             }
             if ($index_filter_by_emplacement) {
                 AdvancedSearchClass::indexFilterByEmplacement($ObjAdvancedSearchClass->id);
             } elseif ($desindex_filter_by_emplacement) {
                 AdvancedSearchClass::desIndexFilterByEmplacement($ObjAdvancedSearchClass->id);
             }
             if ($reindexing_categories) {
                 AdvancedSearchClass::reindexingCategoriesGroups($ObjAdvancedSearchClass);
             }
             $this->generateCss();
             $this->_html .= '<script type="text/javascript">';
             if (!$id_search) {
                 $this->_html .= 'parent.parent.addTabPanel("#wrapAsTab","' . $ObjAdvancedSearchClass->internal_name . '",' . $ObjAdvancedSearchClass->id . ', true, ' . (int) version_compare(_PS_VERSION_, '1.6.0.0', '>=') . ');';
             } else {
                 $this->_html .= 'parent.parent.loadTabPanel("#wrapAsTab","li#TabSearchAdminPanel' . $ObjAdvancedSearchClass->id . '","ul#asTab",' . $ObjAdvancedSearchClass->id . ');';
                 $this->_html .= 'parent.parent.updateSearchNameIntoTab("li#TabSearchAdminPanel' . $ObjAdvancedSearchClass->id . '", ' . Tools::jsonEncode($ObjAdvancedSearchClass->internal_name) . ');';
             }
             $this->_html .= 'parent.parent.show_info("' . $this->l('Search has been updated successfully') . '");parent.parent.closeDialogIframe();';
             $this->_html .= '</script>';
         }
     }
     $this->displayErrorsJs();
     $this->_echoOutput(true);
 }