<?php
  
  //for short textblock between the headline and the forums
  if ($board_config->descr) $BOARD_DESCR = nl2br($board_config->descr);
  else $hide_blocks[] = "BOARD_DESCR";
  
  
  //get the forums
  $forums = $SBBForums->GetForums();
  
  $showforumVARS = array();

  //no forums defined 
  if (!$forums) {
    /************
     * initiate template and assign variables
     ************/         
    $QuickSkin = new QuickSkin("status_messages.html");
    $QuickSkin->assign("INFO", lang("no_forums"));
    $content .= $QuickSkin->result();
    unset($QuickSkin);

  } else {
  //forums found

    //some stats
    $SBBstats = $SBBForums->GetStats();
    $topics = $SBBstats["topics"];
    $posts = $SBBstats["posts"];
    $last = $SBBstats["last"];

    //through the forums
    for ($i=0;$i<$SBBForums->count;$i++) {
      $row = $forums[$i];
      if ($row->cat_id != $tmp_cat_id) {
        $cat_hl = $category[$row->cat_id]->title;
        $cat_descr = $category[$row->cat_id]->descr;
        $j=0;
        $newcat = true;
      } else {
        unset($cat_hl,$cat_descr);
        $newcat = false;
      }
      $this_user = forum_user($last[$row->id]->uid);
      $this_a_user = ($last[$row->id]->a_uid ? forum_user($last[$row->id]->a_uid) : $this_user);
      //assign to template array
      $FORUMS_ARR[] = array("ID" => $row->id,
                            "NEWCAT" => $newcat,
                            "CATHL" => $cat_hl,
                            "CATDESCR" => $cat_descr,
                            "TITLE" => $row->title,
                            "DESCR" => ($row->descr ? $row->descr : "&nbsp;"),
                            "IMG_FORUM_SUFFIX" => "",
                            "FORUM_LINK" => ($board_config->seo ? "$main_path/sbbf" . $row->id . adddescr2link($row->title) . ".html" : "$main_script?todo=show_topics&amp;fid=" . $row->id),
                            "TOPICS" => intval($topics[$row->id]),
                            "POSTS" => intval($topics[$row->id] + $posts[$row->id]),
                            "LASTTOPICID" => $last[$row->id],
                            "LASTTOPIC" => ($last[$row->id] ? short($last[$row->id]->topic,40) : "-" ),
                            "LASTPOSTLINK" => ($board_config->seo ? "$main_path/sbbt" . $last[$row->id]->id . adddescr2link($last[$row->id]->topic) . ".html" : "$main_script?todo=viewtopic&amp;tid=" . $last[$row->id]->id) . "#t" . $last[$row->id]->reply,
                            "LASTPOSTER" => ($this_a_user ? 
                                             "<a href='" . ($board_config->seo ? "$main_path/sbb-user" . $this_a_user->id . adddescr2link($this_a_user->user) . ".html" : "$main_script?todo=showprofile&amp;uid=" . $this_user->id) . "' class='anu " . nick_class($this_a_user->is_admin, $this_a_user->is_mod) . "'>" . $this_a_user->user . "</a>" : 
                                            $last[$row->id]->a_name),
                            "LASTDATE" => $last[$row->id]->a_datetime ? date($date_time_format,strtotime($last[$row->id]->a_datetime ? $last[$row->id]->a_datetime : $last[$row->id]->datetime)) : "n/a",
                      );
      $tmp_cat_id = $row->cat_id;
    }
    
    $STATINFOS1 = sprintf(lang("somestats1"),$SBBstats["cntposts"],$SBBstats["cnttopics"],$SBBstats["cntmembers"],($board_config->seo ? "$main_path/sbb-user" . $SBBstats["latest_member"]->id . adddescr2link($SBBstats["latest_member"]->user) . ".html" : "$main_script?todo=showprofile&amp;uid=" . $SBBstats["latest_member"]->id),$SBBstats["latest_member"]->user);
    if ($SBBstats["onlineguests"] &&  $SBBstats["whoisonline"]) {
      $WHOISONLINE = $SBBstats["onlineguests"] . " " . lang("guests") . ", " . implode(", ",$SBBstats["whoisonline"]);
    } elseif ($SBBstats["onlineguests"]) {
      $WHOISONLINE = $SBBstats["onlineguests"] . " " . lang("guests");
    } elseif ($SBBstats["whoisonline"]) {
      $WHOISONLINE = implode(", ",$SBBstats["whoisonline"]);
    }
  
    /************
     * initiate template and assign variables
     ************/         
    $showforumVARS = array('FORUMS_ARR' => $FORUMS_ARR,
      'STATINFOS1' => $STATINFOS1,
      'WHOISONLINE' => $WHOISONLINE,
      'HEADLINE_BOARD_STATISTICS' => lang("hl_boardstatistics"),
      'HEADLINE_WHOISONLINE' => lang("hl_whoisonline"),
      'BOARD_DESCR' => nl2br($board_config->descr),
      'DESCR_FORUM' => lang("forum"),
      'DESCR_TOPICS' => lang("topics"),
      'DESCR_POSTS' => lang("posts"),
      'DESCR_LAST_POST' => lang("last_post"));

    $QuickSkin = new QuickSkin("show_forums.html");
    $QuickSkin->assign(array_merge($showforumVARS,array("CONF" => $GLOBAL_TEMPLATE_VARS),array("FLAGS" => $TEMPLATE_FLAGS)));
    $content .= $QuickSkin->result();
    unset($QuickSkin);

  } //forums found

?>