You are here

function advanced_forum_preprocess_node in Advanced Forum 5

Same name and namespace in other branches
  1. 6.2 includes/theme.inc \advanced_forum_preprocess_node()
  2. 6 advanced_forum.module \advanced_forum_preprocess_node()
  3. 7.2 includes/theme.inc \advanced_forum_preprocess_node()

Preprocesses template variables for the node template.

File

./advanced_forum.module, line 460
Enables the look and feel of other popular forum software.

Code

function advanced_forum_preprocess_node(&$variables) {
  if (!advanced_forum_treat_as_forum_post('node', $variables)) {

    // We only deal with forum posts.
    return;
  }

  // Set the static variables of the comment wrapper theme function.
  if (function_exists('phptemplate_comment_wrapper')) {
    phptemplate_comment_wrapper(NULL, 'forum', $variables['node']);
  }
  $forum_style = advanced_forum_get_current_style();
  if ($_GET['page'] > 0) {

    // This is the repeated node on the top of subsequent pages.
    // We send this to a special .tpl so people can wipe it out or whatever
    $variables['template_files'][] = "{$forum_style}/advf-forum-repeat-post";
  }
  else {

    // Use our combined node/comment template file
    $variables['template_files'][] = "{$forum_style}/advf-forum-post";
  }

  // The node is the first post, aka topic
  $variables['top_post'] = TRUE;

  // Build the topic header
  $variables['topic_header'] = theme('advanced_forum_topic_header', $variables['node'], $variables['comment_count']);

  /* Node links changes */

  // Change first post from "add comment" to "Reply"
  if (!empty($variables['node']->links) && !empty($variables['node']->links['comment_add'])) {
    $variables['node']->links['comment_add']['title'] = t('Reply');
  }

  // Change links over to buttons when possible and wanted.
  _advanced_forum_buttonify_links($variables['node']->links);

  // Remake the links with our changes
  $variables['links'] = theme('links', $variables['node']->links, array(
    'class' => 'links inline forum-links',
  ));

  // Make an array version of $links
  $variables['links_array'] = $variables['node']->links;

  // User information / author pane
  $variables['account'] = user_load(array(
    'uid' => $variables['node']->uid,
  ));
  $variables['author_pane'] = theme('author_pane', $variables['account'], advanced_forum_path_to_images(), "{$forum_style}/advf-author-pane");
}