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

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

Fixed BugId:75148
* oops CategoryArchiver is never not found

  • 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 ((!$archiver && $ctx->stash('inside_mt_categories')) ||
17        ($ctx->stash('inside_mt_categories') && !$archiver->is_date_based())) {
18        return $ctx->tag('MTCategoryCount', $args);
19    } elseif ($count = $ctx->stash('archive_count')) {
20        return $count;
21    } elseif ($entries = $ctx->stash('entries')) {
22        return count($entries);
23    } else {
24        $eargs = array();
25        $eargs['blog_id'] = $ctx->stash('blog_id');
26        if ($at) {
27            require_once("archive_lib.php");
28            $ts = $ctx->stash('current_timestamp');
29            $tse = $ctx->stash('current_timestamp_end');
30            if (isset($archiver)) {
31                if ($ts && $tse) {
32                    # assign date range if we have both
33                    # start and end date
34                    $eargs['current_timestamp'] = $ts;
35                    $eargs['current_timestamp_end'] = $tse;
36                }
37                $archiver->setup_args($ctx, $eargs);
38            }
39            $eargs['lastn'] = -1;
40            $entries =& $ctx->mt->db->fetch_entries($eargs);
41            return count($entries);
42        }
43    }
44    return 0;
45}
46?>
Note: See TracBrowser for help on using the browser.