Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/20/2011 01:30:01 PM (15 years ago)
Author:
johnjamesjacoby
Message:

Split bp-core up into smaller files, and move user functions into the bp-users component. This provides better definition between what is a 'core' function and what is a 'user' function.

Also remove individual uri_globals and set them directly to $bp in bp_core_set_uri_globals. No reason to have multiple extra globals floating around, and plugins shouldn't be using them directly either.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-catchuri.php

    r3743 r3767  
    66
    77/**
    8  * bp_core_set_uri_globals()
    9  *
    108 * Analyzes the URI structure and breaks it down into parts for use in code.
    119 * The idea is that BuddyPress can use complete custom friendly URI's without the
     
    1311 *
    1412 * Future custom components would then be able to use their own custom URI structure.
     13 *
     14 * @package BuddyPress Core
     15 * @since BuddyPress (r100)
    1516 *
    1617 * The URI's are broken down as follows:
     
    2425 *    - $bp->action_variables: array ['group', 5]
    2526 *
    26  * @package BuddyPress Core
    2727 */
    2828function bp_core_set_uri_globals() {
    29     global $current_component, $current_action, $action_variables;
    30     global $displayed_user_id, $bp_pages;
    31     global $is_member_page;
     29    global $bp, $bp_pages;
    3230    global $bp_unfiltered_uri, $bp_unfiltered_uri_offset;
    33     global $bp, $current_blog;
    34 
    35     /* Fetch all the WP page names for each component */
     31    global $current_blog;
     32
     33    $current_component = '';
     34
     35    if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && is_multisite() ) {
     36        // Only catch URI's on the root blog if we are not running
     37        // on multiple blogs
     38        if ( BP_ROOT_BLOG != (int) $current_blog->blog_id )
     39            return false;
     40    }
     41
     42    // Fetch all the WP page names for each component
    3643    if ( empty( $bp_pages ) )
    3744        $bp_pages = bp_core_get_page_names();
    38 
    39     if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && is_multisite() ) {
    40         /* Only catch URI's on the root blog if we are not running BP on multiple blogs */
    41         if ( BP_ROOT_BLOG != (int) $current_blog->blog_id )
    42             return false;
    43     }
    4445
    4546    // Ajax or not?
     
    5354    // Take GET variables off the URL to avoid problems,
    5455    // they are still registered in the global $_GET variable
    55     $noget = substr( $path, 0, strpos( $path, '?' ) );
    56     if ( $noget != '' )
     56    if ( $noget = substr( $path, 0, strpos( $path, '?' ) ) )
    5757        $path = $noget;
    5858
     
    8484
    8585    // Set the indexes, these are incresed by one if we are not on a VHOST install
    86     $component_index    = 0;
    87     $action_index       = $component_index + 1;
     86    $component_index = 0;
     87    $action_index    = $component_index + 1;
    8888
    8989    // Get site path items
     
    105105
    106106    // Reset the keys by merging with an empty array
    107     $bp_uri            = array_merge( array(), $bp_uri );
     107    $bp_uri = array_merge( array(), $bp_uri );
    108108
    109109    // If a component is set to the front page, force its name into $bp_uri so that $current_component is populated
     
    147147
    148148    // This is not a BuddyPress page, so just return.
    149     if ( !isset( $matches ) )
     149    if ( !isset( $matches ) ) {
     150        $bp->current_component = $current_component;
     151        $bp->current_action    = '';
     152        $bp->action_variables  = '';
     153        $bp->current_item      = '';
    150154        return false;
     155    }
    151156
    152157    // Find the offset
     
    166171        if ( !empty( $bp_uri[$uri_offset + 1] ) ) {
    167172            if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) )
    168                 $displayed_user_id = (int) bp_core_get_userid( urldecode( $bp_uri[$uri_offset + 1] ) );
     173                $bp->displayed_user->id = (int) bp_core_get_userid( urldecode( $bp_uri[$uri_offset + 1] ) );
    169174            else
    170                 $displayed_user_id = (int) bp_core_get_userid_from_nicename( urldecode( $bp_uri[$uri_offset + 1] ) );
     175                $bp->displayed_user->id = (int) bp_core_get_userid_from_nicename( urldecode( $bp_uri[$uri_offset + 1] ) );
    171176
    172177            $uri_offset = $uri_offset + 2;
     
    193198            }
    194199        }
    195     } else
     200    } else {
    196201        $i = 1;
     202    }
     203
     204    // Set the current component in the global
     205    $bp->current_component = $current_component;
    197206
    198207    // Set the current action
    199     $current_action = isset( $bp_uri[$i] ) ? $bp_uri[$i] : '';
     208    $bp->current_action    = isset( $bp_uri[$i] ) ? $bp_uri[$i] : '';
    200209
    201210    // Unset the current_component and action from action_variables
     
    204213
    205214    // Set the entire URI as the action variables, we will unset the current_component and action in a second
    206     $action_variables = $bp_uri;
     215    $bp->action_variables = $bp_uri;
    207216
    208217    // Remove the username from action variables if this is not a VHOST install
    209218    if ( defined( 'VHOST' ) && 'no' == VHOST && empty( $is_root_component ) )
    210         array_shift($bp_uri);
     219        array_shift( $bp_uri );
    211220
    212221    // Reset the keys by merging with an empty array
    213     $action_variables = array_merge( array(), $action_variables );
     222    $bp->action_variables = array_merge( array(), $bp->action_variables );
     223
     224    // Set the current item to empty
     225    $bp->current_item     = '';
    214226}
    215227
     
    244256    // Make the queried/post object an actual valid page
    245257    if ( !empty( $object_id ) ) {
    246         $wp_query->queried_object = &get_post( $object_id );
     258        $wp_query->queried_object    = &get_post( $object_id );
    247259        $wp_query->queried_object_id = $object_id;
    248 
    249         $post = $wp_query->queried_object;
     260        $post                        = $wp_query->queried_object;
    250261    }
    251262
Note: See TracChangeset for help on using the changeset viewer.