You are here

function advanced_forum_preprocess_node in Advanced Forum 6

Same name and namespace in other branches
  1. 5 advanced_forum.module \advanced_forum_preprocess_node()
  2. 6.2 includes/theme.inc \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 397
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;
  }

  // Determine the template file to use for the node.
  if (isset($_GET['page']) && $_GET['page'] > 0) {

    // This is the repeated node on the top of subsequent pages.
    // We send this to a special .tpl so people can adjust it to their needs.
    $variables['template_files'][] = "advf-forum-repeat-post";
  }
  elseif (arg(1) == 'reply') {

    // Use the preview version
    $variables['template_files'][] = "advf-forum-preview-post";
  }
  else {

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

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

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

  // Build the reply link / button here even though it's in the header in case
  // the site admin wants to move it in the template.
  $variables['reply_link'] = theme('advanced_forum_reply_link', $variables['node']);

  /* 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', variable_get('advanced_forum_user_picture_preset', ''), $variables['node'], TRUE);

  // Load the signature.
  if (module_exists('signature_forum')) {

    // If Signature For Forums is installed, use that
    $variables['signature'] = signature_forum_get_signature($variables['node']);
  }
  elseif (variable_get('user_signatures', 0)) {
    if ($variables['account']->signature) {

      // Otherwise load Drupal's built in one, if enabled.
      $variables['signature'] = check_markup($variables['account']->signature, $variables['account']->signature_format);
    }
  }

  // Initialize to avoid notices.
  $variables['classes'] = empty($variables['classes']) ? '' : $variables['classes'];
  $variables['node_classes'] = empty($variables['node_classes']) ? '' : $variables['node_classes'];
}