Skip to:
Content

BuddyPress.org

Changeset 1602


Ignore:
Timestamp:
07/15/2009 12:47:21 AM (15 years ago)
Author:
apeatling
Message:

Updating BuddyPress widgets to support new widget API.

Location:
branches/1.0
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/1.0/bp-activity/bp-activity-widgets.php

    r1520 r1602  
    33/* Register widgets for blogs component */
    44function bp_activity_register_widgets() {
    5     global $current_blog;
    6 
    7     /* Site Wide Activity Widget */
    8     wp_register_sidebar_widget( 'buddypress-activity', __('Site Wide Activity', 'buddypress'), 'bp_activity_widget_sitewide_activity');
    9     wp_register_widget_control( 'buddypress-activity', __('Site Wide Activity', 'buddypress'), 'bp_activity_widget_sitewide_activity_control' );
    10 
    11     if ( is_active_widget( 'bp_activity_widget_sitewide_activity' ) ) {
    12         wp_enqueue_style( 'bp-activity-widget-activity-css', BP_PLUGIN_URL . '/bp-activity/css/widget-activity.css' );     
    13     }
     5    add_action('widgets_init', create_function('', 'return register_widget("BP_Activity_Widget");') );
    146}
    157add_action( 'plugins_loaded', 'bp_activity_register_widgets' );
    168
    17 
    18 function bp_activity_widget_sitewide_activity($args) {
    19     global $bp, $current_blog;
    20    
    21     extract($args);
    22     $options = get_blog_option( $current_blog->blog_id, 'bp_activity_widget_sitewide_activity' );
    23 ?>
    24     <?php echo $before_widget; ?>
    25     <?php echo $before_title
    26         . $widget_name
    27         . $after_title; ?>
    28        
    29     <?php
    30     if ( !$options['max_items'] || empty( $options['max_items'] ) )
    31         $options['max_items'] = 20;
    32     ?>
    33    
    34     <?php
    35     if ( !$activity = wp_cache_get( 'sitewide_activity', 'bp' ) ) {
    36         $activity = bp_activity_get_sitewide_activity( $options['max_items'] );
    37         wp_cache_set( 'sitewide_activity', $activity, 'bp' );
    38     }
    39     ?>
    40 
    41     <?php if ( $activity['activities'] ) : ?>
    42         <div class="item-options" id="activity-list-options">
    43             <img src="<?php echo $bp->activity->image_base; ?>/rss.png" alt="<?php _e( 'RSS Feed', 'buddypress' ) ?>" /> <a href="<?php bp_sitewide_activity_feed_link() ?>" title="<?php _e( 'Site Wide Activity RSS Feed', 'buddypress' ) ?>"><?php _e( 'RSS Feed', 'buddypress' ) ?></a>
    44         </div>
    45         <ul id="site-wide-stream" class="activity-list">
    46         <?php foreach( $activity['activities'] as $item ) : ?>
    47             <li class="<?php echo $item['component_name'] ?>">
    48                 <?php echo apply_filters( 'bp_get_activity_content', bp_activity_content_filter( $item['content'], $item['date_recorded'], '', true, false, true ) ); ?>
    49             </li>
    50         <?php endforeach; ?>
    51         </ul>
    52     <?php else: ?>
    53         <div class="widget-error">
    54             <?php _e('There has been no recent site activity.', 'buddypress') ?>
    55         </div>
    56     <?php endif; ?>
    57 
    58     <?php echo $after_widget; ?>
    59 <?php
    60 }
    61 
    62 function bp_activity_widget_sitewide_activity_control() {
    63     global $current_blog;
    64    
    65     $options = $newoptions = get_blog_option( $current_blog->blog_id, 'bp_activity_widget_sitewide_activity');
    66 
    67     if ( $_POST['bp-activity-widget-sitewide-submit'] ) {
    68         $newoptions['max_items'] = strip_tags( stripslashes( $_POST['bp-activity-widget-sitewide-items-max'] ) );
    69     }
    70    
    71     if ( $options != $newoptions ) {
    72         $options = $newoptions;
    73         update_blog_option( $current_blog->blog_id, 'bp_activity_widget_sitewide_activity', $options );
     9class BP_Activity_Widget extends WP_Widget {
     10    function bp_activity_widget() {
     11        parent::WP_Widget( false, $name = 'Site Wide Activity' );
     12        wp_enqueue_style( 'bp-activity-widget-activity-css', BP_PLUGIN_URL . '/bp-activity/css/widget-activity.css' );     
    7413    }
    7514
     15    function widget($args, $instance) {
     16        global $bp;
     17       
     18        extract( $args );
     19       
     20        echo $before_widget;
     21        echo $before_title
     22           . $widget_name
     23           . $after_title; ?>
     24   
     25        <?php
     26        if ( empty( $instance['max_items'] ) || !$instance['max_items'] )
     27            $instance['max_items'] = 30; ?>
     28       
     29        <?php
     30        if ( !$activity = wp_cache_get( 'sitewide_activity', 'bp' ) ) {
     31            $activity = bp_activity_get_sitewide_activity( $instance['max_items'] );
     32            wp_cache_set( 'sitewide_activity', $activity, 'bp' );
     33        }
     34        ?>
     35
     36        <?php if ( $activity['activities'] ) : ?>
     37            <div class="item-options" id="activity-list-options">
     38                <img src="<?php echo $bp->activity->image_base; ?>/rss.png" alt="<?php _e( 'RSS Feed', 'buddypress' ) ?>" /> <a href="<?php bp_sitewide_activity_feed_link() ?>" title="<?php _e( 'Site Wide Activity RSS Feed', 'buddypress' ) ?>"><?php _e( 'RSS Feed', 'buddypress' ) ?></a>
     39            </div>
     40            <ul id="site-wide-stream" class="activity-list">
     41            <?php foreach( $activity['activities'] as $item ) : ?>
     42                <li class="<?php echo $item['component_name'] ?>">
     43                    <?php echo apply_filters( 'bp_get_activity_content', bp_activity_content_filter( $item['content'], $item['date_recorded'], '', true, false, true ) ); ?>
     44                </li>
     45            <?php endforeach; ?>
     46            </ul>
     47        <?php else: ?>
     48            <div class="widget-error">
     49                <?php _e('There has been no recent site activity.', 'buddypress') ?>
     50            </div>
     51        <?php endif; ?>
     52           
     53        <?php echo $after_widget; ?>
     54    <?php
     55    }
     56
     57    function update( $new_instance, $old_instance ) {
     58        $instance = $old_instance;
     59        $instance['max_items'] = strip_tags( $new_instance['max_items'] );
     60
     61        return $instance;
     62    }
     63
     64    function form( $instance ) {
     65        $instance = wp_parse_args( (array) $instance, array( 'max_items' => 30 ) );
     66        $max_items = strip_tags( $instance['max_items'] );
     67        ?>
     68
     69        <p><label for="bp-core-widget-members-max"><?php _e('Max items to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_items' ); ?>" name="<?php echo $this->get_field_name( 'max_items' ); ?>" type="text" value="<?php echo attribute_escape( $max_items ); ?>" style="width: 30%" /></label></p>
     70    <?php
     71    }
     72}
    7673?>
    77         <p><label for="bp-activity-widget-sitewide-items-max"><?php _e('Max Number of Items:', 'buddypress'); ?> <input class="widefat" id="bp-activity-widget-sitewide-items-max" name="bp-activity-widget-sitewide-items-max" type="text" value="<?php echo attribute_escape( $options['max_items'] ); ?>" style="width: 30%" /></label></p>
    78         <input type="hidden" id="bp-activity-widget-sitewide-submit" name="bp-activity-widget-sitewide-submit" value="1" />
    79 <?php
    80 }
    81 
    82 ?>
  • branches/1.0/bp-blogs/bp-blogs-widgets.php

    r1520 r1602  
    33/* Register widgets for blogs component */
    44function bp_blogs_register_widgets() {
    5     global $current_blog;
    6 
    7     /* Latest Posts Widget */
    8     wp_register_sidebar_widget( 'buddypress-blogs', __('Recent Blog Posts', 'buddypress'), 'bp_blogs_widget_recent_posts');
    9     wp_register_widget_control( 'buddypress-blogs', __('Recent Blog Posts', 'buddypress'), 'bp_blogs_widget_recent_posts_control' );
    10 
    11     if ( is_active_widget( 'bp_blogs_widget_recent_posts' ) ) {
    12         wp_enqueue_style( 'bp-blogs-widget-posts-css', BP_PLUGIN_URL . '/bp-blogs/css/widget-blogs.css' );     
    13     }
     5    add_action('widgets_init', create_function('', 'return register_widget("BP_Blogs_Recent_Posts_Widget");') );
    146}
    157add_action( 'plugins_loaded', 'bp_blogs_register_widgets' );
    168
    17 
    18 function bp_blogs_widget_recent_posts($args) {
    19     global $current_blog;
    20    
    21     extract($args);
    22     $options = get_blog_option( $current_blog->blog_id, 'bp_blogs_widget_recent_posts' );
    23    
    24     if ( empty( $options['max_posts'] ) || !$options['max_posts'] )
    25         $options['max_posts'] = 5;
    26 ?>
    27     <?php echo $before_widget; ?>
    28     <?php echo $before_title
    29         . $widget_name
    30         . $after_title; ?>
    31 
    32     <?php $posts = bp_blogs_get_latest_posts( null, $options['max_posts'] ) ?>
    33     <?php $counter = 0; ?>
    34        
    35     <?php if ( $posts ) : ?>
    36         <div class="item-options" id="recent-posts-options">
    37             <?php _e("Site Wide", 'buddypress') ?>
    38         </div>
    39         <ul id="recent-posts" class="item-list">
    40             <?php foreach ( $posts as $post ) : ?>
    41                 <li>
    42                     <div class="item-avatar">
    43                         <a href="<?php echo bp_post_get_permalink( $post, $post->blog_id ) ?>" title="<?php echo apply_filters( 'the_title', $post->post_title ) ?>"><?php echo bp_core_get_avatar( $post->post_author, 1 ) ?></a>
    44                     </div>
    45 
    46                     <div class="item">
    47                         <h4 class="item-title"><a href="<?php echo bp_post_get_permalink( $post, $post->blog_id ) ?>" title="<?php echo apply_filters( 'the_title', $post->post_title ) ?>"><?php echo apply_filters( 'the_title', $post->post_title ) ?></a></h4>
    48                         <?php if ( !$counter ) : ?>
    49                             <div class="item-content"><?php echo bp_create_excerpt($post->post_content) ?></div>
    50                         <?php endif; ?>
    51                         <div class="item-meta"><em><?php printf( __( 'by %s from the blog <a href="%s">%s</a>', 'buddypress' ), bp_core_get_userlink( $post->post_author ), get_blog_option( $post->blog_id, 'siteurl' ), get_blog_option( $post->blog_id, 'blogname' ) ) ?></em></div>
    52                     </div>
    53                 </li>
    54                 <?php $counter++; ?>   
    55             <?php endforeach; ?>
    56         </ul>
    57     <?php else: ?>
    58         <div class="widget-error">
    59             <?php _e('There are no recent blog posts, why not write one?', 'buddypress') ?>
    60         </div>
    61     <?php endif; ?>
    62 
    63     <?php echo $after_widget; ?>
    64 <?php
    65 }
    66 
    67 function bp_blogs_widget_recent_posts_control() {
    68     global $current_blog;
    69    
    70     $options = $newoptions = get_blog_option( $current_blog->blog_id, 'bp_blogs_widget_recent_posts');
    71 
    72     if ( $_POST['bp-blogs-widget-recent-posts-submit'] ) {
    73         $newoptions['max_posts'] = strip_tags( stripslashes( $_POST['bp-blogs-widget-recent-posts-max'] ) );
    74     }
    75    
    76     if ( $options != $newoptions ) {
    77         $options = $newoptions;
    78         update_blog_option( $current_blog->blog_id, 'bp_blogs_widget_recent_posts', $options );
     9class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
     10    function bp_blogs_recent_posts_widget() {
     11        parent::WP_Widget( false, $name = 'Recent Site Wide Posts' );
     12        wp_enqueue_style( 'bp-blogs-widget-posts-css', BP_PLUGIN_URL . '/bp-blogs/css/widget-blogs.css' );     
    7913    }
    8014
     15    function widget($args, $instance) {
     16        global $bp;
     17       
     18        extract( $args );
     19       
     20        echo $before_widget;
     21        echo $before_title
     22           . $widget_name
     23           . $after_title; ?>
     24   
     25        <?php
     26        if ( empty( $instance['max_posts'] ) || !$instance['max_posts'] )
     27            $instance['max_posts'] = 10; ?>
     28       
     29        <?php $posts = bp_blogs_get_latest_posts( null, $instance['max_posts'] ) ?>
     30        <?php $counter = 0; ?>
     31       
     32        <?php if ( $posts ) : ?>
     33            <div class="item-options" id="recent-posts-options">
     34                <?php _e("Site Wide", 'buddypress') ?>
     35            </div>
     36            <ul id="recent-posts" class="item-list">
     37                <?php foreach ( $posts as $post ) : ?>
     38                    <li>
     39                        <div class="item-avatar">
     40                            <a href="<?php echo bp_post_get_permalink( $post, $post->blog_id ) ?>" title="<?php echo apply_filters( 'the_title', $post->post_title ) ?>"><?php echo bp_core_get_avatar( $post->post_author, 1 ) ?></a>
     41                        </div>
     42
     43                        <div class="item">
     44                            <h4 class="item-title"><a href="<?php echo bp_post_get_permalink( $post, $post->blog_id ) ?>" title="<?php echo apply_filters( 'the_title', $post->post_title ) ?>"><?php echo apply_filters( 'the_title', $post->post_title ) ?></a></h4>
     45                            <?php if ( !$counter ) : ?>
     46                                <div class="item-content"><?php echo bp_create_excerpt($post->post_content) ?></div>
     47                            <?php endif; ?>
     48                            <div class="item-meta"><em><?php printf( __( 'by %s from the blog <a href="%s">%s</a>', 'buddypress' ), bp_core_get_userlink( $post->post_author ), get_blog_option( $post->blog_id, 'siteurl' ), get_blog_option( $post->blog_id, 'blogname' ) ) ?></em></div>
     49                        </div>
     50                    </li>
     51                    <?php $counter++; ?>   
     52                <?php endforeach; ?>
     53            </ul>
     54        <?php else: ?>
     55            <div class="widget-error">
     56                <?php _e('There are no recent blog posts, why not write one?', 'buddypress') ?>
     57            </div>
     58        <?php endif; ?>
     59           
     60        <?php echo $after_widget; ?>
     61    <?php
     62    }
     63
     64    function update( $new_instance, $old_instance ) {
     65        $instance = $old_instance;
     66        $instance['max_posts'] = strip_tags( $new_instance['max_posts'] );
     67
     68        return $instance;
     69    }
     70
     71    function form( $instance ) {
     72        $instance = wp_parse_args( (array) $instance, array( 'max_posts' => 10 ) );
     73        $max_posts = strip_tags( $instance['max_posts'] );
     74        ?>
     75
     76        <p><label for="bp-blogs-widget-posts-max"><?php _e('Max posts to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="text" value="<?php echo attribute_escape( $max_posts ); ?>" style="width: 30%" /></label></p>
     77    <?php
     78    }
     79}
    8180?>
    82         <p><label for="bp-blogs-widget-recent-posts-max"><?php _e('Max Number of Posts:', 'buddypress'); ?> <input class="widefat" id="bp-blogs-widget-recent-posts-max" name="bp-blogs-widget-recent-posts-max" type="text" value="<?php echo attribute_escape( $options['max_posts'] ); ?>" style="width: 30%" /></label></p>
    83         <input type="hidden" id="bp-blogs-widget-recent-posts-submit" name="bp-blogs-widget-recent-posts-submit" value="1" />
    84 <?php
    85 }
    86 
    87 ?>
  • branches/1.0/bp-blogs/css/widget-blogs.css

    r1366 r1602  
    1 .bp_blogs_widget_recent_posts ul.item-list {
     1.widget_bp_blogs_recent_posts_widget ul.item-list {
    22    margin: 15px 0 0 0;
    33    padding: 0;
     
    55}
    66   
    7     .bp_blogs_widget_recent_posts ul.item-list li {
     7    .widget_bp_blogs_recent_posts_widget ul.item-list li {
    88        min-height: 60px;
    99    }
    1010   
    11     .bp_blogs_widget_recent_posts ul.item-list li .item-meta {
    12         margin-left: 35px;
     11    .widget_bp_blogs_recent_posts_widget ul.item-list li .item-meta {
     12        margin-left: 10px;
    1313    }
    14         .bp_blogs_widget_recent_posts ul.item-list li .item h4.item-title {
     14        .widget_bp_blogs_recent_posts_widget ul.item-list li .item h4.item-title {
    1515            clear: none !important;
    1616        }
    1717   
    18     .bp_blogs_widget_recent_posts ul.item-list li .item-avatar {
     18    .widget_bp_blogs_recent_posts_widget ul.item-list li .item-avatar {
    1919        float: left;
    2020        margin: 0 10px 0 0;
    2121    }
    22         .bp_blogs_widget_recent_posts ul.item-list li .item-avatar img.avatar {
     22        .widget_bp_blogs_recent_posts_widget ul.item-list li .item-avatar img.avatar {
    2323            width: 25px;
    2424            height: 25px;
    2525        }
    2626   
    27     .bp_blogs_widget_recent_posts ul li em {
     27    .widget_bp_blogs_recent_posts_widget ul li em {
    2828        font-size: 11px;
    2929    }
  • branches/1.0/bp-core/bp-core-templatetags.php

    r1582 r1602  
    865865        $this->member = $this->next_member();
    866866        $user_id = $this->member->user_id;
     867        $user_registered = $this->member->user_registered;
    867868
    868869        if ( !$this->member = wp_cache_get( 'bp_user_' . $user_id, 'bp' ) ) {
     
    871872        }
    872873       
     874        if ( $user_registered )
     875            $this->member->user_registered = $user_registered;
     876           
    873877        if ( 0 == $this->current_member ) // loop has just started
    874878            do_action('loop_start');
     
    979983
    980984        return apply_filters( 'bp_the_site_member_last_active', $site_members_template->member->last_active );
     985    }
     986
     987function bp_the_site_member_registered() {
     988    echo bp_get_the_site_member_registered();
     989}
     990    function bp_get_the_site_member_registered() {
     991        global $site_members_template;
     992
     993        return apply_filters( 'bp_the_site_member_last_active', strtotime( $site_members_template->member->user_registered ) );
    981994    }
    982995   
  • branches/1.0/bp-core/bp-core-widgets.php

    r1520 r1602  
    33/* Register widgets for the core component */
    44function bp_core_register_widgets() {
    5     global $current_blog;
    6    
    7     /* Site welcome widget */
    8     wp_register_sidebar_widget( 'buddypress-welcome', __( 'Welcome', 'buddypress' ), 'bp_core_widget_welcome' );
    9     wp_register_widget_control( 'buddypress-welcome', __( 'Welcome', 'buddypress' ), 'bp_core_widget_welcome_control' );
    10    
    11     /* Site members widget */
    12     wp_register_sidebar_widget( 'buddypress-members', __( 'Members', 'buddypress' ), 'bp_core_widget_members' );
    13     wp_register_widget_control( 'buddypress-members', __( 'Members', 'buddypress' ), 'bp_core_widget_members_control' );
    14    
    15     /* Include the javascript needed for activated widgets only */
    16     if ( is_active_widget( 'bp_core_widget_members' ) ) {
     5    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Welcome_Widget");') );
     6    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Members_Widget");') );
     7    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Whos_Online_Widget");') );
     8    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Recently_Active_Widget");') );
     9}
     10add_action( 'plugins_loaded', 'bp_core_register_widgets' );
     11
     12/*** WELCOME WIDGET *****************/
     13
     14class BP_Core_Welcome_Widget extends WP_Widget {
     15    function bp_core_welcome_widget() {
     16        parent::WP_Widget( false, $name = 'Welcome' );
     17    }
     18
     19    function widget($args, $instance) {
     20        extract( $args );
     21    ?>
     22        <?php echo $before_widget; ?>
     23        <?php echo $before_title
     24            . $instance['title']
     25            . $after_title; ?>
     26
     27        <?php if ( $instance['title'] ) : ?><h3><?php echo attribute_escape( $instance['title'] ) ?></h3><?php endif; ?>
     28        <?php if ( $instance['text'] ) : ?><p><?php echo attribute_escape( $instance['text'] ) ?></p><?php endif; ?>
     29
     30        <?php if ( !is_user_logged_in() ) { ?>
     31        <div class="create-account"><div class="visit generic-button"><a href="<?php bp_signup_page() ?>" title="<?php _e('Create Account', 'buddypress') ?>"><?php _e('Create Account', 'buddypress') ?></a></div></div>
     32        <?php } ?>
     33   
     34        <?php echo $after_widget; ?>
     35    <?php
     36    }
     37
     38    function update( $new_instance, $old_instance ) {
     39        $instance = $old_instance;
     40        $instance['title'] = strip_tags( $new_instance['title'] );
     41        $instance['text'] = strip_tags( wp_filter_post_kses( $new_instance['text'] ) );
     42
     43        return $instance;
     44    }
     45
     46    function form( $instance ) {
     47        $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );
     48        $title = strip_tags( $instance['title'] );
     49        $text = strip_tags( $instance['text'] );
     50        ?>
     51            <p><label for="bp-widget-welcome-title"><?php _e('Title:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo attribute_escape( $title ); ?>" /></label></p>
     52            <p>
     53                <label for="bp-widget-welcome-text"><?php _e( 'Welcome Text:' , 'buddypress'); ?>
     54                    <textarea id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>" class="widefat" style="height: 100px"><?php echo attribute_escape( $text ); ?></textarea>
     55                </label>
     56            </p>
     57    <?php
     58    }
     59}
     60
     61/*** MEMBERS WIDGET *****************/
     62
     63class BP_Core_Members_Widget extends WP_Widget {
     64    function bp_core_members_widget() {
     65        parent::WP_Widget( false, $name = 'Members' );
    1766        wp_enqueue_script( 'bp_core_widget_members-js', BP_PLUGIN_URL . '/bp-core/js/widget-members.js', array('jquery', 'jquery-livequery-pack') );       
    1867        wp_enqueue_style( 'bp_core_widget_members-css', BP_PLUGIN_URL . '/bp-core/css/widget-members.css' );
    1968    }
    20    
    21     wp_register_sidebar_widget( 'buddypress-whosonline', __( "Who's Online", 'buddypress' ), 'bp_core_widget_whos_online' );
    22     wp_register_widget_control( 'buddypress-whosonline', __( "Who's Online", 'buddypress' ), 'bp_core_widget_whos_online_control' );   
    23 
    24 }
    25 add_action( 'plugins_loaded', 'bp_core_register_widgets' );
    26 
    27 
    28 /*** WELCOME WIDGET *****************/
    29 
    30 function bp_core_widget_welcome($args) {
    31     global $current_blog;
    32    
    33     extract($args);
    34     $options = get_blog_option( $current_blog->blog_id, 'bp_core_widget_welcome' );
     69
     70    function widget($args, $instance) {
     71        global $bp;
     72       
     73        extract( $args );
     74       
     75        echo $before_widget;
     76        echo $before_title
     77           . $widget_name
     78           . $after_title; ?>
     79   
     80        <?php
     81        if ( empty( $instance['max_members'] ) || !$instance['max_members'] )
     82            $instance['max_members'] = 5; ?>
     83       
     84        <?php if ( bp_has_site_members( 'type=newest&max=' . $instance['max_members'] ) ) : ?>
     85            <div class="item-options" id="members-list-options">
     86                <img id="ajax-loader-members" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( 'Loading', 'buddypress' ) ?>" style="display: none;" />
     87                <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a> |
     88                <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="recently-active-members"><?php _e( 'Active', 'buddypress' ) ?></a> |
     89                <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="popular-members"><?php _e( 'Popular', 'buddypress' ) ?></a>
     90            </div>
     91           
     92            <ul id="members-list" class="item-list">
     93                <?php while ( bp_site_members() ) : bp_the_site_member(); ?>
     94                    <li class="vcard">
     95                        <div class="item-avatar">
     96                            <a href="<?php bp_the_site_member_link() ?>"><?php bp_the_site_member_avatar() ?></a>
     97                        </div>
     98
     99                        <div class="item">
     100                            <div class="item-title fn"><a href="<?php bp_the_site_member_name() ?>" title="<?php bp_the_site_member_name() ?>"><?php bp_the_site_member_name() ?></a></div>
     101                            <div class="item-meta"><span class="activity"><?php echo bp_core_get_last_activity( bp_get_the_site_member_registered(), __( 'registered %s ago', 'buddypress' ) ) ?></span></div>
     102                        </div>
     103                    </li>
     104
     105                <?php endwhile; ?>
     106            </ul>       
     107            <?php wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members' ); ?>
     108            <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo attribute_escape( $instance['max_members'] ); ?>" />
     109           
     110        <?php else: ?>
     111
     112            <div class="widget-error">
     113                <?php _e('No one has signed up yet!', 'buddypress') ?>
     114            </div>
     115
     116        <?php endif; ?>
     117           
     118        <?php echo $after_widget; ?>
     119    <?php
     120    }
     121
     122    function update( $new_instance, $old_instance ) {
     123        $instance = $old_instance;
     124        $instance['max_members'] = strip_tags( $new_instance['max_members'] );
     125
     126        return $instance;
     127    }
     128
     129    function form( $instance ) {
     130        $instance = wp_parse_args( (array) $instance, array( 'max_members' => 5 ) );
     131        $max_members = strip_tags( $instance['max_members'] );
     132        ?>
     133
     134        <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo attribute_escape( $max_members ); ?>" style="width: 30%" /></label></p>
     135    <?php
     136    }
     137}
     138
     139/*** WHO'S ONLINE WIDGET *****************/
     140
     141class BP_Core_Whos_Online_Widget extends WP_Widget {
     142    function bp_core_whos_online_widget() {
     143        parent::WP_Widget( false, $name = 'Who\'s Online Avatars' );
     144    }
     145
     146    function widget($args, $instance) {
     147        global $bp;
     148       
     149        extract( $args );
     150       
     151        echo $before_widget;
     152        echo $before_title
     153           . $widget_name
     154           . $after_title; ?>
     155   
     156        <?php
     157        if ( empty( $instance['max_members'] ) || !$instance['max_members'] )
     158            $instance['max_members'] = 5; ?>
     159       
     160        <?php if ( bp_has_site_members( 'type=online&max=' . $instance['max_members'] ) ) : ?>         
     161            <div class="avatar-block">
     162                <?php while ( bp_site_members() ) : bp_the_site_member(); ?>
     163                    <div class="item-avatar">
     164                        <a href="<?php bp_the_site_member_link() ?>" title="<?php bp_the_site_member_name() ?>"><?php bp_the_site_member_avatar() ?></a>
     165                    </div>
     166                <?php endwhile; ?>
     167            </div>                 
     168        <?php else: ?>
     169
     170            <div class="widget-error">
     171                <?php _e( 'There are no users currently online', 'buddypress' ) ?>
     172            </div>
     173
     174        <?php endif; ?>
     175           
     176        <?php echo $after_widget; ?>
     177    <?php
     178    }
     179
     180    function update( $new_instance, $old_instance ) {
     181        $instance = $old_instance;
     182        $instance['max_members'] = strip_tags( $new_instance['max_members'] );
     183
     184        return $instance;
     185    }
     186
     187    function form( $instance ) {
     188        $instance = wp_parse_args( (array) $instance, array( 'max_members' => 5 ) );
     189        $max_members = strip_tags( $instance['max_members'] );
     190        ?>
     191
     192        <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo attribute_escape( $max_members ); ?>" style="width: 30%" /></label></p>
     193    <?php
     194    }
     195}
     196
     197/*** RECENTLY ACTIVE WIDGET *****************/
     198
     199class BP_Core_Recently_Active_Widget extends WP_Widget {
     200    function bp_core_recently_active_widget() {
     201        parent::WP_Widget( false, $name = 'Recently Active Member Avatars' );
     202    }
     203
     204    function widget($args, $instance) {
     205        global $bp;
     206       
     207        extract( $args );
     208       
     209        echo $before_widget;
     210        echo $before_title
     211           . $widget_name
     212           . $after_title; ?>
     213   
     214        <?php
     215        if ( empty( $instance['max_members'] ) || !$instance['max_members'] )
     216            $instance['max_members'] = 5; ?>
     217       
     218        <?php if ( bp_has_site_members( 'type=active&max=' . $instance['max_members'] ) ) : ?>         
     219            <div class="avatar-block">
     220                <?php while ( bp_site_members() ) : bp_the_site_member(); ?>
     221                    <div class="item-avatar">
     222                        <a href="<?php bp_the_site_member_link() ?>" title="<?php bp_the_site_member_name() ?>"><?php bp_the_site_member_avatar() ?></a>
     223                    </div>
     224                <?php endwhile; ?>
     225            </div>                 
     226        <?php else: ?>
     227
     228            <div class="widget-error">
     229                <?php _e( 'There are no recently active members', 'buddypress' ) ?>
     230            </div>
     231
     232        <?php endif; ?>
     233           
     234        <?php echo $after_widget; ?>
     235    <?php
     236    }
     237
     238    function update( $new_instance, $old_instance ) {
     239        $instance = $old_instance;
     240        $instance['max_members'] = strip_tags( $new_instance['max_members'] );
     241
     242        return $instance;
     243    }
     244
     245    function form( $instance ) {
     246        $instance = wp_parse_args( (array) $instance, array( 'max_members' => 5 ) );
     247        $max_members = strip_tags( $instance['max_members'] );
     248        ?>
     249
     250        <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo attribute_escape( $max_members ); ?>" style="width: 30%" /></label></p>
     251    <?php
     252    }
     253}
     254
    35255?>
    36     <?php echo $before_widget; ?>
    37     <?php echo $before_title
    38         . $widget_name
    39         . $after_title; ?>
    40 
    41     <?php if ( $options['title'] ) : ?><h3><?php echo attribute_escape( $options['title'] ) ?></h3><?php endif; ?>
    42     <?php if ( $options['text'] ) : ?><p><?php echo attribute_escape( $options['text'] ) ?></p><?php endif; ?>
    43 
    44     <?php if ( !is_user_logged_in() ) { ?>
    45     <div class="create-account"><div class="visit generic-button"><a href="<?php bp_signup_page() ?>" title="<?php _e('Create Account', 'buddypress') ?>"><?php _e('Create Account', 'buddypress') ?></a></div></div>
    46     <?php } ?>
    47    
    48     <?php echo $after_widget; ?>
    49 <?php
    50 }
    51 
    52 function bp_core_widget_welcome_control() {
    53     global $current_blog;
    54    
    55     $options = $newoptions = get_blog_option( $current_blog->blog_id, 'bp_core_widget_welcome' );
    56 
    57     if ( $_POST['bp-widget-welcome-submit'] ) {
    58         $newoptions['title'] = strip_tags( stripslashes( $_POST['bp-widget-welcome-title'] ) );
    59         $newoptions['text'] = stripslashes( wp_filter_post_kses( $_POST['bp-widget-welcome-text'] ) );
    60     }
    61    
    62     if ( $options != $newoptions ) {
    63         $options = $newoptions;
    64         update_blog_option( $current_blog->blog_id, 'bp_core_widget_welcome', $options );
    65     }
    66 
    67 ?>
    68         <p><label for="bp-widget-welcome-title"><?php _e('Title:', 'buddypress'); ?> <input class="widefat" id="bp-widget-welcome-title" name="bp-widget-welcome-title" type="text" value="<?php echo attribute_escape( $options['title'] ); ?>" /></label></p>
    69         <p>
    70             <label for="bp-widget-welcome-text"><?php _e( 'Welcome Text:' , 'buddypress'); ?>
    71                 <textarea id="bp-widget-welcome-text" name="bp-widget-welcome-text" class="widefat" style="height: 100px"><?php echo htmlspecialchars( $options['text'] ); ?></textarea>
    72             </label>
    73         </p>
    74         <input type="hidden" id="bp-widget-welcome-submit" name="bp-widget-welcome-submit" value="1" />
    75 <?php
    76 }
    77 
    78 /*** MEMBERS WIDGET *****************/
    79 
    80 function bp_core_widget_members($args) {
    81     global $current_blog, $bp;
    82    
    83     extract($args);
    84     $options = get_blog_option( $current_blog->blog_id, 'bp_core_widget_members' );
    85 ?>
    86     <?php echo $before_widget; ?>
    87     <?php echo $before_title
    88         . $widget_name
    89         . $after_title; ?>
    90    
    91     <?php
    92     if ( empty( $options['max_members'] ) || !$options['max_members'] )
    93         $options['max_members'] = 5;
    94        
    95     if ( !$users = wp_cache_get( 'newest_users', 'bp' ) ) {
    96         $users = BP_Core_User::get_newest_users( $options['max_members'] );
    97         wp_cache_set( 'newest_users', $users, 'bp' );
    98     }
    99     ?>
    100    
    101     <?php if ( $users['users'] ) : ?>
    102         <div class="item-options" id="members-list-options">
    103             <img id="ajax-loader-members" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( 'Loading', 'buddypress' ) ?>" style="display: none;" />
    104             <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a> |
    105             <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="recently-active-members"><?php _e( 'Active', 'buddypress' ) ?></a> |
    106             <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="popular-members"><?php _e( 'Popular', 'buddypress' ) ?></a>
    107         </div>
    108         <ul id="members-list" class="item-list">
    109             <?php foreach ( (array) $users['users'] as $user ) : ?>
    110                 <li class="vcard">
    111                     <div class="item-avatar">
    112                         <a href="<?php echo bp_core_get_userlink( $user->user_id, false, true ) ?>"><?php echo bp_core_get_avatar( $user->user_id, 1 ) ?></a>
    113                     </div>
    114 
    115                     <div class="item">
    116                         <div class="item-title fn"><?php echo bp_core_get_userlink( $user->user_id ) ?></div>
    117                         <div class="item-meta"><span class="activity"><?php echo bp_core_get_last_activity( $user->user_registered, __( 'registered %s ago', 'buddypress' ) ) ?></span></div>
    118                     </div>
    119                 </li>
    120                 <?php $counter++; ?>   
    121             <?php endforeach; ?>
    122         </ul>
    123        
    124         <?php
    125         if ( function_exists('wp_nonce_field') )
    126             wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members' );
    127         ?>
    128        
    129         <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo attribute_escape( $options['max_members'] ); ?>" />
    130        
    131     <?php else: ?>
    132         <div class="widget-error">
    133             <?php _e('No one has signed up yet!', 'buddypress') ?>
    134         </div>
    135     <?php endif; ?>
    136    
    137     <?php echo $after_widget; ?>
    138 <?php
    139 }
    140 
    141 function bp_core_widget_members_control() {
    142     global $current_blog;
    143    
    144     $options = $newoptions = get_blog_option( $current_blog->blog_id, 'bp_core_widget_members');
    145 
    146     if ( $_POST['bp-core-widget-members-submit'] ) {
    147         $newoptions['max_members'] = strip_tags( stripslashes( $_POST['bp-core-widget-members-max'] ) );
    148     }
    149    
    150     if ( $options != $newoptions ) {
    151         $options = $newoptions;
    152         update_blog_option( $current_blog->blog_id, 'bp_core_widget_members', $options );
    153     }
    154 
    155     $max_members = attribute_escape( $options['max_members'] );
    156 ?>
    157         <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="bp-core-widget-members-max" name="bp-core-widget-members-max" type="text" value="<?php echo attribute_escape( $options['max_members'] ); ?>" style="width: 30%" /></label></p>
    158         <input type="hidden" id="bp-core-widget-members-submit" name="bp-core-widget-members-submit" value="1" />
    159 <?php
    160 }
    161 
    162 /*** WHO'S ONLINE WIDGET *****************/
    163 
    164 function bp_core_widget_whos_online($args) {
    165     global $current_blog;
    166    
    167     extract($args);
    168     $options = get_blog_option( $current_blog->blog_id, 'bp_core_widget_whos_online' );
    169 ?>
    170     <?php echo $before_widget; ?>
    171     <?php echo $before_title
    172         . $widget_name
    173         . $after_title; ?>
    174 
    175     <?php
    176     if ( empty( $options['max_members'] ) || !$options['max_members'] )
    177         $options['max_members'] = 5;
    178        
    179     if ( !$users = wp_cache_get( 'online_users', 'bp' ) ) {
    180         $users = BP_Core_User::get_online_users( $options['max_members'] );
    181         wp_cache_set( 'online_users', $users, 'bp' );
    182     }
    183     ?>
    184 
    185     <?php $users = BP_Core_User::get_online_users($options['max_members']) ?>
    186 
    187     <?php if ( $users['users'] ) : ?>
    188         <div class="avatar-block">
    189         <?php foreach ( (array) $users['users'] as $user ) : ?>
    190             <div class="item-avatar">
    191                 <a href="<?php echo bp_core_get_userurl($user->user_id) ?>" title="<?php echo bp_core_get_user_displayname( $user->user_id ) ?>"><?php echo bp_core_get_avatar( $user->user_id, 1 ) ?></a>
    192             </div>
    193         <?php endforeach; ?>
    194         </div>
    195            
    196         <?php
    197         if ( function_exists('wp_nonce_field') )
    198             wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members' );
    199         ?>
    200 
    201         <input type="hidden" name="bp_core_widget_members_max" id="bp_core_widget_members_max" value="<?php echo attribute_escape( $options['max_members'] ); ?>" />
    202 
    203     <?php else: ?>
    204         <div class="widget-error">
    205             <?php _e('There are no users currently online.', 'buddypress') ?>
    206         </div>
    207     <?php endif; ?>
    208 
    209     <?php echo $after_widget; ?>
    210    
    211     <div class="clear" style="margin-bottom: 25px"></div>
    212    
    213 <?php
    214 }
    215 
    216 function bp_core_widget_whos_online_control() {
    217     global $current_blog;
    218    
    219     $options = $newoptions = get_blog_option( $current_blog->blog_id, 'bp_core_widget_whos_online' );
    220 
    221     if ( $_POST['bp-widget-whos-online-submit'] ) {
    222         $newoptions['max_members'] = strip_tags( stripslashes( $_POST['bp-widget-whos-online-max-members'] ) );
    223     }
    224    
    225     if ( $options != $newoptions ) {
    226         $options = $newoptions;
    227         update_blog_option( $current_blog->blog_id, 'bp_core_widget_whos_online', $options );
    228     }
    229 
    230 ?>
    231         <p><label for="bp-widget-whos-online-max-members"><?php _e('Maximum number of members to show:', 'buddypress'); ?><br /><input class="widefat" id="bp-widget-whos-online-max-members" name="bp-widget-whos-online-max-members" type="text" value="<?php echo attribute_escape( $options['max_members'] ); ?>" style="width: 30%" /></label></p>
    232         <input type="hidden" id="bp-widget-whos-online-submit" name="bp-widget-whos-online-submit" value="1" />
    233 <?php
    234 }
  • branches/1.0/bp-core/css/widget-members.css

    r1366 r1602  
    1 .bp_core_widget_members ul#members-list {
     1.widget_bp_core_members_widget ul#members-list {
    22    margin: 15px 0 0 0;
    33    padding: 0;
     
    55}
    66   
    7     .bp_core_widget_members ul#members-list li {
     7    .widget_bp_core_members_widget ul#members-list li {
    88        min-height: 60px;
    99    }
    1010   
    11     .bp_core_widget_members ul#members-list li img.avatar {
     11    .widget_bp_core_members_widget ul#members-list li img.avatar {
    1212        float: left;
    1313        margin: 0 10px 0 0;
    1414    }
    1515   
    16     .bp_core_widget_members ul#members-list li span.activity {
     16    .widget_bp_core_members_widget ul#members-list li span.activity {
    1717        font-size: 11px;
    1818    }
    1919   
    20 .bp_core_widget_members img#ajax-loader-members {
     20.widget_bp_core_members_widget img#ajax-loader-members {
    2121    float: right;
    2222}
  • branches/1.0/bp-groups/bp-groups-widgets.php

    r1520 r1602  
    33/* Register widgets for groups component */
    44function groups_register_widgets() {
    5     global $current_blog;
    6    
    7     /* Site welcome widget */
    8     wp_register_sidebar_widget( 'buddypress-groups', __( 'Groups', 'buddypress' ), 'groups_widget_groups_list' );
    9     wp_register_widget_control( 'buddypress-groups', __( 'Groups', 'buddypress' ), 'groups_widget_groups_list_control' );
    10    
    11     /* Include the javascript needed for activated widgets only */
    12     if ( is_active_widget( 'groups_widget_groups_list' ) ) {
    13         wp_enqueue_script( 'groups_widget_groups_list-js', BP_PLUGIN_URL . '/bp-groups/js/widget-groups.js', array('jquery', 'jquery-livequery-pack') );       
    14         wp_enqueue_style( 'groups_widget_members-css', BP_PLUGIN_URL . '/bp-groups/css/widget-groups.css' );       
    15     }
     5    add_action('widgets_init', create_function('', 'return register_widget("BP_Groups_Widget");') );   
    166}
    177add_action( 'plugins_loaded', 'groups_register_widgets' );
     
    2010/*** GROUPS WIDGET *****************/
    2111
    22 function groups_widget_groups_list($args) {
    23     global $current_blog, $bp;
    24    
    25     extract($args);
    26     $options = get_blog_option( $current_blog->blog_id, 'groups_widget_groups_list' );
    27 ?>
    28     <?php echo $before_widget; ?>
    29     <?php echo $before_title
    30         . $widget_name
    31         . $after_title; ?>
    32 
    33     <?php
    34     if ( empty( $options['max_groups'] ) || !$options['max_groups'] )
    35         $options['max_groups'] = 5;
    36        
    37     if ( !$groups = wp_cache_get( 'popular_groups', 'bp' ) ) {
    38         $groups = groups_get_popular( $options['max_groups'], 1 );
    39         wp_cache_set( 'popular_groups', $groups, 'bp' );
    40     }
    41     ?>
    42 
    43     <?php if ( $groups['groups'] ) : ?>
    44         <div class="item-options" id="groups-list-options">
    45             <img id="ajax-loader-groups" src="<?php echo $bp->groups->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( 'Loading', 'buddypress' ) ?>" style="display: none;" />
    46             <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="newest-groups"><?php _e("Newest", 'buddypress') ?></a> |
    47             <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="recently-active-groups"><?php _e("Active", 'buddypress') ?></a> |
    48             <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="popular-groups" class="selected"><?php _e("Popular", 'buddypress') ?></a>
    49         </div>
    50         <ul id="groups-list" class="item-list">
    51             <?php foreach ( $groups['groups'] as $group_id ) : ?>
    52                 <?php
    53                 if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_id->group_id, 'bp' ) ) {
    54                     $group = new BP_Groups_Group( $group_id->group_id, false, false );
    55                     wp_cache_set( 'groups_group_nouserdata_' . $group_id->group_id, $group, 'bp' );
    56                 }   
    57                 ?>
    58                 <li>
    59                     <div class="item-avatar">
    60                         <a href="<?php echo bp_get_group_permalink( $group ) ?>" title="<?php echo bp_get_group_name( $group ) ?>"><?php echo bp_get_group_avatar_thumb( $group ); ?></a>
    61                     </div>
    62 
    63                     <div class="item">
    64                         <div class="item-title"><a href="<?php echo bp_get_group_permalink( $group ) ?>" title="<?php echo bp_get_group_name( $group ) ?>"><?php echo bp_get_group_name( $group ) ?></a></div>
    65                         <div class="item-meta">
    66                         <span class="activity">
    67                             <?php
    68                             if ( 1 == $group->total_member_count )
    69                                 echo $group->total_member_count . __(' member', 'buddypress');
    70                             else
    71                                 echo $group->total_member_count . __(' members', 'buddypress');
    72                             ?>
    73                         </span></div>
    74                     </div>
    75                 </li>
    76                 <?php $counter++; ?>   
    77             <?php endforeach; ?>
    78         </ul>
    79        
    80         <?php
    81         if ( function_exists('wp_nonce_field') )
    82             wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' );
    83         ?>
    84        
    85         <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $options['max_groups'] ); ?>" />
    86        
    87     <?php else: ?>
    88         <div class="widget-error">
    89             <?php _e('There are no groups to display.', 'buddypress') ?>
    90         </div>
    91     <?php endif; ?>
    92    
    93     <?php echo $after_widget; ?>
    94 <?php
    95 }
    96 
    97 function groups_widget_groups_list_control() {
    98     global $current_blog;
    99    
    100     $options = $newoptions = get_blog_option( $current_blog->blog_id, 'groups_widget_groups_list');
    101 
    102     if ( $_POST['groups-widget-groups-list-submit'] ) {
    103         $newoptions['max_groups'] = strip_tags( stripslashes( $_POST['groups-widget-groups-list-max'] ) );
    104     }
    105    
    106     if ( $options != $newoptions ) {
    107         $options = $newoptions;
    108         update_blog_option( $current_blog->blog_id, 'groups_widget_groups_list', $options );
     12class BP_Groups_Widget extends WP_Widget {
     13    function bp_groups_widget() {
     14        parent::WP_Widget( false, $name = 'Groups' );
     15        wp_enqueue_script( 'groups_widget_groups_list-js', BP_PLUGIN_URL . '/bp-groups/js/widget-groups.js', array('jquery', 'jquery-livequery-pack') );       
     16        wp_enqueue_style( 'groups_widget_members-css', BP_PLUGIN_URL . '/bp-groups/css/widget-groups.css' );       
    10917    }
    11018
     19    function widget($args, $instance) {
     20        global $bp;
     21       
     22        extract( $args );
     23       
     24        echo $before_widget;
     25        echo $before_title
     26           . $widget_name
     27           . $after_title; ?>
     28   
     29        <?php
     30        if ( empty( $instance['max_groups'] ) || !$instance['max_groups'] )
     31            $instance['max_groups'] = 5; ?>
     32       
     33        <?php if ( bp_has_site_groups( 'type=popular&max=' . $instance['max_groups'] ) ) : ?>
     34            <div class="item-options" id="groups-list-options">
     35                <img id="ajax-loader-groups" src="<?php echo $bp->groups->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( 'Loading', 'buddypress' ) ?>" style="display: none;" />
     36                <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="newest-groups"><?php _e("Newest", 'buddypress') ?></a> |
     37                <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="recently-active-groups"><?php _e("Active", 'buddypress') ?></a> |
     38                <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="popular-groups" class="selected"><?php _e("Popular", 'buddypress') ?></a>
     39            </div>
     40           
     41            <ul id="groups-list" class="item-list">
     42                <?php while ( bp_site_groups() ) : bp_the_site_group(); ?>
     43                    <li>
     44                        <div class="item-avatar">
     45                            <a href="<?php bp_the_site_group_link() ?>"><?php bp_the_site_group_avatar_thumb() ?></a>
     46                        </div>
     47
     48                        <div class="item">
     49                            <div class="item-title"><a href="<?php bp_the_site_group_link() ?>" title="<?php bp_the_site_group_name() ?>"><?php bp_the_site_group_name() ?></a></div>
     50                            <div class="item-meta"><span class="activity"><?php bp_the_site_group_member_count() ?></span></div>
     51                        </div>
     52                    </li>
     53
     54                <?php endwhile; ?>
     55            </ul>       
     56            <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?>
     57            <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $instance['max_groups'] ); ?>" />
     58           
     59        <?php else: ?>
     60
     61            <div class="widget-error">
     62                <?php _e('There are no groups to display.', 'buddypress') ?>
     63            </div>
     64
     65        <?php endif; ?>
     66           
     67        <?php echo $after_widget; ?>
     68    <?php
     69    }
     70
     71    function update( $new_instance, $old_instance ) {
     72        $instance = $old_instance;
     73        $instance['max_groups'] = strip_tags( $new_instance['max_groups'] );
     74
     75        return $instance;
     76    }
     77
     78    function form( $instance ) {
     79        $instance = wp_parse_args( (array) $instance, array( 'max_groups' => 5 ) );
     80        $max_groups = strip_tags( $instance['max_groups'] );
     81        ?>
     82
     83        <p><label for="bp-groups-widget-groups-max"><?php _e('Max groups to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_groups' ); ?>" name="<?php echo $this->get_field_name( 'max_groups' ); ?>" type="text" value="<?php echo attribute_escape( $max_groups ); ?>" style="width: 30%" /></label></p>
     84    <?php
     85    }
     86}
    11187?>
    112         <p><label for="groups-widget-groups-list-max"><?php _e('Maximum number of groups to show:', 'buddypress'); ?><br /> <input class="widefat" id="groups-widget-groups-list-max" name="groups-widget-groups-list-max" type="text" value="<?php echo attribute_escape( $options['max_groups'] ); ?>" style="width: 30%" /></label></p>
    113         <input type="hidden" id="groups-widget-groups-list-submit" name="groups-widget-groups-list-submit" value="1" />
    114 <?php
    115 }
  • branches/1.0/bp-groups/css/widget-groups.css

    r1366 r1602  
    1 .groups_widget_groups_list ul#groups-list {
     1.widget_bp_groups_widget ul#groups-list {
    22    margin: 15px 0 0 0;
    33    padding: 0;
    44    list-style: none;
    55}
    6    
    7     .groups_widget_groups_list ul#groups-list li {
     6    .widget_bp_groups_widget ul#groups-list li {
    87        min-height: 60px;
    98    }
    109   
    11     .groups_widget_groups_list ul#groups-list li img.avatar {
     10    .widget_bp_groups_widget ul#groups-list li img.avatar {
    1211        float: left;
    1312        margin: 0 10px 0 0;
    1413    }
    1514   
    16     .groups_widget_groups_list ul#groups-list li span.activity {
     15    .widget_bp_groups_widget ul#groups-list li span.activity {
    1716        font-size: 11px;
    1817    }
    1918   
    20 .groups_widget_groups_list img#ajax-loader-groups {
     19.widget_bp_groups_widget img#ajax-loader-groups {
    2120    float: right;
    2221}
Note: See TracChangeset for help on using the changeset viewer.