root/branches/release-29/php/lib/function.mtsubcatsrecurse.php @ 1308

Revision 1308, 2.0 kB (checked in by bsmith, 23 months ago)

Merging commits from release-28 changesets 1274 to 1306

  • 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_mtsubcatsrecurse($args, &$ctx) {
9  $localvars = array('subCatsDepth', 'category', 'subCatIsFirst', 'subCatIsLast', 'subFolderHead', 'subFolderFoot');
10    $fn = $ctx->stash('subCatTokens');
11    #if (!method_exists($ctx,$fn)) {
12    #    return $ctx->error("Called SubCatsRecurse outside of SubCategories tag!");
13    #}
14
15    $cat = $ctx->stash('category');
16
17    # Get the depth info
18    $max_depth = $args['max_depth'];
19    $depth = $ctx->stash('subCatsDepth') or 0;
20
21    # Get the sorting info
22    $sort_method = $ctx->stash('subCatsSortMethod');
23    $sort_order = $ctx->stash('subCatsSortOrder');
24
25    # Get the class info
26    $class = 'category';
27    if (isset($args['class'])) {
28        $class = $args['class'];
29    }
30   
31    $cats =& $ctx->mt->db->fetch_categories(array('blog_id' => $ctx->stash('blog_id'), 'category_id' => $cat['category_id'], 'children' => 1, 'show_empty' => 1, 'class' => $class));
32
33    #$cats = sort_cats($ctx, $sort_method, $sort_order, $child_cats);
34    if (!$cats) {
35        return ''; #$ctx->error("No sub categories!");
36    }
37
38    $count = 0;
39    $res = '';
40
41    require_once("function.mtsetvar.php");
42    $ctx->localize($localvars);
43    $ctx->stash('subCatsDepth', $depth + 1);
44    while ($c = array_shift($cats)) {
45        smarty_function_mtsetvar(array('name' => '__depth__', 'value' => ($depth + 1)), $ctx);
46        $ctx->stash('category', $c);
47        $ctx->stash('subCatIsFirst', !$count);
48        $ctx->stash('subCatIsLast', !count($cats));
49        $ctx->stash('subFolderHead', !$count);
50        $ctx->stash('subFolderFoot', !count($cats));
51        ob_start();
52        $fn($ctx, array());
53        #call_user_method($fn, $ctx, $ctx, array());
54        $res .= ob_get_contents();
55        ob_end_clean();
56        $count++;
57    }
58    $ctx->restore($localvars);
59    return $res;
60}
61?>
Note: See TracBrowser for help on using the browser.