コード例 #1
0
ファイル: nm-search.php プロジェクト: popovdenis/kmst
/**
 * Pulling BBPress search into a function
 *
 * @Param: Search string
 * @return: An array which contains the BBPress results.
 * @author: pete kuhn
 * @version 1.0
 **/
function forums_search_results($q)
{
    global $bbdb;
    $bb_query_form = new BB_Query_Form();
    if ($q = stripslashes($q)) {
        add_filter('bb_recent_search_fields', create_function('$f', 'return $f . ", MAX(post_time) AS post_time";'));
        add_filter('bb_recent_search_group_by', create_function('', 'return "t.topic_id";'));
        $bb_query_form->BB_Query_Form('post', array(), array('per_page' => 5, 'post_status' => 0, 'topic_status' => 0, 'post_text' => $q, 'forum_id', 'tag', 'topic_author', 'post_author'), 'bb_recent_search');
        $recent = $bb_query_form->results;
        $bb_query_form->BB_Query_Form('topic', array('search' => $q), array('post_status' => 0, 'topic_status' => 0, 'search', 'forum_id', 'tag', 'topic_author', 'post_author'), 'bb_relevant_search');
        $relevant = $bb_query_form->results;
        $q = $bb_query_form->get('search');
    }
    do_action('do_search', $q);
    // Cache topics
    if ($recent) {
        $topic_ids = array();
        foreach ($recent as $bb_post) {
            $topic_ids[] = (int) $bb_post->topic_id;
            $bb_post_cache[$bb_post->post_id] = $bb_post;
        }
        $topic_ids = join($topic_ids);
        if ($topics = $bbdb->get_results("SELECT * FROM {$bbdb->topics} WHERE topic_id IN ({$topic_ids})")) {
            $topics = bb_append_meta($topics, 'topic');
        }
    }
    return $recent;
}
コード例 #2
0
ファイル: search.php プロジェクト: achorg/DH-Answers
<?php

require_once './bb-load.php';
if (!($q = trim(@$_GET['search']))) {
    $q = trim(@$_GET['q']);
}
$bb_query_form = new BB_Query_Form();
if ($q = stripslashes($q)) {
    $per_page = ceil((int) bb_get_option('page_topics') / 2);
    /* Recent */
    add_filter('bb_recent_search_fields', create_function('$f', 'return $f . ", MAX(post_time) AS post_time";'));
    add_filter('bb_recent_search_group_by', create_function('', 'return "t.topic_id";'));
    $bb_query_form->BB_Query_Form('post', array(), array('order_by' => 'p.post_time', 'count' => true, 'per_page' => $per_page, 'post_status' => 0, 'topic_status' => 0, 'post_text' => $q, 'forum_id', 'tag', 'topic_author', 'post_author'), 'bb_recent_search');
    $recent = $bb_query_form->results;
    $recent_count = $recent ? $bb_query_form->found_rows : 0;
    /* Relevant */
    $bb_query_form->BB_Query_Form('topic', array('search' => $q), array('per_page' => $per_page, 'count' => true, 'post_status' => 0, 'topic_status' => 0, 'search', 'forum_id', 'tag', 'topic_author', 'post_author'), 'bb_relevant_search');
    $relevant = $bb_query_form->results;
    $relevant_count = $relevant ? $bb_query_form->found_rows : 0;
    $search_count = max($recent_count, $relevant_count);
    $q = $bb_query_form->get('search');
}
do_action('do_search', $q);
// Cache topics
// NOT bbdb::prepared
if ($recent) {
    $topic_ids = array();
    foreach ($recent as $bb_post) {
        $topic_ids[] = (int) $bb_post->topic_id;
    }
    $topic_ids = join($topic_ids);
コード例 #3
0
ファイル: posts.php プロジェクト: laiello/cartonbank
$ip_available = false;
if (bb_current_user_can('view_by_ip')) {
    $ip_available = true;
} elseif (isset($_GET['poster_ip'])) {
    unset($_GET['poster_ip']);
}
$bb_admin_body_class = ' bb-admin-posts';
bb_get_admin_header();
if (!bb_current_user_can('browse_deleted')) {
    die(__("Now how'd you get here?  And what did you think you'd being doing?"));
}
//This should never happen.
add_filter('get_topic_where', 'bb_no_where');
add_filter('get_topic_link', 'bb_make_link_view_all');
add_filter('post_edit_uri', 'bb_make_link_view_all');
$post_query = new BB_Query_Form('post', array('post_status' => 'normal', 'count' => true, 'per_page' => 20));
$bb_posts =& $post_query->results;
$total = $post_query->found_rows;
?>

<div class="wrap">

<h2><?php 
_e('Posts');
$h2_search = $post_query->get('post_text');
$h2_forum = $post_query->get('forum_id');
$h2_tag = $post_query->get('tag_id');
$h2_author = $post_query->get('post_author_id');
$h2_search = $h2_search ? ' ' . sprintf(__('containing &#8220;%s&#8221;'), esc_html($h2_search)) : '';
$h2_forum = $h2_forum ? ' ' . sprintf(__('in &#8220;%s&#8221;'), get_forum_name($h2_forum)) : '';
$h2_tag = $h2_tag ? ' ' . sprintf(__('with tag &#8220;%s&#8221;'), esc_html(bb_get_tag_name($h2_tag))) : '';
コード例 #4
0
ファイル: topics.php プロジェクト: danielcoats/schoolpress
}
$bb_admin_body_class = ' bb-admin-topics';
bb_get_admin_header();
if (!bb_current_user_can('browse_deleted')) {
    die(__("Now how'd you get here?  And what did you think you'd being doing?"));
}
//This should never happen.
add_filter('topic_link', 'bb_make_link_view_all');
add_filter('topic_last_post_link', 'bb_make_link_view_all');
$topic_query_vars = array('topic_status' => 'normal', 'open' => 'open', 'count' => true, 'per_page' => 20);
if (isset($_POST['search']) && $_POST['search']) {
    $topic_query_vars['post_status'] = 'all';
} elseif (isset($_GET['search']) && $_GET['search']) {
    $topic_query_vars['post_status'] = 'all';
}
$topic_query = new BB_Query_Form('topic', $topic_query_vars);
$topics = $topic_query->results;
?>

<div class="wrap">

<h2><?php 
_e('Topics');
$h2_search = $topic_query->get('search');
$h2_forum = $topic_query->get('forum_id');
$h2_tag = $topic_query->get('tag_id');
$h2_author = $topic_query->get('topic_author_id');
$h2_search = $h2_search ? ' ' . sprintf(__('containing &#8220;%s&#8221;'), esc_html($h2_search)) : '';
$h2_forum = $h2_forum ? ' ' . sprintf(__('in &#8220;%s&#8221;'), get_forum_name($h2_forum)) : '';
$h2_tag = $h2_tag ? ' ' . sprintf(__('with tag &#8220;%s&#8221;'), esc_html(bb_get_tag_name($h2_tag))) : '';
$h2_author = $h2_author ? ' ' . sprintf(__('by %s'), esc_html(get_user_name($h2_author))) : '';