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

Revision 1926, 2.0 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
  • 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_block_mtcategories($args, $content, &$ctx, &$repeat) {
9    // status: incomplete
10    // parameters: show_empty
11    $localvars = array('_categories', '_categories_counter', 'category', 'inside_mt_categories', 'entries', '_categories_glue', 'blog_id', 'blog', '__out');
12    if (!isset($content)) {
13        $ctx->localize($localvars);
14        $args['blog_id'] = $ctx->stash('blog_id');
15        $categories = $ctx->mt->db->fetch_categories($args);
16        $glue = $args['glue'];
17        $ctx->stash('_categories_glue', $glue);
18        $ctx->stash('_categories', $categories);
19        $ctx->stash('inside_mt_categories', 1);
20        $ctx->stash('show_empty', isset($args['show_empty']) ? $args['show_empty'] : '0');
21        $ctx->stash('__out', false);
22        $counter = 0;
23    } else {
24        $categories = $ctx->stash('_categories');
25        $counter = $ctx->stash('_categories_counter');
26        $glue = $ctx->stash('_categories_glue');
27        $out =$ctx->stash('__out');
28    }
29    if ($counter < count($categories)) {
30        $category = $categories[$counter];
31        $ctx->stash('category', $category);
32        $ctx->stash('entries', null);
33        $ctx->stash('_categories_counter', $counter + 1);
34        $ctx->stash('blog_id', $category['category_blog_id']);
35        $ctx->stash('ArchiveListHeader', $counter == 0);
36        $ctx->stash('ArchiveListFooter', $counter+1 == count($categories));
37        $ctx->stash('blog',
38            $ctx->mt->db->fetch_blog($category['category_blog_id']));
39        if (!empty($glue) && !empty($content)) {
40            if ($out)
41                $content = $glue . $content;
42            else
43                $ctx->stash('__out', true);
44        }
45        $repeat = true;
46    } else {
47        if (!empty($glue) && $out && !empty($content))
48            $content = $glue . $content;
49        $ctx->restore($localvars);
50        $repeat = false;
51    }
52    return $content;
53}
54?>
Note: See TracBrowser for help on using the browser.