You are here

function theme_forum_display in Drupal 4

Same name and namespace in other branches
  1. 5 modules/forum/forum.module \theme_forum_display()

Format the forum body.

Related topics

1 theme call to theme_forum_display()
forum_page in modules/forum.module
Menu callback; prints a forum listing.

File

modules/forum.module, line 850
Enable threaded discussions about general topics.

Code

function theme_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_per_page) {
  global $user;

  // forum list, topics list, topic browser and 'add new topic' link
  $vocabulary = taxonomy_get_vocabulary(variable_get('forum_nav_vocabulary', ''));
  $title = $vocabulary->name;

  // Breadcrumb navigation:
  $breadcrumb = array();
  if ($tid) {
    $breadcrumb[] = array(
      'path' => 'forum',
      'title' => $title,
    );
  }
  if ($parents) {
    $parents = array_reverse($parents);
    foreach ($parents as $p) {
      if ($p->tid == $tid) {
        $title = $p->name;
      }
      else {
        $breadcrumb[] = array(
          'path' => 'forum/' . $p->tid,
          'title' => $p->name,
        );
      }
    }
  }
  drupal_set_title(check_plain($title));
  $breadcrumb[] = array(
    'path' => $_GET['q'],
  );
  menu_set_location($breadcrumb);
  if (count($forums) || count($parents)) {
    $output = '<div id="forum">';
    $output .= '<ul>';
    if (module_exist('tracker')) {
      if ($user->uid) {
        $output .= ' <li>' . l(t('My discussions.'), "tracker/{$user->uid}") . '</li>';
      }
      $output .= ' <li>' . l(t('Active discussions.'), 'tracker') . '</li>';
    }
    if (user_access('create forum topics')) {
      $output .= '<li>' . l(t('Post new forum topic.'), "node/add/forum/{$tid}") . '</li>';
    }
    else {
      if ($user->uid) {
        $output .= '<li>' . t('You are not allowed to post a new forum topic.') . '</li>';
      }
      else {
        $output .= '<li>' . t('<a href="%login">Login</a> to post a new forum topic.', array(
          '%login' => url('user/login'),
        )) . '</li>';
      }
    }
    $output .= '</ul>';
    $output .= theme('forum_list', $forums, $parents, $tid);
    if ($tid && !in_array($tid, variable_get('forum_containers', array()))) {
      drupal_add_link(array(
        'rel' => 'alternate',
        'type' => 'application/rss+xml',
        'title' => 'RSS - ' . $title,
        'href' => url('taxonomy/term/' . $tid . '/0/feed'),
      ));
      $output .= theme('forum_topic_list', $tid, $topics, $sortby, $forum_per_page);
      $output .= theme('feed_icon', url("taxonomy/term/{$tid}/0/feed"));
    }
    $output .= '</div>';
  }
  else {
    drupal_set_title(t('No forums defined'));
    $output = '';
  }
  return $output;
}