root/branches/release-39/php/lib/function.mtcommentauthorlink.php @ 2503

Revision 2503, 2.1 kB (checked in by takayama, 18 months ago)

Fixed BugId:80007
* Related fix of case 79997

  • 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_mtcommentauthorlink($args, &$ctx) {
9    global $mt;
10    $comment = $ctx->stash('comment');
11    $name = $comment['comment_author'];
12    if (!$name && isset($args['default_name'])) {
13        $name = $args['default_name'];
14    }
15    $name or $name = $mt->translate("Anonymous");
16    $email = $comment['comment_email'];
17    $url = $comment['comment_url'];
18    if (isset($args['show_email']))
19        $show_email = $args['show_email'];
20    else
21        $show_email = 0;
22    if (isset($args['show_url']))
23        $show_url = $args['show_url'];
24    else
25        $show_url = 1;
26
27    $cmntr = $ctx->stash('commenter');
28    if (!isset($cmntr)) {
29        if (isset($comment['comment_commenter_id'])) {
30            $cmntr = $ctx->mt->db->fetch_author($comment['comment_commenter_id']);
31        }
32    }
33
34    if ( $cmntr ) {
35        if ($cmntr['author_url']) {
36            return sprintf('<a title="%s" href="%s">%s</a>', $cmntr['author_url'], $cmntr['author_url'], $name);
37        }
38        return $name;
39    } elseif ($show_url && $url) {
40        require_once "function.mtcgipath.php";
41        $cgi_path = smarty_function_mtcgipath($args, $ctx);
42        $comment_script = $ctx->mt->config('CommentScript');
43        $name = strip_tags($name);
44        $url = strip_tags($url);
45        $url = preg_replace('/>/', '&gt;', $url);
46        if ($comment['comment_id'] && !isset($args['no_redirect'])) {
47            return sprintf('<a title="%s" href="%s%s?__mode=red;id=%d">%s</a>', $url, $cgi_path, $comment_script, $comment['comment_id'], $name);
48        } else {
49            return sprintf('<a title="%s" href="%s">%s</a>', $url, $url, $name);
50        }
51    } elseif ($show_email && $email && is_valid_email($email)) {
52        $email = strip_tags($email);
53        $str = 'mailto:' . $email;
54        if ($args['spam_protect']) {
55            $str = spam_protect($str);
56        }
57        return sprintf('<a href="%s">%s</a>', $str, $name);
58    }
59    return $name;
60}
Note: See TracBrowser for help on using the browser.