function smarty_block_mtifentryrecommended($args, $content, &$ctx, &$repeat)
{
    $localvars = array('cp_if_recommended', 'cp_if_recommended_else');
    if (!isset($content)) {
        $ctx->localize(array('_ifrc_counter', 'conditional', 'else_content'));
        $ctx->stash('_ifrc_counter', 0);
        $ctx->stash('cp_if_recommended_else', 1);
    } else {
        $counter = $ctx->stash('_ifrc_counter');
        if ($counter < 1) {
            $repeat = true;
            $false_block = $ctx->stash('else_content');
            $ctx->stash('_ifrc_false_block', $false_block);
            $ctx->stash('_ifrc_counter', $counter + 1);
            $ctx->stash('conditional', 1);
            $ctx->__stash['cp_if_recommended_else'] = null;
            $ctx->stash('cp_if_recommended', '1');
            return '';
        } else {
            $ctx->restore(array('_ifrc_counter', 'conditional', 'else_content'));
            $repeat = false;
        }
        $false_block = $ctx->stash('_ifrc_false_block');
        $true_block = $content;
        $ctx->__stash['cp_if_recommended'] = null;
        $ctx->__stash['_ifrc_false_block'] = null;
        $entry = $ctx->stash('entry');
        if (!isset($entry)) {
            return $ctx->error('No entry available.');
        }
        $class = $args['class'];
        if (!$class) {
            $class = 'scored';
        }
        if ($class) {
            require_once "MTUtil.php";
            $class = strip_tags($class);
            $class = ' class="' . $class . '"';
        }
        $class_else = $args['class_else'];
        if (!$class_else) {
            $class_else = 'scored-else';
        }
        if ($class_else) {
            require_once "MTUtil.php";
            $class_else = strip_tags($class_else);
            $class_else = ' class="' . $class_else . '"';
        }
        require_once "function.mtstaticwebpath.php";
        $static_path = smarty_function_mtstaticwebpath($args, $ctx);
        require_once "function.mtcgipath.php";
        $cgi_path = smarty_function_mtcgipath($args, $ctx);
        $entry_id = $entry['entry_id'];
        $blog_id = $entry['entry_blog_id'];
        $script = "\n<script type=\"text/javascript\" src=\"{$static_path}mt.js\"></script>\n<script type=\"text/javascript\" src=\"{$static_path}js/tc.js\"></script>\n<script type=\"text/javascript\" src=\"{$static_path}js/tc/client.js\"></script>\n<script type=\"text/javascript\">\nfunction scoredby_script_vote(id) {\n    TC.Client.call({\n        'load': function(c, result) { eval(result); },\n        'method': 'POST',\n        'uri': '{$cgi_path}mt-cp.cgi',\n        'arguments': {\n            '__mode': 'vote',\n            'blog_id': '{$blog_id}',\n            'id': id,\n            'f': 'scored,sum',\n            'jsonp': 'scoredby_script_callback'\n        }\n    });\n}\nfunction scoredby_script_callback(scores_hash) {\n    var true_block = getByID('scored_' + {$entry_id});\n    var false_block = getByID('scored_' + {$entry_id} + '_else');\n    var span;\n    if (scores_hash['{$entry_id}'] && scores_hash['{$entry_id}'].scored) {\n        span = getByID('cp_total_' + {$entry_id});\n        if (true_block)\n            true_block.style.display = '';\n        if (false_block) \n            false_block.style.display = 'none';\n    }\n    else {\n        span = getByID('cp_total_' + {$entry_id} + '_else');\n        if (true_block)\n            true_block.style.display = 'none';\n        if (false_block) \n            false_block.style.display = '';\n    }\n    if (span) {\n        if (scores_hash['{$entry_id}'] && scores_hash['{$entry_id}'].sum)\n            span.innerHTML = scores_hash['{$entry_id}'].sum;\n        else\n            span.innerHTML = 0;\n    }\n}\n</script>";
        $out = "\n{$script}\n<div id=\"scored_{$entry_id}\"{$class} style=\"display:none\">\n    {$true_block}\n</div>\n<div id=\"scored_{$entry_id}_else\"{$class_else} style=\"display:none\">\n    {$false_block}\n</div>\n<script type=\"text/javascript\" src=\"{$cgi_path}mt-cp.cgi?__mode=score&blog_id={$blog_id}&id={$entry_id}&f=scored,sum&jsonp=scoredby_script_callback\"></script>";
        return $out;
    }
}
function smarty_function_mtcommenterauthiconurl($args, &$ctx)
{
    $a =& $ctx->stash('commenter');
    if (!isset($a)) {
        return '';
    }
    require_once "function.mtstaticwebpath.php";
    $static_path = smarty_function_mtstaticwebpath($args, $ctx);
    require_once "commenter_auth_lib.php";
    return _auth_icon_url($static_path, $a);
}
function smarty_function_mtauthorauthiconurl($args, &$ctx)
{
    $author = $ctx->stash('author');
    if (empty($author)) {
        $entry = $ctx->stash('entry');
        if (!empty($entry)) {
            $author = $ctx->mt->db->fetch_author($entry['entry_author_id']);
        }
    }
    if (empty($author)) {
        return $ctx->error("No author available");
    }
    require_once "function.mtstaticwebpath.php";
    $static_path = smarty_function_mtstaticwebpath($args, $ctx);
    require_once "commenter_auth_lib.php";
    return _auth_icon_url($static_path, $author);
}
Пример #4
0
function smarty_function_mtasseturl($args, &$ctx)
{
    $asset = $ctx->stash('asset');
    if (!$asset) {
        return '';
    }
    $blog = $ctx->stash('blog');
    $url = $asset->asset_url;
    $site_url = $blog->site_url();
    $site_url = preg_replace('/\\/$/', '', $site_url);
    $url = preg_replace('/^%r/', $site_url, $url);
    require_once 'function.mtstaticwebpath.php';
    $static_url = smarty_function_mtstaticwebpath($args, $ctx);
    $url = preg_replace('/^%s\\//', $static_url, $url);
    $archive_url = $blog->archive_url();
    if ($archive_url) {
        $archive_url = preg_replace('/\\/$/', '', $archive_url);
        $url = preg_replace('/^%a/', $archive_url, $url);
    }
    return $url;
}
function smarty_function_mtcommentauthoridentity($args, &$ctx)
{
    $cmt = $ctx->stash('comment');
    $cmntr = $ctx->stash('commenter');
    if (!$cmntr) {
        if ($cmt['comment_commenter_id']) {
            # load author related to this commenter.
            $cmntr = $ctx->mt->db->fetch_author($cmt['comment_commenter_id']);
            if (!$cmntr) {
                return "";
            }
        }
    }
    if (!$cmntr) {
        return "";
    }
    if (isset($cmntr['author_url'])) {
        $link = $cmntr['author_url'];
    }
    require_once "function.mtstaticwebpath.php";
    $static_path = smarty_function_mtstaticwebpath($args, $ctx);
    require_once "commenter_auth_lib.php";
    $logo = _auth_icon_url($static_path, $cmntr);
    if (!$logo) {
        $root_url = $static_path . 'images/';
        if (!preg_match('/\\/$/', $root_url)) {
            $root_url .= '/';
        }
        $logo = $root_url . "nav-commenters.gif";
    }
    $result = "<img alt=\"Author Profile Page\" src=\"{$logo}\" width=\"16\" height=\"16\" />";
    if ($link) {
        $result = "<a class=\"commenter-profile\" href=\"{$link}\">{$result}</a>";
    }
    return $result;
}
function _objectloop_get_blog_paths($blog, $args, $ctx)
{
    $blog_paths = array();
    $site_url = $blog->site_url();
    $site_url = preg_replace('/\\/$/', '', $site_url);
    $blog_paths['site_url'] = $site_url;
    require_once 'function.mtstaticwebpath.php';
    $static_url = smarty_function_mtstaticwebpath($args, $ctx);
    $blog_paths['static_url'] = $static_url;
    $archive_url = $blog->archive_url();
    if ($archive_url) {
        $archive_url = preg_replace('/\\/$/', '', $archive_url);
    }
    $blog_paths['archive_url'] = $site_url;
    $site_path = $blog->site_path();
    $site_path = preg_replace('/\\/$/', '', $site_path);
    $blog_paths['site_path'] = $site_path;
    return $blog_paths;
}