function get_max_depth($cat_id) { global $db; if ($cat_id < 0) { $cat_id = 0; } $local_depth = 0; $sql = "select * from " . CATEGORIES_TABLE . " where cat_main = {$cat_id}"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query categorie parm', '', __LINE__, __FILE__, $sql); } while ($row = $db->sql_fetchrow($result)) { $branch_depth = get_max_depth($row['cat_id']); if ($cat_id > 0) { $branch_depth++; } if ($branch_depth > $local_depth) { $local_depth = $branch_depth; } } return $local_depth; }
// 'TOPICS' => $forum_data[$j]['forum_topics'], // 'LAST_POST' => $last_post, // 'MODERATORS' => $moderator_list, // // 'L_MODERATOR' => $l_moderators, // 'L_FORUM_FOLDER_ALT' => $folder_alt, // // 'U_VIEWFORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id")) // ); // } // } // } // } // } // } // for ... categories $max_depth = !$sub_forum ? get_max_depth($viewcat) : 0; $template->assign_vars(array('INC_SPAN' => $max_depth + 2)); enhance_cat($viewcat); // display the index $found = false; for ($i = 0; $i < $total_categories && !$found; $i++) { if ($viewcat == -1 && $category_rows[$i]['cat_main'] == 0 || $viewcat > 0 && $category_rows[$i]['cat_id'] == $viewcat) { display_index_cat($category_rows[$i], $sub_forum, true); $found = $viewcat > 0; } } // End PNphpBB2 Categories Hierarchie Mod } else { message_die(GENERAL_MESSAGE, $lang['No_forums']); } //
function build_index($cur = 'Root', $cat_break = false, &$forum_moderators, $real_level = -1, $max_level = -1, &$keys) { global $template, $db, $cache, $config, $user, $lang, $images, $theme; global $tree, $bbcode, $lofi; if (empty($bbcode)) { include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT; } // init $display = false; // get the sub_forum switch value $sub_forum = intval($config['sub_forum']); if ($sub_forum == 2 && defined('IN_VIEWFORUM')) { $sub_forum = 1; } $pack_first_level = $sub_forum == 2; // verify the cat_break parm if ($cur != 'Root' && $real_level == -1) { $cat_break = false; } // display the level $CH_this = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1; // display each kind of row // root level head if ($real_level == -1) { // get max inc level $max = -1; if ($sub_forum == 2) { $max = 0; } if ($sub_forum == 1) { $max = 1; } $keys = array(); $keys = get_auth_keys($cur, false, -1, $max); $max_level = get_max_depth($cur, false, -1, $keys, $max); } // table header if ($config['split_cat'] && $cat_break && $real_level == 0 || (!$config['split_cat'] || !$cat_break) && $real_level == -1) { // if break, get the local max level if ($config['split_cat'] && $cat_break && $real_level == 0) { $max_level = 0; // the array is sorted $start = false; $stop = false; for ($i = 0; $i < sizeof($keys['id']) && !$stop; $i++) { if ($start && $tree['main'][$keys['idx'][$i]] == $tree['main'][$CH_this]) { $stop = true; $break; } if ($keys['id'][$i] == $cur) { $start = true; } if ($start && !$stop && $keys['level'][$i] > $max_level) { $max_level = $keys['level'][$i]; } } } $template->assign_block_vars('catrow', array('MAIN_CAT_ID' => $cur)); $template->assign_block_vars('catrow.tablehead', array('L_FORUM' => $CH_this < 0 ? $lang['Forum'] : get_object_lang($cur, 'name'), 'INC_SPAN' => $max_level + 2)); } // get the level $level = $keys['level'][$keys['keys'][$cur]]; // sub-forum view management $pull_down = true; if ($sub_forum > 0) { $pull_down = false; // JHL 2012/03/09 //if (($real_level == 0) && ($sub_forum == 1)) if ($real_level == 0 && ($sub_forum == 1 || $sub_forum == 3)) { $pull_down = true; } } if ($level >= 0) { // cat header row if ($tree['type'][$CH_this] == POST_CAT_URL && $pull_down) { // display a cat row $cat = $tree['data'][$CH_this]; $cat_id = $tree['id'][$CH_this]; // get the class colors $class_catLeft = 'cat'; $class_cat = 'cat'; $class_rowpic = 'rowpic'; // send to template $template->assign_block_vars('catrow', array('MAIN_CAT_ID' => $cur)); $template->assign_block_vars('catrow.cathead', array('CAT_TITLE' => get_object_lang($cur, 'name'), 'CAT_DESC' => preg_replace('/<[^>]+>/', '', get_object_lang($cur, 'desc')), 'CLASS_CATLEFT' => $class_catLeft, 'CLASS_CAT' => $class_cat, 'CLASS_ROWPIC' => $class_rowpic, 'INC_SPAN' => $max_level - $level + 2, 'U_VIEWCAT' => append_sid(CMS_PAGE_FORUM . '?' . POST_CAT_URL . '=' . $cat_id))); // add indentation to the display for ($k = 1; $k <= $level; $k++) { $template->assign_block_vars('catrow.cathead.inc', array('INC_CLASS' => $k % 2 ? $theme['td_class1'] : $theme['td_class2'])); } // something displayed $display = true; } } // forum header row if ($level >= 0) { if ($tree['type'][$CH_this] == POST_FORUM_URL || $tree['type'][$CH_this] == POST_CAT_URL && !$pull_down) { // get the data $data = $tree['data'][$CH_this]; $id = $tree['id'][$CH_this]; $type = $tree['type'][$CH_this]; $sub = !empty($tree['sub'][$cur]) && $tree['auth'][$cur]['tree.auth_view']; // specific to the data type $title = get_object_lang($cur, 'name'); $desc = get_object_lang($cur, 'desc'); // specific to something attached if ($sub) { $i_new = $images['forum_sub_unread']; $a_new = $lang['New_posts']; $i_norm = $images['forum_sub_read']; $a_norm = $lang['No_new_posts']; $i_locked = $images['forum_sub_locked_read']; $a_locked = $lang['Forum_locked']; } else { $i_new = $images['forum_nor_unread']; $a_new = $lang['New_posts']; $i_norm = $images['forum_nor_read']; $a_norm = $lang['No_new_posts']; $i_locked = $images['forum_nor_locked_read']; $a_locked = $lang['Forum_locked']; } // forum link type if ($tree['type'][$CH_this] == POST_FORUM_URL && !empty($tree['data'][$CH_this]['forum_link'])) { $i_new = $images['forum_link']; $a_new = $lang['Forum_link']; $i_norm = $images['forum_link']; $a_norm = $lang['Forum_link']; $i_locked = $images['forum_link']; $a_locked = $lang['Forum_link']; } // front icon $link_class = !empty($data['tree.unread_topics']) ? '-new' : ''; $folder_image = !empty($data['tree.unread_topics']) ? $i_new : $i_norm; $folder_alt = !empty($data['tree.unread_topics']) ? $a_new : $a_norm; if ($data['tree.locked']) { $folder_image = $i_locked; $folder_alt = $a_locked; } // moderators list $l_moderators = ''; $moderator_list = ''; if ($type == POST_FORUM_URL) { if (sizeof($forum_moderators[$id]) > 0) { $l_moderators = sizeof($forum_moderators[$id]) == 1 ? $lang['Moderator'] : $lang['Moderators']; $moderator_list = implode(', ', $forum_moderators[$id]); } } // last post $last_post = $lang['No_Posts']; if (isset($data['tree.forum_last_post_id']) && $data['tree.forum_last_post_id'] && (isset($data['tree.topic_last_post_auth']) && $data['tree.topic_last_post_auth'])) { $topic_title = htmlspecialchars_clean($data['tree.topic_title']); $topic_title_plain = $topic_title; $topic_title_short = $topic_title; // SMILEYS IN TITLE - BEGIN if ($config['smilies_topic_title'] && !$lofi) { $bbcode->allow_smilies = $config['allow_smilies'] ? true : false; $topic_title = $bbcode->parse_only_smilies($topic_title); } // SMILEYS IN TITLE - END $topic_title = empty($data['title_compl_infos']) ? $topic_title : $data['title_compl_infos'] . ' ' . $topic_title; if (strlen($topic_title) > intval($config['last_topic_title_length']) - 3) { // remove tags from the short version, in case a smiley or a quick title prefix is in there $topic_title_short = substr(strip_tags($topic_title), 0, intval($config['last_topic_title_length'])) . '...'; } $topic_title = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . (!empty($data['forum_id']) ? POST_FORUM_URL . '=' . $data['forum_id'] . '&' : '') . POST_POST_URL . '=' . $data['tree.forum_last_post_id']) . '#p' . $data['tree.forum_last_post_id'] . '" title="' . $topic_title_plain . '">' . $topic_title_short . '</a><br />'; $last_post_time = create_date_ip($config['default_dateformat'], $data['tree.post_time'], $config['board_timezone']); $last_post = $config['last_topic_title'] ? $topic_title : ''; $last_post .= $last_post_time . '<br />'; $last_post .= $data['tree.post_user_id'] == ANONYMOUS ? $data['tree.post_username'] . ' ' : colorize_username($data['tree.post_user_id'], $data['tree.post_username'], $data['tree.user_color'], $data['tree.user_active']); $last_post .= '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . (!empty($data['forum_id']) ? POST_FORUM_URL . '=' . $data['forum_id'] . '&' : '') . POST_POST_URL . '=' . $data['tree.forum_last_post_id']) . '#p' . $data['tree.forum_last_post_id'] . '" title="' . $topic_title_plain . '"><img src="' . ($data['tree.unread_topics'] ? $images['icon_newest_reply'] : $images['icon_latest_reply']) . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>'; } // links to sub-levels $links = ''; // JHL 2012/03/09 //if ($sub && (!$pull_down || (($type == POST_FORUM_URL) && ($sub_forum > 0))) && (intval($config['sub_level_links']) > 0)) if ($sub && (!$pull_down || $type == POST_FORUM_URL && $sub_forum > 0) && (intval($config['sub_level_links']) > 0 && $sub_forum != 3)) { for ($j = 0; $j < sizeof($tree['sub'][$cur]); $j++) { if ($tree['auth'][$tree['sub'][$cur][$j]]['auth_view']) { $wcur = $tree['sub'][$cur][$j]; $wthis = $tree['keys'][$wcur]; $wdata = $tree['data'][$wthis]; $wname = get_object_lang($wcur, 'name'); $wdesc = get_object_lang($wcur, 'desc'); switch ($tree['type'][$wthis]) { case POST_FORUM_URL: $wpgm = append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $tree['id'][$wthis]); break; case POST_CAT_URL: $wpgm = append_sid(CMS_PAGE_FORUM . '?' . POST_CAT_URL . '=' . $tree['id'][$wthis]); break; default: $wpgm = append_sid(CMS_PAGE_FORUM); break; } $link = ''; $wdesc = preg_replace('/<[^>]+>/', '', $wdesc); if (intval($config['sub_level_links']) == 2) { $wsub = !empty($tree['sub'][$wcur]) && $tree['auth'][$wcur]['tree.auth_view']; // specific to something attached if ($wsub) { $wi_new = $images['icon_minicat_new']; $wa_new = $lang['New_posts']; $wi_norm = $images['icon_minicat']; $wa_norm = $lang['No_new_posts']; $wi_locked = $images['icon_minicat_locked']; $wa_locked = $lang['Forum_locked']; } else { $wi_new = $images['icon_minipost_new']; $wa_new = $lang['New_posts']; $wi_norm = $images['icon_minipost']; $wa_norm = $lang['No_new_posts']; $wi_locked = $images['icon_minipost_lock']; $wa_locked = $lang['Forum_locked']; } // forum link type if ($tree['type'][$wthis] == POST_FORUM_URL && !empty($wdata['forum_link'])) { $wi_new = $images['icon_minilink']; $wa_new = $lang['Forum_link']; $wi_norm = $images['icon_minilink']; $wa_norm = $lang['Forum_link']; $wi_locked = $images['icon_minilink']; $wa_locked = $lang['Forum_link']; } // front icon $wfolder_image = $wdata['tree.unread_topics'] ? $wi_new : $wi_norm; $wfolder_alt = $wdata['tree.unread_topics'] ? $wa_new : $wa_norm; if ($wdata['tree.locked']) { $wfolder_image = $wi_locked; $wfolder_alt = $wa_locked; } if ($lofi == true) { $wlast_post = ''; } else { $wlast_post = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_POST_URL . '=' . $wdata['tree.forum_last_post_id']) . '#p' . $wdata['tree.forum_last_post_id'] . '">'; $wlast_post .= '<img src="' . $wfolder_image . '" alt="' . $wfolder_alt . '" title="' . $wfolder_alt . '" /></a> '; } } $class = $wfolder_image == $wi_new ? 'forumlink2-new' : 'forumlink2'; if ($wname != '') { $link = '<a href="' . $wpgm . '" title="' . $wdesc . '" class="' . $class . '">' . $wname . '</a>'; } if ($link != '') { $links .= ($links != '' ? ', ' : '') . $wlast_post . $link; } } } } // forum icon $icon_img = empty($data['icon']) ? '' : (isset($images[$data['icon']]) ? $images[$data['icon']] : $data['icon']); // UPI2DB - BEGIN if ($user->data['upi2db_access']) { $folder_image_ar_big = $images['forum_nor_ar']; $cat_image_ar_big = $images['forum_sub_ar']; $forum_id = $data['forum_id']; if (!$data['tree.unread_topics'] && !$sub) { if (is_array($user->data['upi2db_unread']['always_read']['forums']) && !in_array($forum_id, $user->data['upi2db_unread']['always_read']['forums'])) { $mark_always_read = '<a href="' . append_sid(CMS_PAGE_FORUM . '?forum_id=' . $forum_id . '&always_read=set') . '"><img src="' . $folder_image . '" alt="' . $lang['upi2db_always_read_forum'] . '" title="' . $lang['upi2db_always_read_forum'] . '" /></a>'; } else { $mark_always_read = '<a href="' . append_sid(CMS_PAGE_FORUM . '?forum_id=' . $forum_id . '&always_read=unset') . '"><img src="' . $folder_image_ar_big . '" alt="' . $lang['upi2db_always_read_forum_unset'] . '" title="' . $lang['upi2db_always_read_forum_unset'] . '" /></a>'; } } else { if ($sub) { $mark_always_read = '<img src="' . $folder_image . '" alt="' . $lang['upi2db_cat_cant_mark_always_read'] . '" title="' . $lang['upi2db_cat_cant_mark_always_read'] . '" />'; } else { $mark_always_read = '<img src="' . $folder_image . '" alt="' . $folder_alt . '" title="' . $folder_alt . '" />'; } } } else { $mark_always_read = '<img src="' . $folder_image . '" alt="' . $folder_alt . '" title="' . $folder_alt . '" />'; } // UPI2DB - END if ($config['url_rw'] == true || $config['url_rw_guests'] == true && $user->data['user_id'] == ANONYMOUS) { $url_viewforum = $type == POST_FORUM_URL ? append_sid(str_replace('--', '-', make_url_friendly($title) . '-vf' . $id . '.html')) : append_sid(str_replace('--', '-', make_url_friendly($title) . '-vc' . $id . '.html')); } else { $url_viewforum = $type == POST_FORUM_URL ? append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $id) : append_sid(CMS_PAGE_FORUM . '?' . POST_CAT_URL . '=' . $id); } // send to template if ($config['show_rss_forum_icon'] && $data['forum_index_icons'] == 1 && $type == POST_FORUM_URL) { $rss_feed_icon = ''; if (!$data['tree.locked'] && $user->data['session_logged_in']) { $rss_feed_icon .= ' <a href="' . append_sid(CMS_PAGE_POSTING . '?mode=newtopic&' . POST_FORUM_URL . '=' . $id) . '"><img src="' . $images['vf_topic_nor'] . '" alt="' . $lang['Post_new_topic'] . '" title="' . $lang['Post_new_topic'] . '" /></a>'; } $rss_feed_icon .= ' <a href="' . append_sid('rss.' . PHP_EXT . '?' . POST_FORUM_URL . '=' . $id) . '"><img src="' . $images['nav_menu_feed'] . '" alt="' . $lang['Rss_news_feeds'] . '" title="' . $lang['Rss_news_feeds'] . '" /></a>'; } else { $rss_feed_icon = ' '; } $template->assign_block_vars('catrow', array()); $template->assign_block_vars('catrow.forumrow', array('FORUM_FOLDER_IMG' => $folder_image, 'ICON_IMG' => $icon_img, 'RSS_FEED_ICON' => $rss_feed_icon, 'FORUM_NAME' => $title, 'FORUM_DESC' => $desc, 'FORUM_TYPE' => $type == POST_FORUM_URL ? 'forum' : 'category', 'POSTS' => $data['tree.forum_posts'], 'TOPICS' => $data['tree.forum_topics'], 'ONLINE' => $config['show_forums_online_users'] == true ? '<br />' . $lang['Online'] . ': ' . $data['tree.forum_online'] : '', 'LAST_POST' => $last_post, 'MODERATORS' => $moderator_list, 'L_MODERATOR' => empty($moderator_list) ? '' : (empty($l_moderators) ? '<br />' : '<br /><b>' . $l_moderators . ':</b> '), 'L_LINKS' => empty($links) ? '' : (empty($lang['Subforums']) ? '' : '<b>' . $lang['Subforums'] . ':</b> '), 'LINKS_BR' => empty($links) ? '' : '<br />', 'LINKS_ROWSPAN' => empty($links) ? '' : ' rowspan="2"', 'LINKS' => $links, 'L_FORUM_FOLDER_ALT' => $folder_alt, 'U_MARK_ALWAYS_READ' => $mark_always_read, 'L_POST_NEW_TOPIC' => $lang['Post_new_topic'], 'U_VIEWFORUM' => $url_viewforum, 'U_POST_NEW_TOPIC' => append_sid(CMS_PAGE_POSTING . '?mode=newtopic&' . POST_FORUM_URL . '=' . $id), 'LINK_CLASS' => $link_class, 'INC_SPAN' => $max_level - $level + 1, 'INC_CLASS' => !($level % 2) ? $theme['td_class1'] : $theme['td_class2'])); // display icon if (!empty($icon_img)) { $template->assign_block_vars('catrow.forumrow.forum_icon', array()); } // add indentation to the display for ($k = 1; $k <= $level; $k++) { $template->assign_block_vars('catrow.forumrow.inc', array('INC_CLASS' => $k % 2 ? $theme['td_class1'] : $theme['td_class2'])); } // forum link type if ($tree['type'][$CH_this] == POST_FORUM_URL && !empty($tree['data'][$CH_this]['forum_link'])) { $s_hit_count = ''; if ($tree['data'][$CH_this]['forum_link_hit_count']) { $s_hit_count = sprintf($lang['Forum_link_visited'], $tree['data'][$CH_this]['forum_link_hit']); } $template->assign_block_vars('catrow.forumrow.forum_link', array('HIT_COUNT' => $s_hit_count)); } else { $template->assign_block_vars('catrow.forumrow.forum_link_no', array()); } // something displayed $display = true; } } // display sub-levels if (!empty($tree['sub'][$cur])) { for ($i = 0; $i < sizeof($tree['sub'][$cur]); $i++) { if (!empty($keys['keys'][$tree['sub'][$cur][$i]])) { $wdisplay = build_index($tree['sub'][$cur][$i], $cat_break, $forum_moderators, $level + 1, $max_level, $keys); if ($wdisplay) { $display = true; } } } } if ($level >= 0) { // forum footer row if ($tree['type'][$CH_this] == POST_FORUM_URL) { } } if ($level >= 0) { // cat footer if ($tree['type'][$CH_this] == POST_CAT_URL && $pull_down) { $template->assign_block_vars('catrow', array()); $template->assign_block_vars('catrow.catfoot', array('INC_SPAN' => $max_level - $level + 5)); // add indentation to the display for ($k = 1; $k <= $level; $k++) { $template->assign_block_vars('catrow.catfoot.inc', array('INC_SPAN' => $max_level - $level + 5, 'INC_CLASS' => $k % 2 ? $theme['td_class1'] : $theme['td_class2'])); } } } // root level footer if ($config['split_cat'] && $cat_break && $real_level == 0 || (!$config['split_cat'] || !$cat_break) && $real_level == -1) { $template->assign_block_vars('catrow', array()); $template->assign_block_vars('catrow.tablefoot', array()); } return $display; }
function build_index($cur = 'Root', $cat_break = false, &$forum_moderators, $real_level = -1, $max_level = -1, &$keys) { global $template, $phpEx, $board_config, $lang, $images; global $tree; // // init // $display = false; // get the sub_forum switch value $sub_forum = intval($board_config['sub_forum']); if ($sub_forum == 2 && defined('IN_VIEWFORUM')) { $sub_forum = 1; } $pack_first_level = $sub_forum == 2; // verify the cat_break parm if ($cur != 'Root' && $real_level == -1) { $cat_break = false; } // display the level $this_key = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1; // // display each kind of row // // root level head if ($real_level == -1) { // get max inc level $max = -1; if ($sub_forum == 2) { $max = 0; } if ($sub_forum == 1) { $max = 1; } $keys = array(); $keys = get_auth_keys($cur, false, -1, $max); $max_level = get_max_depth($cur, false, -1, $keys, $max); } // table header if ($board_config['split_cat'] && $cat_break && $real_level == 0 || (!$board_config['split_cat'] || !$cat_break) && $real_level == -1) { // if break, get the local max level if ($board_config['split_cat'] && $cat_break && $real_level == 0) { $max_level = 0; // the array is sorted $start = false; $stop = false; for ($i = 0; $i < count($keys['id']) && !$stop; $i++) { if ($start && $tree['main'][$keys['idx'][$i]] == $tree['main'][$this_key]) { $stop = true; $break; } if ($keys['id'][$i] == $cur) { $start = true; } if ($start && !$stop && $keys['level'][$i] > $max_level) { $max_level = $keys['level'][$i]; } } } $template->assign_block_vars('catrow', array()); $template->assign_block_vars('catrow.tablehead', array('L_FORUM' => $this_key < 0 ? $lang['Forum'] : get_object_lang($cur, 'name'), 'INC_SPAN' => $max_level + 2)); } // get the level $level = $keys['level'][$keys['keys'][$cur]]; // sub-forum view management $pull_down = true; if ($sub_forum > 0) { $pull_down = false; if ($real_level == 0 && $sub_forum == 1) { $pull_down = true; } } if ($level >= 0) { // cat header row if ($tree['type'][$this_key] == POST_CAT_URL && $pull_down) { // display a cat row $cat = $tree['data'][$this_key]; $cat_id = $tree['id'][$this_key]; // get the class colors $class_catLeft = "catLeft"; $class_cat = "cat"; $class_rowpic = "rowpic"; // send to template $template->assign_block_vars('catrow', array()); $template->assign_block_vars('catrow.cathead', array('CAT_TITLE' => get_object_lang($cur, 'name'), 'CAT_DESC' => ereg_replace('<[^>]+>', '', get_object_lang($cur, 'desc')), 'CLASS_CATLEFT' => $class_catLeft, 'CLASS_CAT' => $class_cat, 'CLASS_ROWPIC' => $class_rowpic, 'INC_SPAN' => $max_level - $level + 2, 'U_VIEWCAT' => append_sid("forum.{$phpEx}?" . POST_CAT_URL . "={$cat_id}"))); // add indentation to the display for ($k = 1; $k <= $level; $k++) { $template->assign_block_vars('catrow.cathead.inc', array('INC_CLASS' => $k % 2 ? 'row1' : 'row2')); } // something displayed $display = true; } } // forum header row if ($level >= 0) { if ($tree['type'][$this_key] == POST_FORUM_URL || $tree['type'][$this_key] == POST_CAT_URL && !$pull_down) { // get the data $data = $tree['data'][$this_key]; $id = $tree['id'][$this_key]; $type = $tree['type'][$this_key]; $sub = !empty($tree['sub'][$cur]) && $tree['auth'][$cur]['tree.auth_view']; // specific to the data type $title = get_object_lang($cur, 'name'); $desc = get_object_lang($cur, 'desc'); // specific to something attached if ($sub) { $i_new = $images['category_new']; $a_new = $lang['New_posts']; $i_norm = $images['category']; $a_norm = $lang['No_new_posts']; $i_locked = $images['category_locked']; $a_locked = $lang['Forum_locked']; } else { $i_new = $images['forum_new']; $a_new = $lang['New_posts']; $i_norm = $images['forum']; $a_norm = $lang['No_new_posts']; $i_locked = $images['forum_locked']; $a_locked = $lang['Forum_locked']; } // forum link type if ($tree['type'][$this_key] == POST_FORUM_URL && !empty($tree['data'][$this_key]['forum_link'])) { $i_new = $images['link']; $a_new = $lang['Forum_link']; $i_norm = $images['link']; $a_norm = $lang['Forum_link']; $i_locked = $images['link']; $a_locked = $lang['Forum_link']; } // front icon $folder_image = $data['tree.unread_topics'] ? $i_new : $i_norm; $folder_alt = $data['tree.unread_topics'] ? $a_new : $a_norm; if ($data['tree.locked']) { $folder_image = $i_locked; $folder_alt = $a_locked; } // moderators list $l_moderators = ''; $moderator_list = ''; if ($type == POST_FORUM_URL) { if (count($forum_moderators[$id]) > 0) { $l_moderators = count($forum_moderators[$id]) == 1 ? $lang['Moderator'] : $lang['Moderators']; $moderator_list = implode(', ', $forum_moderators[$id]); } } // last post $last_post = $lang['No_Posts']; if ($data['tree.topic_last_post_id']) { // resize $topic_title = $data['tree.topic_title']; if (strlen($topic_title) > intval($board_config['last_topic_title_length']) - 3) { $topic_title = substr($topic_title, 0, intval($board_config['last_topic_title_length'])) . '...'; } $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'] . '">' . $topic_title . '</a><br />'; $last_post_time = create_date($board_config['default_dateformat'], $data['tree.post_time'], $board_config['board_timezone']); $last_post = $board_config['last_topic_title'] ? $topic_title : ''; $last_post .= $last_post_time . '<br />'; $last_post .= $data['tree.post_user_id'] == ANONYMOUS ? $data['tree.post_username'] . ' ' : '<a href="' . append_sid("profile.{$phpEx}?mode=viewprofile&" . POST_USERS_URL . '=' . $data['tree.post_user_id']) . '">' . $data['tree.post_username'] . '</a> '; $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['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>'; } // links to sub-levels $links = ''; if ($sub && (!$pull_down || $type == POST_FORUM_URL && $sub_forum > 0) && intval($board_config['sub_level_links']) > 0) { for ($j = 0; $j < count($tree['sub'][$cur]); $j++) { if ($tree['auth'][$tree['sub'][$cur][$j]]['auth_view']) { $wcur = $tree['sub'][$cur][$j]; $wthis = $tree['keys'][$wcur]; $wdata = $tree['data'][$wthis]; $wname = get_object_lang($wcur, 'name'); $wdesc = get_object_lang($wcur, 'desc'); switch ($tree['type'][$wthis]) { case POST_FORUM_URL: $wpgm = append_sid("./viewforum.{$phpEx}?" . POST_FORUM_URL . '=' . $tree['id'][$wthis]); break; case POST_CAT_URL: $wpgm = append_sid("./forum.{$phpEx}?" . POST_CAT_URL . '=' . $tree['id'][$wthis]); break; default: $wpgm = append_sid("./index.{$phpEx}"); break; } $link = ''; $wdesc = ereg_replace('<[^>]+>', '', $wdesc); if ($wname != '') { $link = '<a href="' . $wpgm . '" title="' . $wdesc . '" class="gensmall">' . $wname . '</a>'; } if (intval($board_config['sub_level_links']) == 2) { $wsub = !empty($tree['sub'][$wcur]) && $tree['auth'][$wcur]['tree.auth_view']; // specific to something attached if ($wsub) { $wi_new = $images['icon_minicat_new']; $wa_new = $lang['New_posts']; $wi_norm = $images['icon_minicat']; $wa_norm = $lang['No_new_posts']; $wi_locked = $images['icon_minicat_locked']; $wa_locked = $lang['Forum_locked']; } else { $wi_new = $images['icon_minipost_new']; $wa_new = $lang['icon_minipost']; $wi_norm = $images['icon_minipost']; $wa_norm = $lang['No_new_posts']; $wi_locked = $images['icon_minipost_lock']; $wa_locked = $lang['Forum_locked']; } // forum link type if ($tree['type'][$wthis] == POST_FORUM_URL && !empty($wdata['forum_link'])) { $wi_new = $images['icon_minilink']; $wa_new = $lang['Forum_link']; $wi_norm = $images['icon_minilink']; $wa_norm = $lang['Forum_link']; $wi_locked = $images['icon_minilink']; $wa_locked = $lang['Forum_link']; } // front icon $wfolder_image = $wdata['tree.unread_topics'] ? $wi_new : $wi_norm; $wfolder_alt = $wdata['tree.unread_topics'] ? $wa_new : $wa_norm; if ($wdata['tree.locked']) { $wfolder_image = $wi_locked; $wfolder_alt = $wa_locked; } $wlast_post = '<span style="white-space: nowrap;">'; if ($tree['type'][$wthis] == POST_FORUM_URL && (!empty($wdata['forum_link']) or empty($wdata['tree.topic_last_post_id']))) { $wlast_post .= '<a href="' . append_sid("./viewforum.{$phpEx}?" . POST_FORUM_URL . '=' . $wdata['forum_id']) . '">'; } else { if ($tree['type'][$wthis] == POST_CAT_URL && empty($wdata['tree.topic_last_post_id'])) { $wlast_post .= '<a href="' . append_sid("index.{$phpEx}?" . POST_CAT_URL . '=' . $wdata['cat_id']) . '">'; } else { $wlast_post .= '<a href="' . append_sid("./viewtopic.{$phpEx}?" . POST_POST_URL . '=' . $wdata['tree.topic_last_post_id']) . '#' . $wdata['tree.topic_last_post_id'] . '">'; } } $wlast_post .= '<img src="' . $wfolder_image . '" border="0" alt="' . $wfolder_alt . '" title="' . $wfolder_alt . '" /></a>'; } if ($link != '') { $links .= ($links != '' ? ',</span> ' : '') . $wlast_post . $link; } } } if ($links != '') { $links .= '</span>'; } } // forum icon $icon_img = empty($data['icon']) ? '' : (isset($images[$data['icon']]) ? $images[$data['icon']] : $data['icon']); // send to template $template->assign_block_vars('catrow', array()); $template->assign_block_vars('catrow.forumrow', array('FORUM_FOLDER_IMG' => $folder_image, 'ICON_IMG' => $icon_img, 'FORUM_NAME' => $title, 'FORUM_DESC' => $desc, 'POSTS' => $data['tree.forum_posts'], 'TOPICS' => $data['tree.forum_topics'], 'LAST_POST' => $last_post, 'MODERATORS' => $moderator_list, 'L_MODERATOR' => empty($moderator_list) ? '' : (empty($l_moderators) ? '<br />' : '<br /><b>' . $l_moderators . ':</b> '), 'L_LINKS' => empty($links) ? '' : (empty($lang['Subforums']) ? '<br />' : '<br /><b>' . $lang['Subforums'] . ':</b> '), 'LINKS' => $links, 'L_FORUM_FOLDER_ALT' => $folder_alt, 'U_VIEWFORUM' => $type == POST_FORUM_URL ? append_sid("viewforum.{$phpEx}?" . POST_FORUM_URL . "={$id}") : append_sid("forum.{$phpEx}?" . POST_CAT_URL . "={$id}"), 'U_TARGET' => $tree['type'][$this] == POST_FORUM_URL && !empty($tree['data'][$this]['forum_link']) && !$tree['data'][$this]['forum_link_internal'] ? 'target="_blank"' : '', 'INC_SPAN' => $max_level - $level + 1, 'INC_CLASS' => !($level % 2) ? 'row1' : 'row2')); // display icon if (!empty($icon_img)) { $template->assign_block_vars('catrow.forumrow.forum_icon', array()); } // add indentation to the display for ($k = 1; $k <= $level; $k++) { $template->assign_block_vars('catrow.forumrow.inc', array('INC_CLASS' => $k % 2 ? 'row1' : 'row2')); } // forum link type if ($tree['type'][$this_key] == POST_FORUM_URL && !empty($tree['data'][$this_key]['forum_link'])) { $s_hit_count = ''; if ($tree['data'][$this_key]['forum_link_hit_count']) { $s_hit_count = sprintf($lang['Forum_link_visited'], $tree['data'][$this_key]['forum_link_hit']); } $template->assign_block_vars('catrow.forumrow.forum_link', array('HIT_COUNT' => $s_hit_count)); } else { $template->assign_block_vars('catrow.forumrow.forum_link_no', array()); } // something displayed $display = true; } } // display sub-levels for ($i = 0; $i < count($tree['sub'][$cur]); $i++) { if (!empty($keys['keys'][$tree['sub'][$cur][$i]])) { $wdisplay = build_index($tree['sub'][$cur][$i], $cat_break, $forum_moderators, $level + 1, $max_level, $keys); if ($wdisplay) { $display = true; } } } if ($level >= 0) { // forum footer row if ($tree['type'][$this_key] == POST_FORUM_URL) { } } if ($level >= 0) { // cat footer if ($tree['type'][$this_key] == POST_CAT_URL && $pull_down) { $template->assign_block_vars('catrow', array()); $template->assign_block_vars('catrow.catfoot', array('INC_SPAN' => $max_level - $level + 5)); // add indentation to the display for ($k = 1; $k <= $level; $k++) { $template->assign_block_vars('catrow.catfoot.inc', array('INC_SPAN' => $max_level - $level + 5, 'INC_CLASS' => $k % 2 ? 'row1' : 'row2')); } } } // root level footer if ($board_config['split_cat'] && $cat_break && $real_level == 0 || (!$board_config['split_cat'] || !$cat_break) && $real_level == -1) { $template->assign_block_vars('catrow', array()); $template->assign_block_vars('catrow.tablefoot', array()); } return $display; }