root/branches/release-29/php/lib/block.mtauthorprevious.php @ 1333

Revision 1333, 1.4 kB (checked in by takayama, 22 months ago)

Fixed BugId:65812
* Changed scheme_version to 4.0037
* Added basename column to MT_Author

  • Assigning basename when author saved

* Changed to use MTAuthorBasename instead of MTAuthorDisplayName

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_mtauthorprevious($args, $content, &$ctx, &$repeat) {
9    static $_prev_cache = array();
10    if (!isset($content)) {
11        $prev_author = null;
12        $ctx->localize(array('author'));
13        $author = $ctx->stash('author');
14        if ($author) {
15            $author_id = $author['author_id'];
16            if (isset($_prev_cache[$author_id])) {
17                $prev_author = $_prev_cache[$author_id];
18            } else {
19                $name = $author['author_name'];
20                $blog_id = $ctx->stash('blog_id');
21                $args = array('sort_by' => 'author_name',
22                              'sort_order' => 'descend',
23                              'start_string' => $name,
24                              'lastn' => 1,
25                              'blog_id' => $blog_id,
26                              'need_entry' => 1);
27                list($prev_author) = $ctx->mt->db->fetch_authors($args);
28                if ($prev_author) {
29                    $_prev_cache[$author_id] = $prev_author;
30                    $ctx->stash('author', $prev_author);
31                } else
32                    $repeat = false;
33            }
34        }
35    } else {
36        $ctx->restore(array('author'));
37    }
38    return $content;
39}
40?>
Note: See TracBrowser for help on using the browser.