Ticket #1274: 1274.2.diff
File 1274.2.diff, 9.3 KB (added by , 14 years ago) |
---|
-
bb-includes/functions.bb-formatting.php
271 271 return $text; 272 272 } 273 273 274 function bb_show_topic_context( $term, $text ) { 275 $text = strip_tags( $text ); 276 $term = preg_quote( $term ); 277 $text = preg_replace( "|.*?(.{0,80})$term(.{0,80}).*|is", "$1<strong>$term</strong>$2", $text, 1 ); 278 $text = substr( $text, 0, 210 ); 279 return $text; 280 } 281 274 282 function bb_post_text_context( $post_text ) { 275 283 return bb_show_context( $GLOBALS['q'], $post_text ); 276 284 } 277 285 278 286 function bb_show_context( $term, $text ) { 279 $text = strip_tags($text); 280 $term = preg_quote($term); 281 $text = preg_replace("|.*?(.{0,80})$term(.{0,80}).*|is", "... $1<strong>$term</strong>$2 ...", $text, 1); 282 $text = substr($text, 0, 210); 287 $text = strip_shortcodes( $text ); 288 $text = strip_tags( $text ); 289 $term = preg_quote( $term ); 290 $text = preg_replace( "|.*?(.{0,80})$term(.{0,80}).*|is", "... $1<strong>$term</strong>$2 ...", $text, 1 ); 291 $text = substr( $text, 0, 210 ); 283 292 return $text; 284 293 } 285 294 -
bb-includes/functions.bb-template.php
497 497 $title = array(); 498 498 499 499 switch ( bb_get_location() ) { 500 case 'search-page': 501 if ( !$q = trim( @$_GET['search'] ) ) 502 if ( !$q = trim( @$_GET['q'] ) ) 503 break; 504 $title[] = sprintf( __( 'Search for %s' ), esc_html( $q ) ); 505 break; 500 506 case 'front-page': 501 507 if ( !empty( $args['front'] ) ) 502 508 $title[] = $args['front']; … … 515 521 if ( bb_is_tag() ) 516 522 $title[] = esc_html( bb_get_tag_name() ); 517 523 518 $title[] = __( 'Tags');524 $title[] = __( 'Tags' ); 519 525 break; 520 526 521 527 case 'profile-page': … … 1636 1642 $query_obj->form( $args ); 1637 1643 } 1638 1644 1645 function bb_search_pages() { 1646 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 ) ) ); 1648 } 1649 1639 1650 /** 1640 1651 * bb_topic_pagecount() - Print the total page count for a topic 1641 1652 * -
bb-templates/kakumei/search.php
4 4 <?php bb_topic_search_form(); ?> 5 5 6 6 <?php if ( !empty ( $q ) ) : ?> 7 <h3 id="search-for"><?php _e('Search for')?> “<?php echo esc_html($q); ?>”</h3>7 <h3 id="search-for"><?php printf( __( 'Search for %s' ), '“' . esc_html( $q ) . '”' ); ?></h3> 8 8 <?php endif; ?> 9 9 10 10 <?php if ( $recent ) : ?> 11 11 <div id="results-recent" class="search-results"> 12 <h4><?php _e( 'Recent Posts')?></h4>12 <h4><?php _e( 'Recent Posts' )?></h4> 13 13 <ol> 14 14 <?php foreach ( $recent as $bb_post ) : ?> 15 15 <li<?php alt_class( 'recent' ); ?>> 16 <a href="<?php post_link(); ?>"><?php topic_title($bb_post->topic_id); ?></a>17 <span class="freshness"><?php printf( __( 'Posted %s'), bb_datetime_format_i18n( bb_get_post_time( array( 'format' => 'timestamp' ) ) ) ); ?></span>18 <p><?php echo bb_show_context( $q, $bb_post->post_text); ?></p>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> 18 <p><?php echo bb_show_context( $q, $bb_post->post_text ); ?></p> 19 19 </li> 20 20 <?php endforeach; ?> 21 21 </ol> … … 24 24 25 25 <?php if ( $relevant ) : ?> 26 26 <div id="results-relevant" class="search-results"> 27 <h4><?php _e( 'Relevant posts')?></h4>27 <h4><?php _e( 'Relevant Topics' )?></h4> 28 28 <ol> 29 <?php foreach ( $relevant as $ bb_post) : ?>29 <?php foreach ( $relevant as $topic ) : ?> 30 30 <li<?php alt_class( 'relevant' ); ?>> 31 <a href="<?php post_link(); ?>"><?php topic_title($bb_post->topic_id); ?></a>32 <span class="freshness"><?php printf( __( 'Posted %s'), bb_datetime_format_i18n( bb_get_post_time( array( 'format' => 'timestamp' ) )) ); ?></span>33 <p><?php post_text(); ?></p>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( __( 'Last post <a href="%1$s">%2$s ago</a> by <a href="%3$s">%4$s</a>'), get_topic_last_post_link(), get_topic_time(), get_user_profile_link( $topic->topic_last_poster ), get_topic_last_poster() ); ?></span> 33 <p><?php echo bb_show_context( $q, $topic->post_text ); ?></p> 34 34 </li> 35 35 <?php endforeach; ?> 36 36 </ol> … … 38 38 <?php endif; ?> 39 39 40 40 <?php if ( $q && !$recent && !$relevant ) : ?> 41 <p><?php _e('No results found.') ?></p> 41 <p><?php printf( __( 'Your search %s did not return any results. Here are some suggestions:' ), '“<em>' . esc_html( $q ) . '</em>”' ); ?></p> 42 <ul id="search-suggestions"> 43 <li><?php _e( 'Make sure all words are spelled correctly' ); ?></li> 44 <li><?php _e( 'Try different keywords' ); ?></li> 45 <li><?php _e( 'Try more general keywords' ); ?></li> 46 </ul> 47 <?php else: ?> 48 <?php bb_search_pages(); ?> 49 <br /> 42 50 <?php endif; ?> 51 43 52 <br /> 44 <p><?php printf(__('You may also try your <a href="http://google.com/search?q=site:%1$s %2$s">search at Google</a>'), bb_get_uri(null, null, BB_URI_CONTEXT_TEXT), urlencode($q)) ?></p> 45 <?php bb_get_footer(); ?> 53 <p><?php printf( __( 'You may also try your <a href="%s">search at Google</a>.' ), 'http://google.com/search?q=site:' . bb_get_uri( null, null, BB_URI_CONTEXT_TEXT ) . urlencode( ' ' . $q ) ); ?></p> 54 55 <?php bb_get_footer(); ?> 56 No newline at end of file -
bb-templates/kakumei/style.css
846 846 847 847 #search-for { margin: 15px 0 5px; } 848 848 849 ul#search-suggestions { margin-left: 25px; } 850 849 851 .search-results { margin: 0 0 10px; } 850 852 851 853 .search-results ol { margin: 5px 0 0 28px; } 852 854 853 .search-results ol li { margin: 0 0 3px; }855 .search-results ol li { border-bottom: 1px solid #ccc; padding: 2px 5px 0 5px; min-height: 50px; } 854 856 857 .search-results ol li.alt { background-color: #f8f8f8; } 858 859 .search-results ol li:hover { background-color: #e4f3e1; } 860 861 .search-results ol li a.result { font-size: 15px; } 862 863 .search-results ol li span.freshness { float: right; font-style: italic; } 864 855 865 /* Login, Register, Profile Edit 856 866 =================================== */ 857 867 -
search.php
1 1 <?php 2 require_once( './bb-load.php');2 require_once( './bb-load.php' ); 3 3 4 4 if ( !$q = trim( @$_GET['search'] ) ) 5 5 $q = trim( @$_GET['q'] ); … … 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 $search_start = 5 * ( $page - 1); 14 $search_stop = 5; 15 16 /* Recent */ 10 17 add_filter( 'bb_recent_search_fields', create_function( '$f', 'return $f . ", MAX(post_time) AS post_time";' ) ); 11 18 add_filter( 'bb_recent_search_group_by', create_function( '', 'return "t.topic_id";' ) ); 12 $bb_query_form->BB_Query_Form( 'post', array(), array( 'order_by' => 'p.post_time', 'p er_page' => 5, '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, 'post_status' => 0, 'topic_status' => 0, 'post_text' => $q, 'forum_id', 'tag', 'topic_author', 'post_author' ), 'bb_recent_search' ); 13 20 $recent = $bb_query_form->results; 14 15 $bb_query_form->BB_Query_Form( 'post', array( 'search' => $q ), array( 'post_status' => 0, 'topic_status' => 0, 'search', 'forum_id', 'tag', 'topic_author', 'post_author' ), 'bb_relevant_search' ); 21 if ( $recent ) { 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 { 25 $recent_count = 0; 26 } 27 28 /* 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' ); 16 30 $relevant = $bb_query_form->results; 31 if ( $recent ) { 32 $relevant_count = isset( $bb_query_form->count ) ? $bb_query_form->count : count( $relevant ); 33 $relevant = array_slice( $relevant, $search_start, $search_stop ); 34 } else { 35 $relevant_count = 0; 36 } 17 37 18 $ bb_query_form->type = 'topic';19 38 $search_count = max( $recent_count, $relevant_count ); 39 20 40 $q = $bb_query_form->get( 'search' ); 21 41 } 22 42 … … 34 54 $topics = bb_append_meta( $topics, 'topic' ); 35 55 endif; 36 56 37 bb_load_template( 'search.php', array( 'q', 'recent', 'relevant'), $q );57 bb_load_template( 'search.php', array( 'q', 'recent', 'relevant', 'page', 'search_count' ), $q ); 38 58 39 ?> 59 ?> 60 No newline at end of file