function advanced_forum_preprocess_forum_submitted in Advanced Forum 6.2
Same name and namespace in other branches
- 5 advanced_forum.module \advanced_forum_preprocess_forum_submitted()
- 6 advanced_forum.module \advanced_forum_preprocess_forum_submitted()
- 7.2 includes/theme.inc \advanced_forum_preprocess_forum_submitted()
Preprocesses template variables for the submitted by/in template.
File
- includes/
theme.inc, line 250 - Holds theme functions and template preprocesses. Other style related functions are in style.inc
Code
function advanced_forum_preprocess_forum_submitted(&$variables) {
advanced_forum_add_template_suggestions("submitted", $variables['template_files']);
// Avoid E_ALL warning
$variables['topic_link'] = '';
if (isset($variables['topic']->node_title)) {
$nid = $variables['topic']->nid;
// Make a fake node object to avoid the node load
$node = new stdClass();
$node->nid = $nid;
$node->type = $variables['topic']->type;
// Find the page of the first unread comment, if any
$num_comments = db_result(db_query('SELECT COUNT(cid) FROM {comments} WHERE nid = %d', $nid));
$new_replies = advanced_forum_reply_num_new($nid);
$query = advanced_forum_page_first_new($num_comments, $new_replies, $node);
// Format the node title with a link
$title_length = variable_get('advanced_forum_topic_title_length', 15);
if ($title_length == 0) {
$short_topic_title = $variables['topic']->node_title;
}
else {
$short_topic_title = truncate_utf8($variables['topic']->node_title, $title_length, TRUE, TRUE);
}
$fragment = $new_replies ? 'new' : NULL;
$variables['topic_link'] = l($short_topic_title, "node/{$nid}", array(
'query' => $query,
'fragment' => $fragment,
));
}
// For items posted more than $cutoff hours ago, offer an actual date.
$cutoff = variable_get('advanced_forum_time_ago_cutoff', 48) * 60 * 60;
if (isset($variables['topic']->timestamp)) {
$timestamp = $variables['topic']->timestamp;
if (time() - $timestamp > $cutoff) {
$variables['date_posted'] = format_date($timestamp, 'small');
}
}
}