Ticket #1274: search.php.diff
| File search.php.diff, 2.7 KB (added by , 16 years ago) |
|---|
-
search.php
7 7 $bb_query_form = new BB_Query_Form; 8 8 9 9 if ( $q = stripslashes( $q ) ) { 10 /* Paging hack */11 global $page;12 if ( !$page ) $page = 1;13 10 $per_page = ceil( (int) bb_get_option( 'page_topics' ) / 2 ); 14 $search_start = $per_page * ( $page - 1 );15 $search_stop = $per_page;16 11 17 12 /* Recent */ 18 13 add_filter( 'bb_recent_search_fields', create_function( '$f', 'return $f . ", MAX(post_time) AS post_time";' ) ); 19 14 add_filter( 'bb_recent_search_group_by', create_function( '', 'return "t.topic_id";' ) ); 20 $bb_query_form->BB_Query_Form( 'post', array(), array( 'order_by' => 'p.post_time', ' page' => 1, 'per_page' => -1, 'post_status' => 0, 'topic_status' => 0, 'post_text' => $q, 'forum_id', 'tag', 'topic_author', 'post_author' ), 'bb_recent_search' );15 $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' ); 21 16 $recent = $bb_query_form->results; 22 if ( $recent ) { 23 $recent_count = isset( $bb_query_form->count ) ? $bb_query_form->count : count( $recent ); 24 $recent = array_slice( $recent, $search_start, $search_stop ); 25 } else { 26 $recent_count = 0; 27 } 17 $recent_count = $recent ? $bb_query_form->found_rows : 0; 28 18 29 19 /* Relevant */ 30 $bb_query_form->BB_Query_Form( 'topic', array( 'search' => $q ), array( 'p age' => 1, 'post_status' => 0, 'per_page' => -1, 'topic_status' => 0, 'search', 'forum_id', 'tag', 'topic_author', 'post_author' ), 'bb_relevant_search' );20 $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' ); 31 21 $relevant = $bb_query_form->results; 32 if ( $relevant ) { 33 $relevant_count = isset( $bb_query_form->count ) ? $bb_query_form->count : count( $relevant ); 34 $relevant = array_slice( $relevant, $search_start, $search_stop ); 35 } else { 36 $relevant_count = 0; 37 } 22 $relevant_count = $relevant ? $bb_query_form->found_rows : 0; 38 23 39 24 $search_count = max( $recent_count, $relevant_count ); 40 25 … … 55 40 $topics = bb_append_meta( $topics, 'topic' ); 56 41 endif; 57 42 58 bb_load_template( 'search.php', array( 'q', 'recent', 'relevant', 'page', 'per_page', 'search_count' ), $q ); 59 60 ?> 61 No newline at end of file 43 bb_load_template( 'search.php', array( 'q', 'recent', 'relevant', 'per_page', 'search_count' ), $q );