Make WordPress Core


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

Paging cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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') {
Note: See TracChangeset for help on using the changeset viewer.