| 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 | |
|---|
| 8 | function 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'); |
|---|
| 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 | $counter = 0; |
|---|
| 22 | } else { |
|---|
| 23 | $categories = $ctx->stash('_categories'); |
|---|
| 24 | $counter = $ctx->stash('_categories_counter'); |
|---|
| 25 | $glue = $ctx->stash('_categories_glue'); |
|---|
| 26 | } |
|---|
| 27 | if ($counter < count($categories)) { |
|---|
| 28 | $category = $categories[$counter]; |
|---|
| 29 | $ctx->stash('category', $category); |
|---|
| 30 | $ctx->stash('entries', null); |
|---|
| 31 | $ctx->stash('_categories_counter', $counter + 1); |
|---|
| 32 | $ctx->stash('blog_id', $category['category_blog_id']); |
|---|
| 33 | $ctx->stash('ArchiveListHeader', $counter == 0); |
|---|
| 34 | $ctx->stash('ArchiveListFooter', $counter+1 == count($categories)); |
|---|
| 35 | $ctx->stash('blog', |
|---|
| 36 | $ctx->mt->db->fetch_blog($category['category_blog_id'])); |
|---|
| 37 | if ($counter > 0) $content = $content . $glue; |
|---|
| 38 | $repeat = true; |
|---|
| 39 | } else { |
|---|
| 40 | $ctx->restore($localvars); |
|---|
| 41 | $repeat = false; |
|---|
| 42 | } |
|---|
| 43 | return $content; |
|---|
| 44 | } |
|---|
| 45 | ?> |
|---|