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

Revision 1174, 1.5 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_mtentryadditionalcategories($args, $content, &$ctx, &$repeat) {
9    $localvars = array('_categories', 'category', '_categories_counter');
10    if (!isset($content)) {
11        $ctx->localize($localvars);
12        $entry = $ctx->stash('entry');
13        $args['entry_id'] = $entry['entry_id'];
14        $primary_category_id = $entry['placement_category_id'];
15        $categories = $ctx->mt->db->fetch_categories($args);
16        if ($categories && $primary_category_id) {
17            $list = array();
18            foreach ($categories as $cat) {
19                if ($cat['category_id'] != $primary_category_id)
20                    $list[] = $cat;
21            }
22            $categories = $list;
23        }
24        $ctx->stash('_categories', $categories);
25        $counter = 0;
26    } else {
27        $categories = $ctx->stash('_categories');
28        $counter = $ctx->stash('_categories_counter');
29    }
30    if ($counter < count($categories)) {
31        $category = $categories[$counter];
32        $ctx->stash('category', $category);
33        $ctx->stash('_categories_counter', $counter + 1);
34        $repeat = true;
35        if (($counter > 0) && isset($args['glue'])) {
36            $content = $content . $args['glue'];
37        }
38    } else {
39        $ctx->restore($localvars);
40        $repeat = false;
41    }
42    return $content;
43}
44?>
Note: See TracBrowser for help on using the browser.