Changeset 2103
- Timestamp:
- 04/25/08 11:36:53 (22 months ago)
- Location:
- branches/release-36
- Files:
-
- 9 added
- 4 modified
-
lib/MT/CMS/Blog.pm (modified) (1 diff)
-
lib/MT/Template/ContextHandlers.pm (modified) (1 diff)
-
php/lib/block.mtentries.php (modified) (2 diffs)
-
php/lib/block.mtifcurrentpage.php (added)
-
php/lib/block.mtifmoreresults.php (added)
-
php/lib/block.mtifpreviousresults.php (added)
-
php/lib/block.mtpagerblock.php (added)
-
php/lib/function.mtcurrentpage.php (added)
-
php/lib/function.mtnextlink.php (added)
-
php/lib/function.mtpagerlink.php (added)
-
php/lib/function.mtpreviouslink.php (added)
-
php/lib/function.mttotalpages.php (added)
-
php/lib/mtdb_base.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-36/lib/MT/CMS/Blog.pm
r2051 r2103 2211 2211 RewriteCond %{REQUEST_FILENAME} !-f 2212 2212 # anything else is handed to mtview.php for resolution 2213 RewriteRule ^(.*)\$ $mtview_server_url [L,QSA] 2213 # passthrough query parameters 2214 RewriteRule ^(.*)(\\?.*)\?\$ $mtview_server_url\$2 [L,QSA] 2214 2215 </IfModule> 2215 2216 -
branches/release-36/lib/MT/Template/ContextHandlers.pm
r2062 r2103 561 561 my $limit = $_[0]->stash('limit'); 562 562 my $offset = $_[0]->stash('offset'); 563 $limit ? $offset / $limit + 1 : 1 563 $limit ? $offset / $limit + 1 : 1; 564 564 }, 565 565 TotalPages => sub { 566 566 my $limit = $_[0]->stash('limit'); 567 return 1 unless $limit; 567 568 my $count = $_[0]->stash('count'); 568 569 require POSIX; -
branches/release-36/php/lib/block.mtentries.php
r1926 r2103 39 39 } 40 40 41 if ( isset($args['offset']) && ($args['offset'] == 'auto') ) { 42 $l = 0; 43 if ( $args['limit'] ) { 44 if ( $args['limit'] == 'auto' ) { 45 if ( $_REQUEST['limit'] ) 46 $l = $_REQUEST['limit']; 47 else { 48 $blog_id = intval($ctx->stash('blog_id')); 49 $blog = $ctx->mt->db->fetch_blog($blog_id); 50 $l = $blog['blog_entries_on_index']; 51 } 52 } 53 else 54 $l = $args['limit']; 55 } 56 if ( !$l ) 57 $l = 20; 58 $ctx->stash('__pager_limit', $l); 59 if ( $_REQUEST['offset'] ) 60 $ctx->stash('__pager_offset', $_REQUEST['offset']); 61 } 62 41 63 $entries = $ctx->stash('entries'); 42 64 if (!isset($entries)) { … … 77 99 $args['tag'] or $args['tags'] or $args['tags'] = is_array($tag) ? $tag['tag_name'] : $tag; 78 100 } 79 $entries =& $ctx->mt->db->fetch_entries($args); 101 if ( isset($args['offset']) && ($args['offset'] == 'auto') ) 102 $total_count = 0; 103 $entries =& $ctx->mt->db->fetch_entries($args, $total_count); 104 if ( isset($args['offset']) && ($args['offset'] == 'auto') ) 105 $ctx->stash('__pager_total_count', $total_count); 80 106 $ctx->stash('entries', $entries); 81 107 } -
branches/release-36/php/lib/mtdb_base.php
r2091 r2103 413 413 } 414 414 415 function &fetch_entries($args ) {415 function &fetch_entries($args, &$total_count = NULL) { 416 416 if ($sql = $this->include_exclude_blogs($args)) { 417 417 $blog_filter = 'and entry_blog_id ' . $sql; … … 422 422 } 423 423 424 $pagination = 0; 424 425 # automatically include offset if in request 425 426 if ($args['offset'] == 'auto') { 427 $pagination = 1; 426 428 $args['offset'] = 0; 427 429 if ($args['limit'] || $args['lastn']) { … … 801 803 $post_select_limit = $rco; 802 804 $no_resort = 1; 805 } elseif ( !is_null($total_count) ) { 806 $orig_limit = $limit; 807 $orig_offset = $offset; 803 808 } else { 804 809 $sql = $this->apply_limit_sql($sql . " <LIMIT>", $limit, $offset); … … 810 815 $entries = array(); 811 816 $j = 0; 812 $offset = $post_select_offset ? $post_select_offset : 0;817 $offset = $post_select_offset ? $post_select_offset : $orig_offset; 813 818 $limit = $post_select_limit ? $post_select_limit : 0; 814 819 $id_list = array(); 820 $_total_count = 0; 815 821 while (true) { 816 822 $e = $this->query_fetch(ARRAY_A); … … 826 832 } 827 833 } 834 $_total_count++; 835 if ( !is_null($total_count) ) { 836 if ( ($orig_limit > 0) 837 && ( ($_total_count-$offset) > $orig_limit) ) { 838 // collected all the entries; only count numbers; 839 continue; 840 } 841 } 828 842 if ($offset && ($j++ < $offset)) continue; 829 843 $e['entry_authored_on'] = $this->db2ts($e['entry_authored_on']); … … 833 847 $this->_comment_count_cache[$e['entry_id']] = $e['entry_comment_count']; 834 848 $this->_ping_count_cache[$e['entry_id']] = $e['entry_ping_count']; 835 if (($limit > 0) && (count($entries) >= $limit)) break; 849 if ( is_null($total_count) ) { 850 // the request does not want total count; break early 851 if (($limit > 0) && (count($entries) >= $limit)) break; 852 } 853 } 854 if ( !is_null($total_count) ) { 855 $total_count = $_total_count; 836 856 } 837 857
