Exemplo n.º 1
0
function data_quote($pData, $pParams)
{
    global $gLibertySystem, $gBitSmarty, $gBitSystem;
    if (empty($pParams['format_guid'])) {
        // default should be set - if not, we'll use tikiwiki - can't use PLUGIN_GUID_TIKIWIKI since it might not be defined.
        $pParams['format_guid'] = $gBitSystem->getConfig('default_format', 'tikiwiki');
    }
    $rendererHash = array();
    $rendererHash['content_id'] = 0;
    $rendererHash['format_guid'] = $pParams['format_guid'];
    $rendererHash['data'] = trim($pData);
    $formatGuid = $rendererHash['format_guid'];
    $ret = "";
    if ($func = $gLibertySystem->getPluginFunction($formatGuid, 'load_function')) {
        $ret = $func($rendererHash, $this);
    }
    $quote = array();
    $user = empty($pParams['user']) ? NULL : $pParams['user'];
    if (!empty($pParams['comment_id'])) {
        if ($gBitSystem->getActivePackage() == 'boards') {
            $c = new BitBoardPost(preg_replace('/[^0-9]/', '', $pParams['comment_id']));
        } else {
            $c = new LibertyComment(preg_replace('/[^0-9]/', '', $pParams['comment_id']));
        }
        if (empty($c->mInfo['title'])) {
            $c->mInfo['title'] = "#" . $c->mCommentId;
        }
        $quote['cite_url'] = $c->getDisplayUrl();
        $quote['title'] = $c->mInfo['title'];
        $quote['created'] = $c->mInfo['created'];
        if (empty($user)) {
            $user = $c->mInfo['login'];
        }
    }
    $quote['login'] = $user;
    if (!empty($user)) {
        $u = new BitUser();
        $u->load(TRUE, $user);
        $quote['user_url'] = $u->getDisplayUrl();
        $quote['user_display_name'] = $u->mInfo['display_name'];
    }
    $quote['ret'] = $ret;
    $gBitSmarty->assign("quote", $quote);
    $repl = $gBitSmarty->fetch("bitpackage:liberty/plugins/data_quote.tpl");
    return $repl;
}