Skip to:
Content

BuddyPress.org

Changeset 6827


Ignore:
Timestamp:
03/01/2013 09:34:55 PM (14 years ago)
Author:
boonebgorges
Message:

Enables theme compat for legacy bbPress 1.x forum content

  • Don't exclude top-level forum directory page from wp_nav_menu() as long as forums are correctly installed
  • Introduces BP_Forums_Legacy_Theme_Compat
  • Tweaks forum directory table styling

Fixes #4854

Props imath

Location:
trunk
Files:
4 edited

Legend:

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

    r6800 r6827  
    9292                $pages[] = $bp->pages->register->id;
    9393
    94         if ( !empty( $bp->pages->forums ) )
     94        if ( !empty( $bp->pages->forums ) && ( !bp_is_active( 'forums' ) || ( bp_is_active( 'forums' ) && bp_forums_has_directory() && !bp_forums_is_installed_correctly() ) ) )
    9595                $pages[] = $bp->pages->forums->id;
    9696
  • trunk/bp-forums/bp-forums-screens.php

    r6406 r6827  
    119119}
    120120add_action( 'bp_screens', 'bp_forums_screen_single_topic' );
     121
     122
     123/** Theme Compatability *******************************************************/
     124
     125/**
     126 * The main theme compat class for legacy BuddyPress forums, as powered by bbPress 1.x
     127 *
     128 * This class sets up the necessary theme compatability actions to safely output
     129 * old forum template parts to the_title and the_content areas of a theme.
     130 *
     131 * @since BuddyPress (1.7)
     132 */
     133class BP_Forum_Legacy_Theme_Compat {
     134
     135        /**
     136         * Setup the old forums component theme compatibility
     137         *
     138         * @since BuddyPress (1.7)
     139         */
     140        public function __construct() {
     141                add_action( 'bp_setup_theme_compat', array( $this, 'is_legacy_forum' ) );
     142        }
     143
     144        /**
     145         * Are we looking at something that needs old forum theme compatability?
     146         *
     147         * @since BuddyPress (1.7)
     148         */
     149        public function is_legacy_forum() {
     150
     151                // Bail if not looking at a group
     152                if ( ! bp_is_forums_component() )
     153                        return;
     154
     155                // forum Directory
     156                if ( ( ! bp_current_action() || ( 'tag' == bp_current_action() && bp_action_variables() ) ) && ! bp_current_item() ) {
     157
     158                        if ( ! bp_forums_has_directory() )
     159                                return false;
     160
     161                        if ( ! bp_forums_is_installed_correctly() ) {
     162                                bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' );
     163                                bp_core_redirect( bp_get_root_domain() );
     164                        }
     165
     166                        bp_update_is_directory( true, 'forums' );
     167
     168                        do_action( 'bp_forums_directory_forums_setup' );
     169
     170                        add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'directory_dummy_post' ) );
     171                        add_filter( 'bp_replace_the_content',                    array( $this, 'directory_content'    ) );
     172
     173                }
     174
     175        }
     176
     177        /** Directory *************************************************************/
     178
     179        /**
     180         * Update the global $post with directory data
     181         *
     182         * @since BuddyPress (1.7)
     183         */
     184        public function directory_dummy_post() {
     185
     186                // Title based on ability to create groups
     187                if ( is_user_logged_in() ) {
     188                        $title = __( 'Forums', 'buddypress' ) . '&nbsp;<a class="button show-hide-new bp-title-button" href="#new-topic" id="new-topic-button">' . __( 'New Topic', 'buddypress' ) . '</a>';
     189                } else {
     190                        $title = __( 'Forums', 'buddypress' );
     191                }
     192
     193                bp_theme_compat_reset_post( array(
     194                        'ID'             => 0,
     195                        'post_title'     => $title,
     196                        'post_author'    => 0,
     197                        'post_date'      => 0,
     198                        'post_content'   => '',
     199                        'post_type'      => 'bp_forum',
     200                        'post_status'    => 'publish',
     201                        'is_archive'     => true,
     202                        'comment_status' => 'closed'
     203                ) );
     204        }
     205
     206        /**
     207         * Filter the_content with the old forum index template part
     208         *
     209         * @since BuddyPress (1.7)
     210         */
     211        public function directory_content() {
     212                bp_buffer_template_part( 'forums/index' );
     213        }
     214}
     215new BP_Forum_Legacy_Theme_Compat();
  • trunk/bp-templates/bp-legacy/buddypress/forums/index.php

    r6284 r6827  
    1 <?php do_action( 'bp_before_directory_forums' ); ?>
     1<div id="buddypress">
     2       
     3        <?php do_action( 'bp_before_directory_forums' ); ?>
    24
    3 <form action="" method="post" id="forums-search-form" class="dir-form">
     5        <form action="" method="post" id="forums-search-form" class="dir-form">
    46
    5         <?php do_action( 'bp_before_directory_forums_content' ); ?>
     7                <?php do_action( 'bp_before_directory_forums_content' ); ?>
    68
    7         <div id="forums-dir-search" class="dir-search" role="search">
     9                <div id="forums-dir-search" class="dir-search" role="search">
    810
    9                 <?php bp_directory_forums_search_form(); ?>
     11                        <?php bp_directory_forums_search_form(); ?>
    1012
    11         </div>
    12 </form>
     13                </div>
     14        </form>
    1315
    14 <?php do_action( 'bp_before_topics' ); ?>
     16        <?php do_action( 'bp_before_topics' ); ?>
    1517
    16 <form action="" method="post" id="forums-directory-form" class="dir-form">
     18        <form action="" method="post" id="forums-directory-form" class="dir-form">
    1719
    18         <div class="item-list-tabs" role="navigation">
    19                 <ul>
    20                         <li class="selected" id="forums-all"><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() ); ?>"><?php printf( __( 'All Topics <span>%s</span>', 'buddypress' ), bp_get_forum_topic_count() ); ?></a></li>
     20                <div class="item-list-tabs" role="navigation">
     21                        <ul>
     22                                <li class="selected" id="forums-all"><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() ); ?>"><?php printf( __( 'All Topics <span>%s</span>', 'buddypress' ), bp_get_forum_topic_count() ); ?></a></li>
    2123
    22                         <?php if ( is_user_logged_in() && bp_get_forum_topic_count_for_user( bp_loggedin_user_id() ) ) : ?>
     24                                <?php if ( is_user_logged_in() && bp_get_forum_topic_count_for_user( bp_loggedin_user_id() ) ) : ?>
    2325
    24                                 <li id="forums-personal"><a href="<?php echo trailingslashit( bp_loggedin_user_domain() . bp_get_forums_slug() . '/topics' ); ?>"><?php printf( __( 'My Topics <span>%s</span>', 'buddypress' ), bp_get_forum_topic_count_for_user( bp_loggedin_user_id() ) ); ?></a></li>
     26                                        <li id="forums-personal"><a href="<?php echo trailingslashit( bp_loggedin_user_domain() . bp_get_forums_slug() . '/topics' ); ?>"><?php printf( __( 'My Topics <span>%s</span>', 'buddypress' ), bp_get_forum_topic_count_for_user( bp_loggedin_user_id() ) ); ?></a></li>
     27
     28                                <?php endif; ?>
     29
     30                                <?php do_action( 'bp_forums_directory_group_types' ); ?>
     31
     32                        </ul>
     33                </div>
     34
     35                <div class="item-list-tabs" id="subnav" role="navigation">
     36                        <ul>
     37
     38                                <?php do_action( 'bp_forums_directory_group_sub_types' ); ?>
     39
     40                                <li id="forums-order-select" class="last filter">
     41
     42                                        <label for="forums-order-by"><?php _e( 'Order By:', 'buddypress' ); ?></label>
     43                                        <select id="forums-order-by">
     44                                                <option value="active"><?php _e( 'Last Active', 'buddypress' ); ?></option>
     45                                                <option value="popular"><?php _e( 'Most Posts', 'buddypress' ); ?></option>
     46                                                <option value="unreplied"><?php _e( 'Unreplied', 'buddypress' ); ?></option>
     47
     48                                                <?php do_action( 'bp_forums_directory_order_options' ); ?>
     49
     50                                        </select>
     51                                </li>
     52                        </ul>
     53                </div>
     54
     55                <div id="forums-dir-list" class="forums dir-list" role="main">
     56
     57                        <?php bp_get_template_part( 'forums/forums-loop' ); ?>
     58
     59                </div>
     60
     61                <?php do_action( 'bp_directory_forums_content' ); ?>
     62
     63                <?php wp_nonce_field( 'directory_forums', '_wpnonce-forums-filter' ); ?>
     64
     65        </form>
     66
     67        <?php do_action( 'bp_after_directory_forums' ); ?>
     68
     69        <?php do_action( 'bp_before_new_topic_form' ); ?>
     70
     71        <div id="new-topic-post">
     72
     73                <?php if ( is_user_logged_in() ) : ?>
     74
     75                        <?php if ( bp_is_active( 'groups' ) && bp_has_groups( 'user_id=' . bp_loggedin_user_id() . '&type=alphabetical&max=100&per_page=100' ) ) : ?>
     76
     77                                <form action="" method="post" id="forum-topic-form" class="standard-form">
     78
     79                                        <?php do_action( 'groups_forum_new_topic_before' ); ?>
     80
     81                                        <a name="post-new"></a>
     82                                        <h5><?php _e( 'Create New Topic:', 'buddypress' ); ?></h5>
     83
     84                                        <?php do_action( 'template_notices' ); ?>
     85
     86                                        <label><?php _e( 'Title:', 'buddypress' ); ?></label>
     87                                        <input type="text" name="topic_title" id="topic_title" value="" maxlength="100" />
     88
     89                                        <label><?php _e( 'Content:', 'buddypress' ); ?></label>
     90                                        <textarea name="topic_text" id="topic_text"></textarea>
     91
     92                                        <label><?php _e( 'Tags (comma separated):', 'buddypress' ); ?></label>
     93                                        <input type="text" name="topic_tags" id="topic_tags" value="" />
     94
     95                                        <label><?php _e( 'Post In Group Forum:', 'buddypress' ); ?></label>
     96                                        <select id="topic_group_id" name="topic_group_id">
     97
     98                                                <option value=""><?php /* translators: no option picked in select box */ _e( '----', 'buddypress' ); ?></option>
     99
     100                                                <?php while ( bp_groups() ) : bp_the_group(); ?>
     101
     102                                                        <?php if ( bp_group_is_forum_enabled() && ( bp_current_user_can( 'bp_moderate' ) || 'public' == bp_get_group_status() || bp_group_is_member() ) ) : ?>
     103
     104                                                                <option value="<?php bp_group_id(); ?>"><?php bp_group_name(); ?></option>
     105
     106                                                        <?php endif; ?>
     107
     108                                                <?php endwhile; ?>
     109
     110                                        </select><!-- #topic_group_id -->
     111
     112                                        <?php do_action( 'groups_forum_new_topic_after' ); ?>
     113
     114                                        <div class="submit">
     115                                                <input type="submit" name="submit_topic" id="submit" value="<?php _e( 'Post Topic', 'buddypress' ); ?>" />
     116                                                <input type="button" name="submit_topic_cancel" id="submit_topic_cancel" value="<?php _e( 'Cancel', 'buddypress' ); ?>" />
     117                                        </div>
     118
     119                                        <?php wp_nonce_field( 'bp_forums_new_topic' ); ?>
     120
     121                                </form><!-- #forum-topic-form -->
     122
     123                        <?php elseif ( bp_is_active( 'groups' ) ) : ?>
     124
     125                                <div id="message" class="info">
     126
     127                                        <p><?php printf( __( "You are not a member of any groups so you don't have any group forums you can post in. To start posting, first find a group that matches the topic subject you'd like to start. If this group does not exist, why not <a href='%s'>create a new group</a>? Once you have joined or created the group you can post your topic in that group's forum.", 'buddypress' ), site_url( bp_get_groups_root_slug() . '/create/' ) ); ?></p>
     128
     129                                </div>
    25130
    26131                        <?php endif; ?>
    27132
    28                         <?php do_action( 'bp_forums_directory_group_types' ); ?>
     133                <?php endif; ?>
     134        </div><!-- #new-topic-post -->
    29135
    30                 </ul>
    31         </div>
     136        <?php do_action( 'bp_after_new_topic_form' ); ?>
    32137
    33         <div class="item-list-tabs" id="subnav" role="navigation">
    34                 <ul>
    35 
    36                         <?php do_action( 'bp_forums_directory_group_sub_types' ); ?>
    37 
    38                         <li id="forums-order-select" class="last filter">
    39 
    40                                 <label for="forums-order-by"><?php _e( 'Order By:', 'buddypress' ); ?></label>
    41                                 <select id="forums-order-by">
    42                                         <option value="active"><?php _e( 'Last Active', 'buddypress' ); ?></option>
    43                                         <option value="popular"><?php _e( 'Most Posts', 'buddypress' ); ?></option>
    44                                         <option value="unreplied"><?php _e( 'Unreplied', 'buddypress' ); ?></option>
    45 
    46                                         <?php do_action( 'bp_forums_directory_order_options' ); ?>
    47 
    48                                 </select>
    49                         </li>
    50                 </ul>
    51         </div>
    52 
    53         <div id="forums-dir-list" class="forums dir-list" role="main">
    54 
    55                 <?php bp_get_template_part( 'forums/forums-loop' ); ?>
    56 
    57         </div>
    58 
    59         <?php do_action( 'bp_directory_forums_content' ); ?>
    60 
    61         <?php wp_nonce_field( 'directory_forums', '_wpnonce-forums-filter' ); ?>
    62 
    63 </form>
    64 
    65 <?php do_action( 'bp_after_directory_forums' ); ?>
    66 
    67 <?php do_action( 'bp_before_new_topic_form' ); ?>
    68 
    69 <div id="new-topic-post">
    70 
    71         <?php if ( is_user_logged_in() ) : ?>
    72 
    73                 <?php if ( bp_is_active( 'groups' ) && bp_has_groups( 'user_id=' . bp_loggedin_user_id() . '&type=alphabetical&max=100&per_page=100' ) ) : ?>
    74 
    75                         <form action="" method="post" id="forum-topic-form" class="standard-form">
    76 
    77                                 <?php do_action( 'groups_forum_new_topic_before' ); ?>
    78 
    79                                 <a name="post-new"></a>
    80                                 <h5><?php _e( 'Create New Topic:', 'buddypress' ); ?></h5>
    81 
    82                                 <?php do_action( 'template_notices' ); ?>
    83 
    84                                 <label><?php _e( 'Title:', 'buddypress' ); ?></label>
    85                                 <input type="text" name="topic_title" id="topic_title" value="" maxlength="100" />
    86 
    87                                 <label><?php _e( 'Content:', 'buddypress' ); ?></label>
    88                                 <textarea name="topic_text" id="topic_text"></textarea>
    89 
    90                                 <label><?php _e( 'Tags (comma separated):', 'buddypress' ); ?></label>
    91                                 <input type="text" name="topic_tags" id="topic_tags" value="" />
    92 
    93                                 <label><?php _e( 'Post In Group Forum:', 'buddypress' ); ?></label>
    94                                 <select id="topic_group_id" name="topic_group_id">
    95 
    96                                         <option value=""><?php /* translators: no option picked in select box */ _e( '----', 'buddypress' ); ?></option>
    97 
    98                                         <?php while ( bp_groups() ) : bp_the_group(); ?>
    99 
    100                                                 <?php if ( bp_group_is_forum_enabled() && ( bp_current_user_can( 'bp_moderate' ) || 'public' == bp_get_group_status() || bp_group_is_member() ) ) : ?>
    101 
    102                                                         <option value="<?php bp_group_id(); ?>"><?php bp_group_name(); ?></option>
    103 
    104                                                 <?php endif; ?>
    105 
    106                                         <?php endwhile; ?>
    107 
    108                                 </select><!-- #topic_group_id -->
    109 
    110                                 <?php do_action( 'groups_forum_new_topic_after' ); ?>
    111 
    112                                 <div class="submit">
    113                                         <input type="submit" name="submit_topic" id="submit" value="<?php _e( 'Post Topic', 'buddypress' ); ?>" />
    114                                         <input type="button" name="submit_topic_cancel" id="submit_topic_cancel" value="<?php _e( 'Cancel', 'buddypress' ); ?>" />
    115                                 </div>
    116 
    117                                 <?php wp_nonce_field( 'bp_forums_new_topic' ); ?>
    118 
    119                         </form><!-- #forum-topic-form -->
    120 
    121                 <?php elseif ( bp_is_active( 'groups' ) ) : ?>
    122 
    123                         <div id="message" class="info">
    124 
    125                                 <p><?php printf( __( "You are not a member of any groups so you don't have any group forums you can post in. To start posting, first find a group that matches the topic subject you'd like to start. If this group does not exist, why not <a href='%s'>create a new group</a>? Once you have joined or created the group you can post your topic in that group's forum.", 'buddypress' ), site_url( bp_get_groups_root_slug() . '/create/' ) ); ?></p>
    126 
    127                         </div>
    128 
    129                 <?php endif; ?>
    130 
    131         <?php endif; ?>
    132 </div><!-- #new-topic-post -->
    133 
    134 <?php do_action( 'bp_after_new_topic_form' ); ?>
    135 
    136 <?php do_action( 'bp_after_directory_forums_content' ); ?>
     138        <?php do_action( 'bp_after_directory_forums_content' ); ?>
     139       
     140</div>
  • trunk/bp-templates/bp-legacy/css/buddypress.css

    r6808 r6827  
    942942        margin: 0;
    943943        width: auto;
     944        clear: both;
    944945}
    945946#buddypress table.forum tr.sticky td {
Note: See TracChangeset for help on using the changeset viewer.