root/branches/release-33/php/lib/function.mtarchivecount.php @ 1766

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

Fixed BugId:70282
* Changed to use isset function

  • 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 ((!isset($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            $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.