Make WordPress Core

Changeset 1536


Ignore:
Timestamp:
08/16/2004 10:50:06 PM (21 years ago)
Author:
rboren
Message:

Paging cleanup.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit.php

    r1527 r1536  
    9393<?php
    9494if (empty($m)) $showposts = 15;
     95$nopaging = true;
    9596include(ABSPATH.'wp-blog-header.php');
    9697
  • trunk/wp-blog-header.php

    r1531 r1536  
    125125    $posts_per_page = $showposts;
    126126}
     127if ( !isset($nopaging) ) {
     128  $nopaging = '';
     129}
    127130
    128131$archive_mode = get_settings('archive_mode');
    129132$use_gzipcompression = get_settings('gzipcompression');
    130133
    131 $more_wpvars = array('posts_per_page', 'what_to_show', 'showposts');
     134$more_wpvars = array('posts_per_page', 'what_to_show', 'showposts', 'nopaging');
    132135
    133136// Construct the query string.
  • trunk/wp-includes/classes.php

    r1533 r1536  
    395395        }
    396396
    397         if ((!$whichcat) && (!$q['m']) && (!$q['p']) && (!$q['w']) && (!$q['s']) && empty($q['poststart']) && empty($q['postend'])) {
    398             if ($q['what_to_show'] == 'posts') {
    399                 $limits = ' LIMIT '.$q['posts_per_page'];
    400             } elseif ($q['what_to_show'] == 'days' && empty($q['monthnum']) && empty($q['year']) && empty($q['day'])) {
    401                 $lastpostdate = get_lastpostdate();
    402                 $lastpostdate = mysql2date('Y-m-d 00:00:00',$lastpostdate);
    403                 $lastpostdate = mysql2date('U',$lastpostdate);
    404                 $otherdate = date('Y-m-d H:i:s', ($lastpostdate - (($q['posts_per_page']-1) * 86400)));
    405                 $where .= " AND post_date > '$otherdate'";
    406             }
    407         }
    408 
    409         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'])) {
    410             if ($q['what_to_show'] == 'posts') {
    411                 $q['poststart'] = intval($q['poststart']);
    412                 $q['postend'] = intval($q['postend']);
    413                 $limposts = $q['postend'] - $q['poststart'];
    414                 $limits = ' LIMIT '.$q['poststart'].','.$limposts;
    415             } elseif ($q['what_to_show'] == 'days') {
    416                 $q['poststart'] = intval($q['poststart']);
    417                 $q['postend'] = intval($q['postend']);
    418                 $limposts = $q['postend'] - $q['poststart'];
    419                 $lastpostdate = get_lastpostdate();
    420                 $lastpostdate = mysql2date('Y-m-d 00:00:00',$lastpostdate);
    421                 $lastpostdate = mysql2date('U',$lastpostdate);
    422                 $startdate = date('Y-m-d H:i:s', ($lastpostdate - (($q['poststart'] -1) * 86400)));
    423                 $otherdate = date('Y-m-d H:i:s', ($lastpostdate - (($q['postend'] -1) * 86400)));
    424                 $where .= " AND post_date > '$otherdate' AND post_date < '$startdate'";
    425             }
    426         } else {
    427             if (($q['what_to_show'] == 'posts') && (! is_single()) && (!$q['more'])) {
    428                 if ($pagenow != 'post.php') {
    429                     $pgstrt = '';
    430                     if ($q['paged']) {
    431                         $pgstrt = (intval($q['paged']) -1) * $q['posts_per_page'] . ', ';
    432                     }
    433                     $limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
    434                 } else {
    435                     if (($q['m']) || ($q['p']) || ($q['w']) || ($q['s']) || ($whichcat)) {
    436                         $limits = '';
    437                     } else {
    438                         $pgstrt = '';
    439                         if ($q['paged']) {
    440                             $pgstrt = (intval($q['paged']) -1) * $q['posts_per_page'] . ', ';
    441                         }
    442                         $limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
    443                     }
    444                 }
    445             }
    446             elseif (($q['m']) || ($q['p']) || ($q['w']) || ($q['s']) || ($whichcat) || ($q['author']) || $q['monthnum'] || $q['year'] || $q['day']) {
    447                 $limits = '';
    448             }
    449         }
     397    // Paging
     398    if ( !empty($q['postend']) && ($q['postend'] > $q['poststart']) ) {
     399      if ($q['what_to_show'] == 'posts') {
     400        $q['poststart'] = intval($q['poststart']);
     401        $q['postend'] = intval($q['postend']);
     402        $limposts = $q['postend'] - $q['poststart'];
     403        $limits = ' LIMIT '.$q['poststart'].','.$limposts;
     404      } elseif ($q['what_to_show'] == 'days') {
     405        $q['poststart'] = intval($q['poststart']);
     406        $q['postend'] = intval($q['postend']);
     407        $limposts = $q['postend'] - $q['poststart'];
     408        $lastpostdate = get_lastpostdate();
     409        $lastpostdate = mysql2date('Y-m-d 00:00:00',$lastpostdate);
     410        $lastpostdate = mysql2date('U',$lastpostdate);
     411        $startdate = date('Y-m-d H:i:s', ($lastpostdate - (($q['poststart'] -1) * 86400)));
     412        $otherdate = date('Y-m-d H:i:s', ($lastpostdate - (($q['postend'] -1) * 86400)));
     413        $where .= " AND post_date > '$otherdate' AND post_date < '$startdate'";
     414      }
     415    } else if (empty($q['nopaging']) && ! is_single()) {
     416      $page = $q['paged'];
     417      if (empty($page)) {
     418        $page = 1;
     419      }
     420
     421      if (($q['what_to_show'] == 'posts')) {
     422        $pgstrt = '';
     423        $pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', ';
     424        $limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
     425      } elseif ($q['what_to_show'] == 'days') {
     426        $lastpostdate = get_lastpostdate();
     427        $lastpostdate = mysql2date('Y-m-d 00:00:00',$lastpostdate);
     428        $lastpostdate = mysql2date('U',$lastpostdate);
     429        $startdate = date('Y-m-d H:i:s', ($lastpostdate - ((intval($page) -1) * ($q['posts_per_page']-1) * 86400)));
     430        $enddate = date('Y-m-d H:i:s', ($lastpostdate - (intval($page) * ($q['posts_per_page']-1) * 86400)));
     431        if ($page > 1) {
     432          $where .= " AND post_date > '$enddate' AND post_date < '$startdate'";
     433        } else {
     434          $where .= " AND post_date > '$enddate'";
     435        }
     436      }
     437    }
    450438
    451439        if ($q['p'] == 'all') {
  • trunk/wp-includes/template-functions-links.php

    r1534 r1536  
    430430    global $request, $posts_per_page, $wpdb;
    431431    if (! is_single()) {
    432         $nxt_request = $request;
    433         if ($pos = strpos(strtoupper($request), 'LIMIT')) {
     432        $show_what = get_query_var('what_to_show');
     433
     434    if (get_query_var('what_to_show') == 'posts') {
     435      $nxt_request = $request;
     436      if ($pos = strpos(strtoupper($request), 'LIMIT')) {
    434437            $nxt_request = substr($request, 0, $pos);
    435         }
    436         $nxt_result = $wpdb->query($nxt_request);
    437         $numposts = $wpdb->num_rows;
    438         $max_page = ceil($numposts / $posts_per_page);
     438      }
     439
     440      $nxt_result = $wpdb->query($nxt_request);
     441      $numposts = $wpdb->num_rows;
     442      $max_page = ceil($numposts / $posts_per_page);
     443    } else {
     444      $max_page = 999999;
     445    }
     446
    439447        if ($max_page > 1) {
    440448            previous_posts_link($prelabel);
     
    445453}
    446454
    447 
    448455?>
Note: See TracChangeset for help on using the changeset viewer.