You are here

function advanced_forum_preprocess_forums in Advanced Forum 6

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

Preprocesses template variables for the forum template.

This function adds additional functionality to the core forum preprocess.

File

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

Code

function advanced_forum_preprocess_forums($variables) {
  $variables['template_files'][] = 'advf-forums';
  if (empty($variables['topics'])) {

    // We don't want the links on the top of the forum overview
    $variables['links_orig'] = $variables['links'];
    $variables['links'] = array();
    $variables['forum_description'] = '';
  }
  else {

    // Grab the forum description and make it available to the template file
    $forum = taxonomy_get_term($variables['tid']);
    $variables['forum_description'] = $forum->description;

    // To avoid translation issues, make the button version optional
    if (variable_get('advanced_forum_button_links', 1)) {
      if (isset($variables['links']['forum'])) {
        $title_image = advanced_forum_theme_image(t('new-topic.png'), t('New topic'));
        $variables['links']['forum']['title'] = $title_image;
        $variables['links']['forum']['html'] = TRUE;
      }
      if (isset($variables['links']['poll'])) {
        $title_image = advanced_forum_theme_image(t('new-poll.png'), t('New poll'));
        $variables['links']['poll']['title'] = $title_image;
        $variables['links']['poll']['html'] = TRUE;
      }
    }
  }
  $tid = $variables['tid'];

  // Add in the mark as read link if user has access and we're not on a container.
  if (advanced_forum_markasread_access() && !in_array($tid, variable_get('forum_containers', array()))) {
    if ($tid) {
      $title = t('Mark all topics read');
      $link = "forum/markasread/{$tid}";
    }
    else {
      $title = t('Mark all forums read');
      $link = "forum/markasread";
    }

    // To avoid translation issues, make the button version optional
    if (variable_get('advanced_forum_button_links', 1)) {
      $title_image = advanced_forum_theme_image(t('mark-read.png'), t('Mark read'));
      $variables['links']['markasread'] = array(
        'title' => $title_image,
        'href' => $link,
        'html' => TRUE,
      );
      $variables['links_orig']['markasread'] = array(
        'title' => $title_image,
        'href' => $link,
        'html' => TRUE,
      );
    }
    else {
      $variables['links']['markasread'] = array(
        'title' => $title,
        'href' => $link,
      );
      $variables['links_orig']['markasread'] = array(
        'title' => $title,
        'href' => $link,
      );
    }
  }
}