Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/13/2009 01:01:37 AM (16 years ago)
Author:
apeatling
Message:

Initial support for threaded activity stream commenting. Some major performance improvements around fetching profile and group data.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs/bp-blogs-templatetags.php

    r1949 r2088  
    55function bp_blog_signup_enabled() {
    66    $active_signup = get_site_option( 'registration' );
    7    
     7
    88    if ( !$active_signup )
    99        $active_signup = 'all';
    10        
     10
    1111    $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"
    12    
     12
    1313    if ( 'none' == $active_signup || 'user' == $active_signup )
    1414        return false;
    15    
     15
    1616    return true;
    1717}
     
    2020    global $current_user, $current_site;
    2121    global $bp;
    22        
     22
    2323    require_once( ABSPATH . WPINC . '/registration.php' );
    2424
     
    4848            <input type="hidden" name="stage" value="gimmeanotherblog" />
    4949            <?php do_action( "signup_hidden_fields" ); ?>
    50            
     50
    5151            <?php bp_blogs_signup_blog($blogname, $blog_title, $errors); ?>
    5252            <p>
    5353                <input id="submit" type="submit" name="submit" class="submit" value="<?php _e('Create Blog &raquo;', 'buddypress') ?>" />
    5454            </p>
    55            
     55
    5656            <?php wp_nonce_field( 'bp_blog_signup_form' ) ?>
    5757        </form>
     
    6262function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' ) {
    6363    global $current_site;
    64    
     64
    6565    // Blog name
    6666    if( 'no' == constant( "VHOST" ) )
     
    9090    // Blog Title
    9191    ?>
    92     <label for="blog_title"><?php _e('Blog Title:', 'buddypress') ?></label>   
     92    <label for="blog_title"><?php _e('Blog Title:', 'buddypress') ?></label>
    9393    <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
    9494        <p class="error"><?php echo $errmsg ?></p>
     
    9999    <p>
    100100        <label for="blog_public_on"><?php _e('Privacy:', 'buddypress') ?></label>
    101         <?php _e('I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress'); ?> 
     101        <?php _e('I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress'); ?>
    102102
    103103
     
    119119    global $wpdb, $current_user, $blogname, $blog_title, $errors, $domain, $path;
    120120
    121     if ( !check_admin_referer( 'bp_blog_signup_form' ) ) 
     121    if ( !check_admin_referer( 'bp_blog_signup_form' ) )
    122122        return false;
    123123
    124124    $current_user = wp_get_current_user();
    125    
     125
    126126    if( !is_user_logged_in() )
    127127        die();
     
    137137
    138138    $public = (int) $_POST['blog_public'];
    139    
     139
    140140    $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // depreciated
    141141    $meta = apply_filters( 'add_signup_meta', $meta );
    142    
     142
    143143    /* If this is a VHOST install, remove the username from the domain as we are setting this blog
    144144       up inside a user domain, not the root domain. */
    145    
     145
    146146    wpmu_create_blog( $domain, $path, $blog_title, $current_user->id, $meta, $wpdb->siteid );
    147147    bp_blogs_confirm_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta);
     
    169169function bp_create_blog_link() {
    170170    global $bp;
    171    
     171
    172172    if ( bp_is_home() ) {
    173173        echo apply_filters( 'bp_create_blog_link', '<a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog">' . __('Create a Blog', 'buddypress') . '</a>' );
     
    177177function bp_blogs_blog_tabs() {
    178178    global $bp, $groups_template;
    179    
     179
    180180    // Don't show these tabs on a user's own profile
    181181    if ( bp_is_home() )
    182182        return false;
    183    
     183
    184184    $current_tab = $bp->current_action
    185185?>
     
    187187        <li<?php if ( 'my-blogs' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/my-blogs"><?php printf( __( "%s's Blogs", 'buddypress' ), $bp->displayed_user->fullname )  ?></a></li>
    188188        <li<?php if ( 'recent-posts' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/recent-posts"><?php printf( __( "%s's Recent Posts", 'buddypress' ), $bp->displayed_user->fullname )  ?></a></li>
    189         <li<?php if ( 'recent-comments' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/recent-comments"><?php printf( __( "%s's Recent Comments", 'buddypress' ), $bp->displayed_user->fullname )  ?></a></li> 
     189        <li<?php if ( 'recent-comments' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/recent-comments"><?php printf( __( "%s's Recent Comments", 'buddypress' ), $bp->displayed_user->fullname )  ?></a></li>
    190190    </ul>
    191191<?php
     
    202202    var $blogs;
    203203    var $blog;
    204    
     204
    205205    var $in_the_loop;
    206    
     206
    207207    var $pag_page;
    208208    var $pag_num;
    209209    var $pag_links;
    210210    var $total_blog_count;
    211    
     211
    212212    function bp_blogs_user_blogs_template( $user_id, $per_page, $max ) {
    213213        global $bp;
    214        
     214
    215215        if ( !$user_id )
    216216            $user_id = $bp->displayed_user->id;
     
    223223            wp_cache_set( 'bp_blogs_for_user_' . $user_id, $this->blogs, 'bp' );
    224224        }
    225        
     225
    226226        if ( !$max || $max >= (int)$this->blogs['count'] )
    227227            $this->total_blog_count = (int)$this->blogs['count'];
    228228        else
    229229            $this->total_blog_count = (int)$max;
    230        
     230
    231231        $this->blogs = array_slice( (array)$this->blogs['blogs'], intval( ( $this->pag_page - 1 ) * $this->pag_num), intval( $this->pag_num ) );
    232        
     232
    233233        if ( $max ) {
    234234            if ( $max >= count($this->blogs) )
     
    239239            $this->blog_count = count($this->blogs);
    240240        }
    241        
     241
    242242        $this->pag_links = paginate_links( array(
    243243            'base' => add_query_arg( 'fpage', '%#%' ),
     
    250250        ));
    251251    }
    252    
     252
    253253    function has_blogs() {
    254254        if ( $this->blog_count )
    255255            return true;
    256        
     256
    257257        return false;
    258258    }
    259    
     259
    260260    function next_blog() {
    261261        $this->current_blog++;
    262262        $this->blog = $this->blogs[$this->current_blog];
    263        
     263
    264264        return $this->blog;
    265265    }
    266    
     266
    267267    function rewind_blogs() {
    268268        $this->current_blog = -1;
     
    271271        }
    272272    }
    273    
    274     function user_blogs() { 
     273
     274    function user_blogs() {
    275275        if ( $this->current_blog + 1 < $this->blog_count ) {
    276276            return true;
     
    284284        return false;
    285285    }
    286    
     286
    287287    function the_blog() {
    288288        global $blog;
     
    290290        $this->in_the_loop = true;
    291291        $blog = $this->next_blog();
    292        
     292
    293293        if ( 0 == $this->current_blog ) // loop has just started
    294294            do_action('loop_start');
     
    324324function bp_blogs_pagination_count() {
    325325    global $bp, $blogs_template;
    326    
     326
    327327    $from_num = intval( ( $blogs_template->pag_page - 1 ) * $blogs_template->pag_num ) + 1;
    328328    $to_num = ( $from_num + ( $blogs_template->pag_num - 1 ) > $blogs_template->total_blog_count ) ? $blogs_template->total_blog_count : $from_num + ( $blogs_template->pag_num - 1 ) ;
     
    346346    function bp_get_blog_title() {
    347347        global $blogs_template;
    348            
    349         return apply_filters( 'bp_get_blog_title', $blogs_template->blog['title'] );
     348
     349        return apply_filters( 'bp_get_blog_title', $blogs_template->blog->name );
    350350    }
    351351
     
    355355    function bp_get_blog_description() {
    356356        global $blogs_template;
    357        
    358         return apply_filters( 'bp_get_blog_description', $blogs_template->blog['description'] );
     357
     358        return apply_filters( 'bp_get_blog_description', $blogs_template->blog->description );
    359359    }
    360360
     
    363363}
    364364    function bp_get_blog_permalink() {
    365         global $blogs_template; 
    366        
    367         return apply_filters( 'bp_get_blog_permalink', $blogs_template->blog['siteurl'] );
     365        global $blogs_template;
     366
     367        return apply_filters( 'bp_get_blog_permalink', $blogs_template->blog->siteurl );
    368368    }
    369369
     
    378378    var $posts;
    379379    var $post;
    380    
     380
    381381    var $in_the_loop;
    382    
     382
    383383    var $pag_page;
    384384    var $pag_num;
    385385    var $pag_links;
    386386    var $total_post_count;
    387    
     387
    388388    function bp_blogs_blog_post_template( $user_id, $per_page, $max ) {
    389389        global $bp;
    390        
     390
    391391        if ( !$user_id )
    392392            $user_id = $bp->displayed_user->id;
     
    394394        $this->pag_page = isset( $_GET['fpage'] ) ? intval( $_GET['fpage'] ) : 1;
    395395        $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page;
    396        
     396
    397397        if ( !$this->posts = wp_cache_get( 'bp_user_posts_' . $user_id, 'bp' ) ) {
    398398            $this->posts = bp_blogs_get_posts_for_user( $user_id );
    399399            wp_cache_set( 'bp_user_posts_' . $user_id, $this->posts, 'bp' );
    400400        }
    401        
     401
    402402        if ( !$max || $max >= (int)$this->posts['count'] )
    403403            $this->total_post_count = (int)$this->posts['count'];
    404404        else
    405405            $this->total_post_count = (int)$max;
    406        
     406
    407407        $this->posts = array_slice( (array)$this->posts['posts'], intval( ( $this->pag_page - 1 ) * $this->pag_num), intval( $this->pag_num ) );
    408408
     
    415415            $this->post_count = count($this->posts);
    416416        }
    417        
     417
    418418        $this->pag_links = paginate_links( array(
    419419            'base' => add_query_arg( 'fpage', '%#%' ),
     
    424424            'next_text' => '&raquo;',
    425425            'mid_size' => 1
    426         )); 
    427     }
    428    
     426        ));
     427    }
     428
    429429    function has_posts() {
    430430        if ( $this->post_count )
    431431            return true;
    432        
     432
    433433        return false;
    434434    }
    435    
     435
    436436    function next_post() {
    437437        $this->current_post++;
    438438        $this->post = $this->posts[$this->current_post];
    439        
     439
    440440        return $this->post;
    441441    }
    442    
     442
    443443    function rewind_posts() {
    444444        $this->current_post = -1;
     
    447447        }
    448448    }
    449    
    450     function user_posts() { 
     449
     450    function user_posts() {
    451451        if ( $this->current_post + 1 < $this->post_count ) {
    452452            return true;
     
    460460        return false;
    461461    }
    462    
     462
    463463    function the_post() {
    464464        global $post;
     
    466466        $this->in_the_loop = true;
    467467        $post = $this->next_post();
    468        
     468
    469469        if ( 0 == $this->current_post ) // loop has just started
    470470            do_action('loop_start');
     
    484484    extract( $r, EXTR_SKIP );
    485485
    486     $posts_template = new BP_Blogs_Blog_Post_Template( $user_id, $per_page, $max ); 
     486    $posts_template = new BP_Blogs_Blog_Post_Template( $user_id, $per_page, $max );
    487487    return apply_filters( 'bp_has_posts', $posts_template->has_posts(), &$posts_template );
    488488}
     
    500500function bp_post_pagination_count() {
    501501    global $bp, $posts_template;
    502    
     502
    503503    $from_num = intval( ( $posts_template->pag_page - 1 ) * $posts_template->pag_num ) + 1;
    504504    $to_num = ( $from_num + ( $posts_template->pag_num - 1 ) > $posts_template->total_post_count ) ? $posts_template->total_post_count : $from_num + ( $posts_template->pag_num - 1 ) ;
     
    522522    function bp_get_post_id() {
    523523        global $posts_template;
    524         return apply_filters( 'bp_get_post_id', $posts_template->post->ID );   
    525     }
    526    
     524        return apply_filters( 'bp_get_post_id', $posts_template->post->ID );
     525    }
     526
    527527function bp_post_title( $deprecated = true ) {
    528528    if ( !$deprecated )
     
    533533    function bp_get_post_title() {
    534534        global $posts_template;
    535        
     535
    536536        return apply_filters( 'bp_get_post_title', $posts_template->post->post_title );
    537537    }
     
    539539function bp_post_permalink() {
    540540    global $posts_template;
    541    
    542     echo bp_post_get_permalink();   
     541
     542    echo bp_post_get_permalink();
    543543}
    544544
    545545function bp_post_excerpt() {
    546     echo bp_get_post_excerpt(); 
     546    echo bp_get_post_excerpt();
    547547}
    548548    function bp_get_post_excerpt() {
    549549        global $posts_template;
    550         echo apply_filters( 'bp_get_post_excerpt', $posts_template->post->post_excerpt );   
     550        echo apply_filters( 'bp_get_post_excerpt', $posts_template->post->post_excerpt );
    551551    }
    552552
     
    567567    function bp_get_post_status() {
    568568        global $posts_template;
    569         return apply_filters( 'bp_get_post_status', $posts_template->post->post_status );   
    570     }
    571    
     569        return apply_filters( 'bp_get_post_status', $posts_template->post->post_status );
     570    }
     571
    572572function bp_post_date( $date_format = null, $deprecated = true ) {
    573573    if ( !$date_format )
    574574        $date_format = get_option('date_format');
    575        
     575
    576576    if ( !$deprecated )
    577577        return bp_get_post_date( $date_format );
     
    593593    function bp_get_post_comment_count() {
    594594        global $posts_template;
    595         return apply_filters( 'bp_get_post_comment_count', $posts_template->post->comment_count ); 
     595        return apply_filters( 'bp_get_post_comment_count', $posts_template->post->comment_count );
    596596    }
    597597
    598598function bp_post_comments( $zero = 'No Comments', $one = '1 Comment', $more = '% Comments', $css_class = '', $none = 'Comments Off' ) {
    599599    global $posts_template, $wpdb;
    600    
     600
    601601    $number = (int)$posts_template->post->comment_count;
    602    
     602
    603603    if ( 0 == $number && 'closed' == $posts_template->postcomment_status && 'closed' == $posts_template->postping_status ) {
    604604        echo '<span' . ((!empty($css_class)) ? ' class="' . $css_class . '"' : '') . '>' . $none . '</span>';
     
    614614
    615615    echo '<a href="';
    616    
     616
    617617    if ( 0 == $number )
    618618        echo bp_post_get_permalink() . '#respond';
     
    620620        echo bp_post_get_permalink() . '#comments';
    621621    echo '"';
    622    
     622
    623623    if ( !empty( $css_class ) ) {
    624624        echo ' class="'.$css_class.'" ';
     
    629629
    630630    echo ' title="' . sprintf( __('Comment on %s', 'buddypress'), $title ) . '">';
    631    
     631
    632632    if ( 1 == $number )
    633633        printf( __( '%d Comment', 'buddypress' ), $number );
    634634    else
    635635        printf( __( '%d Comments', 'buddypress' ), $number );
    636        
     636
    637637    echo '</a>';
    638638}
     
    646646    function bp_get_post_author() {
    647647        global $posts_template;
    648        
     648
    649649        return apply_filters( 'bp_get_post_author', bp_core_get_userlink( $posts_template->post->post_author ) );
    650650    }
     
    664664            $post_id = $posts_template->post->ID;
    665665
    666         return apply_filters( 'bp_get_post_category', get_the_category_list( $separator, $parents, $post_id ) );   
     666        return apply_filters( 'bp_get_post_category', get_the_category_list( $separator, $parents, $post_id ) );
    667667    }
    668668
    669669function bp_post_tags( $before = '', $sep = ', ', $after = '' ) {
    670670    global $posts_template, $wpdb;
    671    
     671
    672672    /* Disabling this for now as it's too expensive and there is no global tags directory */
    673673    return false;
    674    
     674
    675675    switch_to_blog( $posts_template->post->blog_id );
    676676    $terms = bp_post_get_term_list( $before, $sep, $after );
     
    692692    function bp_get_post_blog_name() {
    693693        global $posts_template;
    694         return apply_filters( 'bp_get_post_blog_name', get_blog_option( $posts_template->post->blog_id, 'blogname' ) ); 
     694        return apply_filters( 'bp_get_post_blog_name', get_blog_option( $posts_template->post->blog_id, 'blogname' ) );
    695695    }
    696696
    697697function bp_post_blog_permalink() {
    698     echo bp_get_post_blog_permalink(); 
     698    echo bp_get_post_blog_permalink();
    699699}
    700700    function bp_get_post_blog_permalink() {
    701701        global $posts_template;
    702         return apply_filters( 'bp_get_post_blog_permalink', get_blog_option( $posts_template->post->blog_id, 'siteurl' ) ); 
    703     }
    704    
     702        return apply_filters( 'bp_get_post_blog_permalink', get_blog_option( $posts_template->post->blog_id, 'siteurl' ) );
     703    }
     704
    705705function bp_post_get_permalink( $post = null, $blog_id = null ) {
    706706    global $current_blog, $posts_template;
    707    
     707
    708708    if ( !$post )
    709         $post = $posts_template->post; 
    710        
     709        $post = $posts_template->post;
     710
    711711    if ( !$blog_id )
    712712        $blog_id = $posts_template->post->blog_id;
    713        
     713
    714714    if ( !$post || !$blog_id )
    715715        return false;
    716        
     716
    717717    $rewritecode = array(
    718718        '%year%',
     
    735735
    736736    $permalink = get_blog_option( $blog_id, 'permalink_structure' );
    737     $site_url = get_blog_option( $blog_id, 'siteurl' ); 
     737    $site_url = get_blog_option( $blog_id, 'siteurl' );
    738738
    739739    if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending')) ) {
     
    753753            if ( empty($category) ) {
    754754                $default_category = get_category( get_option( 'default_category' ) );
    755                 $category = is_wp_error( $default_category ) ? '' : $default_category->slug; 
     755                $category = is_wp_error( $default_category ) ? '' : $default_category->slug;
    756756            }
    757757        }
     
    789789function bp_post_get_term_list( $before = '', $sep = '', $after = '' ) {
    790790    global $posts_template;
    791    
     791
    792792    $terms = get_the_terms( $posts_template->post->ID, 'post_tag' );
    793793
     
    801801        $link = get_blog_option( BP_ROOT_BLOG, 'siteurl') . '/tag/' . $term->slug;
    802802        $link = apply_filters('term_link', $link);
    803        
     803
    804804        $term_links[] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>';
    805805    }
     
    820820    var $comments;
    821821    var $comment;
    822    
     822
    823823    var $in_the_loop;
    824    
     824
    825825    var $pag_page;
    826826    var $pag_num;
    827827    var $pag_links;
    828828    var $total_comment_count;
    829    
     829
    830830    function bp_blogs_post_comment_template( $user_id, $per_page, $max ) {
    831831        global $bp;
    832        
     832
    833833        if ( !$user_id )
    834834            $user_id = $bp->displayed_user->id;
     
    836836        $this->pag_page = isset( $_GET['compage'] ) ? intval( $_GET['compage'] ) : 1;
    837837        $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page;
    838        
     838
    839839        if ( !$this->comments = wp_cache_get( 'bp_user_comments_' . $user_id, 'bp' ) ) {
    840840            $this->comments = bp_blogs_get_comments_for_user( $user_id );
    841841            wp_cache_set( 'bp_user_comments_' . $user_id, $this->comments, 'bp' );
    842842        }
    843        
     843
    844844        if ( !$max || $max >= (int)$this->comments['count'] )
    845845            $this->total_comment_count = (int)$this->comments['count'];
    846846        else
    847847            $this->total_comment_count = (int)$max;
    848        
     848
    849849        $this->comments = array_slice( (array)$this->comments['comments'], intval( ( $this->pag_page - 1 ) * $this->pag_num), intval( $this->pag_num ) );
    850850
     
    857857            $this->comment_count = count($this->comments);
    858858        }
    859        
     859
    860860        $this->pag_links = paginate_links( array(
    861861            'base' => add_query_arg( 'compage', '%#%' ),
     
    867867            'mid_size' => 1
    868868        ));
    869                
    870     }
    871    
     869
     870    }
     871
    872872    function has_comments() {
    873873        if ( $this->comment_count )
    874874            return true;
    875        
     875
    876876        return false;
    877877    }
    878    
     878
    879879    function next_comment() {
    880880        $this->current_comment++;
    881881        $this->comment = $this->comments[$this->current_comment];
    882        
     882
    883883        return $this->comment;
    884884    }
    885    
     885
    886886    function rewind_comments() {
    887887        $this->current_comment = -1;
     
    890890        }
    891891    }
    892    
    893     function user_comments() { 
     892
     893    function user_comments() {
    894894        if ( $this->current_comment + 1 < $this->comment_count ) {
    895895            return true;
     
    903903        return false;
    904904    }
    905    
     905
    906906    function the_comment() {
    907907        global $comment;
     
    909909        $this->in_the_loop = true;
    910910        $comment = $this->next_comment();
    911        
     911
    912912        if ( 0 == $this->current_comment ) // loop has just started
    913913            do_action('loop_start');
     
    926926    $r = wp_parse_args( $args, $defaults );
    927927    extract( $r, EXTR_SKIP );
    928    
     928
    929929    $comments_template = new BP_Blogs_Post_Comment_Template( $user_id, $per_page, $max );
    930930    return apply_filters( 'bp_has_comments', $comments_template->has_comments(), &$comments_template );
     
    946946    function bp_get_comments_pagination() {
    947947        global $comments_template;
    948        
     948
    949949        return apply_filters( 'bp_get_comments_pagination', $comments_template->pag_links );
    950950    }
     
    966966    function bp_get_comment_post_permalink() {
    967967        global $comments_template;
    968        
     968
    969969        return apply_filters( 'bp_get_comment_post_permalink', bp_post_get_permalink( $comments_template->comment->post, $comments_template->comment->blog_id ) . '#comment-' . $comments_template->comment->comment_ID );
    970970    }
     
    978978    function bp_get_comment_post_title( $deprecated = true ) {
    979979        global $comments_template;
    980        
     980
    981981        return apply_filters( 'bp_get_comment_post_title', $comments_template->comment->post->post_title );
    982982    }
     
    984984function bp_comment_author( $deprecated = true ) {
    985985    global $comments_template;
    986    
     986
    987987    if ( !$deprecated )
    988988        return bp_get_comment_author();
     
    10101010    if ( !$date_format )
    10111011        $date_format = get_option('date_format');
    1012        
     1012
    10131013    if ( !$deprecated )
    10141014        return bp_get_comment_date( $date_format );
    1015     else 
     1015    else
    10161016        echo bp_get_comment_date( $date_format );
    10171017}
     
    10271027function bp_comment_blog_permalink( $deprecated = true ) {
    10281028    if ( !$deprecated )
    1029         return bp_get_comment_blog_permalink(); 
     1029        return bp_get_comment_blog_permalink();
    10301030    else
    10311031        echo bp_get_comment_blog_permalink();
     
    10391039function bp_comment_blog_name( $deprecated = true ) {
    10401040    global $comments_template;
    1041    
     1041
    10421042    if ( !$deprecated )
    1043         return bp_get_comment_blog_permalink(); 
     1043        return bp_get_comment_blog_permalink();
    10441044    else
    1045         echo bp_get_comment_blog_permalink();   
     1045        echo bp_get_comment_blog_permalink();
    10461046}
    10471047    function bp_get_comment_blog_name( $deprecated = true ) {
     
    10601060    var $blogs;
    10611061    var $blog;
    1062    
     1062
    10631063    var $in_the_loop;
    1064    
     1064
    10651065    var $pag_page;
    10661066    var $pag_num;
    10671067    var $pag_links;
    10681068    var $total_blog_count;
    1069    
     1069
    10701070    function bp_blogs_site_blogs_template( $type, $per_page, $max ) {
    10711071        global $bp;
     
    10731073        $this->pag_page = isset( $_REQUEST['bpage'] ) ? intval( $_REQUEST['bpage'] ) : 1;
    10741074        $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    1075                
     1075
    10761076        if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) {
    10771077            $this->blogs = BP_Blogs_Blog::search_blogs( $_REQUEST['s'], $this->pag_num, $this->pag_page );
     
    10831083                    $this->blogs = BP_Blogs_Blog::get_random( $this->pag_num, $this->pag_page );
    10841084                    break;
    1085                
     1085
    10861086                case 'newest':
    10871087                    $this->blogs = BP_Blogs_Blog::get_newest( $this->pag_num, $this->pag_page );
    1088                     break; 
    1089                
     1088                    break;
     1089
    10901090                case 'active': default:
    10911091                    $this->blogs = BP_Blogs_Blog::get_active( $this->pag_num, $this->pag_page );
    1092                     break;                 
     1092                    break;
    10931093            }
    10941094        }
    1095        
     1095
    10961096        if ( !$max || $max >= (int)$this->blogs['total'] )
    10971097            $this->total_blog_count = (int)$this->blogs['total'];
     
    11091109            $this->blog_count = count($this->blogs);
    11101110        }
    1111        
     1111
    11121112        $this->pag_links = paginate_links( array(
    11131113            'base' => add_query_arg( 'bpage', '%#%' ),
     
    11181118            'next_text' => '&raquo;',
    11191119            'mid_size' => 1
    1120         ));     
    1121     }
    1122    
     1120        ));
     1121    }
     1122
    11231123    function has_blogs() {
    11241124        if ( $this->blog_count )
    11251125            return true;
    1126        
     1126
    11271127        return false;
    11281128    }
    1129    
     1129
    11301130    function next_blog() {
    11311131        $this->current_blog++;
    11321132        $this->blog = $this->blogs[$this->current_blog];
    1133        
     1133
    11341134        return $this->blog;
    11351135    }
    1136    
     1136
    11371137    function rewind_blogs() {
    11381138        $this->current_blog = -1;
     
    11411141        }
    11421142    }
    1143    
    1144     function blogs() { 
     1143
     1144    function blogs() {
    11451145        if ( $this->current_blog + 1 < $this->blog_count ) {
    11461146            return true;
     
    11541154        return false;
    11551155    }
    1156    
     1156
    11571157    function the_blog() {
    11581158        global $blog;
     
    11601160        $this->in_the_loop = true;
    11611161        $this->blog = $this->next_blog();
    1162        
     1162
    11631163        if ( 0 == $this->current_blog ) // loop has just started
    11641164            do_action('loop_start');
     
    11681168function bp_rewind_site_blogs() {
    11691169    global $site_blogs_template;
    1170    
    1171     $site_blogs_template->rewind_blogs();   
     1170
     1171    $site_blogs_template->rewind_blogs();
    11721172}
    11731173
     
    11831183    $r = wp_parse_args( $args, $defaults );
    11841184    extract( $r, EXTR_SKIP );
    1185    
     1185
    11861186    // type: active ( default ) | random | newest | popular
    1187    
     1187
    11881188    if ( $max ) {
    11891189        if ( $per_page > $max )
    11901190            $per_page = $max;
    11911191    }
    1192        
     1192
    11931193    $site_blogs_template = new BP_Blogs_Site_Blogs_Template( $type, $per_page, $max );
    11941194
     
    11981198function bp_site_blogs() {
    11991199    global $site_blogs_template;
    1200    
     1200
    12011201    return $site_blogs_template->blogs();
    12021202}
     
    12041204function bp_the_site_blog() {
    12051205    global $site_blogs_template;
    1206    
     1206
    12071207    return $site_blogs_template->the_blog();
    12081208}
     
    12101210function bp_site_blogs_pagination_count() {
    12111211    global $bp, $site_blogs_template;
    1212    
     1212
    12131213    $from_num = intval( ( $site_blogs_template->pag_page - 1 ) * $site_blogs_template->pag_num ) + 1;
    12141214    $to_num = ( $from_num + ( $site_blogs_template->pag_num - 1 ) > $site_blogs_template->total_blog_count ) ? $site_blogs_template->total_blog_count : $from_num + ( $site_blogs_template->pag_num - 1 ) ;
     
    12261226        return apply_filters( 'bp_get_site_blogs_pagination_links', $site_blogs_template->pag_links );
    12271227    }
    1228    
     1228
    12291229function bp_the_site_blog_avatar() {
    12301230    echo bp_get_the_site_blog_avatar();
     
    12321232    function bp_get_the_site_blog_avatar() {
    12331233        global $site_blogs_template, $bp;
    1234        
     1234
    12351235        /***
    12361236         * In future BuddyPress versions you will be able to set the avatar for a blog.
     
    13091309        echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ). '" name="search_terms" />';
    13101310    }
    1311    
     1311
    13121312    if ( isset( $_REQUEST['letter'] ) ) {
    13131313        echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
    13141314    }
    1315    
     1315
    13161316    if ( isset( $_REQUEST['blogs_search'] ) ) {
    13171317        echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['blogs_search'] ) . '" name="search_terms" />';
Note: See TracChangeset for help on using the changeset viewer.