コード例 #1
0
function smarty_function_mtcommenteruserpic($args, &$ctx)
{
    $comment = $ctx->stash('comment');
    if (!$comment) {
        return $ctx->error("No comments available");
    }
    $cmntr = $ctx->stash('commenter');
    if (!$cmntr) {
        return '';
    }
    $asset_id = isset($cmntr->author_userpic_asset_id) ? $cmntr->author_userpic_asset_id : 0;
    $asset = $ctx->mt->db()->fetch_assets(array('id' => $asset_id));
    if (!$asset) {
        return '';
    }
    $blog =& $ctx->stash('blog');
    require_once "MTUtil.php";
    $userpic_url = userpic_url($asset[0], $blog, $cmntr);
    if (empty($userpic_url)) {
        return '';
    }
    $mt = MT::get_instance();
    $dimensions = sprintf('width="%s" height="%s"', $mt->config('UserpicThumbnailSize'), $mt->config('UserpicThumbnailSize'));
    $link = sprintf('<img src="%s?%d" %s alt="%s" />', encode_html($userpic_url), $asset_id, $dimensions, encode_html($asset->label));
    return $link;
}
コード例 #2
0
function smarty_function_mtcommenteruserpic($args, &$ctx)
{
    $comment = $ctx->stash('comment');
    if (!$comment) {
        return $ctx->error("No comment available");
    }
    $cmntr = $ctx->stash('commenter');
    if (!$cmntr) {
        return '';
    }
    $asset_id = isset($cmntr['author_userpic_asset_id']) ? $cmntr['author_userpic_asset_id'] : 0;
    $asset = $ctx->mt->db->fetch_assets(array('id' => $asset_id));
    if (!$asset) {
        return '';
    }
    $blog =& $ctx->stash('blog');
    require_once "MTUtil.php";
    $userpic_url = userpic_url($asset[0], $blog, $cmntr);
    if (empty($userpic_url)) {
        return '';
    }
    $asset_path = asset_path($asset[0]['asset_file_path'], $blog);
    list($src_w, $src_h, $src_type, $src_attr) = getimagesize($asset_path);
    $dimensions = sprintf('width="%s" height="%s"', $src_w, $src_h);
    $link = sprintf('<img src="%s" %s alt="%s" />', encode_html($userpic_url), $dimensions, encode_html($asset['label']));
    return $link;
}
コード例 #3
0
function smarty_function_mtcommenteruserpicurl($args, &$ctx)
{
    $comment = $ctx->stash('comment');
    if (!$comment) {
        return $ctx->error("No comment available");
    }
    $cmntr = $ctx->stash('commenter');
    if (!$cmntr) {
        return '';
    }
    $asset_id = isset($cmntr['author_userpic_asset_id']) ? $cmntr['author_userpic_asset_id'] : 0;
    $asset = $ctx->mt->db->fetch_assets(array('id' => $asset_id));
    if (!$asset) {
        return '';
    }
    $blog =& $ctx->stash('blog');
    require_once "MTUtil.php";
    $userpic_url = userpic_url($asset[0], $blog, $cmntr);
    return $userpic_url;
}
コード例 #4
0
function smarty_function_mtentryauthoruserpicurl($args, &$ctx)
{
    $entry = $ctx->stash('entry');
    if (!$entry) {
        return '';
    }
    $author = $ctx->mt->db->fetch_author($entry['entry_author_id']);
    if (!$author) {
        return '';
    }
    $asset_id = isset($author['author_userpic_asset_id']) ? $author['author_userpic_asset_id'] : 0;
    $asset = $ctx->mt->db->fetch_assets(array('id' => $asset_id));
    if (!$asset) {
        return '';
    }
    $blog =& $ctx->stash('blog');
    require_once "MTUtil.php";
    $userpic_url = userpic_url($asset[0], $blog, $author);
    return $userpic_url;
}
コード例 #5
0
function smarty_function_mtauthoruserpicurl($args, &$ctx)
{
    $author = $ctx->stash('author');
    if (empty($author)) {
        $entry = $ctx->stash('entry');
        if (!empty($entry)) {
            $author = $entry->author();
        }
    }
    if (empty($author)) {
        return $ctx->error("No author available");
    }
    $asset_id = isset($author->author_userpic_asset_id) ? $author->author_userpic_asset_id : 0;
    $asset = $ctx->mt->db()->fetch_assets(array('id' => $asset_id));
    if (!$asset) {
        return '';
    }
    $blog =& $ctx->stash('blog');
    require_once "MTUtil.php";
    $userpic_url = userpic_url($asset[0], $blog, $author);
    return $userpic_url;
}
コード例 #6
0
ファイル: sso_helpers.php プロジェクト: easunlee/MT-copy
function mt_dsq_get_avatar_url($user)
{
    global $mt;
    $asset_id = isset($user['author_userpic_asset_id']) ? $user['author_userpic_asset_id'] : 0;
    $asset = $mt->db->fetch_assets(array('id' => $asset_id));
    if (!$asset) {
        return '';
    }
    require_once "MTUtil.php";
    $avatar_url = userpic_url($asset[0], $mt->blog_id, $author);
    if (substr($avatar_url, 0, 1) == '/') {
        $permalink = get_permalink();
        $permalink = explode("/", $permalink);
        $avatar_url = "{$permalink['0']}//{$permalink[2]}{$avatar_url}";
    }
    return $avatar_url;
}