From 41dfdfd0f6ec1b37749683699d6e24f040e39c75 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 3 Oct 2006 15:40:26 +0000 Subject: [PATCH] Pageinate upload tabs. From the Paginator, mdawaffe. fixes #3193 git-svn-id: http://svn.automattic.com/wordpress/trunk@4276 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/upload-functions.php | 2 -- wp-admin/upload-js.php | 6 +++++ wp-admin/upload-rtl.css | 2 +- wp-admin/upload.css | 15 +++++++---- wp-admin/upload.php | 43 +++++++++++++++++++++++++------- wp-includes/general-template.php | 11 +++++--- 6 files changed, 59 insertions(+), 20 deletions(-) diff --git a/wp-admin/upload-functions.php b/wp-admin/upload-functions.php index 1586336448..f1ce454b17 100644 --- a/wp-admin/upload-functions.php +++ b/wp-admin/upload-functions.php @@ -303,8 +303,6 @@ function wp_upload_tab_browse() { echo "\n\n"; echo "
\n"; - -// echo $total; break; endswitch; diff --git a/wp-admin/upload-js.php b/wp-admin/upload-js.php index e11de55293..01c00556f9 100644 --- a/wp-admin/upload-js.php +++ b/wp-admin/upload-js.php @@ -165,6 +165,9 @@ addLoadEvent( function() { var filesEl = $('upload-files'); if ( filesEl ) filesEl.hide(); + var navEl = $('current-tab-nav'); + if ( navEl ) + navEl.hide(); this.grabImageData(id); }, @@ -173,6 +176,9 @@ addLoadEvent( function() { var filesEl = $('upload-files'); if ( filesEl ) filesEl.show(); + var navEl = $('current-tab-nav'); + if ( navEl ) + navEl.show(); } if ( !this.ID ) this.grabImageData(0); diff --git a/wp-admin/upload-rtl.css b/wp-admin/upload-rtl.css index 73357e0613..92d4d47707 100644 --- a/wp-admin/upload-rtl.css +++ b/wp-admin/upload-rtl.css @@ -2,7 +2,7 @@ body { font: 13px Tahoma, "Lucida Grande", "Lucida Sans Unicode", Verdana; } #upload-menu li { margin: 0 .75em 0 0; } -#upload-menu .current a { +#upload-menu .current div { border-right: 0; border-left: 2px solid #448abd; } diff --git a/wp-admin/upload.css b/wp-admin/upload.css index 2a54a1f08c..217571b3a7 100644 --- a/wp-admin/upload.css +++ b/wp-admin/upload.css @@ -14,21 +14,26 @@ body { background: #dfe8f1; } #upload-menu li { margin: 0 0 0 .75em; } -#upload-menu a { - display: block; - padding: 5px; +#upload-menu li div { color: #000; + padding: 5px; border-top: 3px solid #fff; +} + +#upload-menu li a { + color: #000; text-decoration: none; border-bottom: none; } -#upload-menu .current a { +#upload-menu li span a.page-numbers { color: #00019b; } + +#upload-menu .current div { background: #dfe8f1; border-right: 2px solid #448abd; } -#upload-menu a:hover { +#upload-menu div:hover { background: #dfe8f1; color: #000; } diff --git a/wp-admin/upload.php b/wp-admin/upload.php index 32d82daf2a..d301109600 100644 --- a/wp-admin/upload.php +++ b/wp-admin/upload.php @@ -24,14 +24,16 @@ elseif ( get_post( $post_id ) ) $wp_upload_tabs = array(); $all_atts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment'"); $post_atts = 0; + if ( $pid ) { - $wp_upload_tabs['upload'] = array(__('Upload'), 'upload_files', 'wp_upload_tab_upload'); + // 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 + $wp_upload_tabs['upload'] = array(__('Upload'), 'upload_files', 'wp_upload_tab_upload', 0); if ( $all_atts && $post_atts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = '$post_id'") ) - $wp_upload_tabs['browse'] = array(__('Browse'), 'upload_files', "wp_upload_tab_browse"); + $wp_upload_tabs['browse'] = array(__('Browse'), 'upload_files', "wp_upload_tab_browse", $action ? 0 : $post_atts); if ( $post_atts < $all_atts ) - $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse'); + $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse', $action ? 0 : $all_atts); } else - $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse'); + $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse', $action ? 0 : $all_atts); $wp_upload_tabs = array_merge($wp_upload_tabs, apply_filters( 'wp_upload_tabs', array() )); @@ -54,14 +56,37 @@ include_once('admin-header.php'); echo "\n\n"; echo "
\n"; diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 99d195e852..3860e0887e 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -902,6 +902,8 @@ function paginate_links( $arg = '' ) { // Who knows what else people pass in $args $total = (int) $total; + if ( $total < 2 ) + return; $current = (int) $current; $end_size = 0 < (int) $end_size ? (int) $end_size : 1; // Out of bounds? Make it the default. $mid_size = 0 <= (int) $mid_size ? (int) $mid_size : 2; @@ -912,7 +914,8 @@ function paginate_links( $arg = '' ) { $dots = false; if ( $prev_next && $current && 1 < $current ) : - $link = str_replace('%_%', 2 == $current ? '' : str_replace('%#%', $current - 1, $format), $base); + $link = str_replace('%_%', 2 == $current ? '' : $format, $base); + $link = str_replace('%#%', $current - 1, $link); if ( $add_args ) $link = add_query_arg( $add_args, $link ); $page_links[] = ""; @@ -923,7 +926,8 @@ function paginate_links( $arg = '' ) { $dots = true; else : if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) : - $link = str_replace('%_%', 1 == $n ? '' : str_replace('%#%', $n, $format), $base); + $link = str_replace('%_%', 1 == $n ? '' : $format, $base); + $link = str_replace('%#%', $n, $link); if ( $add_args ) $link = add_query_arg( $add_args, $link ); $page_links[] = "$n"; @@ -935,7 +939,8 @@ function paginate_links( $arg = '' ) { endif; endfor; if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) : - $link = str_replace('%_%', str_replace('%#%', $current + 1, $format), $base); + $link = str_replace('%_%', $format, $base); + $link = str_replace('%#%', $current + 1, $link); if ( $add_args ) $link = add_query_arg( $add_args, $link ); $page_links[] = "";