function config_action() { if (!empty($_POST['skip_wizard_config'])) { $this->view->success_message = 'Step was skipped.'; return $this->_next_action('config'); } if (!empty($_POST['config_process'])) { return $this->_next_action('config'); } $this->view->config_content = $this->_generate_config_file_content(); $this->view->sphinx_conf = $this->_config->get_option('sphinx_conf'); $this->view->render('/admin/wizard/sphinx_config.phtml'); exit; }
function _get_stat_keywords($page, $period_param) { $start = ($page - 1) * $this->_keywords_per_page; if ($period_param > 0) { $this->_sphinx->SetFilterRange("date_added", strtotime("-{$period_param} days"), time()); } $sort_order = 'desc'; if (!empty($_REQUEST['sort_order']) && strtolower($_REQUEST['sort_order']) == 'asc') { $sort_order = 'asc'; } $sort_by_param = !empty($_REQUEST['sort_by']) ? $_REQUEST['sort_by'] : 'date'; switch (strtolower($sort_by_param)) { case 'cnt': $sort_by = '@count'; break; case 'date': default: $sort_by = 'date_added'; break; } $this->_sphinx->SetGroupBy("keywords_crc", SPH_GROUPBY_ATTR, "{$sort_by} {$sort_order}"); if ('asc' == $sort_order) { $this->_sphinx->SetSortMode(SPH_SORT_ATTR_ASC, "date_added"); } else { $this->_sphinx->SetSortMode(SPH_SORT_ATTR_DESC, "date_added"); } $this->_sphinx->SetLimits($start, $this->_keywords_per_page); $res = $this->_sphinx->Query("", $this->_config->get_option('sphinx_index') . 'stats'); if (empty($res['matches'])) { return array(); } $this->_results = $res; $ids = array_keys($res['matches']); $sql = 'select id, keywords, date_added from ' . $this->_table_prefix . 'sph_stats where id in (' . implode(',', $ids) . ') order by FIELD(id, ' . implode(',', $ids) . ')'; $keywords = $this->_wpdb->get_results($sql, OBJECT_K); foreach ($res['matches'] as $index => $match) { $keywords[$index]->cnt = $match['attrs']['@count']; } return $keywords; }
function _get_new_keywords($page, $status) { $sterm_value = !empty($_REQUEST['sterm']) ? $_REQUEST['sterm'] : ''; switch ($status) { case 'approved': $status_filter = array(1); $sort_order = "@count desc"; break; case 'ban': $status_filter = array(2); $sort_order = "@count desc"; break; case 'new': default: $status_filter = array(0); $sort_order = "date_added desc"; break; } $start = ($page - 1) * $this->_keywords_per_page; $this->_sphinx->SetFilter('status', $status_filter); $this->_sphinx->SetGroupBy("keywords_crc", SPH_GROUPBY_ATTR, $sort_order); $this->_sphinx->SetSortMode(SPH_SORT_ATTR_DESC, 'date_added'); $this->_sphinx->SetLimits($start, $this->_keywords_per_page); $res = $this->_sphinx->Query($sterm_value, $this->_config->get_option('sphinx_index') . 'stats'); if (empty($res['matches'])) { return array(); } $this->_results = $res; $ids = array_keys($res['matches']); $sql = 'select id, keywords, date_added from ' . $this->_table_prefix . 'sph_stats where id in (' . implode(',', $ids) . ') order by FIELD(id, ' . implode(',', $ids) . ')'; $keywords = $this->_wpdb->get_results($sql, OBJECT_K); foreach ($res['matches'] as $index => $match) { $keywords[$index]->cnt = $match['attrs']['@count']; } return $keywords; }