Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/12/2008 11:58:11 PM (18 years ago)
Author:
apeatling
Message:

Fixed catch-uri functions so that BuddyPress no longer has to be installed in the root of a site.

File:
1 edited

Legend:

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

    r388 r392  
    1717 *   - VHOST: http:// andy.domain.com / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
    1818 *   - NO VHOST: http:// domain.com / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
     19 *   - OUTSIDE ROOT: http:// domain.com / sites / buddypress / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
    1920 *
    20  * Example:
     21 *      Example:
    2122 *    - http://andy.domain.com/profile/edit/group/5/
    2223 *    - $current_component: string 'profile'
     
    2829function bp_core_set_uri_globals() {
    2930        global $current_component, $current_action, $action_variables;
    30        
     31
    3132        /* Fetch the current URI and explode each part seperated by '/' into an array */
    3233        $bp_uri = explode( "/", $_SERVER['REQUEST_URI'] );
    33 
    34         /* This is used to determine where the component and action indexes should start */
    35         $root_components = explode( ',', BP_CORE_ROOT_COMPONENTS );
    36         $is_root_component = in_array( $bp_uri[1], $root_components );
    3734       
    3835        /* Set the indexes, these are incresed by one if we are not on a VHOST install */
    3936        $component_index = 0;
    40         $action_index = 1;
     37        $action_index = $component_index + 1;
     38       
     39        /* Get site path items */
     40        $paths = explode( '/', bp_core_get_site_path() );
    4141
    42         if ( VHOST == 'no' && !$is_root_component ) {
    43                 $component_index++;
    44                 $action_index++;
    45         }
     42        /* Take empties off the end */
     43        if ( $paths[count($paths) - 1] == "" )
     44                array_pop( $paths );
    4645
     46        /* Take empties off the start */
     47        if ( $paths[0] == "" )
     48                array_shift( $paths );
     49       
    4750        /* Take empties off the end */
    4851        if ( $bp_uri[count($bp_uri) - 1] == "" )
     
    5255        if ( $bp_uri[0] == "" )
    5356                array_shift( $bp_uri );
    54 
     57               
    5558        /* Get total URI segment count */
    5659        $bp_uri_count = count( $bp_uri ) - 1;
     60
     61        for ( $i = 0; $i < $bp_uri_count; $i++ ) {
     62                if ( in_array( $bp_uri[$i], $paths )) {
     63                        unset( $bp_uri[$i] );
     64                }
     65        }
    5766       
     67        /* Reset the keys by merging with an empty array */
     68        $bp_uri = array_merge( array(), $bp_uri );
     69       
     70        /* This is used to determine where the component and action indexes should start */
     71        $root_components = explode( ',', BP_CORE_ROOT_COMPONENTS );
     72        $is_root_component = in_array( $bp_uri[0], $root_components );
     73       
     74        if ( VHOST == 'no' && !$is_root_component ) {
     75                $component_index++;
     76                $action_index++;
     77        }
     78
    5879        /* Set the current component */
    5980        $current_component = $bp_uri[$component_index];
     
    6586        $action_variables = $bp_uri;
    6687
    67         /* Remove the username from action variables if this is not a VHOST install */
    68         if ( VHOST == 'no' )
    69                 unset($action_variables[0]);
    70 
    7188        /* Unset the current_component and action from action_variables */
    7289        unset($action_variables[$component_index]);
    7390        unset($action_variables[$action_index]);
     91
     92        /* Remove the username from action variables if this is not a VHOST install */
     93        if ( VHOST == 'no' && !$is_root_component )
     94                array_shift($action_variables);
    7495       
    7596        /* Reset the keys by merging with an empty array */
Note: See TracChangeset for help on using the changeset viewer.