Make WordPress Core

Changeset 4276


Ignore:
Timestamp:
10/03/2006 03:40:26 PM (18 years ago)
Author:
ryan
Message:

Pageinate upload tabs. From the Paginator, mdawaffe. fixes #3193

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/upload-functions.php

    r4274 r4276  
    304304
    305305        echo "<form action='' id='browse-form'><input type='hidden' id='nonce-value' value='" . wp_create_nonce( 'inlineuploading' )  . "' /></form>\n";
    306 
    307 //      echo $total;
    308306        break;
    309307    endswitch;
  • trunk/wp-admin/upload-js.php

    r4274 r4276  
    166166            if ( filesEl )
    167167                filesEl.hide();
     168            var navEl = $('current-tab-nav');
     169            if ( navEl )
     170                navEl.hide();
    168171            this.grabImageData(id);
    169172        },
     
    174177                if ( filesEl )
    175178                    filesEl.show();
     179                var navEl = $('current-tab-nav');
     180                if ( navEl )
     181                    navEl.show();
    176182            }
    177183            if ( !this.ID )
  • trunk/wp-admin/upload-rtl.css

    r4274 r4276  
    33#upload-menu li { margin: 0 .75em 0 0; }
    44
    5 #upload-menu .current a {
     5#upload-menu .current div {
    66    border-right: 0;
    77    border-left: 2px solid #448abd;
  • trunk/wp-admin/upload.css

    r4274 r4276  
    1515#upload-menu li { margin: 0 0 0 .75em; }
    1616
    17 #upload-menu a {
    18     display: block;
     17#upload-menu li div {
     18    color: #000;
    1919    padding: 5px;
     20    border-top: 3px solid #fff;
     21}
     22
     23#upload-menu li a {
    2024    color: #000;
    21     border-top: 3px solid #fff;
    2225    text-decoration: none;
    2326    border-bottom: none;
    2427}
    2528
    26 #upload-menu .current a {
     29#upload-menu li span a.page-numbers { color: #00019b; }
     30
     31#upload-menu .current div {
    2732    background: #dfe8f1;
    2833    border-right: 2px solid #448abd;
    2934}
    3035
    31 #upload-menu a:hover {
     36#upload-menu div:hover {
    3237    background: #dfe8f1;
    3338    color: #000;
  • trunk/wp-admin/upload.php

    r4274 r4276  
    2525$all_atts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment'");
    2626$post_atts = 0;
     27
    2728if ( $pid ) {
    28     $wp_upload_tabs['upload'] = array(__('Upload'), 'upload_files', 'wp_upload_tab_upload');
     29    // 0 => tab display name, 1 => required cap, 2 => function that produces tab content, 3 => total number objects OR array(total, objects per page), 4 => add_query_args
     30    $wp_upload_tabs['upload'] = array(__('Upload'), 'upload_files', 'wp_upload_tab_upload', 0);
    2931    if ( $all_atts && $post_atts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = '$post_id'") )
    30         $wp_upload_tabs['browse'] = array(__('Browse'), 'upload_files', "wp_upload_tab_browse");
     32        $wp_upload_tabs['browse'] = array(__('Browse'), 'upload_files', "wp_upload_tab_browse", $action ? 0 : $post_atts);
    3133    if ( $post_atts < $all_atts )
    32         $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse');
     34        $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse', $action ? 0 : $all_atts);
    3335} else
    34     $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse');
     36    $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse', $action ? 0 : $all_atts);
    3537
    3638    $wp_upload_tabs = array_merge($wp_upload_tabs, apply_filters( 'wp_upload_tabs', array() ));
     
    5557foreach ( $wp_upload_tabs as $t => $tab_array ) { // We've already done the current_user_can check
    5658    $class = 'upload-tab';
    57     $href = add_query_arg( array('tab' => $t, 'ID' => '', 'action' => '') );
    58     if ( isset($tab_array[3]) && is_array($tab_array[3]) )
    59         add_query_arg( $tab_array[3], $href );
     59    $href = add_query_arg( array('tab' => $t, 'ID' => '', 'action' => '', 'paged' => '') );
     60    if ( isset($tab_array[4]) && is_array($tab_array[4]) )
     61        add_query_arg( $tab_array[4], $href );
    6062    $_href = wp_specialchars( $href, 1 );
    61     if ( $tab == $t )
     63    $page_links = '';
     64    if ( $tab == $t ) {
    6265        $class .= ' current';
    63     echo "\t<li class='$class left'><a href='$_href' title='{$tab_array[0]}'>{$tab_array[0]}</a></li>\n";
     66        if ( $tab_array[3] ) {
     67            if ( is_array($tab_array[3]) ) {
     68                $total = $tab_array[3][0];
     69                $per = $tab_array[3][1];
     70            } else {
     71                $total = $tab_array[3];
     72                $per = 10;
     73            }
     74            $page_links = paginate_links( array(
     75                'base' => add_query_arg( 'paged', '%#%' ),
     76                'format' => '',
     77                'total' => ceil($total / $per),
     78                'current' => $paged ? $paged : 1,
     79                'prev_text' => '&laquo;',
     80                'next_text' => '&raquo;'
     81            ));
     82            if ( $page_links )
     83                $page_links = "<span id='current-tab-nav'>: $page_links</span>";
     84        }
     85    }
     86
     87    echo "\t<li class='$class left'><div><a href='$_href' title='{$tab_array[0]}'>{$tab_array[0]}</a>$page_links</div></li>\n";
    6488}
     89unset($t, $tab_array, $href, $_href, $page_links, $total, $per, $class);
    6590echo "</ul>\n\n";
    6691
  • trunk/wp-includes/general-template.php

    r4275 r4276  
    903903    // Who knows what else people pass in $args
    904904    $total    = (int) $total;
     905    if ( $total < 2 )
     906        return;
    905907    $current  = (int) $current;
    906908    $end_size = 0  < (int) $end_size ? (int) $end_size : 1; // Out of bounds?  Make it the default.
     
    913915
    914916    if ( $prev_next && $current && 1 < $current ) :
    915         $link = str_replace('%_%', 2 == $current ? '' : str_replace('%#%', $current - 1, $format), $base);
     917        $link = str_replace('%_%', 2 == $current ? '' : $format, $base);
     918        $link = str_replace('%#%', $current - 1, $link);
    916919        if ( $add_args )
    917920            $link = add_query_arg( $add_args, $link );
     
    924927        else :
    925928            if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
    926                 $link = str_replace('%_%', 1 == $n ? '' : str_replace('%#%', $n, $format), $base);
     929                $link = str_replace('%_%', 1 == $n ? '' : $format, $base);
     930                $link = str_replace('%#%', $n, $link);
    927931                if ( $add_args )
    928932                    $link = add_query_arg( $add_args, $link );
     
    936940    endfor;
    937941    if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) :
    938         $link = str_replace('%_%', str_replace('%#%', $current + 1, $format), $base);
     942        $link = str_replace('%_%', $format, $base);
     943        $link = str_replace('%#%', $current + 1, $link);
    939944        if ( $add_args )
    940945            $link = add_query_arg( $add_args, $link );
Note: See TracChangeset for help on using the changeset viewer.