Skip to:
Content

BuddyPress.org

Changeset 3627


Ignore:
Timestamp:
12/30/2010 10:13:05 PM (16 years ago)
Author:
boonebgorges
Message:

Replaces generic 'Search anything' default directory search text with component-specific text. Fixes #1915. Fixes ->forums->slug so that it is properly set in the bp_pages way

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs.php

    r3578 r3627  
    1313                define ( 'BP_BLOGS_SLUG', $bp->pages->blogs->slug );
    1414
    15         /* For internal identification */
     15        // For internal identification
    1616        $bp->blogs->id = 'blogs';
    1717
     
    2323        $bp->blogs->format_notification_function = 'bp_blogs_format_notifications';
    2424
    25         /* Register this in the active components array */
     25        // Register this in the active components array
    2626        $bp->active_components[$bp->blogs->slug] = $bp->blogs->id;
     27
     28        // The default text for the blogs directory search box 
     29        $bp->default_search_strings[$bp->blogs->slug] = __( 'Search Blogs...', 'buddypress' );
    2730
    2831        do_action( 'bp_blogs_setup_globals' );
  • trunk/bp-blogs/bp-blogs-templatetags.php

    r3616 r3627  
    505505        global $bp;
    506506
    507         $search_value = __( 'Search anything...', 'buddypress' );
    508         if ( !empty( $_GET['s'] ) )
    509                 $search_value = stripslashes( $_GET['s'] );
     507        $default_search_value = bp_get_search_default_text();
     508        $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value;
    510509
    511510        ?>
    512511        <form action="" method="get" id="search-blogs-form">
    513                 <label><input type="text" name="s" id="blogs_search" value="<?php echo esc_attr( $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>
     512                <label><input type="text" name="s" id="blogs_search" value="<?php echo esc_attr( $search_value ) ?>"  onfocus="if (this.value == '<?php echo $default_search_value ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php echo $default_search_value ?>';}" /></label>
    514513                <input type="submit" id="blogs_search_submit" name="blogs_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    515514        </form>
  • trunk/bp-core.php

    r3612 r3627  
    168168        if ( !$bp->current_component && $bp->displayed_user->id )
    169169                $bp->current_component = $bp->default_component;
     170
     171        // The default text for the members directory search box
     172        $bp->default_search_strings[$bp->members->slug] = __( 'Search Members...', 'buddypress' );
    170173
    171174        do_action( 'bp_core_setup_globals' );
  • trunk/bp-core/bp-core-templatetags.php

    r3622 r3627  
    455455        global $bp;
    456456
    457         $search_value = __( 'Search anything...', 'buddypress' );
    458         if ( !empty( $_GET['s'] ) )
    459                 $search_value = stripslashes( $_GET['s'] );
     457        $default_search_value = bp_get_search_default_text();
     458        $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value;
    460459
    461460        ?>
    462461        <form action="" method="get" id="search-members-form">
    463                 <label><input type="text" name="s" id="members_search" value="<?php echo esc_attr( $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>
     462                <label><input type="text" name="s" id="members_search" value="<?php echo esc_attr( $search_value ) ?>"  onfocus="if (this.value == '<?php echo $default_search_value ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php echo $default_search_value ?>';}" /></label>
    464463                <input type="submit" id="members_search_submit" name="members_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    465464        </form>
     
    10491048}
    10501049
     1050/**
     1051 * Get the default text for the search box for a given component.
     1052 *
     1053 * @global object $bp BuddyPress global settings
     1054 * @return string
     1055 * @since 1.3
     1056 */
     1057function bp_search_default_text() {
     1058        echo bp_get_search_default_text();
     1059}
     1060        function bp_get_search_default_text( $component = false ) {
     1061                global $bp;
     1062               
     1063                if ( empty( $component ) )
     1064                        $component = $bp->current_component;
     1065               
     1066                $default_text = __( 'Search anything...', 'buddypress' );
     1067               
     1068                if ( !empty( $bp->default_search_strings[$component] ) ) {
     1069                        // Most of the time, $component will be the actual component name
     1070                        $default_text = $bp->default_search_strings[$component];
     1071                } else {
     1072                        // When the request comes through AJAX, we need to get the component name
     1073                        // out of $bp->pages
     1074                        if ( !empty( $bp->pages->{$component}->slug ) ) {
     1075                                $key = $bp->pages->{$component}->slug;
     1076                                if ( !empty( $bp->default_search_strings[$key] ) )
     1077                                        $default_text = $bp->default_search_strings[$key];
     1078                        }
     1079                }
     1080               
     1081                return apply_filters( 'bp_search_default_text', $default_text, $component );
     1082        }
     1083
    10511084function bp_search_form() {
    10521085        $form = '
  • trunk/bp-forums.php

    r3592 r3627  
    55        define( 'BP_FORUMS_PARENT_FORUM_ID', 1 );
    66
    7 if ( !defined( 'BP_FORUMS_SLUG' ) )
    8         define( 'BP_FORUMS_SLUG', 'forums' );
    9 
    107if ( !defined( 'BB_PATH' ) )
    118        require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-bbpress.php' );
     
    1411require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-filters.php' );
    1512
     13/**
     14 * Puts important forums component data into the $bp global for later use.
     15 *
     16 * @package BuddyPress Forums
     17 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     18 */
    1619function bp_forums_setup() {
    1720        global $bp;
    18 
    19         /* For internal identification */
     21       
     22        if ( !defined( 'BP_FORUMS_SLUG' ) )
     23                define ( 'BP_FORUMS_SLUG', $bp->pages->forums->slug );
     24
     25        // For internal identification
    2026        $bp->forums->id = 'forums';
    2127
     
    2632                $bp->forums->bbconfig = $bp->site_options['bb-config-location'];
    2733
    28         /* Register this in the active components array */
     34        // Register this in the active components array
    2935        $bp->active_components[$bp->forums->slug] = $bp->forums->id;
     36
     37        // The default text for the forums directory search box
     38        $bp->default_search_strings[$bp->forums->slug] = __( 'Search Forum Topics...', 'buddypress' );
    3039
    3140        do_action( 'bp_forums_setup' );
  • trunk/bp-forums/bp-forums-templatetags.php

    r3616 r3627  
    10291029        global $bp;
    10301030
    1031         $search_value = __( 'Search anything...', 'buddypress' );
    1032         if ( !empty( $_REQUEST['fs'] ) )
    1033                 $search_value = stripslashes( $_REQUEST['fs'] );
     1031        $default_search_value = bp_get_search_default_text();
     1032        $search_value = !empty( $_REQUEST['fs'] ) ? stripslashes( $_REQUEST['fs'] ) : $default_search_value;
    10341033
    10351034?>
    10361035        <form action="" method="get" id="search-forums-form">
    1037                 <label><input type="text" name="s" id="forums_search" value="<?php echo esc_attr( $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>
     1036                <label><input type="text" name="s" id="forums_search" value="<?php echo esc_attr( $search_value ) ?>"  onfocus="if (this.value == '<?php echo $default_search_value ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php echo $default_search_value ?>';}" /></label>
    10381037                <input type="submit" id="forums_search_submit" name="forums_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    10391038        </form>
  • trunk/bp-groups.php

    r3620 r3627  
    55require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-filters.php' );
    66
     7/**
     8 * Puts important groups component data into the $bp global for later use.
     9 *
     10 * @package BuddyPress Groups
     11 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     12 */
    713function groups_setup_globals() {
    8         global $bp, $wpdb;
     14        global $bp;
    915
    1016        if ( !defined( 'BP_GROUPS_SLUG' ) )
     
    4046        // Auto join group when non group member performs group activity
    4147        $bp->groups->auto_join = defined( 'BP_DISABLE_AUTO_GROUP_JOIN' ) ? false : true;
     48
     49        // The default text for the groups directory search box
     50        $bp->default_search_strings[$bp->groups->slug] = __( 'Search Groups...', 'buddypress' );
    4251
    4352        do_action( 'groups_setup_globals' );
  • trunk/bp-groups/bp-groups-templatetags.php

    r3616 r3627  
    18721872        global $bp;
    18731873
    1874         $search_value = __( 'Search anything...', 'buddypress' );
    1875         if ( !empty( $_REQUEST['s'] ) )
    1876                 $search_value = stripslashes( $_REQUEST['s'] );
     1874        $default_search_value = bp_get_search_default_text();
     1875        $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value;
    18771876
    18781877?>
    18791878        <form action="" method="get" id="search-groups-form">
    1880                 <label><input type="text" name="s" id="groups_search" value="<?php echo esc_attr( $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>
     1879                <label><input type="text" name="s" id="groups_search" value="<?php echo esc_attr( $search_value ) ?>"  onfocus="if (this.value == '<?php echo $default_search_value ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php echo $default_search_value ?>';}" /></label>
    18811880                <input type="submit" id="groups_search_submit" name="groups_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    18821881        </form>
  • trunk/bp-themes/bp-default/_inc/ajax.php

    r3592 r3627  
    5454                $qs[] = 'page=' . $_POST['page'];
    5555
    56         if ( !empty( $_POST['search_terms'] ) && __( 'Search anything...', 'buddypress' ) != $_POST['search_terms'] && 'false' != $_POST['search_terms'] && 'undefined' != $_POST['search_terms'] )
     56        $object_search_text = bp_get_search_default_text( $object );
     57        if ( !empty( $_POST['search_terms'] ) && $object_search_text != $_POST['search_terms'] && 'false' != $_POST['search_terms'] && 'undefined' != $_POST['search_terms'] )
    5758                $qs[] = 'search_terms=' . $_POST['search_terms'];
    5859
Note: See TracChangeset for help on using the changeset viewer.