Show
Ignore:
Timestamp:
04/25/08 11:36:53 (19 months ago)
Author:
fumiakiy
Message:

Implemented PHP version of pager related tags. Dynamically published archives can now be pagination-enabled by adding these tags and specify "auto" to limit and offset.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/release-36/php/lib/block.mtentries.php

    r1926 r2103  
    3939    } 
    4040 
     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 
    4163    $entries = $ctx->stash('entries'); 
    4264    if (!isset($entries)) { 
     
    7799            $args['tag'] or $args['tags'] or $args['tags'] = is_array($tag) ? $tag['tag_name'] : $tag; 
    78100        } 
    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); 
    80106        $ctx->stash('entries', $entries); 
    81107    }