Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 19th, 2012  |  syntax: None  |  size: 19.68 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /***************************************************************************
  3.  *                      functions_hierarchy.php
  4.  *                      -------------------
  5.  *  begin               : Saturday, Feb 13, 2001
  6.  *  copyright           : (C) 2003 Ptirhiik (Pierre) http://www.rpgnet-fr.com
  7.  *  email               : admin@rpgnet-fr.com
  8.  *  modification        : (C) 2003 Przemo http://www.przemo.org/phpBB2/
  9.  *  date modification   : ver. 1.12.0 2005/11/11 13:28
  10.  *
  11.  ***************************************************************************/
  12.  
  13. /***************************************************************************
  14.  *      This program is free software; you can redistribute it and/or modify
  15.  *      it under the terms of the GNU General Public License as published by
  16.  *      the Free Software Foundation; either version 2 of the License, or
  17.  *      (at your option) any later version.
  18.  ***************************************************************************/
  19.  
  20. function get_max_depth($cur = 'Root', $all = false, $level = -1, &$keys, $max = -1)
  21. {
  22.         global $tree;
  23.         if ( empty($keys['id']) )
  24.         {
  25.                 $keys = array();
  26.                 $keys = get_auth_keys($cur, $all);
  27.         }
  28.  
  29.         $max_level = 0;
  30.         for($i = 0; $i < count($keys['id']); $i++)
  31.         {
  32.                 if ( $keys['level'][$i] > $max_level )
  33.                 {
  34.                         $max_level = $keys['level'][$i];
  35.                 }
  36.         }
  37.         return $max_level;
  38. }
  39.  
  40. function build_index($cur = 'Root', $cat_break = false, &$forum_moderators, $real_level = -1, $max_level = -1, &$keys, $br = false)
  41. {
  42.         global $userdata, $db, $lang, $template, $phpEx, $board_config, $lang, $images, $theme;
  43.         global $tree, $phpEx, $idx_buffer, $readhist_buffer, $userdata, $HTTP_COOKIE_VARS, $unique_cookie_name;
  44.         // init
  45.         $display = false;
  46.  
  47.         $board_config['split_cat'] = (!$board_config['split_cat_over']) ? $userdata['user_split_cat'] : $board_config['split_cat'];
  48.  
  49.         // get the sub_forum switch value
  50.         $board_config['sub_forum'] = (!$board_config['sub_forum_over']) ? $userdata['user_sub_forum'] : $board_config['sub_forum'];
  51.         $sub_forum = intval($board_config['sub_forum']);
  52.         if ( ($sub_forum == 2) && defined('IN_VIEWFORUM') )
  53.         {
  54.                 $sub_forum = 1;
  55.         }
  56.         $pack_first_level = ($sub_forum == 2);
  57.  
  58.         // verify the cat_break parm
  59.         if ( ($cur != 'Root') && ($real_level == -1) )
  60.         {
  61.                 $cat_break = false;
  62.         }
  63.  
  64.         // display the level
  65.         $athis = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1;
  66.  
  67.         // display each kind of row
  68.  
  69.         // root level head
  70.         if ( $real_level == -1 )
  71.         {
  72.                 // get max inc level
  73.                 $max = -1;
  74.                 if ( $sub_forum == 2 )
  75.                 {
  76.                         $max = 0;
  77.                 }
  78.                 if ( $sub_forum == 1 )
  79.                 {
  80.                         $max = 1;
  81.                 }
  82.                 $keys = array();
  83.                 $keys = get_auth_keys($cur, false, -1, $max);
  84.                 $max_level = get_max_depth($cur, false, -1, $keys, $max);
  85.         }
  86.  
  87.         // table header
  88.         if ( ($board_config['split_cat'] && $cat_break && ($real_level == 0)) || ((!$board_config['split_cat'] || !$cat_break) && ($real_level == -1)) )
  89.         {
  90.                 // if break, get the local max level
  91.                 if ( $board_config['split_cat'] && $cat_break && ($real_level == 0) )
  92.                 {
  93.                         $max_level = 0;
  94.                         // the array is sorted
  95.                         $start = false;
  96.                         $stop = false;
  97.                         for($i=0; ($i < count($keys['id']) && !$stop); $i++)
  98.                         {
  99.                                 if ( $start && ($tree['main'][$keys['idx'][$i]] == $tree['main'][$athis]) )
  100.                                 {
  101.                                         $stop = true;
  102.                                         $break;
  103.                                 }
  104.                                 if ( $keys['id'][$i] == $cur )
  105.                                 {
  106.                                         $start = true;
  107.                                 }
  108.                                 if ( $start && !$stop && ($keys['level'][$i] > $max_level) )
  109.                                 {
  110.                                         $max_level = $keys['level'][$i];
  111.                                 }
  112.                         }
  113.                 }
  114.                 $template->assign_block_vars('catrow', array());
  115.                 $template->assign_block_vars('catrow.tablehead', array(
  116.                         'CAT_ID' => $cur,
  117.                         'L_FORUM' => ($athis < 0) ? $lang['Forum'] : get_object_lang($cur, 'name'),
  118.                         'INC_SPAN' => $max_level + 2)
  119.                 );
  120.                 if ( $cur != 'Root' )
  121.                 {
  122.                         $template->assign_block_vars('catrow.tablehead.br', array('CAT_ID' => $cur));
  123.                 }
  124.         }
  125.  
  126.         // get the level
  127.         $level = $keys['level'][$keys['keys'][$cur]];
  128.  
  129.         // sub-forum view management
  130.         $pull_down = true;
  131.         if ( $sub_forum > 0 )
  132.         {
  133.                 $pull_down = false;
  134.                 if ( ($real_level == 0) && ($sub_forum == 1) )
  135.                 {
  136.                         $pull_down = true;
  137.                 }
  138.         }
  139.  
  140.         if ( $level >= 0 )
  141.         {
  142.                 // cat header row
  143.                 if ( ($tree['type'][$athis] == POST_CAT_URL) && $pull_down )
  144.                 {
  145.                         // display a cat row
  146.                         $cat = $tree['data'][$athis];
  147.                         $cat_id = $tree['id'][$athis];
  148.  
  149.                         // get the class colors
  150.                         $class_catLeft = 'catLeft';
  151.                         $class_cat = 'cat';
  152.                         $class_rowpic = 'rowpic';
  153.  
  154.                         // send to template
  155.                         $template->assign_block_vars('catrow', array());
  156.                         $template->assign_block_vars('catrow.cathead', array(
  157.                                 'CAT_ID' => $cat_id,
  158.                                 'CAT_TITLE'     => get_object_lang($cur, 'name'),
  159.                                 'CLASS_CATLEFT' => $class_catLeft,
  160.                                 'CLASS_CAT'     => $class_cat,
  161.                                 'CLASS_ROWPIC'  => $class_rowpic,
  162.                                 'INC_SPAN'      => $max_level - $level + 2,
  163.                                 'U_VIEWCAT'     => append_sid("index.$phpEx?" . POST_CAT_URL . "=$cat_id"))
  164.                         );
  165.  
  166.  
  167.                         // add indentation to the display
  168.                         for($k = 1; $k <= $level; $k++)
  169.                         {
  170.                                 $template->assign_block_vars('catrow.cathead.inc', array(
  171.                                         'INC_CLASS' => ($k % 2) ? 'row1' : 'row2')
  172.                                 );
  173.                         }
  174.                         if (!empty($cat['cat_desc']))
  175.                         {
  176.                                 $template->assign_block_vars('catrow', array());
  177.                                 $template->assign_block_vars('catrow.cattitle', array(
  178.                                         'CAT_DESCRIPTION' => get_object_lang(POST_CAT_URL . $cat_id, 'desc'),
  179.                                         'INC_SPAN_ALL' => $max_level - $level + 5)
  180.                                 );
  181.                                 // add indentation to the display
  182.                                 for($k = 1; $k <= $level; $k++)
  183.                                 {
  184.                                         $template->assign_block_vars('catrow.cattitle.inc', array(
  185.                                                 'INC_CLASS' => ($k % 2) ? 'row1' : 'row2')
  186.                                         );
  187.                                 }
  188.                         }
  189.  
  190.                         // something displayed
  191.                         $display = true;
  192.                 }
  193.         }
  194.  
  195.         // forum header row
  196.         if ( $level >= 0 )
  197.         {
  198.                 if ( ($tree['type'][$athis] == POST_FORUM_URL) || (($tree['type'][$athis] == POST_CAT_URL) && !$pull_down) )
  199.                 {
  200.                         // get the data
  201.                         $data   = $tree['data'][$athis];
  202.                         $id = $tree['id'][$athis];
  203.                         $type = $tree['type'][$athis];
  204.                         $sub = (!empty($tree['sub'][$cur]) && $tree['auth'][$cur]['tree.auth_view']);
  205.  
  206.                         // specific to the data type
  207.                         $title = get_object_lang($cur, 'name');
  208.                         $desc = get_object_lang($cur, 'desc');
  209.  
  210.                         // specific to something attached
  211.                         if ( $sub )
  212.                         {
  213.                                 $i_new          = $images['category_new'];
  214.                                 $a_new          = $lang['New_posts'];
  215.                                 $i_norm         = $images['category'];
  216.                                 $a_norm         = $lang['No_new_posts'];
  217.                                 $i_locked       = $images['category_locked'];
  218.                                 $a_locked       = $lang['Forum_locked'];
  219.                         }
  220.                         else
  221.                         {
  222.                                 $i_new          = $images['forum_new'];
  223.                                 $a_new          = $lang['New_posts'];
  224.                                 $i_norm         = $images['forum'];
  225.                                 $a_norm         = $lang['No_new_posts'];
  226.                                 $i_locked       = $images['forum_locked'];
  227.                                 $a_locked       = $lang['Forum_locked'];
  228.                         }
  229.  
  230.                         // forum link type
  231.                         if ( ($tree['type'][$athis] == POST_FORUM_URL) && !empty($tree['data'][$athis]['forum_link']) )
  232.                         {
  233.                                 $i_new          = $images['link'];
  234.                                 $a_new          = $lang['Forum_link'];
  235.                                 $i_norm         = $images['link'];
  236.                                 $a_norm         = $lang['Forum_link'];
  237.                                 $i_locked       = $images['link'];
  238.                                 $a_locked       = $lang['Forum_link'];
  239.                         }
  240.  
  241.                         if ( defined('IN_VIEWFORUM') && !defined('UNREAD_POSTS') && $userdata['user_id'] != ANONYMOUS )
  242.                         {
  243.                                 define('UNREAD_POSTS', true);
  244.                                 $userdata = user_unread_posts();
  245.                         }
  246.  
  247.                         $forum_id = $tree['id'][$athis];
  248.  
  249.                         // front icon
  250.                         if ( $userdata['session_logged_in'] && $forum_id && $type == POST_FORUM_URL )
  251.                         {
  252.                                 if ( isset($userdata['unread_data'][$forum_id]) )
  253.                                 {
  254.                                         $smart_new = true;
  255.                                 }
  256.                         }
  257.  
  258.                         $folder_image = ( $smart_new ) ? $i_new : $i_norm;
  259.                         $folder_alt = ( $smart_new ) ? $a_new : $a_norm;
  260.  
  261.                         if ( $data['tree.locked'] )
  262.                         {
  263.                                 $folder_image = $i_locked;
  264.                                 $folder_alt     = $a_locked;
  265.                         }
  266.  
  267.                         // moderators list
  268.                         $l_moderators   = '&nbsp;';
  269.                         $moderator_list = '&nbsp;';
  270.                         if ( $type == POST_FORUM_URL )
  271.                         {
  272.                                 $forum_moderators = moderarots_list($id, 'groups');
  273.                                 $count_moderators = count($forum_moderators);
  274.  
  275.                                 if ( $count_moderators > 0 )
  276.                                 {
  277.                                         $moderator_list = implode(', ', $forum_moderators);
  278.                                         $l_moderators = ( $count_moderators == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
  279.                                 }
  280.                         }
  281.  
  282.                         // last post ------------------------------------------------------------------
  283.                         $last_post = '--';
  284.  
  285.                         if ( $data['tree.topic_last_post_id'] )
  286.                         {
  287.                                 $topic_title = $data['tree.topic_title'];
  288.                                 if ( strlen($topic_title) > (intval($board_config['last_topic_title_length']) -3 ) )
  289.                                 {
  290.                                         $topic_title = substr($topic_title, 0, intval($board_config['last_topic_title_length'])) . '...';
  291.                                 }
  292.                                 $topic_title = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $data['tree.topic_last_post_id']) . '#' . $data['tree.topic_last_post_id'] . '" title="' . $data['tree.topic_title'] . '" class="gensmall">' . $topic_title . '</a>';
  293.                                
  294.                                
  295.                         //----------------------------------------------- MODIFICATION
  296.                                 $x = $db -> sql_query('select u.user_avatar from phpbb_users u, phpbb_posts p where u.user_id = p.poster_id AND p.post_id='.$data['tree.topic_last_post_id']);
  297.                                 $xs = $db -> sql_fetchrow($x);
  298.                                 if($xs['user_avatar']!='')
  299.                                 $Avat = '<img src="images/avatars/'.$xs['user_avatar'].'" width=32 height=32 style="border:1px solid #ccc;">';
  300.                                 else $Avat = '<img src="templates/FairGameCS/images/icons/noavatar.png" width=32 height=32 style="border:1px solid #ccc;">';
  301.                         //      -----------------------------------------------
  302.                                
  303.                                 $board_config['last_topic_title'] = (!$board_config['last_topic_title_over']) ? $userdata['user_last_topic_title'] : $board_config['last_topic_title'];
  304.                                 $last_postmsg = (($board_config['last_topic_title']) ? $topic_title : '');
  305.                                 //$last_postmsg = ($board_config['last_topic_title']) ? '' . $lang['Last_Post'] . ': ' . $last_postmsg . '' : '';
  306.                                 $last_postmsg = ($board_config['last_topic_title']) ?   $last_postmsg . '<br>przez ' : '';
  307.  
  308.                                
  309.                                
  310.                                 $colored_username = color_username($data['tree.user_level'], $data['tree.user_jr'], $data['tree.post_user_id'], $data['tree.post_username']);
  311.                                 $color_username = $colored_username[0];
  312.  
  313.                                 $last_post_time = create_date($board_config['default_dateformat'], $data['tree.post_time'], $board_config['board_timezone']);
  314.                                
  315.                                 if ( $data['post_approve'] || !$data['forum_moderate'] )
  316.                                 {
  317.                                         $last_post = ( $data['tree.post_user_id'] == ANONYMOUS ) ? $data['tree.post_username'] . $data['tree.post_user_avatar'].' ' : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $data['tree.post_user_id']) . '"' . $colored_username[1] . ' class="gensmall">' . $color_username . '</a> ';
  318.                                 }
  319.                                 $last_post .= '<br>'.$last_post_time . '';
  320.                                 //$last_post .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $data['tree.topic_last_post_id']) . '#' . $data['tree.topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['Last_Post'] . '" title="' . $lang['Last_Post'] . '" /></a>';
  321.                         }
  322.  
  323.                         // links to sub-levels
  324.                         $links = '';
  325.                         $board_config['sub_level_links'] = (!$board_config['sub_level_links_over']) ? $userdata['user_sub_level_links'] : $board_config['sub_level_links'];
  326.                         if ( $sub && !$pull_down && (intval($board_config['sub_level_links']) > 0) && ((($real_level == 0) && ($sub_forum == 1)) || ($real_level == 1) || ($sub_forum == 2)) )
  327.                         {
  328.                                 for($j=0; $j < count($tree['sub'][$cur]); $j++) if ( $tree['auth'][ $tree['sub'][$cur][$j] ]['auth_view'] )
  329.                                 {
  330.                                         $wcur   = $tree['sub'][$cur][$j];
  331.                                         $wthis  = $tree['keys'][$wcur];
  332.                                         $wdata  = $tree['data'][$wthis];
  333.                                         $wname  = get_object_lang($wcur, 'name');
  334.                                         $wdesc  = get_object_lang($wcur, 'desc');
  335.                                         switch($tree['type'][$wthis])
  336.                                         {
  337.                                                 case POST_FORUM_URL:
  338.                                                         $wpgm = append_sid("./viewforum.$phpEx?" . POST_FORUM_URL . '=' . $tree['id'][$wthis]);
  339.                                                         break;
  340.                                                 case POST_CAT_URL:
  341.                                                         $wpgm = append_sid("./index.$phpEx?" . POST_CAT_URL . '=' . $tree['id'][$wthis]);
  342.                                                         break;
  343.                                                 default:
  344.                                                         $wpgm = append_sid("./index.$phpEx");
  345.                                                         break;
  346.                                         }
  347.                                         $link = '';
  348.                                         if ( $wname != '' )
  349.                                         {
  350.                                                 $style_color = ($tree['data'][$wthis]['forum_color']) ? ' style="color: #' . $tree['data'][$wthis]['forum_color'] . '"' : '';
  351.                                                 $link = '<a href="' . $wpgm . '" title="' . htmlspecialchars(strip_tags($wdesc)) . '" class="gensmall"' . $style_color . '>' . $wname . '</a>';
  352.                                         }
  353.  
  354.                                         if ( intval($board_config['sub_level_links']) == 2 )
  355.                                         {
  356.                                                 $wsub = (!empty($tree['sub'][$wcur]) && $tree['auth'][$wcur]['tree.auth_view']);
  357.  
  358.                                                 // specific to something attached
  359. //                                              if ( $wsub )
  360. //                                              {
  361.                                                         $wi_new         = $images['icon_minicat_new'];
  362.                                                         $wa_new         = $lang['New_posts'];
  363.                                                         $wi_norm        = $images['icon_minicat'];
  364.                                                         $wa_norm        = $lang['No_new_posts'];
  365.                                                         $wi_locked      = $images['icon_minicat_locked'];
  366.                                                         $wa_locked      = $lang['Forum_locked'];
  367. /*                                              }
  368.                                                 else
  369.                                                 {
  370.                                                         $wi_new         = $images['icon_minipost_new'];
  371.                                                         $wa_new         = $lang['New_posts'];
  372.                                                         $wi_norm        = $images['icon_minipost'];
  373.                                                         $wa_norm        = $lang['No_new_posts'];
  374.                                                         $wi_locked      = $images['icon_minipost_lock'];
  375.                                                         $wa_locked      = $lang['Forum_locked'];
  376.                                                 }
  377. */
  378.                                                 // forum link type
  379.                                                 if ( ($tree['type'][$wthis] == POST_FORUM_URL) && !empty($wdata['forum_link']) )
  380.                                                 {
  381.                                                         $wi_new         = $images['icon_minilink'];
  382.                                                         $wa_new         = $lang['Forum_link'];
  383.                                                         $wi_norm        = $images['icon_minilink'];
  384.                                                         $wa_norm        = $lang['Forum_link'];
  385.                                                         $wi_locked      = $images['icon_minilink'];
  386.                                                         $wa_locked      = $lang['Forum_link'];
  387.                                                 }
  388.  
  389.                                                 // front icon
  390.  
  391.                                                 $u_id = $tree['id'][$wthis];
  392.                                                 $wdata['tree.unread_topics'] = ($userdata['unread_data'][$u_id]) ? true : false;
  393.  
  394.                                                 $wfolder_image  = ( $wdata['tree.unread_topics'] ) ? $wi_new : $wi_norm;
  395.                                                 $wfolder_alt    = ( $wdata['tree.unread_topics'] ) ? $wa_new : $wa_norm;
  396.                                                 if ( $wdata['tree.locked'] )
  397.                                                 {
  398.                                                         $wfolder_image  = $wi_locked;
  399.                                                         $wfolder_alt    = $wa_locked;
  400.                                                 }
  401.                                                 $wlast_post = '<a href="' . append_sid("./viewtopic.$phpEx?" . POST_POST_URL . '=' . $wdata['tree.topic_last_post_id']) . '#' . $wdata['tree.topic_last_post_id'] . '">';
  402.                                                 $wlast_post .= '<img src="' . $wfolder_image . '" border="0" alt="' . $wfolder_alt . '" title="' . $wfolder_alt . '" align="middle" /></a>';
  403.                                         }
  404.                                         if ( $link != '' )
  405.                                         {
  406.                                                 $links .= (($links != '') ? ', ' : '') . $wlast_post . $link;
  407.                                         }
  408.                                 }
  409.                         }
  410.  
  411.                         if ( $userdata['session_logged_in'] && !$tree['type'][$wthis] && $board_config['ctop'] && $userdata['ctop'])
  412.                         {
  413.                                 $count_unread_posts = unread_forums_posts('count', $id);
  414.                                 $count_unread_topics = (is_array($userdata['unread_data'][$id])) ? count($userdata['unread_data'][$id]) : 0;
  415.  
  416.                                 $num_new_topics = ($count_unread_topics) ? '<br />' . $lang['unread_topicsss'] . ' <b>' . $count_unread_topics . '</b>' : '';
  417.                                 $num_new_posts = ($count_unread_posts) ? '<br />' . $lang['unread_postsss'] . ' <b>' . $count_unread_posts . '</b>' : '';
  418.                         }
  419.  
  420.                         // send to template
  421.                         $template->assign_block_vars('catrow', array());
  422.                         $template->assign_block_vars('catrow.forumrow', array(
  423.                                 'FORUM_ID' => $id,
  424. //                              'CAT_ID' => str_replace(POST_CAT_URL, '', $tree['main'][$athis]),
  425.                                 'FORUM_FOLDER_IMG' => $folder_image,
  426.                                 'FORUM_NAME' => replace_encoded($title),
  427.                                 'FORUM_DESC' => replace_encoded($desc),
  428.                                 'POSTS' => $data['tree.forum_posts'],
  429.                                 'TOPICS' => $data['tree.forum_topics'],
  430.                                 'LAST_POST'     => $last_post,
  431.                                 'LAST_POSTMSG'  => replace_encoded($last_postmsg),
  432.                         // ---------------------- modification
  433.                                 'LAST_POST_USER_AVATAR' => $Avat,
  434.                         // ------------------------------------
  435.                                 'MODERATORS' => $moderator_list,
  436.                                 'L_MODERATOR' => $l_moderators,
  437.                                 'MODERATORS' => $moderator_list,
  438.                                 'L_MODERATOR' => $l_moderators,
  439.                                 'L_FORUM_FOLDER_ALT' => $folder_alt,
  440.                                 'U_VIEWFORUM' => ($type == POST_FORUM_URL) ? append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$id") : append_sid("index.$phpEx?" . POST_CAT_URL . "=$id"),
  441.                                 'FORUM_COLOR' => ($tree['data'][$athis]['forum_color'] != '' && $tree['type'][$athis] != POST_CAT_URL) ? ' style="color: #' . $tree['data'][$athis]['forum_color'] . '"' : '',
  442.                                 'NUM_NEW_TOPICS' => $num_new_topics,
  443.                                 'NUM_NEW_POSTS' => $num_new_posts,
  444.                                 'INC_SPAN' => $max_level- $level+1,
  445.                                 'INC_CLASS'     => ( !($level % 2) ) ? 'row1' : 'row2')
  446.                         );
  447.  
  448.                         // add indentation to the display
  449.                         for($k=1; $k <= $level; $k++)
  450.                         {
  451.                                 $template->assign_block_vars('catrow.forumrow.inc', array(
  452.                                         'INC_CLASS' => ($k % 2) ? 'row1' : 'row2')
  453.                                 );
  454.                         }
  455.  
  456.                         // add the links row
  457.                         if ( !empty($links) )
  458.                         {
  459.                                 $template->assign_block_vars('catrow.forumrow.links', array(
  460.                                         'L_LINKS' => (empty($moderator_list) ? '' : '<br />'),
  461.                                         'LINKS' => $links)
  462.                                 );
  463.                         }
  464.  
  465.                         // forum link type
  466.                         if ( ($tree['type'][$athis] == POST_FORUM_URL) && !empty($tree['data'][$athis]['forum_link']) )
  467.                         {
  468.                                 $s_hit_count = '';
  469.                                 if ( $tree['data'][$athis]['forum_link_hit_count'] )
  470.                                 {
  471.                                         $s_hit_count = sprintf($lang['Forum_link_visited'], $tree['data'][$athis]['forum_link_hit']);
  472.                                 }
  473.                                 $template->assign_block_vars('catrow.forumrow.forum_link', array(
  474.                                         'HIT_COUNT' => $s_hit_count)
  475.                                 );
  476.                         }
  477.                         else
  478.                         {
  479.                                 $template->assign_block_vars('catrow.forumrow.forum_link_no', array());
  480.                         }
  481.                         // something displayed
  482.                         $display = true;
  483.                 }
  484.         }
  485.  
  486.         // display sub-levels
  487.         $ctsc = count($tree['sub'][$cur]);
  488.         for($i = 0; $i < $ctsc; $i++) if ( !empty($keys['keys'][$tree['sub'][$cur][$i]]) )
  489.         {
  490.                 $last = ($i == ($ctsc-1)) ? true : false;
  491.                 $wdisplay = build_index($tree['sub'][$cur][$i], $cat_break, $forum_moderators, $level+1, $max_level, $keys, $last);
  492.                 if ( $wdisplay )
  493.                 {
  494.                         $display = true;
  495.                 }
  496.         }
  497.  
  498.         if ( $level >=0 )
  499.         {
  500.                 // forum footer row
  501.                 if ( $tree['type'][$athis] == POST_FORUM_URL )
  502.                 {
  503.                 }
  504.         }
  505.  
  506.         if ( $level >= 0 )
  507.         {
  508.                 // cat footer
  509.                 if ( ($tree['type'][$athis] == POST_CAT_URL) && $pull_down )
  510.                 {
  511.                         $template->assign_block_vars('catrow', array());
  512.                         $template->assign_block_vars('catrow.catfoot', array(
  513.                                 'INC_SPAN' => $max_level - $level+5)
  514.                         );
  515.  
  516.                         // add indentation to the display
  517.                         for($k = 1; $k <= $level; $k++)
  518.                         {
  519.                                 $template->assign_block_vars('catrow.catfoot.inc', array(
  520.                                         'INC_SPAN' => $max_level - $level+5,
  521.                                         'INC_CLASS' => ($k % 2) ? 'row1' : 'row2')
  522.                                 );
  523.                         }
  524.                 }
  525.         }
  526.  
  527.         // root level footer
  528.         if ( ($board_config['split_cat'] && $cat_break && $real_level == 0) || ((!$board_config['split_cat'] || !$cat_break) && $real_level == -1) )
  529.         {
  530.                 $template->assign_block_vars('catrow', array());
  531.                 $template->assign_block_vars('catrow.tablefoot', array());
  532.                 if ( $cur != 'Root' )
  533.                 {
  534.                         $template->assign_block_vars('catrow.tablefoot.br_bottom', array(
  535.                                 'CAT_ID' => $cur,'CAT_TITLE' => get_object_lang($cur, 'name'),
  536.                                 'BR' => ($br) ? '' : '<br />',
  537.                         ));
  538.                 }
  539.         }
  540.  
  541.         return $display;
  542. }
  543.  
  544.  
  545. function display_index($cur='Root')
  546. {
  547.         global $board_config, $template, $userdata, $lang, $db, $nav_links, $phpEx;
  548.         global $images, $nav_separator, $nav_cat_desc;
  549.  
  550.         $template->set_filenames(array(
  551.                 'index' => 'index_box.tpl')
  552.         );
  553.  
  554.         $forum_moderators = array();
  555.  
  556.         $board_config['split_cat'] = (!$board_config['split_cat_over']) ? $userdata['user_split_cat'] : $board_config['split_cat'];
  557.  
  558.         // let's dump all of this on the template
  559.         $keys = array();
  560.         $display = build_index($cur, $board_config['split_cat'], $forum_moderators, -1, -1, $keys);
  561.  
  562.         // constants
  563.         $template->assign_vars(array(
  564.                 'L_FORUM' => $lang['Forum'],
  565.                 'L_TOPICS' => $lang['Topics'],
  566.                 'L_POSTS' => $lang['Posts'],
  567.                 'L_LASTPOST' => $lang['Last_Post'])
  568.         );
  569.         $template->assign_vars(array(
  570.                 'SPACER' => $images['spacer'],
  571.                 'NAV_SEPARATOR' => $nav_separator,
  572.                 'NAV_CAT_DESC' => $nav_cat_desc)
  573.         );
  574.         if ( $display )
  575.         {
  576.                 $template->assign_var_from_handle('BOARD_INDEX', 'index');
  577.         }
  578.         return $display;
  579. }
  580.  
  581. ?>