root/branches/dipper/php/lib/function.mtarchivecount.php @ 1748

Revision 1748, 1.5 kB (checked in by takayama, 20 months ago)

Fixed BugId:75148
* Fixed for nested category based archive count issue.

  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2# Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd.
3# This program is distributed under the terms of the
4# GNU General Public License, version 2.
5#
6# $Id$
7
8function smarty_function_mtarchivecount($args, &$ctx) {
9    $at = '';
10    $archiver = null;
11    if ($at = $ctx->stash('current_archive_type')) {
12        require_once("archive_lib.php");
13        global $_archivers;
14        $archiver = $_archivers[$at];
15    }
16    if ($ctx->stash('inside_mt_categories') && !$archiver->is_date_based()) {
17        return $ctx->tag('MTCategoryCount', $args);
18    } elseif ($count = $ctx->stash('archive_count')) {
19        return $count;
20    } elseif ($entries = $ctx->stash('entries')) {
21        return count($entries);
22    } else {
23        $eargs = array();
24        $eargs['blog_id'] = $ctx->stash('blog_id');
25        if ($at) {
26            require_once("archive_lib.php");
27            $ts = $ctx->stash('current_timestamp');
28            $tse = $ctx->stash('current_timestamp_end');
29            if (isset($archiver)) {
30                if ($ts && $tse) {
31                    # assign date range if we have both
32                    # start and end date
33                    $eargs['current_timestamp'] = $ts;
34                    $eargs['current_timestamp_end'] = $tse;
35                }
36                $archiver->setup_args($ctx, $eargs);
37            }
38            $eargs['lastn'] = -1;
39            $entries =& $ctx->mt->db->fetch_entries($eargs);
40            return count($entries);
41        }
42    }
43    return 0;
44}
45?>
Note: See TracBrowser for help on using the browser.