Paging cleanup.
git-svn-id: http://svn.automattic.com/wordpress/trunk@1536 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f3c3e4b218
commit
f510f2a85d
|
@ -92,6 +92,7 @@ if( isset( $_GET['m'] ) )
|
|||
</tr>
|
||||
<?php
|
||||
if (empty($m)) $showposts = 15;
|
||||
$nopaging = true;
|
||||
include(ABSPATH.'wp-blog-header.php');
|
||||
|
||||
if ($posts) {
|
||||
|
|
|
@ -124,11 +124,14 @@ if ( isset($showposts) && $showposts ) {
|
|||
$showposts = (int) $showposts;
|
||||
$posts_per_page = $showposts;
|
||||
}
|
||||
if ( !isset($nopaging) ) {
|
||||
$nopaging = '';
|
||||
}
|
||||
|
||||
$archive_mode = get_settings('archive_mode');
|
||||
$use_gzipcompression = get_settings('gzipcompression');
|
||||
|
||||
$more_wpvars = array('posts_per_page', 'what_to_show', 'showposts');
|
||||
$more_wpvars = array('posts_per_page', 'what_to_show', 'showposts', 'nopaging');
|
||||
|
||||
// Construct the query string.
|
||||
$query_string = '';
|
||||
|
|
|
@ -394,59 +394,47 @@ class WP_Query {
|
|||
}
|
||||
}
|
||||
|
||||
if ((!$whichcat) && (!$q['m']) && (!$q['p']) && (!$q['w']) && (!$q['s']) && empty($q['poststart']) && empty($q['postend'])) {
|
||||
if ($q['what_to_show'] == 'posts') {
|
||||
$limits = ' LIMIT '.$q['posts_per_page'];
|
||||
} elseif ($q['what_to_show'] == 'days' && empty($q['monthnum']) && empty($q['year']) && empty($q['day'])) {
|
||||
$lastpostdate = get_lastpostdate();
|
||||
$lastpostdate = mysql2date('Y-m-d 00:00:00',$lastpostdate);
|
||||
$lastpostdate = mysql2date('U',$lastpostdate);
|
||||
$otherdate = date('Y-m-d H:i:s', ($lastpostdate - (($q['posts_per_page']-1) * 86400)));
|
||||
$where .= " AND post_date > '$otherdate'";
|
||||
}
|
||||
}
|
||||
// Paging
|
||||
if ( !empty($q['postend']) && ($q['postend'] > $q['poststart']) ) {
|
||||
if ($q['what_to_show'] == 'posts') {
|
||||
$q['poststart'] = intval($q['poststart']);
|
||||
$q['postend'] = intval($q['postend']);
|
||||
$limposts = $q['postend'] - $q['poststart'];
|
||||
$limits = ' LIMIT '.$q['poststart'].','.$limposts;
|
||||
} elseif ($q['what_to_show'] == 'days') {
|
||||
$q['poststart'] = intval($q['poststart']);
|
||||
$q['postend'] = intval($q['postend']);
|
||||
$limposts = $q['postend'] - $q['poststart'];
|
||||
$lastpostdate = get_lastpostdate();
|
||||
$lastpostdate = mysql2date('Y-m-d 00:00:00',$lastpostdate);
|
||||
$lastpostdate = mysql2date('U',$lastpostdate);
|
||||
$startdate = date('Y-m-d H:i:s', ($lastpostdate - (($q['poststart'] -1) * 86400)));
|
||||
$otherdate = date('Y-m-d H:i:s', ($lastpostdate - (($q['postend'] -1) * 86400)));
|
||||
$where .= " AND post_date > '$otherdate' AND post_date < '$startdate'";
|
||||
}
|
||||
} else if (empty($q['nopaging']) && ! is_single()) {
|
||||
$page = $q['paged'];
|
||||
if (empty($page)) {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
if ( !empty($q['postend']) && ($q['postend'] > $q['poststart']) && (!$q['m']) && empty($q['monthnum']) && empty($q['year']) && empty($q['day']) &&(!$q['w']) && (!$whichcat) && (!$q['s']) && (!$q['p'])) {
|
||||
if ($q['what_to_show'] == 'posts') {
|
||||
$q['poststart'] = intval($q['poststart']);
|
||||
$q['postend'] = intval($q['postend']);
|
||||
$limposts = $q['postend'] - $q['poststart'];
|
||||
$limits = ' LIMIT '.$q['poststart'].','.$limposts;
|
||||
} elseif ($q['what_to_show'] == 'days') {
|
||||
$q['poststart'] = intval($q['poststart']);
|
||||
$q['postend'] = intval($q['postend']);
|
||||
$limposts = $q['postend'] - $q['poststart'];
|
||||
$lastpostdate = get_lastpostdate();
|
||||
$lastpostdate = mysql2date('Y-m-d 00:00:00',$lastpostdate);
|
||||
$lastpostdate = mysql2date('U',$lastpostdate);
|
||||
$startdate = date('Y-m-d H:i:s', ($lastpostdate - (($q['poststart'] -1) * 86400)));
|
||||
$otherdate = date('Y-m-d H:i:s', ($lastpostdate - (($q['postend'] -1) * 86400)));
|
||||
$where .= " AND post_date > '$otherdate' AND post_date < '$startdate'";
|
||||
}
|
||||
} else {
|
||||
if (($q['what_to_show'] == 'posts') && (! is_single()) && (!$q['more'])) {
|
||||
if ($pagenow != 'post.php') {
|
||||
$pgstrt = '';
|
||||
if ($q['paged']) {
|
||||
$pgstrt = (intval($q['paged']) -1) * $q['posts_per_page'] . ', ';
|
||||
}
|
||||
$limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
|
||||
} else {
|
||||
if (($q['m']) || ($q['p']) || ($q['w']) || ($q['s']) || ($whichcat)) {
|
||||
$limits = '';
|
||||
} else {
|
||||
$pgstrt = '';
|
||||
if ($q['paged']) {
|
||||
$pgstrt = (intval($q['paged']) -1) * $q['posts_per_page'] . ', ';
|
||||
}
|
||||
$limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (($q['m']) || ($q['p']) || ($q['w']) || ($q['s']) || ($whichcat) || ($q['author']) || $q['monthnum'] || $q['year'] || $q['day']) {
|
||||
$limits = '';
|
||||
}
|
||||
}
|
||||
if (($q['what_to_show'] == 'posts')) {
|
||||
$pgstrt = '';
|
||||
$pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', ';
|
||||
$limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
|
||||
} elseif ($q['what_to_show'] == 'days') {
|
||||
$lastpostdate = get_lastpostdate();
|
||||
$lastpostdate = mysql2date('Y-m-d 00:00:00',$lastpostdate);
|
||||
$lastpostdate = mysql2date('U',$lastpostdate);
|
||||
$startdate = date('Y-m-d H:i:s', ($lastpostdate - ((intval($page) -1) * ($q['posts_per_page']-1) * 86400)));
|
||||
$enddate = date('Y-m-d H:i:s', ($lastpostdate - (intval($page) * ($q['posts_per_page']-1) * 86400)));
|
||||
if ($page > 1) {
|
||||
$where .= " AND post_date > '$enddate' AND post_date < '$startdate'";
|
||||
} else {
|
||||
$where .= " AND post_date > '$enddate'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($q['p'] == 'all') {
|
||||
$where = '';
|
||||
|
|
|
@ -429,13 +429,21 @@ function previous_posts_link($label='« Previous Page') {
|
|||
function posts_nav_link($sep=' — ', $prelabel='« Previous Page', $nxtlabel='Next Page »') {
|
||||
global $request, $posts_per_page, $wpdb;
|
||||
if (! is_single()) {
|
||||
$nxt_request = $request;
|
||||
if ($pos = strpos(strtoupper($request), 'LIMIT')) {
|
||||
$show_what = get_query_var('what_to_show');
|
||||
|
||||
if (get_query_var('what_to_show') == 'posts') {
|
||||
$nxt_request = $request;
|
||||
if ($pos = strpos(strtoupper($request), 'LIMIT')) {
|
||||
$nxt_request = substr($request, 0, $pos);
|
||||
}
|
||||
$nxt_result = $wpdb->query($nxt_request);
|
||||
$numposts = $wpdb->num_rows;
|
||||
$max_page = ceil($numposts / $posts_per_page);
|
||||
}
|
||||
|
||||
$nxt_result = $wpdb->query($nxt_request);
|
||||
$numposts = $wpdb->num_rows;
|
||||
$max_page = ceil($numposts / $posts_per_page);
|
||||
} else {
|
||||
$max_page = 999999;
|
||||
}
|
||||
|
||||
if ($max_page > 1) {
|
||||
previous_posts_link($prelabel);
|
||||
echo preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $sep);
|
||||
|
@ -444,5 +452,4 @@ function posts_nav_link($sep=' — ', $prelabel='« Previous Page', $nx
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
Loading…
Reference in New Issue