function smarty_function_mtsupportdirectoryurl($args, &$ctx)
{
    require_once "MTUtil.php";
    $url = support_directory_url();
    if (isset($args['with_domain']) && $args['with_domain'] && !preg_match("!^http!", $url)) {
        $blog = $ctx->stash('blog');
        if (!isset($blog)) {
            return $url;
        }
        $host = $blog->site_url();
        if (!preg_match("!^/!", $url)) {
            $url = '/' . $url;
        }
        if (preg_match("!(https?://[^/:]+)(:\\d+)?/?!", $host, $matches)) {
            $url = $matches[1] . $url;
        }
    }
    return $url;
}
function smarty_function_mtsupportdirectoryurl($args, &$ctx)
{
    require_once "MTUtil.php";
    $url = support_directory_url();
    return $url;
}
示例#3
0
function userpic_url($asset, $blog, $author)
{
    $mt = MT::get_instance();
    $format = $mt->translate('userpic-[_1]-%wx%h%x', array($author->author_id));
    $max_dim = $mt->config('UserpicThumbnailSize');
    # generate thumbnail
    $src_file = asset_path($asset->asset_file_path, $blog);
    $cache_path = $mt->config('AssetCacheDir');
    $image_path = $cache_path . DIRECTORY_SEPARATOR . 'userpics';
    $support_directory_path = support_directory_path();
    require_once 'thumbnail_lib.php';
    $thumb = new Thumbnail($src_file);
    $thumb->width($max_dim);
    $thumb->height($max_dim);
    $thumb->format($support_directory_path . DIRECTORY_SEPARATOR . $image_path . DIRECTORY_SEPARATOR . $format);
    $thumb->type('png');
    $thumb->square(true);
    $thumb->id($asset->asset_id);
    if (!$thumb->get_thumbnail()) {
        return '';
    }
    $basename = basename($thumb->dest());
    if (DIRECTORY_SEPARATOR != '/') {
        $image_path = str_replace(DIRECTORY_SEPARATOR, '/', $image_path);
    }
    $support_directory_url = support_directory_url();
    $url = sprintf("%s%s/%s", $support_directory_url, $image_path, $basename);
    return $url;
}