function advanced_forum_views_post_render in Advanced Forum 6.2
Same name and namespace in other branches
- 7.2 advanced_forum.module \advanced_forum_views_post_render()
Post render a view and replace any advanced forum tokens.
File
- ./
advanced_forum.module, line 551 - Enables the look and feel of other popular forum software.
Code
function advanced_forum_views_post_render(&$view, &$output) {
if (!is_object($view->style_plugin) || !$view->style_plugin
->uses_row_plugin()) {
return;
}
$plugin = $view->display_handler
->get_option('row_plugin');
if ($plugin == 'node' || $plugin == 'nodecomment_threaded') {
// Look for token matches in the output:
$matches = array();
$tokens = array();
// We want to change the look of the 'new' marker from the default, slightly:
$tokens['<span class="new">' . t('new') . '</span>'] = '<span class="new">(' . t('new') . ')</span>';
// Replace the Author Pane token with the actual Author Pane.
// Note that this token will only exist if Author Pane is enabled.
if (preg_match_all('/<!--post:author-pane-([\\d]+)-->/us', $output, $matches)) {
foreach ($matches[1] as $match => $uid) {
$token = $matches[0][$match];
// This is the exact string that matched.
if (!isset($tokens[$token])) {
$account = user_load($uid);
$tokens[$token] = theme('author_pane', $account, 'advanced_forum', variable_get('advanced_forum_user_picture_preset', ''), NULL, TRUE);
}
}
}
// Replace the Post edited token.
if (preg_match_all('/<!--post:post-edited-([\\d]+)-->/us', $output, $matches)) {
foreach ($matches[1] as $match => $nid) {
$token = $matches[0][$match];
// This is the exact string that matched.
if (!isset($tokens[$token])) {
if (user_access('view last edited notice')) {
$sql = 'SELECT uid, log, timestamp FROM {node_revisions} WHERE nid = %d ORDER BY timestamp DESC';
$row = db_fetch_object(db_query($sql, $nid));
$tokens[$token] = theme('advanced_forum_post_edited', $row->uid, $row->timestamp, $row->log);
}
else {
// No access; remove token.
$tokens[$token] = '';
}
}
}
}
// Replace the core Signature token.
if (preg_match_all('/<!--post:signature-core-([\\d]+)-->/us', $output, $matches)) {
foreach ($matches[1] as $match => $uid) {
$token = $matches[0][$match];
// This is the exact string that matched.
if (!isset($tokens[$token])) {
$account = user_load($uid);
if ($account->signature) {
$tokens[$token] = check_markup($account->signature, $account->signature_format, FALSE);
}
}
}
}
// Replace the posted by viewer tokens with class if appropriate.
if (preg_match_all('/<!--post:poster-id-([\\d]+)-->/us', $output, $matches)) {
foreach ($matches[1] as $match => $uid) {
$token = $matches[0][$match];
// This is the exact string that matched.
if (!isset($tokens[$token])) {
global $user;
if ($user->uid > 0 && $uid == $user->uid) {
// This post is by current user.
$tokens[$token] = " post-by-viewer";
}
else {
$tokens[$token] = "";
}
}
}
}
// Perform replacements.
$output = strtr($output, $tokens);
}
}