root/branches/release-35/php/lib/function.mtarchivecount.php @ 1956

Revision 1956, 1.6 kB (checked in by bchoate, 20 months ago)

Added support for phrases on count tags. BugId:79359

  • 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    $count = 0;
17    if ((!isset($archiver) && $ctx->stash('inside_mt_categories')) ||
18        ($ctx->stash('inside_mt_categories') && !$archiver->is_date_based())) {
19        return $ctx->tag('MTCategoryCount', $args);
20    } elseif ($count = $ctx->stash('archive_count')) {
21        # $count is set
22    } elseif ($entries = $ctx->stash('entries')) {
23        $count = count($entries);
24    } else {
25        $eargs = array();
26        $eargs['blog_id'] = $ctx->stash('blog_id');
27        if ($at) {
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            $count = count($entries);
42        }
43    }
44    $ctx->count_format($count, $args);
45}
Note: See TracBrowser for help on using the browser.