Changeset 2194 for trunk/bp-forums/bp-forums-templatetags.php
- Timestamp:
- 12/17/2009 12:24:10 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/bp-forums/bp-forums-templatetags.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-forums/bp-forums-templatetags.php
r2168 r2194 19 19 var $order; 20 20 21 function BP_Forums_Template_Forum( $type, $forum_id, $ page, $per_page, $max, $no_stickies, $filter) {21 function BP_Forums_Template_Forum( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms ) { 22 22 global $bp; 23 23 … … 31 31 switch ( $type ) { 32 32 case 'newest': default: 33 $this->topics = bp_forums_get_forum_topics( array( ' forum_id' => $forum_id, 'filter' => $filter, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );33 $this->topics = bp_forums_get_forum_topics( array( 'user_id' => $user_id, 'forum_id' => $forum_id, 'filter' => $search_terms, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) ); 34 34 break; 35 35 36 36 case 'popular': 37 $this->topics = bp_forums_get_forum_topics( array( ' type' => 'popular', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );37 $this->topics = bp_forums_get_forum_topics( array( 'user_id' => $user_id, 'type' => 'popular', 'filter' => $search_terms, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) ); 38 38 break; 39 39 40 40 case 'unreplied': 41 $this->topics = bp_forums_get_forum_topics( array( ' type' => 'unreplied', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );41 $this->topics = bp_forums_get_forum_topics( array( 'user_id' => $user_id, 'type' => 'unreplied', 'filter' => $search_terms, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) ); 42 42 break; 43 43 44 case 'personal':45 $this->topics = bp_forums_get_forum_topics( array( 'type' => 'personal', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );46 break;47 48 44 case 'tag': 49 $this->topics = bp_forums_get_forum_topics( array( ' type' => 'tag', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );45 $this->topics = bp_forums_get_forum_topics( array( 'user_id' => $user_id, 'type' => 'tag', 'filter' => $search_terms, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) ); 50 46 break; 51 47 } … … 158 154 'type' => 'newest', 159 155 'forum_id' => false, 156 'user_id' => false, 160 157 'page' => 1, 161 158 'per_page' => 15, 162 159 'max' => false, 163 160 'no_stickies' => false, 164 ' filter' => false161 'search_terms' => false 165 162 ); 166 163 … … 170 167 /* If we're in a single group, set this group's forum_id */ 171 168 if ( !$forum_id && $bp->groups->current_group ) { 172 $ forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' );169 $bp->groups->current_group->forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ); 173 170 174 171 /* If it turns out there is no forum for this group, return false so we don't fetch all global topics */ 175 if ( !$ forum_id )172 if ( !$bp->groups->current_group->forum_id ) 176 173 return false; 177 174 } … … 179 176 /* If we're viewing a tag in the directory, let's auto set the filter to the tag name */ 180 177 if ( $bp->is_directory && 'tag' == $type && !empty( $bp->action_variables[0] ) ) 181 $ filter= $bp->action_variables[0];182 183 /* If $_GET[' s'] is set, let's auto populate the filtervar */178 $search_terms = $bp->action_variables[0]; 179 180 /* If $_GET['fs'] is set, let's auto populate the search_terms var */ 184 181 if ( $bp->is_directory && !empty( $_GET['fs'] ) ) 185 $ filter= $_GET['fs'];186 187 $forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $ page, $per_page, $max, $no_stickies, $filter);182 $search_terms = $_GET['fs']; 183 184 $forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms ); 188 185 189 186 return apply_filters( 'bp_has_topics', $forum_template->has_topics(), &$forum_template ); … … 935 932 936 933 function bp_directory_forums_search_form() { 937 global $bp; ?> 938 <form action="<?php echo $bp->root_domain . '/' . $bp->forums->slug . '/'; ?>" method="get" id="search-forums-form"> 939 <label><input type="text" name="fs" id="forums_search" value="<?php if ( isset( $_GET['fs'] ) ) { echo attribute_escape( $_GET['fs'] ); } else { _e( 'Search anything...', 'buddypress' ); } ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label> 940 <input type="submit" id="forums_search_submit" name="submit" value="<?php _e( 'Search', 'buddypress' ) ?>" /> 934 global $bp; 935 936 $search_value = __( 'Search anything...', 'buddypress' ); 937 if ( !empty( $_REQUEST['fs'] ) ) 938 $search_value = $_REQUEST['fs']; 939 940 else if ( !empty( $_COOKIE['bp-forums-search-terms'] ) && 'false' != $_COOKIE['bp-forums-search-terms'] ) 941 $search_value = $_COOKIE['bp-forums-search-terms']; 942 943 ?> 944 <form action="" method="get" id="search-forums-form"> 945 <label><input type="text" name="s" id="forums_search" value="<?php echo attribute_escape($search_value) ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label> 946 <input type="submit" id="forums_search_submit" name="forums_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" /> 941 947 </form> 942 948 <?php 943 949 } 944 945 950 function bp_forum_permalink() { 946 951 echo bp_get_forum_permalink();
Note: See TracChangeset
for help on using the changeset viewer.