function smarty_function_mtassetfilepath($args, &$ctx)
{
    $asset = $ctx->stash('asset');
    if (!$asset) {
        return '';
    }
    $blog = $ctx->stash('blog');
    $asset_file = $asset->asset_file_path;
    $blog_site_path = $blog->site_path();
    $blog_site_path = preg_replace('/\\/$/', '', $blog_site_path);
    $asset_file = preg_replace('/^%a/', $blog_site_path, $asset_file);
    require_once 'MTUtil.php';
    $static_path = static_file_path();
    $asset_file = preg_replace('/^%s/', $static_path, $asset_file);
    $blog_archive_path = $blog->archive_path();
    if (!$blog_archive_path) {
        $blog_archive_path = $blog_site_path;
    }
    if ($blog_archive_path) {
        $blog_archive_path = preg_replace('/\\/$/', '', $blog_archive_path);
        $asset_file = preg_replace('/^%r/', $blog_archive_path, $asset_file);
    }
    return $asset_file;
}
Example #2
0
function userpic_url($asset, $blog, $author)
{
    global $mt;
    $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';
    $static_file_path = static_file_path() . 'support';
    require_once 'thumbnail_lib.php';
    $thumb = new Thumbnail($src_file);
    $thumb_w = $max_dim;
    $thumb_h = $max_dim;
    $dest;
    $thumb_name = $static_file_path . DIRECTORY_SEPARATOR . $image_path . DIRECTORY_SEPARATOR . $format;
    if (!$thumb->get_thumbnail($dest, $thumb_w, $thumb_h, $asset['asset_id'], $scale, $thumb_name, 'png', true)) {
        return '';
    }
    $basename = basename($dest);
    $static_path = $mt->config('StaticWebPath');
    $static_path = preg_replace('/\\/$/', '', $static_path);
    $static_path .= '/support';
    $url = sprintf("%s/%s/%s", $static_path, $image_path, $basename);
    return $url;
}
Example #3
0
function support_directory_path()
{
    $mt = MT::get_instance();
    $path = $mt->config('SupportDirectoryPath');
    if (!$path) {
        $path = static_file_path();
        $path .= 'support';
    }
    return $path;
}