root/branches/release-26/php/lib/block.mtentrytags.php @ 1174

Revision 1174, 2.0 kB (checked in by bchoate, 23 months ago)

Updated copyright year for source.

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_block_mtentrytags($args, $content, &$ctx, &$repeat) {
9    $localvars = array('_tags', 'Tag', '_tags_counter', 'tag_min_count', 'tag_max_count','all_tag_count');
10    if (!isset($content)) {
11        $class = 'entry';
12        if (isset($args['class'])) {
13            $class = $args['class'];
14        }
15        $ctx->localize($localvars);
16        require_once("MTUtil.php");
17        $entry = $ctx->stash('entry');
18        $blog_id = $entry['entry_blog_id'];
19        $tags = $ctx->mt->db->fetch_entry_tags(array('blog_id' => $blog_id, 'class' => $class));
20        if (!is_array($tags)) $tags = array();
21
22        $min = 0; $max = 0;
23        $all_count = 0;
24        $tagnames = '';
25        foreach ($tags as $tag) {
26            $count = $tag['tag_count'];
27            if ($count > $max) $max = $count;
28            if ($count < $min or $min == 0) $min = $count;
29            $all_count += $count;
30        }
31        $ctx->stash('tag_min_count', $min);
32        $ctx->stash('tag_max_count', $max);
33        $ctx->stash('all_tag_count', $all_count);
34
35        $entry = $ctx->stash('entry');
36        $tags = $ctx->mt->db->fetch_entry_tags(array('entry_id' => $entry['entry_id'], 'blog_id' => $blog_id, 'class' => $class));
37        if (!is_array($tags)) $tags = array();
38        $ctx->stash('_tags', $tags);
39       
40        $counter = 0;
41    } else {
42        $tags = $ctx->stash('_tags');
43        $counter = $ctx->stash('_tags_counter');
44    }
45    if ($counter < count($tags)) {
46        $tag = $tags[$counter];
47        $ctx->stash('Tag', $tag);
48        $ctx->stash('_tags_counter', $counter + 1);
49        $repeat = true;
50        if (($counter > 0) && isset($args['glue'])) {
51            $content = $content . $args['glue'];
52        }
53    } else {
54        $ctx->restore($localvars);
55        $repeat = false;
56    }
57    return $content;
58}
59?>
Note: See TracBrowser for help on using the browser.