Ticket #1274: 2436-fixes.3.diff
| File 2436-fixes.3.diff, 6.3 KB (added by , 16 years ago) |
|---|
-
bb-templates/kakumei/search.php
14 14 <?php foreach ( $recent as $bb_post ) : ?> 15 15 <li<?php alt_class( 'recent' ); ?>> 16 16 <a class="result" href="<?php post_link(); ?>"><?php echo bb_show_topic_context( $q, get_topic_title( $bb_post->topic_id ) ); ?></a> 17 <span class="freshness"><?php printf( __( ' Posted by <a href="%1$s">%2$s</a> on %3$s'), get_user_profile_link( $bb_post->poster_id ), get_post_author(), bb_datetime_format_i18n( bb_get_post_time( array( 'format' => 'timestamp' ) ) ) ); ?></span>17 <span class="freshness"><?php printf( __( 'By <a href="%1$s">%2$s</a> on %3$s'), get_user_profile_link( $bb_post->poster_id ), get_post_author(), bb_datetime_format_i18n( bb_get_post_time( array( 'format' => 'timestamp' ) ) ) ); ?></span> 18 18 <p><?php echo bb_show_context( $q, $bb_post->post_text ); ?></p> 19 19 </li> 20 20 <?php endforeach; ?> … … 27 27 <h4><?php _e( 'Relevant Topics' )?></h4> 28 28 <ol> 29 29 <?php foreach ( $relevant as $topic ) : ?> 30 <?php $bb_post = bb_get_first_post( $topic ); ?> 30 31 <li<?php alt_class( 'relevant' ); ?>> 31 <a class="result" href="<?php post_link( $topic->post_id); ?>"><?php echo bb_show_topic_context( $q, get_topic_title() ); ?></a>32 <span class="freshness"><?php printf( __( ' Posted by <a href="%1$s">%2$s</a> on %3$s' ), get_user_profile_link( $topic->topic_id), get_topic_author(), bb_datetime_format_i18n( get_topic_start_time( array( 'format' => 'timestamp' ) ) ) ); ?></span>33 <p><?php echo bb_show_context( $q, $ topic->post_text ); ?></p>32 <a class="result" href="<?php post_link(); ?>"><?php echo bb_show_topic_context( $q, get_topic_title() ); ?></a> 33 <span class="freshness"><?php printf( __( 'By <a href="%1$s">%2$s</a> on %3$s' ), get_user_profile_link( $topic->topic_poster ), get_topic_author(), bb_datetime_format_i18n( get_topic_start_time( array( 'format' => 'timestamp' ) ) ) ); ?></span> 34 <p><?php echo bb_show_context( $q, $bb_post->post_text ); ?></p> 34 35 </li> 35 36 <?php endforeach; ?> 36 37 </ol> 37 38 </div> 38 39 <?php endif; ?> 39 40 41 <?php bb_search_pages( array( 'before' => '<div class="nav">', 'after' => '</div>' ) ); ?> 42 40 43 <?php if ( $q && !$recent && !$relevant ) : ?> 41 44 <p><?php printf( __( 'Your search %s did not return any results. Here are some suggestions:' ), '“<em>' . esc_html( $q ) . '</em>”' ); ?></p> 42 45 <ul id="search-suggestions"> … … 44 47 <li><?php _e( 'Try different keywords' ); ?></li> 45 48 <li><?php _e( 'Try more general keywords' ); ?></li> 46 49 </ul> 47 <?php else: ?>48 <?php bb_search_pages(); ?>49 <br />50 50 <?php endif; ?> 51 51 52 52 <br /> -
bb-includes/functions.bb-template.php
1642 1642 $query_obj->form( $args ); 1643 1643 } 1644 1644 1645 function bb_search_pages() { 1645 function bb_search_pages( $args = null ) { 1646 $defaults = array( 'before' => '', 'after' => '' ); 1647 $args = wp_parse_args( $args, $defaults ); 1648 1646 1649 global $page, $search_count; 1647 echo apply_filters( 'bb_search_pages', get_page_number_links( array( 'page' => $page, 'total' => $search_count, 'per_page' => 5, 'mod_rewrite' => false ) ) ); 1650 1651 if ( $pages = apply_filters( 'bb_search_pages', get_page_number_links( array( 'page' => $page, 'total' => $search_count, 'per_page', 'mod_rewrite' => false ) ) ) ) 1652 echo $args['before'] . $pages . $args['after']; 1648 1653 } 1649 1654 1650 1655 /** -
search.php
8 8 9 9 if ( $q = stripslashes( $q ) ) { 10 10 /* Paging hack */ 11 global $page;12 if ( !$page ) $page = 1;13 $search_start = 5 * ( $page - 1);14 $search_stop = 5;15 11 //global $page; 12 //if ( !$page ) $page = 1; 13 //$search_start = 5 * ( $page - 1 ); 14 //$search_stop = 5; 15 16 16 /* Recent */ 17 17 add_filter( 'bb_recent_search_fields', create_function( '$f', 'return $f . ", MAX(post_time) AS post_time";' ) ); 18 18 add_filter( 'bb_recent_search_group_by', create_function( '', 'return "t.topic_id";' ) ); 19 $bb_query_form->BB_Query_Form( 'post', array(), array( 'order_by' => 'p.post_time', 'page' => 1, 'post_status' => 0, 'topic_status' => 0, 'post_text' => $q, 'forum_id', 'tag', 'topic_author', 'post_author' ), 'bb_recent_search' );19 $bb_query_form->BB_Query_Form( 'post', array(), array( 'order_by' => 'p.post_time', /*'page' => 1, */'per_page' => 5, 'post_status' => 0, 'topic_status' => 0, 'post_text' => $q, 'forum_id', 'tag', 'topic_author', 'post_author' ), 'bb_recent_search' ); 20 20 $recent = $bb_query_form->results; 21 21 if ( $recent ) { 22 22 $recent_count = isset( $bb_query_form->count ) ? $bb_query_form->count : count( $recent ); 23 $recent = array_slice( $recent, $search_start, $search_stop );24 } else {23 //$recent = array_slice( $recent, $search_start, $search_stop ); 24 } else 25 25 $recent_count = 0; 26 } 27 26 28 27 /* Relevant */ 29 $bb_query_form->BB_Query_Form( 'topic', array( 'search' => $q ), array( 'page' => 1, 'post_status' => 0, 'topic_status' => 0, 'search', 'forum_id', 'tag', 'topic_author', 'post_author' ), 'bb_relevant_search' );28 $bb_query_form->BB_Query_Form( 'topic', array( 'search' => $q ), array( /*'page' => 1, */'per_page' => 5, 'post_status' => 0, 'topic_status' => 0, 'search', 'forum_id', 'tag', 'topic_author', 'post_author' ), 'bb_relevant_search' ); 30 29 $relevant = $bb_query_form->results; 31 if ( $re cent ) {30 if ( $relevant ) { 32 31 $relevant_count = isset( $bb_query_form->count ) ? $bb_query_form->count : count( $relevant ); 33 $relevant = array_slice( $relevant, $search_start, $search_stop );34 } else {32 //$relevant = array_slice( $relevant, $search_start, $search_stop ); 33 } else 35 34 $relevant_count = 0; 36 } 37 38 $search_count = max( $recent_count, $relevant_count ); 39 35 36 $search_count = max( $recent_count, $relevant_count ); // todo: fix this to be results total 37 40 38 $q = $bb_query_form->get( 'search' ); 41 39 } 42 40 … … 54 52 $topics = bb_append_meta( $topics, 'topic' ); 55 53 endif; 56 54 57 bb_load_template( 'search.php', array( 'q', 'recent', 'relevant', 'page','search_count' ), $q );55 bb_load_template( 'search.php', array( 'q', 'recent', 'relevant', /*'page', */'search_count' ), $q ); 58 56 59 57 ?>