function doQuote($bbcode, $action, $name, $default, $params, $content)
{
if ($action == Nbbc::BBCODE_CHECK) {
return true;
}
if (is_string($default)) {
$defaultParts = explode(';', $default);
// support vbulletin style quoting.
$Url = array_pop($defaultParts);
if (count($defaultParts) == 0) {
$params['name'] = $Url;
} else {
$params['name'] = implode(';', $defaultParts);
$params['url'] = $Url;
}
}
$title = '';
if (isset($params['name'])) {
$username = trim($params['name']);
$username = html_entity_decode($username, ENT_QUOTES, 'UTF-8');
$User = Gdn::userModel()->getByUsername($username);
if ($User) {
$userAnchor = userAnchor($User);
} else {
$userAnchor = anchor(htmlspecialchars($username, null, 'UTF-8'), '/profile/' . rawurlencode($username));
}
$title = concatSep(' ', $title, $userAnchor, t('Quote wrote', 'wrote'));
}
if (isset($params['date'])) {
$title = concatSep(' ', $title, t('Quote on', 'on'), htmlspecialchars(trim($params['date'])));
}
if ($title) {
$title = $title . ':';
}
if (isset($params['url'])) {
$url = trim($params['url']);
if (preg_match('/(c|d)-(\\d+)/', strtolower($url), $matches)) {
if ($matches[1] === 'd') {
$url = "/discussion/{$matches[2]}";
} else {
$url = "/discussion/comment/{$matches[2]}#Comment_{$matches[2]}";
}
} elseif (is_numeric($url)) {
$url = "/discussion/comment/{$url}#Comment_{$url}";
} elseif (!$bbcode->isValidURL($url)) {
$url = '';
}
if ($url) {
$title = concatSep(' ', $title, anchor('<span class="ArrowLink">ยป</span>', $url, ['class' => 'QuoteLink']));
}
}
if ($title) {
$title = "<div class=\"QuoteAuthor\">{$title}</div>";
}
return "\n<blockquote class=\"Quote UserQuote\">\n{$title}\n<div class=\"QuoteText\">{$content}</div>\n</blockquote>\n";
}