本文整理汇总了PHP中Search::prepareSearchFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP Search::prepareSearchFilter方法的具体用法?PHP Search::prepareSearchFilter怎么用?PHP Search::prepareSearchFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Search
的用法示例。
在下文中一共展示了Search::prepareSearchFilter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postRssSearch
/**
* If a search feed, set it up
*/
public function postRssSearch($h)
{
$search = $h->cage->get->sanitizeTags('search');
if (!$search || !$h->isActive('search')) {
return false;
}
require_once PLUGINS . 'search/search.php';
$search_plugin = new Search();
$prepared_search = $search_plugin->prepareSearchFilter($h, $search);
extract($prepared_search);
// override "relevance DESC" so the RSS feed updates with the latest related terms.
$h->vars['postRssOrderBy'] = "post_date DESC";
$h->vars['postRssFeed']['description'] = $h->lang["sb_base_rss_stories_search"] . " " . stripslashes($search);
}
示例2: prepareSearchFilter
/**
* Prepare search filter
*/
public function prepareSearchFilter($h, $search, $return = 'posts')
{
$searchFuncs = new Search();
return $searchFuncs->prepareSearchFilter($this, $search, $return);
}
示例3: settings
/**
* Main function that calls others
*
* @return bool
*/
public function settings($h)
{
// grab the number of pending posts:
$sql = "SELECT COUNT(post_id) FROM " . TABLE_POSTS . " WHERE post_status = %s";
$num_pending = $h->db->get_var($h->db->prepare($sql, 'pending'));
if (!$num_pending) {
$num_pending = "0";
}
$h->vars['num_pending'] = $num_pending;
// clear variables:
$h->vars['search_term'] = '';
// Get settings
$submit_settings = $h->getSerializedSettings('submit');
$set_pending = $submit_settings['set_pending'];
if ($set_pending == 'some_pending' || $set_pending == 'all_pending') {
$h->vars['post_status_filter'] = 'pending';
} else {
$h->vars['post_status_filter'] = 'all';
}
// Get unique statuses for Filter form:
$h->vars['statuses'] = $h->getUniqueStatuses();
// if checkboxes
if ($h->cage->get->getAlpha('type') == 'checkboxes' && $h->cage->get->keyExists('post')) {
foreach ($h->cage->get->keyExists('post') as $id => $checked) {
$h->readPost($id);
$h->message = $h->lang["post_man_checkboxes_status_changed"];
// default "Changed status" message
switch ($h->cage->get->testAlnumLines('checkbox_action')) {
case 'new_selected':
$h->changePostStatus('new');
$h->pluginHook('post_man_status_new');
break;
case 'top_selected':
$h->changePostStatus('top');
$h->pluginHook('post_man_status_top');
break;
case 'pending_selected':
$h->changePostStatus('pending');
$h->pluginHook('post_man_status_pending');
break;
case 'bury_selected':
$h->changePostStatus('buried');
$h->pluginHook('post_man_status_buried');
break;
case 'delete_selected':
$h->deletePost();
$h->pluginHook('post_man_delete');
$h->message = $h->lang["post_man_checkboxes_post_deleted"];
break;
default:
// do nothing
$h->message = $h->lang["post_man_checkboxes_no_action"];
$h->messageType = 'red';
break;
}
}
// Need to clear both these caches to be sure related items are updated in widgets, etc.:
$h->clearCache('html_cache', false);
$h->clearCache('db_cache', false);
}
$p = new Post();
// if search
$search_term = '';
if ($h->cage->get->getAlpha('type') == 'search') {
$search_term = $h->cage->get->sanitizeTags('search_value');
$h->vars['search_term'] = $search_term;
// used to refill the search box after a search
if ($h->isActive('search')) {
if (strlen($search_term) < 3) {
$h->message = $h->lang["user_man_search_too_short"];
$h->messageType = 'red';
} else {
$s = new Search();
require_once PLUGINS . 'sb_base/libs/SbBaseFunctions.php';
$sbFuncs = new SbBaseFunctions();
// get count
$s->prepareSearchFilter($h, stripslashes(trim($h->db->escape($search_term))), 'count');
$filtered_search = $sbFuncs->filter($h->vars['filter'], 0, true, $h->vars['select'], $h->vars['orderby']);
$posts_count = $sbFuncs->getPosts($h, $filtered_search);
$count = $posts_count[0]->number;
// get query
$s->prepareSearchFilter($h, stripslashes(trim($h->db->escape($search_term))), 'query');
$prepared_filter = $sbFuncs->filter($h->vars['filter'], 0, true, $h->vars['select'], $h->vars['orderby']);
if (isset($prepared_filter[1])) {
$query = $h->db->prepare($prepared_filter);
} else {
$query = $prepared_filter[0];
// returns the prepared query array
}
}
} else {
$h->message = $h->lang["post_man_need_search"];
$h->messageType = 'red';
}
}
//.........这里部分代码省略.........
示例4: getRelatedPosts
/**
* Get related results from the database
*
* @param string $search_terms - space separated string of words
* @param int $num_posts - the max number of posts to return
* return array|false
*/
public function getRelatedPosts($h, $search_terms = '', $num_posts = 10)
{
if (!$h->isActive('search')) {
return false;
}
require_once PLUGINS . 'search/search.php';
$search = new Search();
$h->vars['filter']['post_archived != %s'] = 'Y';
$h->vars['filter']['post_id != %d'] = $h->post->id;
$prepared_search = $search->prepareSearchFilter($h, $search_terms);
extract($prepared_search);
// include sb_base_functions class:
require_once PLUGINS . 'sb_base/libs/SbBaseFunctions.php';
$funcs = new SbBaseFunctions();
$prepared_filter = $funcs->filter($h->vars['filter'], $num_posts, false, $h->vars['select'], $h->vars['orderby']);
$results = $funcs->getPosts($h, $prepared_filter);
return $results;
}