root/branches/release-38/php/lib/function.mtcommentauthor.php @ 2400

Revision 2400, 0.8 kB (checked in by bchoate, 18 months ago)

Use default of 'Anonymous' for CommentAuthor tag unless a default attribute is explicitly given. BugId:79842

  • 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_mtcommentauthor($args, &$ctx) {
9    $c = $ctx->stash('comment');
10    if (!$c)
11        return $ctx->error("No comment available");
12    $a = isset($c['comment_author']) ? $c['comment_author'] : '';
13    if ($c['comment_commenter_id']) {
14        $commenter = $ctx->stash('commenter');
15        if (is_array($commenter))
16            $commenter = $commenter[0];
17        if ($commenter)
18            $a = $commenter['author_nickname'];
19    }
20    if (isset($args['default']))
21        $a or $a = $args['default'];
22    else {
23        global $mt;
24        $a or $a = $mt->translate("Anonymous");
25    }
26    $a or $a = '';
27    return strip_tags($a);
28}
Note: See TracBrowser for help on using the browser.