/** * Draw admin page * */ function print_admin_page() { if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } $options = $this->config->get_admin_options(); $wizard = new WizardController($this->config); if (!empty($_POST['start_wizard']) || empty($options['sphinx_conf']) && 'false' == $options['wizard_done']) { $this->view->menu = 'wizard'; $wizard->start_action(); } if (!empty($_GET['menu'])) { switch ($_GET['menu']) { case 'terms_editor': $terms_editor = new TermsEditorController($this->config); $terms_editor->index_action(); $this->view->menu = 'terms_editor'; //return; break; case 'stats': $stats = new StatsController($this->config); $stats->index_action(); $this->view->menu = 'stats'; //return; break; case 'search_settings': $this->view->menu = 'search_settings'; break; } } $sphinxService = new SphinxService($this->config); $res = false; $error_message = $success_message = ''; if (!empty($_POST['reindex_sphinx'])) { $res = $sphinxService->reindex(); $success_message = 'Sphinx successfully reindexed.'; } else { if (!empty($_POST['start_sphinx'])) { $res = $sphinxService->start(); $success_message = 'Sphinx successfully started.'; } elseif (!empty($_POST['stop_sphinx'])) { $res = $sphinxService->stop(); $success_message = 'Sphinx successfully stopped.'; } elseif (isset($_POST['update_SphinxSearchSettings'])) { $this->update_options(); $success_message = 'Settings updated.'; } } if (is_array($res)) { $error_message = $res['err']; } $this->view->assign('index_modify_time', $sphinxService->get_index_modify_time()); if (!empty($error_message)) { $this->view->assign('error_message', $error_message); } if (!empty($success_message)) { $this->view->assign('success_message', $success_message); } $devOptions = $this->config->get_admin_options(); //update options $this->view->assign('devOptions', $devOptions); //load admin panel template $this->view->assign('header', 'Sphinx Search for Wordpress'); $this->view->assign('is_sphinx_path_secure', $this->_isSphinxPathSecure()); if ('true' != $devOptions['check_stats_table_column_status']) { global $table_prefix; $this->view->assign('error_message', "{$table_prefix}sph_stats table required an update.<br>\n Please run the following command in MySQL client to update the table: <br>\n alter table {$table_prefix}sph_stats add `status` tinyint(1) NOT NULL DEFAULT '0';\n <br><br>\n This update will allow to use Sphinx Search for Top/Related and Latest search terms widgets!"); } $this->view->render('admin/layout.phtml'); }
function indexing_action() { $this->view->devOptions = $this->_config->get_admin_options(); if (!empty($_POST['skip_wizard_indexsation'])) { $this->view->success_message = 'Step was skipped.'; return $this->_next_action('indexing'); } if (!empty($_POST['process_indexing'])) { $sphinxService = new SphinxService($this->_config); $res = $sphinxService->reindex(); if (true === $res) { $this->view->indexsation_done = true; $this->view->success_message = 'Indexing is done successfully!'; return $this->_next_action('indexing'); } else { $this->view->error_message = $res['err']; } } $this->view->indexsation_done = false; $this->view->render('admin/wizard/sphinx_indexsation.phtml'); exit; }
function upgrade_table_statistics_in_v3() { global $wpdb, $table_prefix; //check for column status $result = $wpdb->get_results("SHOW COLUMNS FROM {$table_prefix}sph_stats"); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; } foreach ($result as $column) { if ('status' == $column->Field) { $options['check_stats_table_column_status'] = 'true'; $this->config->update_admin_options($options); } } if ('true' == $options['check_stats_table_column_status']) { //set up sphinx for stats in widgest or not $wizard = new WizardController($this->config); $config_file_name = $this->config->get_option('sphinx_conf'); $config_file_content = $wizard->_generate_config_file_content(); $wizard->_save_config($config_file_name, $config_file_content); $sphinxService = new SphinxService($this->config); $ret = $sphinxService->reindex('stats'); } }