Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/14/2009 03:24:05 PM (16 years ago)
Author:
apeatling
Message:

Committing core code support for new default theme.

Removed all deprecated code since it will be released as a separate plugin for backwards compatibility if people need it.

Removed the wire and status updates components since there is no support in the theme for these. If people still want this functionality then I'm sure there is someone in the community that could spend a bit of time and release them as plugins. I'm happy to guide.

Removed a lot of template loop duplication. There are no longer site loops and user loops (e.g. bp_has_site_groups() / bp_has_groups() ). There are now bp_has_members(), bp_has_groups(), bp_has_blogs() and you can pass a "user_id" parameter into these loops to limit results to only that user or users.

Merged activity stream functions. There are no longer functions for bp_activity_get_sitewide() / bp_activity_get_for_user() / bp_activity_get_friends_activity() instead there is simply one function: bp_activity_get() and you can pass in parameters to filter on just friends, for a single user, or anything your heart desires. Actually, filtering is extremely fine grained, so I encourage devs to check out the filter functions.

Lots of other code cleanup.

The new default theme will be committed straight after this. The original default folder will be renamed to bp-classic.

File:
1 edited

Legend:

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

    r2158 r2168  
    11<?php
    22
    3 function bp_groups_header_tabs() {
    4     global $bp, $create_group_step, $completed_to_step;
    5 ?>
    6     <li<?php if ( !isset($bp->action_variables[0]) || 'recently-active' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/recently-active"><?php _e( 'Recently Active', 'buddypress' ) ?></a></li>
    7     <li<?php if ( 'recently-joined' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/recently-joined"><?php _e( 'Recently Joined', 'buddypress' ) ?></a></li>
    8     <li<?php if ( 'most-popular' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/most-popular""><?php _e( 'Most Popular', 'buddypress' ) ?></a></li>
    9     <li<?php if ( 'admin-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/admin-of""><?php _e( 'Administrator Of', 'buddypress' ) ?></a></li>
    10     <li<?php if ( 'mod-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/mod-of""><?php _e( 'Moderator Of', 'buddypress' ) ?></a></li>
    11     <li<?php if ( 'alphabetically' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/alphabetically""><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li>
    12 <?php
    13     do_action( 'groups_header_tabs' );
    14 }
    15 
    16 function bp_groups_filter_title() {
    17     global $bp;
    18 
    19     $current_filter = $bp->action_variables[0];
    20 
    21     switch ( $current_filter ) {
    22         case 'recently-active': default:
    23             _e( 'Recently Active', 'buddypress' );
    24             break;
    25         case 'recently-joined':
    26             _e( 'Recently Joined', 'buddypress' );
    27             break;
    28         case 'most-popular':
    29             _e( 'Most Popular', 'buddypress' );
    30             break;
    31         case 'admin-of':
    32             _e( 'Administrator Of', 'buddypress' );
    33             break;
    34         case 'mod-of':
    35             _e( 'Moderator Of', 'buddypress' );
    36             break;
    37         case 'alphabetically':
    38             _e( 'Alphabetically', 'buddypress' );
    39         break;
    40     }
    41     do_action( 'bp_groups_filter_title' );
    42 }
    43 
    44 function bp_is_group_admin_screen( $slug ) {
    45     global $bp;
    46 
    47     if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action )
    48         return false;
    49 
    50     if ( $bp->action_variables[0] == $slug )
    51         return true;
    52 
    53     return false;
    54 }
    55 
    56 function bp_group_current_avatar() {
    57     global $bp;
    58 
    59     if ( $bp->groups->current_group->avatar_full ) { ?>
    60         <img src="<?php echo attribute_escape( $bp->groups->current_group->avatar_full ) ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" />
    61     <?php } else { ?>
    62         <img src="<?php echo $bp->groups->image_base . '/none.gif' ?>" alt="<?php _e( 'No Group Avatar', 'buddypress' ) ?>" class="avatar" />
    63     <?php }
    64 }
    65 
    66 
    67 function bp_get_group_has_avatar() {
    68     global $bp;
    69 
    70     if ( !empty( $_FILES ) || !bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'no_grav' => true ) ) )
    71         return false;
    72 
    73     return true;
    74 }
    75 
    76 function bp_group_avatar_delete_link() {
    77     echo bp_get_group_avatar_delete_link();
    78 }
    79     function bp_get_group_avatar_delete_link() {
    80         global $bp;
    81 
    82         return apply_filters( 'bp_get_group_avatar_delete_link', wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/group-avatar/delete', 'bp_group_avatar_delete' ) );
    83     }
    84 
    85 function bp_group_avatar_edit_form() {
    86     groups_avatar_upload();
    87 }
    88 
    89 function bp_custom_group_boxes() {
    90     do_action( 'groups_custom_group_boxes' );
    91 }
    92 
    93 function bp_custom_group_admin_tabs() {
    94     do_action( 'groups_custom_group_admin_tabs' );
    95 }
    96 
    97 function bp_custom_group_fields_editable() {
    98     do_action( 'groups_custom_group_fields_editable' );
    99 }
    100 
    101 function bp_custom_group_fields() {
    102     do_action( 'groups_custom_group_fields' );
    103 }
    104 
    105 
    1063/*****************************************************************************
    107  * User Groups Template Class/Tags
     4 * Groups Template Class/Tags
    1085 **/
    1096
    110 class BP_Groups_User_Groups_Template {
     7class BP_Groups_Template {
    1118    var $current_group = -1;
    1129    var $group_count;
     
    12623    var $order;
    12724
    128     function bp_groups_user_groups_template( $user_id, $type, $per_page, $max, $slug, $filter ) {
     25    function bp_groups_template( $user_id, $type, $page, $per_page, $max, $slug, $search_terms ) {
    12926        global $bp;
    13027
    131         if ( !$user_id )
    132             $user_id = $bp->displayed_user->id;
    133 
    134         $this->pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : 1;
     28        $this->pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : $page;
    13529        $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    13630
    13731        switch ( $type ) {
    138             case 'recently-joined':
    139                 $this->groups = groups_get_recently_joined_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
     32            case 'active': default:
     33                $this->groups = groups_get_active( $this->pag_num, $this->pag_page, $user_id, $search_terms );
    14034                break;
    14135
     36            case 'alphabetical': default:
     37                $this->groups = groups_get_alphabetically( $this->pag_num, $this->pag_page, $user_id, $search_terms );
     38                break;
     39
     40            case 'random':
     41                $this->groups = groups_get_random_groups( $this->pag_num, $this->pag_page, $user_id, $search_terms );
     42                break;
     43
     44            case 'newest':
     45                $this->groups = groups_get_newest( $this->pag_num, $this->pag_page, $user_id, $search_terms );
     46                break;
     47
    14248            case 'popular':
    143                 $this->groups = groups_get_most_popular_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
     49                $this->groups = groups_get_popular( $this->pag_num, $this->pag_page, $user_id, $search_terms );
    14450                break;
    14551
     52            case 'most-forum-topics':
     53                $this->groups = groups_get_by_most_forum_topics( $this->pag_num, $this->pag_page, $user_id, $search_terms );
     54                break;
     55
     56            case 'most-forum-posts':
     57                $this->groups = groups_get_by_most_forum_posts( $this->pag_num, $this->pag_page, $user_id, $search_terms );
     58                break;
     59
    14660            case 'admin-of':
    147                 $this->groups = groups_get_user_is_admin_of( $user_id, $this->pag_num, $this->pag_page, $filter );
     61                if ( $user_id )
     62                    $this->groups = groups_get_user_is_admin_of( $user_id, $this->pag_num, $this->pag_page, $search_terms );
    14863                break;
    14964
    15065            case 'mod-of':
    151                 $this->groups = groups_get_user_is_mod_of( $user_id, $this->pag_num, $this->pag_page, $filter );
     66                if ( $user_id )
     67                    $this->groups = groups_get_user_is_mod_of( $user_id, $this->pag_num, $this->pag_page, $filter );
    15268                break;
    15369
    154             case 'alphabetical':
    155                 $this->groups = groups_get_alphabetically_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
    156                 break;
    157 
    15870            case 'invites':
    159                 $this->groups = groups_get_invites_for_user();
     71                if ( $user_id )
     72                    $this->groups = groups_get_invites_for_user();
    16073                break;
    16174
     
    16477                $group->group_id = BP_Groups_Group::get_id_from_slug($slug);
    16578                $this->groups = array( $group );
    166                 break;
    167 
    168             case 'active': default:
    169                 $this->groups = groups_get_recently_active_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
    17079                break;
    17180        }
     
    201110            'total' => ceil($this->total_group_count / $this->pag_num),
    202111            'current' => $this->pag_page,
    203             'prev_text' => '&laquo;',
    204             'next_text' => '&raquo;',
     112            'prev_text' => '&larr;',
     113            'next_text' => '&rarr;',
    205114            'mid_size' => 1
    206115        ));
     
    228137    }
    229138
    230     function user_groups() {
     139    function groups() {
    231140        if ( $this->current_group + 1 < $this->group_count ) {
    232141            return true;
     
    249158        if ( $this->single_group )
    250159            $this->group = new BP_Groups_Group( $this->group->group_id, true, true );
     160        else {
     161            if ( $this->group )
     162                wp_cache_set( 'groups_group_nouserdata_' . $group->group_id, $this->group, 'bp' );
     163        }
    251164
    252165        if ( 0 == $this->current_group ) // loop has just started
     
    260173    $defaults = array(
    261174        'type' => 'active',
    262         'user_id' => false,
    263         'per_page' => 10,
     175        'page' => 1,
     176        'per_page' => 20,
    264177        'max' => false,
    265         'slug' => false,
    266         'filter' => false
     178
     179        'user_id' => false, // Pass a user ID to limit to groups this user has joined
     180        'slug' => false, // Pass a group slug to only return that group
     181        'search_terms' => false // Pass search terms to return only matching groups
    267182    );
    268183
     
    295210    }
    296211
    297     if ( isset( $_REQUEST['group-filter-box'] ) )
    298         $filter = $_REQUEST['group-filter-box'];
    299 
    300     $groups_template = new BP_Groups_User_Groups_Template( $user_id, $type, $per_page, $max, $slug, $filter );
     212    if ( isset( $_REQUEST['group-filter-box'] ) || isset( $_REQUEST['s'] ) )
     213        $search_terms = ( isset( $_REQUEST['group-filter-box'] ) ) ? $_REQUEST['group-filter-box'] : $_REQUEST['s'];
     214
     215    $groups_template = new BP_Groups_Template( $user_id, $type, $page, $per_page, $max, $slug, $search_terms );
    301216    return apply_filters( 'bp_has_groups', $groups_template->has_groups(), &$groups_template );
    302217}
     
    304219function bp_groups() {
    305220    global $groups_template;
    306     return $groups_template->user_groups();
     221    return $groups_template->groups();
    307222}
    308223
     
    614529            $group =& $groups_template->group;
    615530
    616         return apply_filters( 'bp_get_group_date_created', date( get_option( 'date_format' ), $group->date_created ) );
     531        return apply_filters( 'bp_get_group_date_created', bp_core_time_since( strtotime( $group->date_created ) ) );
    617532    }
    618533
     
    720635    $label = __('Filter Groups', 'buddypress');
    721636    $name = 'group-filter-box';
     637
    722638?>
    723639    <form action="<?php echo $action ?>" id="group-search-form" method="post">
     
    748664}
    749665
    750 function bp_group_pagination() {
    751     echo bp_get_group_pagination();
    752 }
    753     function bp_get_group_pagination() {
     666function bp_groups_pagination_links() {
     667    echo bp_get_groups_pagination_links();
     668}
     669    function bp_get_groups_pagination_links() {
    754670        global $groups_template;
    755671
    756         return apply_filters( 'bp_get_group_pagination', $groups_template->pag_links );
    757     }
    758 
    759 function bp_group_pagination_count() {
     672        return apply_filters( 'bp_get_groups_pagination_links', $groups_template->pag_links );
     673    }
     674
     675function bp_groups_pagination_count() {
    760676    global $bp, $groups_template;
    761677
     
    789705
    790706        return apply_filters( 'bp_get_group_total_members', $group->total_member_count );
     707    }
     708
     709function bp_group_member_count() {
     710    echo bp_get_group_member_count();
     711}
     712    function bp_get_group_member_count() {
     713        global $groups_template;
     714
     715        if ( 1 == (int) $groups_template->group->total_member_count )
     716            return apply_filters( 'bp_get_group_member_count', sprintf( __( '%d member', 'buddypress' ), (int) $groups_template->group->total_member_count ) );
     717        else
     718            return apply_filters( 'bp_get_group_member_count', sprintf( __( '%d members', 'buddypress' ), (int) $groups_template->group->total_member_count ) );
    791719    }
    792720
     
    12611189}
    12621190
     1191function bp_group_hidden_fields() {
     1192    if ( isset( $_REQUEST['s'] ) ) {
     1193        echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />';
     1194    }
     1195
     1196    if ( isset( $_REQUEST['letter'] ) ) {
     1197        echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
     1198    }
     1199
     1200    if ( isset( $_REQUEST['groups_search'] ) ) {
     1201        echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['groups_search'] ) . '" name="search_terms" />';
     1202    }
     1203}
     1204
    12631205
    12641206/***************************************************************************
     
    13081250            'total' => ceil( $this->total_member_count / $this->pag_num ),
    13091251            'current' => $this->pag_page,
    1310             'prev_text' => '&laquo;',
    1311             'next_text' => '&raquo;',
     1252            'prev_text' => '&larr;',
     1253            'next_text' => '&rarr;',
    13121254            'mid_size' => 1
    13131255        ));
     
    15371479        $is_enabled = bp_are_previous_group_creation_steps_complete( $slug ); ?>
    15381480
    1539         <li<?php if ( $bp->groups->current_create_step == $slug ) : ?> class="current"<?php endif; ?>><?php if ( $is_enabled ) : ?><a href="<?php echo $bp->loggedin_user->domain . $bp->groups->slug ?>/create/step/<?php echo $slug ?>"><?php endif; ?><?php echo $counter ?>. <?php echo $step['name'] ?><?php if ( $is_enabled ) : ?></a><?php endif; ?></li><?php
     1481        <li<?php if ( $bp->groups->current_create_step == $slug ) : ?> class="current"<?php endif; ?>><?php if ( $is_enabled ) : ?><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/create/step/<?php echo $slug ?>/"><?php else: ?><span><?php endif; ?><?php echo $counter ?>. <?php echo $step['name'] ?><?php if ( $is_enabled ) : ?></a><?php else: ?></span><?php endif ?></li><?php
    15401482        $counter++;
    15411483    }
     
    15611503            $bp->action_variables[1] = array_shift( array_keys( $bp->groups->group_creation_steps ) );
    15621504
    1563         return apply_filters( 'bp_get_group_creation_form_action', $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->action_variables[1] );
     1505        return apply_filters( 'bp_get_group_creation_form_action', $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->action_variables[1] );
    15641506    }
    15651507
     
    17871729    }
    17881730
    1789 /********************************************************************************
    1790  * Site Groups Template Tags
    1791  **/
    1792 
    1793 class BP_Groups_Site_Groups_Template {
    1794     var $current_group = -1;
    1795     var $group_count;
    1796     var $groups;
    1797     var $group;
    1798 
    1799     var $in_the_loop;
    1800 
    1801     var $pag_page;
    1802     var $pag_num;
    1803     var $pag_links;
    1804     var $total_group_count;
    1805 
    1806     function bp_groups_site_groups_template( $type, $per_page, $max ) {
    1807         global $bp;
    1808 
    1809         /* TODO: Move $_REQUEST vars out of here */
    1810 
    1811         $this->pag_page = isset( $_REQUEST['gpage'] ) ? intval( $_REQUEST['gpage'] ) : 1;
    1812         $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    1813 
    1814         if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) {
    1815             $this->groups = BP_Groups_Group::search_groups( $_REQUEST['s'], $this->pag_num, $this->pag_page );
    1816         } else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) {
    1817             $this->groups = BP_Groups_Group::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page );
    1818 
    1819         } else {
    1820             switch ( $type ) {
    1821                 case 'active': default:
    1822                     $this->groups = groups_get_active( $this->pag_num, $this->pag_page );
    1823                     break;
    1824 
    1825                 case 'alphabetical': default:
    1826                     $this->groups = groups_get_alphabetically( $this->pag_num, $this->pag_page );
    1827                     break;
    1828 
    1829                 case 'random':
    1830                     $this->groups = groups_get_random_groups( $this->pag_num, $this->pag_page );
    1831                     break;
    1832 
    1833                 case 'newest':
    1834                     $this->groups = groups_get_newest( $this->pag_num, $this->pag_page );
    1835                     break;
    1836 
    1837                 case 'popular':
    1838                     $this->groups = groups_get_popular( $this->pag_num, $this->pag_page );
    1839                     break;
    1840 
    1841                 case 'most-forum-topics':
    1842                     $this->groups = groups_get_by_most_forum_topics( $this->pag_num, $this->pag_page );
    1843                     break;
    1844 
    1845                 case 'most-forum-posts':
    1846                     $this->groups = groups_get_by_most_forum_posts( $this->pag_num, $this->pag_page );
    1847                     break;
    1848             }
    1849         }
    1850 
    1851         if ( !$max || $max >= (int)$this->groups['total'] )
    1852             $this->total_group_count = (int)$this->groups['total'];
    1853         else
    1854             $this->total_group_count = (int)$max;
    1855 
    1856         $this->groups = $this->groups['groups'];
    1857 
    1858         if ( $max ) {
    1859             if ( $max >= count($this->groups) )
    1860                 $this->group_count = count($this->groups);
    1861             else
    1862                 $this->group_count = (int)$max;
    1863         } else {
    1864             $this->group_count = count($this->groups);
    1865         }
    1866 
    1867         if ( (int) $this->total_group_count && (int) $this->pag_num ) {
    1868             $this->pag_links = paginate_links( array(
    1869                 'base' => add_query_arg( 'gpage', '%#%' ),
    1870                 'format' => '',
    1871                 'total' => ceil( (int) $this->total_group_count / (int) $this->pag_num ),
    1872                 'current' => (int) $this->pag_page,
    1873                 'prev_text' => '&laquo;',
    1874                 'next_text' => '&raquo;',
    1875                 'mid_size' => 1
    1876             ));
    1877     }
    1878     }
    1879 
    1880     function has_groups() {
    1881         if ( $this->group_count )
    1882             return true;
    1883 
    1884         return false;
    1885     }
    1886 
    1887     function next_group() {
    1888         $this->current_group++;
    1889         $this->group = $this->groups[$this->current_group];
    1890 
    1891         return $this->group;
    1892     }
    1893 
    1894     function rewind_groups() {
    1895         $this->current_group = -1;
    1896         if ( $this->group_count > 0 ) {
    1897             $this->group = $this->groups[0];
    1898         }
    1899     }
    1900 
    1901     function groups() {
    1902         if ( $this->current_group + 1 < $this->group_count ) {
    1903             return true;
    1904         } elseif ( $this->current_group + 1 == $this->group_count ) {
    1905             do_action('loop_end');
    1906             // Do some cleaning up after the loop
    1907             $this->rewind_groups();
    1908         }
    1909 
    1910         $this->in_the_loop = false;
    1911         return false;
    1912     }
    1913 
    1914     function the_group() {
    1915         global $group;
    1916 
    1917         $this->in_the_loop = true;
    1918         $this->group = $this->next_group();
    1919 
    1920         if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $this->group->group_id, 'bp' ) ) {
    1921             $group = new BP_Groups_Group( $this->group->group_id, false, false );
    1922             wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' );
    1923         }
    1924 
    1925         $this->group = $group;
    1926 
    1927         if ( 0 == $this->current_group ) // loop has just started
    1928             do_action('loop_start');
    1929     }
    1930 }
    1931 
    1932 function bp_rewind_site_groups() {
    1933     global $site_groups_template;
    1934 
    1935     $site_groups_template->rewind_groups();
    1936 }
    1937 
    1938 function bp_has_site_groups( $args = '' ) {
    1939     global $site_groups_template;
    1940 
    1941     $defaults = array(
    1942         'type' => 'active',
    1943         'per_page' => 10,
    1944         'max' => false
    1945     );
    1946 
    1947     $r = wp_parse_args( $args, $defaults );
    1948     extract( $r, EXTR_SKIP );
    1949 
    1950     // type: active ( default ) | random | newest | popular
    1951 
    1952     if ( $max ) {
    1953         if ( $per_page > $max )
    1954             $per_page = $max;
    1955     }
    1956 
    1957     $site_groups_template = new BP_Groups_Site_Groups_Template( $type, $per_page, $max );
    1958     return apply_filters( 'bp_has_site_groups', $site_groups_template->has_groups(), &$site_groups_template );
    1959 }
    1960 
    1961 function bp_site_groups() {
    1962     global $site_groups_template;
    1963 
    1964     return $site_groups_template->groups();
    1965 }
    1966 
    1967 function bp_the_site_group() {
    1968     global $site_groups_template;
    1969 
    1970     return $site_groups_template->the_group();
    1971 }
    1972 
    1973 function bp_site_groups_pagination_count() {
    1974     global $bp, $site_groups_template;
    1975 
    1976     $from_num = intval( ( $site_groups_template->pag_page - 1 ) * $site_groups_template->pag_num ) + 1;
    1977     $to_num = ( $from_num + ( $site_groups_template->pag_num - 1 ) > $site_groups_template->total_group_count ) ? $site_groups_template->total_group_count : $from_num + ( $site_groups_template->pag_num - 1) ;
    1978 
    1979     echo sprintf( __( 'Viewing group %d to %d (of %d groups)', 'buddypress' ), $from_num, $to_num, $site_groups_template->total_group_count ); ?> &nbsp;
    1980     <span class="ajax-loader"></span><?php
    1981 }
    1982 
    1983 function bp_site_groups_pagination_links() {
    1984     echo bp_get_site_groups_pagination_links();
    1985 }
    1986     function bp_get_site_groups_pagination_links() {
    1987         global $site_groups_template;
    1988 
    1989         return apply_filters( 'bp_get_site_groups_pagination_links', $site_groups_template->pag_links );
    1990     }
    1991 
    1992 function bp_the_site_group_id() {
    1993     echo bp_get_the_site_group_id();
    1994 }
    1995     function bp_get_the_site_group_id() {
    1996         global $site_groups_template;
    1997 
    1998         return apply_filters( 'bp_get_the_site_group_id', $site_groups_template->group->id );
    1999     }
    2000 
    2001 function bp_the_site_group_avatar( $args = '' ) {
    2002     echo bp_get_the_site_group_avatar( $args );
    2003 }
    2004     function bp_get_the_site_group_avatar( $args = '' ) {
    2005         global $site_groups_template;
    2006 
    2007         $defaults = array(
    2008             'type' => 'full',
    2009             'width' => false,
    2010             'height' => false,
    2011             'class' => 'avatar',
    2012             'id' => false,
    2013             'alt' => __( 'Group avatar', 'buddypress' )
    2014         );
    2015 
    2016         $r = wp_parse_args( $args, $defaults );
    2017         extract( $r, EXTR_SKIP );
    2018 
    2019         return apply_filters( 'bp_the_site_group_avatar', bp_core_fetch_avatar( array( 'item_id' => $site_groups_template->group->id, 'object' => 'group', 'type' => $type, 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height ) ) );
    2020     }
    2021 
    2022 function bp_the_site_group_avatar_thumb() {
    2023     echo bp_get_the_site_group_avatar_thumb();
    2024 }
    2025     function bp_get_the_site_group_avatar_thumb() {
    2026         global $site_groups_template;
    2027 
    2028         return apply_filters( 'bp_get_the_site_group_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $site_groups_template->group->id, 'object' => 'group', 'type' => 'thumb', 'avatar_dir' => 'group-avatars', 'alt' => __( 'Group Avatar', 'buddypress' ) ) ) );
    2029     }
    2030 
    2031 function bp_the_site_group_avatar_mini() {
    2032     echo bp_get_the_site_group_avatar_mini();
    2033 }
    2034     function bp_get_the_site_group_avatar_mini() {
    2035         global $site_groups_template;
    2036 
    2037         return apply_filters( 'bp_get_the_site_group_avatar_mini', bp_core_fetch_avatar( array( 'item_id' => $site_groups_template->group->id, 'object' => 'group', 'type' => 'thumb', 'width' => 30, 'height' => 30, 'avatar_dir' => 'group-avatars', 'alt' => __( 'Group Avatar', 'buddypress' ) ) ) );
    2038     }
    2039 
    2040 function bp_the_site_group_link() {
    2041     echo bp_get_the_site_group_link();
    2042 }
    2043     function bp_get_the_site_group_link() {
    2044         global $site_groups_template;
    2045 
    2046         return apply_filters( 'bp_get_the_site_group_link', bp_get_group_permalink( $site_groups_template->group ) );
    2047     }
    2048 
    2049 function bp_the_site_group_name() {
    2050     echo bp_get_the_site_group_name();
    2051 }
    2052     function bp_get_the_site_group_name() {
    2053         global $site_groups_template;
    2054 
    2055         return apply_filters( 'bp_get_the_site_group_name', bp_get_group_name( $site_groups_template->group ) );
    2056     }
    2057 
    2058 
    2059 function bp_the_site_group_last_active() {
    2060     echo bp_get_the_site_group_last_active();
    2061 }
    2062     function bp_get_the_site_group_last_active() {
    2063         global $site_groups_template;
    2064 
    2065         return apply_filters( 'bp_get_the_site_group_last_active', sprintf( __( 'active %s ago', 'buddypress' ), bp_get_group_last_active( $site_groups_template->group ) ) );
    2066     }
    2067 
    2068 function bp_the_site_group_join_button() {
    2069     global $site_groups_template;
    2070 
    2071     echo bp_group_join_button( $site_groups_template->group );
    2072 }
    2073 
    2074 function bp_the_site_group_description() {
    2075     echo bp_get_the_site_group_description();
    2076 }
    2077     function bp_get_the_site_group_description() {
    2078         global $site_groups_template;
    2079 
    2080         return apply_filters( 'bp_get_the_site_group_description', bp_get_group_description( $site_groups_template->group ) );
    2081     }
    2082 
    2083 function bp_the_site_group_description_excerpt() {
    2084     echo bp_get_the_site_group_description_excerpt();
    2085 }
    2086     function bp_get_the_site_group_description_excerpt() {
    2087         global $site_groups_template;
    2088 
    2089         return apply_filters( 'bp_get_the_site_group_description_excerpt', bp_create_excerpt( bp_get_group_description( $site_groups_template->group, false ), 25 ) );
    2090     }
    2091 
    2092 function bp_the_site_group_date_created() {
    2093     echo bp_get_the_site_group_date_created();
    2094 }
    2095     function bp_get_the_site_group_date_created() {
    2096         global $site_groups_template;
    2097 
    2098         return apply_filters( 'bp_get_the_site_group_date_created', bp_core_time_since( $site_groups_template->group->date_created ) );
    2099     }
    2100 
    2101 function bp_the_site_group_member_count() {
    2102     echo bp_get_the_site_group_member_count();
    2103 }
    2104     function bp_get_the_site_group_member_count() {
    2105         global $site_groups_template;
    2106 
    2107         if ( 1 == (int) $site_groups_template->group->total_member_count )
    2108             return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d member', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) );
    2109         else
    2110             return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d members', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) );
    2111     }
    2112 
    2113 function bp_the_site_group_type() {
    2114     echo bp_get_the_site_group_type();
    2115 }
    2116     function bp_get_the_site_group_type() {
    2117         global $site_groups_template;
    2118 
    2119         return apply_filters( 'bp_get_the_site_group_type', bp_get_group_type( $site_groups_template->group ) );
    2120     }
    2121 
    2122 function bp_the_site_group_forum_topic_count( $args = '' ) {
    2123     echo bp_get_the_site_group_forum_topic_count( $args );
    2124 }
    2125     function bp_get_the_site_group_forum_topic_count( $args = '' ) {
    2126         global $site_groups_template;
    2127 
    2128         $defaults = array(
    2129             'showtext' => false
    2130         );
    2131 
    2132         $r = wp_parse_args( $args, $defaults );
    2133         extract( $r, EXTR_SKIP );
    2134 
    2135         if ( !$forum_id = groups_get_groupmeta( $site_groups_template->group->id, 'forum_id' ) )
    2136             return false;
    2137 
    2138         if ( !function_exists( 'bp_forums_get_forum_topicpost_count' ) )
    2139             return false;
    2140 
    2141         if ( !$site_groups_template->group->forum_counts )
    2142             $site_groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int)$forum_id );
    2143 
    2144         if ( (bool) $showtext ) {
    2145             if ( 1 == (int) $site_groups_template->group->forum_counts[0]->topics )
    2146                 $total_topics = sprintf( __( '%d topic', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->topics );
    2147             else
    2148                 $total_topics = sprintf( __( '%d topics', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->topics );
    2149         } else {
    2150             $total_topics = (int) $site_groups_template->group->forum_counts[0]->topics;
    2151         }
    2152 
    2153         return apply_filters( 'bp_get_the_site_group_forum_topic_count', $total_topics, (bool)$showtext );
    2154     }
    2155 
    2156 function bp_the_site_group_forum_post_count( $args = '' ) {
    2157     echo bp_get_the_site_group_forum_post_count( $args );
    2158 }
    2159     function bp_get_the_site_group_forum_post_count( $args = '' ) {
    2160         global $site_groups_template;
    2161 
    2162         $defaults = array(
    2163             'showtext' => false
    2164         );
    2165 
    2166         $r = wp_parse_args( $args, $defaults );
    2167         extract( $r, EXTR_SKIP );
    2168 
    2169         if ( !$forum_id = groups_get_groupmeta( $site_groups_template->group->id, 'forum_id' ) )
    2170             return false;
    2171 
    2172         if ( !function_exists( 'bp_forums_get_forum_topicpost_count' ) )
    2173             return false;
    2174 
    2175         if ( !$site_groups_template->group->forum_counts )
    2176             $site_groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int)$forum_id );
    2177 
    2178         if ( (bool) $showtext ) {
    2179             if ( 1 == (int) $site_groups_template->group->forum_counts[0]->posts )
    2180                 $total_posts = sprintf( __( '%d post', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->posts );
    2181             else
    2182                 $total_posts = sprintf( __( '%d posts', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->posts );
    2183         } else {
    2184             $total_posts = (int) $site_groups_template->group->forum_counts[0]->posts;
    2185         }
    2186 
    2187         return apply_filters( 'bp_get_the_site_group_forum_post_count', $total_posts, (bool)$showtext );
    2188     }
    2189 
    2190 function bp_the_site_group_hidden_fields() {
    2191     if ( isset( $_REQUEST['s'] ) ) {
    2192         echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />';
    2193     }
    2194 
    2195     if ( isset( $_REQUEST['letter'] ) ) {
    2196         echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
    2197     }
    2198 
    2199     if ( isset( $_REQUEST['groups_search'] ) ) {
    2200         echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['groups_search'] ) . '" name="search_terms" />';
    2201     }
    2202 }
    2203 
    22041731function bp_directory_groups_search_form() {
    2205     global $bp; ?>
     1732    global $bp;
     1733
     1734    $search_value = __( 'Search anything...', 'buddypress' );
     1735    if ( !empty( $_REQUEST['s'] ) )
     1736        $search_value = $_REQUEST['s'];
     1737
     1738    else if ( !empty( $_COOKIE['bp-groups-search-terms'] ) && 'false' != $_COOKIE['bp-groups-search-terms'] )
     1739        $search_value = $_COOKIE['bp-groups-search-terms'];
     1740
     1741?>
    22061742    <form action="" method="get" id="search-groups-form">
    2207         <label><input type="text" name="s" id="groups_search" value="<?php if ( isset( $_GET['s'] ) ) { echo attribute_escape( $_GET['s'] ); } else { _e( 'Search anything...', 'buddypress' ); } ?>"  onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
     1743        <label><input type="text" name="s" id="groups_search" value="<?php echo attribute_escape($search_value) ?>"  onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
    22081744        <input type="submit" id="groups_search_submit" name="groups_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    22091745    </form>
    22101746<?php
    22111747}
     1748
     1749function bp_groups_header_tabs() {
     1750    global $bp, $create_group_step, $completed_to_step;
     1751?>
     1752    <li<?php if ( !isset($bp->action_variables[0]) || 'recently-active' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/recently-active"><?php _e( 'Recently Active', 'buddypress' ) ?></a></li>
     1753    <li<?php if ( 'recently-joined' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/recently-joined"><?php _e( 'Recently Joined', 'buddypress' ) ?></a></li>
     1754    <li<?php if ( 'most-popular' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/most-popular""><?php _e( 'Most Popular', 'buddypress' ) ?></a></li>
     1755    <li<?php if ( 'admin-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/admin-of""><?php _e( 'Administrator Of', 'buddypress' ) ?></a></li>
     1756    <li<?php if ( 'mod-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/mod-of""><?php _e( 'Moderator Of', 'buddypress' ) ?></a></li>
     1757    <li<?php if ( 'alphabetically' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/alphabetically""><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li>
     1758<?php
     1759    do_action( 'groups_header_tabs' );
     1760}
     1761
     1762function bp_groups_filter_title() {
     1763    global $bp;
     1764
     1765    $current_filter = $bp->action_variables[0];
     1766
     1767    switch ( $current_filter ) {
     1768        case 'recently-active': default:
     1769            _e( 'Recently Active', 'buddypress' );
     1770            break;
     1771        case 'recently-joined':
     1772            _e( 'Recently Joined', 'buddypress' );
     1773            break;
     1774        case 'most-popular':
     1775            _e( 'Most Popular', 'buddypress' );
     1776            break;
     1777        case 'admin-of':
     1778            _e( 'Administrator Of', 'buddypress' );
     1779            break;
     1780        case 'mod-of':
     1781            _e( 'Moderator Of', 'buddypress' );
     1782            break;
     1783        case 'alphabetically':
     1784            _e( 'Alphabetically', 'buddypress' );
     1785        break;
     1786    }
     1787    do_action( 'bp_groups_filter_title' );
     1788}
     1789
     1790function bp_is_group_admin_screen( $slug ) {
     1791    global $bp;
     1792
     1793    if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action )
     1794        return false;
     1795
     1796    if ( $bp->action_variables[0] == $slug )
     1797        return true;
     1798
     1799    return false;
     1800}
     1801
     1802/************************************************************************************
     1803 * Group Avatar Template Tags
     1804 **/
     1805
     1806function bp_group_current_avatar() {
     1807    global $bp;
     1808
     1809    if ( $bp->groups->current_group->avatar_full ) { ?>
     1810        <img src="<?php echo attribute_escape( $bp->groups->current_group->avatar_full ) ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" />
     1811    <?php } else { ?>
     1812        <img src="<?php echo $bp->groups->image_base . '/none.gif' ?>" alt="<?php _e( 'No Group Avatar', 'buddypress' ) ?>" class="avatar" />
     1813    <?php }
     1814}
     1815
     1816function bp_get_group_has_avatar() {
     1817    global $bp;
     1818
     1819    if ( !empty( $_FILES ) || !bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'no_grav' => true ) ) )
     1820        return false;
     1821
     1822    return true;
     1823}
     1824
     1825function bp_group_avatar_delete_link() {
     1826    echo bp_get_group_avatar_delete_link();
     1827}
     1828    function bp_get_group_avatar_delete_link() {
     1829        global $bp;
     1830
     1831        return apply_filters( 'bp_get_group_avatar_delete_link', wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/group-avatar/delete', 'bp_group_avatar_delete' ) );
     1832    }
     1833
     1834function bp_group_avatar_edit_form() {
     1835    groups_avatar_upload();
     1836}
     1837
     1838function bp_custom_group_boxes() {
     1839    do_action( 'groups_custom_group_boxes' );
     1840}
     1841
     1842function bp_custom_group_admin_tabs() {
     1843    do_action( 'groups_custom_group_admin_tabs' );
     1844}
     1845
     1846function bp_custom_group_fields_editable() {
     1847    do_action( 'groups_custom_group_fields_editable' );
     1848}
     1849
     1850function bp_custom_group_fields() {
     1851    do_action( 'groups_custom_group_fields' );
     1852}
     1853
    22121854
    22131855/************************************************************************************
     
    22571899            'total' => ceil( $this->total_request_count / $this->pag_num ),
    22581900            'current' => $this->pag_page,
    2259             'prev_text' => '&laquo;',
    2260             'next_text' => '&raquo;',
     1901            'prev_text' => '&larr;',
     1902            'next_text' => '&rarr;',
    22611903            'mid_size' => 1
    22621904        ));
Note: See TracChangeset for help on using the changeset viewer.