Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/25/2009 04:01:43 PM (15 years ago)
Author:
apeatling
Message:

Removed blogs, groups and members directory from the home theme into the BuddyPress member theme. The directories now have their own templates and theme based CSS and provide much easier editing.

Moved the $bp global setup to a higher priority action - from the 'wp' action to the 'plugins_loaded' action. This stops occurrences where the $bp global was not defined yet.

File:
1 edited

Legend:

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

    r1138 r1250  
    55    check_ajax_referer('directory_blogs');
    66   
    7     $pag_page = isset( $_POST['page'] ) ? intval( $_POST['page'] ) : 1;
    8     $pag_num = isset( $_POST['num'] ) ? intval( $_POST['num'] ) : 10;
    9    
    10     if ( isset( $_POST['letter'] ) && $_POST['letter'] != '' ) {
    11         $blogs = BP_Blogs_Blog::get_by_letter( $_POST['letter'], $pag_num, $pag_page );
    12     } else if ( isset ( $_POST['blogs_search'] ) && $_POST['blogs_search'] != '' ) {
    13         $blogs = BP_Blogs_Blog::search_blogs( $_POST['blogs_search'], $pag_num, $pag_page );
    14     } else {
    15         $blogs = BP_Blogs_Blog::get_all( $pag_num, $pag_page );
    16     }
    17    
    18     $pag_links = paginate_links( array(
    19         'base' => add_query_arg( 'page', '%#%' ),
    20         'format' => '',
    21         'total' => ceil( $blogs['total'] / $pag_num ),
    22         'current' => $pag_page,
    23         'prev_text' => '«',
    24         'next_text' => '»',
    25         'mid_size' => 1
    26     ));
    27    
    28     $from_num = intval( ( $pag_page - 1 ) * $pag_num ) + 1;
    29     $to_num = ( $from_num + 9 > $blogs['total'] ) ? $blogs['total'] : $from_num + 9;
    30 
    31     if ( $blogs['blogs'] ) {
    32         echo '0[[SPLIT]]'; // return valid result.
    33        
    34         ?>
    35         <div id="blog-dir-count" class="pag-count">
    36             <?php echo sprintf( __( 'Viewing blog %d to %d (%d total active blogs)', 'buddypress' ), $from_num, $to_num, $blogs['total'] ); ?> &nbsp;
    37             <img id="ajax-loader-blogs" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( "Loading", "buddypress" ) ?>" style="display: none;" />
    38         </div>
    39    
    40         <div class="pagination-links" id="blog-dir-pag">
    41             <?php echo $pag_links ?>
    42         </div>
    43 
    44         <ul id="blogs-list" class="item-list">
    45         <?php foreach ( $blogs['blogs'] as $blog ) : ?>
    46             <li>
    47                 <div class="item-avatar">
    48                     <img src="<?php echo 'http://www.gravatar.com/avatar/' . md5( $blog->blog_id . '.blogs@' . $bp->root_domain ) . '?d=identicon&amp;s=50'; ?>" class="avatar" alt="<?php _e( 'Blog Identicon', 'buddypress' ) ?>" />
    49                 </div>
    50 
    51                 <div class="item">
    52                     <div class="item-title"><a href="<?php echo get_blog_option( $blog->blog_id, 'siteurl' ) ?>" title="<?php echo get_blog_option( $blog->blog_id, 'blogname' ) ?>"><?php echo get_blog_option( $blog->blog_id, 'blogname' ) ?></a></div>
    53                     <div class="item-meta"><span class="activity"><?php echo bp_core_get_last_activity( bp_blogs_get_blogmeta( $blog->blog_id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) ) ?></span></div>
    54                 </div>
    55                
    56                 <div class="action">
    57                     <div class="blog-button visit">
    58                         <a href="<?php echo get_blog_option( $blog->blog_id, 'siteurl' ) ?>" class="visit" title="<?php printf( __( 'Visit %s', 'buddypress' ), get_blog_option( $blog->blog_id, 'blogname' ) ) ?>"><?php _e( 'Visit Blog', 'buddypress' ) ?></a>
    59                     </div>
    60                     <div class="meta">
    61                         <?php
    62                             if ( $post = bp_blogs_get_latest_posts( $blog->blog_id, 1 ) ) {
    63                                 printf( __( 'Latest Post: %s', 'buddypress' ), '<a href="' . bp_post_get_permalink( $post[0], $blog->blog_id ) . '">' . apply_filters( 'the_title', $post[0]->post_title ) . '</a>' );
    64                             }
    65                         ?>
    66                     </div>
    67                 </div>
    68                
    69                 <div class="clear"></div>
    70             </li>
    71         <?php endforeach; ?>
    72         </ul>   
    73     <?php
    74     } else {
    75         echo "-1[[SPLIT]]<div id='message' class='error'><p>" . __("No blogs matched the current filter.", 'buddypress') . '</p></div>';
    76     }
    77    
    78     if ( isset( $_POST['letter'] ) ) {
    79         echo '<input type="hidden" id="selected_letter" value="' . $_POST['letter'] . '" name="selected_letter" />';
    80     }
    81    
    82     if ( isset( $_POST['blogs_search'] ) ) {
    83         echo '<input type="hidden" id="search_terms" value="' . $_POST['blogs_search'] . '" name="search_terms" />';
    84     }
    85 
     7    load_template( TEMPLATEPATH . '/directories/blogs/blogs-loop.php' );
    868}
    879add_action( 'wp_ajax_directory_blogs', 'bp_blogs_ajax_directory_blogs' );
Note: See TracChangeset for help on using the changeset viewer.