[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-forums/bbpress/ -> search.php (source)

   1  <?php
   2  require_once ( './bb-load.php' );
   3  
   4  if ( !$q = trim( @$_GET['search'] ) )
   5      $q = trim( @$_GET['q'] );
   6  
   7  $bb_query_form = new BB_Query_Form;
   8  
   9  if ( $q = stripslashes( $q ) ) {
  10      $per_page = ceil( (int) bb_get_option( 'page_topics' ) / 2 );
  11      
  12      /* Recent */
  13      add_filter( 'bb_recent_search_fields',   create_function( '$f', 'return $f . ", MAX(post_time) AS post_time";' ) );
  14      add_filter( 'bb_recent_search_group_by', create_function( '', 'return "t.topic_id";' ) );
  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' );
  16      $recent = $bb_query_form->results;
  17      $recent_count = $recent ? $bb_query_form->found_rows : 0;
  18      
  19      /* Relevant */
  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' );
  21      $relevant = $bb_query_form->results;
  22      $relevant_count = $relevant ? $bb_query_form->found_rows : 0;
  23      
  24      $search_count = max( $recent_count, $relevant_count );
  25      
  26      $q = $bb_query_form->get( 'search' );
  27  }
  28  
  29  do_action( 'do_search', $q );
  30  
  31  // Cache topics
  32  // NOT bbdb::prepared
  33  if ( $recent ) :
  34      $topic_ids = array();
  35      foreach ($recent as $bb_post) {
  36          $topic_ids[] = (int) $bb_post->topic_id;
  37      }
  38      $topic_ids = join($topic_ids);
  39      if ( $topics = $bbdb->get_results("SELECT * FROM $bbdb->topics WHERE topic_id IN ($topic_ids)") )
  40          $topics = bb_append_meta( $topics, 'topic' );
  41  endif;
  42  
  43  bb_load_template( 'search.php', array( 'q', 'recent', 'relevant', 'per_page', 'search_count' ), $q );


Generated: Thu Dec 7 01:01:35 2017 Cross-referenced by PHPXref 0.7.1