Skip to:
Content

BuddyPress.org

Changeset 1376


Ignore:
Timestamp:
04/22/2009 10:34:05 AM (16 years ago)
Author:
apeatling
Message:

Making the wire template loop easier to use.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-themes/buddypress-member/wire/post-list.php

    r1366 r1376  
    33
    44    <form name="wire-post-list-form" id="wire-post-list-form" action="" method="post">
    5     <?php if ( bp_has_wire_posts( bp_wire_item_id(), bp_wire_can_post() ) ) : ?>
     5    <?php if ( bp_has_wire_posts( 'item_id=' . bp_wire_item_id() . '&can_post=' . bp_wire_can_post() ) ) : ?>
    66       
    77        <?php if ( bp_wire_needs_pagination() ) : ?>
  • trunk/bp-wire/bp-wire-templatetags.php

    r1366 r1376  
    1818    var $table_name;
    1919   
    20     function bp_wire_posts_template( $item_id, $can_post ) {
     20    function bp_wire_posts_template( $item_id, $can_post, $per_page, $max ) {
    2121        global $bp;
    2222       
     
    2424            $this->table_name = $bp->profile->table_name_wire;
    2525           
    26             // Seeing as we're viewing a users wire, lets remove any new wire
    27             // post notifications
    28             if ( 'all-posts' == $bp->current_action )
     26            // If the user is viewing their own wire, delete the notifications.
     27            if ( 'all-posts' == $bp->current_action && bp_is_home() )
    2928                bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'xprofile', 'new_wire_post' );
    3029           
     
    3433       
    3534        $this->pag_page = isset( $_REQUEST['wpage'] ) ? intval( $_REQUEST['wpage'] ) : 1;
    36         $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : 5;
     35        $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    3736
    3837        $this->wire_posts = BP_Wire_Post::get_all_for_item( $item_id, $this->table_name, $this->pag_page, $this->pag_num );
     
    104103}
    105104
    106 function bp_has_wire_posts( $item_id = null, $can_post = true ) {
     105function bp_has_wire_posts( $args = '' ) {
    107106    global $wire_posts_template, $bp;
     107   
     108    $defaults = array(
     109        'item_id' => false,
     110        'can_post' => true,
     111        'per_page' => 5,
     112        'max' => false
     113    );
     114
     115    $r = wp_parse_args( $args, $defaults );
     116    extract( $r, EXTR_SKIP );
    108117   
    109118    if ( !$item_id )
    110119        return false;
    111120       
    112     $wire_posts_template = new BP_Wire_Posts_Template( $item_id, $can_post );       
     121    $wire_posts_template = new BP_Wire_Posts_Template( $item_id, $can_post, $per_page, $max );     
    113122    return $wire_posts_template->has_wire_posts();
    114123}
     
    209218   
    210219    $from_num = intval( ( $wire_posts_template->pag_page - 1 ) * $wire_posts_template->pag_num ) + 1;
    211     $to_num = ( $from_num + 4 > $wire_posts_template->total_wire_post_count ) ? $wire_posts_template->total_wire_post_count : $from_num + 4;
     220    $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);
    212221   
    213222    echo apply_filters( 'bp_wire_pagination_count', sprintf( __( 'Viewing post %d to %d (%d total posts)', 'buddypress' ), $from_num, $to_num, $wire_posts_template->total_wire_post_count ) ); 
Note: See TracChangeset for help on using the changeset viewer.