Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/25/2009 04:01:43 PM (17 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-groups/bp-groups-ajax.php

    r1238 r1250  
    212212
    213213        check_ajax_referer('directory_groups');
    214        
    215         $pag_page = isset( $_POST['page'] ) ? intval( $_POST['page'] ) : 1;
    216         $pag_num = isset( $_POST['num'] ) ? intval( $_POST['num'] ) : 10;
    217        
    218         if ( isset( $_POST['letter'] ) && $_POST['letter'] != '' ) {
    219                 $groups = BP_Groups_Group::get_by_letter( $_POST['letter'], $pag_num, $pag_page );
    220         } else if ( isset ( $_POST['groups_search'] ) && $_POST['groups_search'] != '' ) {
    221                 $groups = BP_Groups_Group::search_groups( $_POST['groups_search'], $pag_num, $pag_page );
    222         } else {
    223                 $groups = BP_Groups_Group::get_active( $pag_num, $pag_page );
    224         }
    225        
    226         $pag_links = paginate_links( array(
    227                 'base' => add_query_arg( 'page', '%#%' ),
    228                 'format' => '',
    229                 'total' => ceil( $groups['total'] / $pag_num ),
    230                 'current' => $pag_page,
    231                 'prev_text' => '«',
    232                 'next_text' => '»',
    233                 'mid_size' => 1
    234         ));
    235        
    236         $from_num = intval( ( $pag_page - 1 ) * $pag_num ) + 1;
    237         $to_num = ( $from_num + 9 > $groups['total'] ) ? $groups['total'] : $from_num + 9;
    238 
    239         if ( $groups['groups'] ) {
    240                 echo '0[[SPLIT]]'; // return valid result.
    241                
    242                 ?>
    243                 <div id="group-dir-count" class="pag-count">
    244                         <?php echo sprintf( __( 'Viewing group %d to %d (%d total active groups)', 'buddypress' ), $from_num, $to_num, $groups['total'] ); ?> &nbsp;
    245                         <img id="ajax-loader-groups" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( "Loading", "buddypress" ) ?>" style="display: none;" />
    246                 </div>
    247        
    248                 <div class="pagination-links" id="group-dir-pag">
    249                         <?php echo $pag_links ?>
    250                 </div>
    251                
    252                 <?php $counter = 0; ?>
    253                 <ul id="groups-list" class="item-list">
    254                 <?php foreach ( $groups['groups'] as $group_id ) : ?>
    255                        
    256                         <?php $alt = ( $counter % 2 == 1 ) ? ' class="alt"' : ''; ?>
    257                         <?php
    258                                 if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_id->group_id, 'bp' ) ) {
    259                                         $group = new BP_Groups_Group( $group_id->group_id, false, false );
    260                                         wp_cache_set( 'groups_group_nouserdata_' . $group_id->group_id, $group, 'bp' );
    261                                 }       
    262                         ?>
    263                        
    264                         <li<?php echo $alt ?>>
    265                                 <div class="item-avatar">
    266                                         <img src="<?php echo $group->avatar_thumb ?>" class="avatar" alt="<?php echo $group->name ?> <?php _e( 'Avatar', 'buddypress' ) ?>" />
    267                                 </div>
    268 
    269                                 <div class="item">
    270                                         <div class="item-title"><a href="<?php echo bp_group_permalink( $group ) ?>" title="<?php echo $group->name ?>"><?php echo $group->name ?></a></div>
    271                                         <div class="item-meta"><span class="activity"><?php echo bp_core_get_last_activity( groups_get_groupmeta( $group->id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) ) ?></span></div>
    272                                         <div class="item-meta desc"><?php echo bp_create_excerpt( $group->description ) ?></div>
    273                                 </div>
    274                        
    275                                 <div class="action">
    276                                         <?php bp_group_join_button( $group ) ?>
    277                                         <div class="meta">
    278                                                 <?php $member_count = groups_get_groupmeta( $group->id, 'total_member_count' ) ?>
    279                                                 <?php echo ucwords($group->status) ?> <?php _e( 'Group', 'buddypress' ) ?> /
    280                                                 <?php if ( 1 == $member_count ) : ?>
    281                                                         <?php printf( __( '%d member', 'buddypress' ), $member_count ) ?>
    282                                                 <?php else : ?>
    283                                                         <?php printf( __( '%d members', 'buddypress' ), $member_count ) ?>
    284                                                 <?php endif; ?>
    285                                         </div>
    286                                 </div>
    287                        
    288                                 <div class="clear"></div>
    289                         </li>
    290                        
    291                         <?php $counter++ ?>
    292                 <?php endforeach; ?>
    293                 </ul>   
    294         <?php
    295         } else {
    296                 echo "-1[[SPLIT]]<div id='message' class='error'><p>" . __("No groups matched the current filter.", 'buddypress') . '</p></div>';
    297         }
    298        
    299         if ( isset( $_POST['letter'] ) ) {
    300                 echo '<input type="hidden" id="selected_letter" value="' . $_POST['letter'] . '" name="selected_letter" />';
    301         }
    302        
    303         if ( isset( $_POST['groups_search'] ) ) {
    304                 echo '<input type="hidden" id="search_terms" value="' . $_POST['groups_search'] . '" name="search_terms" />';
    305         }
    306 
     214
     215        load_template( TEMPLATEPATH . '/directories/groups/groups-loop.php' );
    307216}
    308217add_action( 'wp_ajax_directory_groups', 'bp_core_ajax_directory_groups' );
Note: See TracChangeset for help on using the changeset viewer.