Changeset 2077 for trunk/bp-wire/bp-wire-templatetags.php
- Timestamp:
- 11/02/2009 07:54:21 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/bp-wire/bp-wire-templatetags.php (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-wire/bp-wire-templatetags.php
r1910 r2077 6 6 var $wire_posts; 7 7 var $wire_post; 8 8 9 9 var $in_the_loop; 10 10 11 11 var $pag_page; 12 12 var $pag_num; 13 13 var $pag_links; 14 14 var $total_wire_post_count; 15 15 16 16 var $can_post; 17 17 18 18 var $table_name; 19 19 20 20 function bp_wire_posts_template( $item_id, $component_slug, $can_post, $per_page, $max ) { 21 21 global $bp; … … 25 25 } else 26 26 $this->table_name = $bp->{$bp->active_components[$component_slug]}->table_name_wire; 27 27 28 28 $this->pag_page = isset( $_REQUEST['wpage'] ) ? intval( $_REQUEST['wpage'] ) : 1; 29 29 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; … … 31 31 $this->wire_posts = BP_Wire_Post::get_all_for_item( $item_id, $this->table_name, $this->pag_page, $this->pag_num ); 32 32 $this->total_wire_post_count = (int)$this->wire_posts['count']; 33 33 34 34 $this->wire_posts = $this->wire_posts['wire_posts']; 35 35 $this->wire_post_count = count($this->wire_posts); 36 36 37 37 if ( is_site_admin() || ( (int)get_site_option('non-friend-wire-posting') && ( $bp->current_component == $bp->profile->slug || $bp->current_component == $bp->wire->slug ) ) ) 38 38 $this->can_post = 1; 39 39 else 40 40 $this->can_post = $can_post; 41 41 42 42 $this->pag_links = paginate_links( array( 43 43 'base' => add_query_arg( 'wpage', '%#%', $bp->displayed_user->domain ), … … 49 49 'mid_size' => 1 50 50 )); 51 52 } 53 51 52 } 53 54 54 function has_wire_posts() { 55 55 if ( $this->wire_post_count ) 56 56 return true; 57 57 58 58 return false; 59 59 } 60 60 61 61 function next_wire_post() { 62 62 $this->current_wire_post++; 63 63 $this->wire_post = $this->wire_posts[$this->current_wire_post]; 64 64 65 65 return $this->wire_post; 66 66 } 67 67 68 68 function rewind_wire_posts() { 69 69 $this->current_wire_post = -1; … … 72 72 } 73 73 } 74 75 function user_wire_posts() { 74 75 function user_wire_posts() { 76 76 if ( $this->current_wire_post + 1 < $this->wire_post_count ) { 77 77 return true; … … 85 85 return false; 86 86 } 87 87 88 88 function the_wire_post() { 89 89 global $wire_post; … … 99 99 function bp_has_wire_posts( $args = '' ) { 100 100 global $wire_posts_template, $bp; 101 101 102 102 $defaults = array( 103 103 'item_id' => false, … … 110 110 $r = wp_parse_args( $args, $defaults ); 111 111 extract( $r, EXTR_SKIP ); 112 112 113 113 if ( !$item_id ) 114 114 return false; 115 116 $wire_posts_template = new BP_Wire_Posts_Template( $item_id, $component_slug, $can_post, $per_page, $max ); 115 116 $wire_posts_template = new BP_Wire_Posts_Template( $item_id, $component_slug, $can_post, $per_page, $max ); 117 117 return apply_filters( 'bp_has_wire_posts', $wire_posts_template->has_wire_posts(), &$wire_posts_template ); 118 118 } … … 133 133 if ( !$item_id ) 134 134 return false; 135 135 136 136 if ( !$empty_message ) 137 137 $empty_message = __("There are currently no wire posts.", 'buddypress'); 138 138 139 139 if ( !$title ) 140 140 $title = __('Wire', 'buddypress'); … … 146 146 $bp_wire_can_post = $can_post; 147 147 $bp_wire_show_email_notify = $show_email_notify; 148 148 149 149 locate_template( array( '/wire/post-list.php' ), true ); 150 150 } … … 157 157 return apply_filters( 'bp_get_wire_title', $bp_wire_header ); 158 158 } 159 159 160 160 function bp_wire_item_id( $deprecated = false ) { 161 161 global $bp_item_id; 162 162 163 163 if ( $deprecated ) 164 164 echo bp_get_wire_item_id(); … … 179 179 return apply_filters( 'bp_get_wire_no_posts_message', $bp_wire_msg ); 180 180 } 181 181 182 182 function bp_wire_can_post() { 183 183 global $bp_wire_can_post; … … 192 192 function bp_wire_post_id( $deprecated = true ) { 193 193 global $wire_posts_template; 194 194 195 195 if ( !$deprecated ) 196 196 return bp_get_wire_post_id(); … … 218 218 if ( $wire_posts_template->total_wire_post_count > $wire_posts_template->pag_num ) 219 219 return true; 220 220 221 221 return false; 222 222 } … … 230 230 return apply_filters( 'bp_get_wire_pagination', $wire_posts_template->pag_links ); 231 231 } 232 232 233 233 function bp_wire_pagination_count() { 234 234 echo bp_get_wire_pagination_count(); … … 238 238 239 239 $from_num = intval( ( $wire_posts_template->pag_page - 1 ) * $wire_posts_template->pag_num ) + 1; 240 $to_num = ( $from_num + ( $wire_posts_template->pag_num - 1) > $wire_posts_template->total_wire_post_count ) ? $wire_posts_template->total_wire_post_count : $from_num + ( $wire_posts_template->pag_num - 1); 241 242 return apply_filters( 'bp_get_wire_pagination_count', sprintf( __( 'Viewing post %d to %d (%d total posts)', 'buddypress' ), $from_num, $to_num, $wire_posts_template->total_wire_post_count ) ); 243 } 244 240 $to_num = ( $from_num + ( $wire_posts_template->pag_num - 1) > $wire_posts_template->total_wire_post_count ) ? $wire_posts_template->total_wire_post_count : $from_num + ( $wire_posts_template->pag_num - 1); 241 242 return apply_filters( 'bp_get_wire_pagination_count', sprintf( __( 'Viewing post %d to %d (%d total posts)', 'buddypress' ), $from_num, $to_num, $wire_posts_template->total_wire_post_count ) ); 243 } 244 245 245 function bp_wire_ajax_loader_src() { 246 246 echo bp_get_wire_ajax_loader_src(); … … 262 262 function bp_get_wire_post_date() { 263 263 global $wire_posts_template; 264 264 265 265 return apply_filters( 'bp_get_wire_post_date', mysql2date( get_blog_option( BP_ROOT_BLOG, 'date_format'), $wire_posts_template->wire_post->date_posted ) ); 266 266 } … … 268 268 function bp_wire_post_author_name( $deprecated = true ) { 269 269 global $wire_posts_template; 270 270 271 271 if ( !$deprecated ) 272 272 return bp_get_wire_post_author_name(); … … 291 291 function bp_wire_get_post_form() { 292 292 global $wire_posts_template; 293 293 294 294 if ( is_user_logged_in() && $wire_posts_template->can_post ) 295 locate_template( array( '/wire/post-form.php' ), true ); 295 locate_template( array( '/wire/post-form.php' ), true ); 296 296 } 297 297 … … 339 339 return bp_get_wire_poster_date(); 340 340 else 341 echo bp_get_wire_poster_date(); 341 echo bp_get_wire_poster_date(); 342 342 } 343 343 function bp_get_wire_poster_date() { 344 return apply_filters( 'bp_get_wire_poster_date', mysql2date( get_blog_option( BP_ROOT_BLOG, 'date_format' ), date("Y-m-d H:i:s") ) ); 344 return apply_filters( 'bp_get_wire_poster_date', mysql2date( get_blog_option( BP_ROOT_BLOG, 'date_format' ), date("Y-m-d H:i:s") ) ); 345 345 } 346 346
Note: See TracChangeset
for help on using the changeset viewer.