root/branches/release-35/php/lib/block.mtentrytags.php @ 1926

Revision 1926, 2.2 kB (checked in by takayama, 20 months ago)

Fixed BugId:76389
* Loop tags does not add 'glue', if row in loop tag was empty

  • MTFor
  • MTLoop
  • MTTags
  • MTEntryTags
  • MTEntries
  • MTEntryCategories
  • MTCategories
  • MTEntryAdditionalCategories
  • MTParentCategories
  • MTAssetTags
  • MTPagerBlock
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', '__out');
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        $ctx->stash('__out', false);
40       
41        $counter = 0;
42    } else {
43        $tags = $ctx->stash('_tags');
44        $counter = $ctx->stash('_tags_counter');
45        $out = $ctx->stash('__out');
46    }
47    if ($counter < count($tags)) {
48        $tag = $tags[$counter];
49        $ctx->stash('Tag', $tag);
50        $ctx->stash('_tags_counter', $counter + 1);
51        $repeat = true;
52        if (isset($args['glue']) && !empty($content)) {
53            if ($out)
54                $content = $args['glue']. $content;
55            else
56                $ctx->stash('__out', true);
57        }
58    } else {
59        if (isset($args['glue']) && $out && !empty($content))
60            $content = $args['glue']. $content;
61        $ctx->restore($localvars);
62        $repeat = false;
63    }
64    return $content;
65}
66?>
Note: See TracBrowser for help on using the browser.