Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/09/2011 06:40:20 PM (15 years ago)
Author:
djpaul
Message:

Fix pagination symbol i18n. Tidy whitespace. Fixes #3456, props r-a-y

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-forums/bp-forums-template.php

    r4907 r4955  
    102102    }
    103103
    104     function __construct( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms, $offset = false, $number = false ) { 
     104    function __construct( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms, $offset = false, $number = false ) {
    105105        global $bp;
    106106
     
    114114
    115115        switch ( $type ) {
    116             case 'newest': default:             
     116            case 'newest': default:
    117117                $this->topics = bp_forums_get_forum_topics( array( 'user_id' => $user_id, 'forum_id' => $forum_id, 'filter' => $search_terms, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $no_stickies, 'offset' => $offset, 'number' => $number ) );
    118118                break;
     
    153153                $this->total_topic_count = (int)$max;
    154154            }
    155            
     155
    156156            if ( $max ) {
    157157                if ( $max >= count($this->topics) ) {
     
    177177                'total'     => ceil( (int)$this->total_topic_count / (int)$this->pag_num),
    178178                'current'   => $this->pag_page,
    179                 'prev_text' => '←',
    180                 'next_text' => '→',
     179                'prev_text' => _x( '←', 'Forum topic pagination previous text', 'buddypress' ),
     180                'next_text' => _x( '→', 'Forum topic pagination next text', 'buddypress' ),
    181181                'mid_size'  => 1
    182182            ) );
     
    261261    if ( !empty( $bp->displayed_user->id ) )
    262262        $user_id = $bp->displayed_user->id;
    263    
     263
    264264    // "Replied" query must be manually modified
    265265    if ( 'replies' == bp_current_action() ) {
    266266        $user_id = 0; // User id must be handled manually by the filter, not by BB_Query
    267        
     267
    268268        add_filter( 'get_topics_distinct',   'bp_forums_add_replied_distinct_sql', 20 );
    269269        add_filter( 'get_topics_join',       'bp_forums_add_replied_join_sql', 20 );
     
    286286    if ( bp_is_directory() && !empty( $_GET['fs'] ) )
    287287        $search_terms = $_GET['fs'];
    288    
     288
    289289    // Get the pagination arguments from $_REQUEST
    290290    $page     = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) : 1;
    291291    $per_page = isset( $_REQUEST['n'] ) ? intval( $_REQUEST['n'] ) : 20;
    292    
     292
    293293    // Unless set otherwise, stickies appear in normal order on the global forum directory
    294294    if ( bp_is_directory() && bp_is_forums_component() && !bp_forums_enable_global_directory_stickies() )
     
    316316        $type = 'tags';
    317317    }
    318    
     318
    319319    /** Sticky logic ******************************************************************/
    320    
     320
    321321    if ( $do_stickies ) {
    322322        // Fetch the stickies
    323323        $stickies_template = new BP_Forums_Template_Forum( $type, $forum_id, $user_id, 0, 0, $max, 'sticky', $search_terms );
    324        
     324
    325325        // If stickies are found, try merging them
    326326        if ( $stickies_template->has_topics() ) {
    327        
    328             // If stickies are for current $page       
     327
     328            // If stickies are for current $page
    329329            $page_start_num = ( ( $page - 1 ) * $per_page ) + 1;
    330330            $page_end_num   = $page * $per_page <= $stickies_template->total_topic_count ? $page * $per_page : $stickies_template->total_topic_count;
    331            
     331
    332332            // Calculate the number of sticky topics that will be shown on this page
    333333            if ( $stickies_template->topic_count < $page_start_num ) {
    334334                $this_page_stickies = 0;
    335             } else {           
     335            } else {
    336336                $this_page_stickies = $stickies_template->topic_count - $per_page * floor( $stickies_template->topic_count / $per_page ) * ( $page - 1 ); // Total stickies minus sticky count through this page
    337                
     337
    338338                // $this_page_stickies cannot be more than $per_page or less than 0
    339339                if ( $this_page_stickies > $per_page )
     
    342342                    $this_page_stickies = 0;
    343343            }
    344            
     344
    345345            // Calculate the total number of topics that will be shown on this page
    346346            $this_page_topics = $stickies_template->total_topic_count >= ( $page * $per_page ) ? $per_page : $page_end_num - ( $page_start_num - 1 );
    347            
     347
    348348            // If the number of stickies to be shown is less than $per_page, fetch some
    349349            // non-stickies to fill in the rest
     
    351351                // How many non-stickies do we need?
    352352                $non_sticky_number = $this_page_topics - $this_page_stickies;
    353                
    354                 // Calculate the non-sticky offset         
     353
     354                // Calculate the non-sticky offset
    355355                // How many non-stickies on all pages up to this point?
    356356                $non_sticky_total = $page_end_num - $stickies_template->topic_count;
    357                
     357
    358358                // The offset is the number of total non-stickies, less the number
    359359                // to be shown on this page
    360360                $non_sticky_offset = $non_sticky_total - $non_sticky_number;
    361                
     361
    362362                // Fetch the non-stickies
    363363                $forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $user_id, 1, $per_page, $max, 'no', $search_terms, $non_sticky_offset, $non_sticky_number );
    364                
     364
    365365                // If there are stickies to merge on this page, do it now
    366366                if ( $this_page_stickies ) {
    367367                    // Correct the topic_count
    368368                    $forum_template->topic_count += (int)$this_page_stickies;
    369                    
     369
    370370                    // Figure out which stickies need to be included
    371371                    $this_page_sticky_topics = array_slice( $stickies_template->topics, 0 - $this_page_stickies );
    372                    
     372
    373373                    // Merge these topics into the forum template
    374374                    $forum_template->topics = array_merge( $this_page_sticky_topics, (array)$forum_template->topics );
     
    377377                // This page has no non-stickies
    378378                $forum_template = $stickies_template;
    379                
     379
    380380                // Adjust the topic count and trim the topics
    381381                $forum_template->topic_count = $this_page_stickies;
    382                 $forum_template->topics      = array_slice( $forum_template->topics, $page - 1 );   
     382                $forum_template->topics      = array_slice( $forum_template->topics, $page - 1 );
    383383            }
    384                    
     384
    385385            // Because we're using a manual offset and number for the topic query, we
    386386            // must set the page number manually, and recalculate the pagination links
    387387            $forum_template->pag_num     = $per_page;
    388388            $forum_template->pag_page    = $page;
    389            
     389
    390390            $forum_template->pag_links = paginate_links( array(
    391391                'base'      => add_query_arg( array( 'p' => '%#%', 'n' => $forum_template->pag_num ) ),
     
    393393                'total'     => ceil( (int)$forum_template->total_topic_count / (int)$forum_template->pag_num ),
    394394                'current'   => $forum_template->pag_page,
    395                 'prev_text' => '&larr;',
    396                 'next_text' => '&rarr;',
     395                'prev_text' => _x( '&larr;', 'Forum topic pagination previous text', 'buddypress' ),
     396                'next_text' => _x( '&rarr;', 'Forum topic pagination next text', 'buddypress' ),
    397397                'mid_size'  => 1
    398398            ) );
    399            
     399
    400400        } else {
    401401            // Fetch the non-sticky topics if no stickies were found
     
    406406        $forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $user_id, $page, $per_page, $max, 'all', $search_terms );
    407407    }
    408        
     408
    409409    return apply_filters( 'bp_has_topics', $forum_template->has_topics(), $forum_template );
    410410}
     
    865865function bp_forums_tag_name() {
    866866    echo bp_get_forums_tag_name();
    867 }   
     867}
    868868    /**
    869869     * Outputs the currently viewed tag name
     
    874874    function bp_get_forums_tag_name() {
    875875        $tag_name = bp_is_directory() && bp_is_forums_component() ? bp_action_variable( 0 ) : false;
    876        
     876
    877877        return apply_filters( 'bp_get_forums_tag_name', $tag_name );
    878878    }
     
    940940        $this->__construct( $topic_id, $per_page, $max, $order );
    941941    }
    942        
     942
    943943    function __construct( $topic_id, $per_page, $max, $order ) {
    944944        global $bp, $current_user, $forum_template;
     
    974974            }
    975975        }
    976        
     976
    977977        // Load topic tags
    978978        $this->topic_tags = bb_get_topic_tags( $this->topic_id );
     
    984984                'total'     => ceil( (int)$this->total_post_count / (int)$this->pag_num ),
    985985                'current'   => $this->pag_page,
    986                 'prev_text' => '&larr;',
    987                 'next_text' => '&rarr;',
     986                'prev_text' => _x( '&larr;', 'Forum thread pagination previous text', 'buddypress' ),
     987                'next_text' => _x( '&rarr;', 'Forum thread pagination next text', 'buddypress' ),
    988988                'mid_size'  => 1
    989989            ) );
     
    10691069            return false;
    10701070    }
    1071    
     1071
    10721072    return apply_filters( 'bp_has_topic_posts', $topic_template->has_posts(), $topic_template );
    10731073}
     
    13351335    function bp_get_forum_topic_tag_list( $format = 'string' ) {
    13361336        global $topic_template;
    1337        
     1337
    13381338        $tags_data = !empty( $topic_template->topic_tags ) ? $topic_template->topic_tags : false;
    1339        
     1339
    13401340        $tags = array();
    1341        
     1341
    13421342        if ( $tags_data ) {
    13431343            foreach( $tags_data as $tag_data ) {
     
    13451345            }
    13461346        }
    1347        
     1347
    13481348        if ( 'string' == $format )
    13491349            $tags = implode( ', ', $tags );
    1350            
     1350
    13511351        return apply_filters( 'bp_forum_topic_tag_list', $tags, $format );
    13521352    }
     
    13621362function bp_forum_topic_has_tags() {
    13631363    global $topic_template;
    1364    
     1364
    13651365    $has_tags = false;
    1366    
     1366
    13671367    if ( !empty( $topic_template->topic_tags ) )
    13681368        $has_tags = true;
    1369    
     1369
    13701370    return apply_filters( 'bp_forum_topic_has_tags', $has_tags );
    13711371}
Note: See TracChangeset for help on using the changeset viewer.