Skip to:
Content

bbPress.org

Ticket #1274: 2436-fixes.3.diff

File 2436-fixes.3.diff, 6.3 KB (added by mr_pelle, 16 years ago)

further update. Restores 5 item per page. Does NOT fix everything yet!

  • bb-templates/kakumei/search.php

     
    1414<?php foreach ( $recent as $bb_post ) : ?>
    1515                <li<?php alt_class( 'recent' ); ?>>
    1616                        <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>
    1818                        <p><?php echo bb_show_context( $q, $bb_post->post_text ); ?></p>
    1919                </li>
    2020<?php endforeach; ?>
     
    2727        <h4><?php _e( 'Relevant Topics' )?></h4>
    2828        <ol>
    2929<?php foreach ( $relevant as $topic ) : ?>
     30<?php $bb_post = bb_get_first_post( $topic ); ?>
    3031                <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>
    3435                </li>
    3536<?php endforeach; ?>
    3637        </ol>
    3738</div>
    3839<?php endif; ?>
    3940
     41<?php bb_search_pages( array( 'before' => '<div class="nav">', 'after' => '</div>' ) ); ?>
     42
    4043<?php if ( $q && !$recent && !$relevant ) : ?>
    4144<p><?php printf( __( 'Your search %s did not return any results. Here are some suggestions:' ), '&#8220;<em>' . esc_html( $q ) . '</em>&#8221;' ); ?></p>
    4245<ul id="search-suggestions">
     
    4447    <li><?php _e( 'Try different keywords' ); ?></li>
    4548    <li><?php _e( 'Try more general keywords' ); ?></li>
    4649</ul>
    47 <?php else: ?>
    48         <?php bb_search_pages(); ?>
    49         <br />
    5050<?php endif; ?>
    5151
    5252<br />
  • bb-includes/functions.bb-template.php

     
    16421642        $query_obj->form( $args );
    16431643}
    16441644
    1645 function bb_search_pages() {
     1645function bb_search_pages( $args = null ) {
     1646        $defaults = array( 'before' => '', 'after' => '' );
     1647        $args = wp_parse_args( $args, $defaults );
     1648
    16461649        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'];
    16481653}
    16491654
    16501655/**
  • search.php

     
    88
    99if ( $q = stripslashes( $q ) ) {
    1010        /* 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
    1616        /* Recent */
    1717        add_filter( 'bb_recent_search_fields',   create_function( '$f', 'return $f . ", MAX(post_time) AS post_time";' ) );
    1818        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' );
    2020        $recent = $bb_query_form->results;
    2121        if ( $recent ) {
    2222                $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
    2525                $recent_count = 0;
    26         }
    27        
     26
    2827        /* 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' );
    3029        $relevant = $bb_query_form->results;
    31         if ( $recent ) {
     30        if ( $relevant ) {
    3231                $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
    3534                $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
    4038        $q = $bb_query_form->get( 'search' );
    4139}
    4240
     
    5452                $topics = bb_append_meta( $topics, 'topic' );
    5553endif;
    5654
    57 bb_load_template( 'search.php', array( 'q', 'recent', 'relevant', 'page', 'search_count' ), $q );
     55bb_load_template( 'search.php', array( 'q', 'recent', 'relevant', /*'page', */'search_count' ), $q );
    5856
    5957?>