private static function prepareBreadCrumb($Menu) { WoW_Forums::InitForums(); $forum_categories = WoW_Forums::GetForumCategories(); if (is_array($forum_categories)) { $tmp_cat = 0; foreach ($forum_categories as $category) { $info = $category['category_info']; $forums_output[$tmp_cat] = array('label' => $info['title'], 'url' => '/forum/#forum' . $info['cat_id']); $subcats = $category['subcategories']; if (is_array($subcats)) { $tmp_subcat = 0; foreach ($subcats as $subcat) { $subcats_output[$tmp_subcat] = array('label' => $subcat['title'], 'url' => '/forum/' . $subcat['cat_id'] . '/'); $tmp_subcat++; } $forums_output[$tmp_cat]['children'] = $subcats_output; } $tmp_cat++; } } $Menu['children'][3]['children'] = $forums_output; return $Menu; }
public function main() { WoW_Template::SetTemplateTheme('wow'); WoW_Template::SetPageData('body_class', WoW_Locale::GetLocale(LOCALE_DOUBLE)); WoW_Template::SetMenuIndex('menu-forums'); $url_data = WoW::GetUrlData('forum'); $page = isset($_GET['page']) && preg_match('/([0-9]+)/i', $_GET['page']) ? $_GET['page'] : 1; WoW_Template::SetPageData('current_page', $page); // Clear category/thread values WoW_Forums::SetCategoryId(0); WoW_Forums::SetThreadId(0); // Check preview if (isset($url_data['action4'], $url_data['action5'], $url_data['action6']) && $url_data['action4'] . $url_data['action5'] . $url_data['action6'] == 'topicpostpreview') { $post_text = isset($_POST['post']) ? $_POST['post'] : null; if ($post_text == null) { //This can not be here, it causes error when preview blank post text //WoW_Template::ErrorPage(500); } // Convert BB codes to HTML WoW_Forums::BBCodesToHTML($post_text); // Output json header('Content-type: text/json'); echo '{"detail":"' . $post_text . '"}'; exit; } // Set values (if any) if ($url_data['category_id'] > 0) { if (!WoW_Forums::SetCategoryId($url_data['category_id'])) { WoW_Template::ErrorPage(404); exit; } if (isset($url_data['action5']) && $url_data['action5'] == 'topic' && WoW_Account::IsHaveActiveCharacter()) { // Check $_POST query if (isset($_POST['xstoken'])) { $post_allowed = true; $required_post_fields = array('xstoken', 'sessionPersist', 'subject', 'postCommand_detail'); foreach ($required_post_fields as $field) { if (!isset($_POST[$field])) { $post_allowed = false; } } if ($post_allowed) { $post_info = WoW_Forums::AddNewThread($url_data['category_id'], $_POST, false); if (is_array($post_info)) { header('Location: ' . WoW::GetWoWPath() . '/wow/' . WoW_Locale::GetLocale() . '/forum/topic/' . $post_info['thread_id']); exit; } } } // Topic create WoW_Template::SetPageIndex('forum_new_topic'); WoW_Template::SetPageData('page', 'forum_new_topic'); } else { WoW_Template::SetPageIndex('forum_category'); WoW_Template::SetPageData('page', 'forum_category'); } } elseif ($url_data['thread_id'] > 0) { if (!WoW_Forums::SetThreadId($url_data['thread_id'])) { WoW_Template::ErrorPage(404); exit; } if (isset($url_data['action4']) && $url_data['action4'] == 'topic' && preg_match('/([0-9]+)/i', $url_data['action5']) && WoW_Account::IsHaveActiveCharacter()) { // Check $_POST query if (isset($_POST['xstoken'])) { $post_allowed = true; $required_post_fields = array('xstoken', 'sessionPersist', 'detail'); foreach ($required_post_fields as $field) { if (!isset($_POST[$field])) { $post_allowed = false; } } if ($post_allowed) { $post_info = WoW_Forums::AddNewPost(null, $url_data['thread_id'], $_POST); if (is_array($post_info)) { header('Location: ' . WoW::GetWoWPath() . '/wow/' . WoW_Locale::GetLocale() . '/forum/topic/' . $url_data['thread_id']); exit; } } } } WoW_Template::SetPageIndex('forum_thread'); WoW_Template::SetPageData('page', 'forum_thread'); } elseif (isset($url_data['action4']) && $url_data['action4'] == 'topic' && isset($url_data['action5']) && $url_data['action5'] == 'post' && isset($url_data['action6']) && preg_match('/([0-9]+)/i', $url_data['action6'])) { if (isset($url_data['action7']) && WoW_Account::IsHaveActiveCharacter()) { switch ($url_data['action7']) { case 'frag': $Quote = WoW_Forums::QuotePost($url_data['action6']); header('Content-type: text/json'); echo '{"detail":"' . $Quote['message'] . '","name":"' . $Quote['name'] . '"}'; exit; break; case 'edit': if (isset($_POST['xstoken'])) { $post_allowed = true; $required_post_fields = array('xstoken', 'sessionPersist', 'postCommand_detail'); foreach ($required_post_fields as $field) { if (!isset($_POST[$field])) { $post_allowed = false; } } if ($post_allowed) { $thread_id = WoW_Forums::EditPost($url_data['action6'], $_POST); if ($thread_id) { header('Location: ' . WoW::GetWoWPath() . '/wow/' . WoW_Locale::GetLocale() . '/forum/topic/' . $thread_id); exit; } } } if ($post = WoW_Forums::GetPost($url_data['action6'])) { if (!WoW_Forums::SetThreadId($post['thread_id'])) { WoW_Template::ErrorPage(404); exit; } WoW_Template::SetPageData('edit_text', $post['message']); WoW_Template::SetPageIndex('forum_edit_post'); WoW_Template::SetPageData('page', 'forum_edit_post'); } break; } } } elseif ($url_data['action4'] == 'blizztracker') { // Set Blizz tracker as active WoW_Forums::SetBlizzTrackerActive(); // Init Blizz tracker! WoW_Forums::InitBlizzTracker(false, $page); WoW_Template::SetPageIndex('forum_blizztracker'); WoW_Template::SetPageData('page', 'forum_blizztracker'); } else { // Init Blizz tracker! WoW_Forums::InitBlizzTracker(true); WoW_Template::SetPageIndex('forum_index'); WoW_Template::SetPageData('page', 'forum_index'); WoW_Template::SetPageData('body_class', WoW_Locale::GetLocale(LOCALE_DOUBLE) . ' station-home'); } // Init the forums! WoW_Forums::InitForums($page); WoW_Template::SetPageData('forum_category_title', WoW_Forums::GetCategoryTitle()); WoW_Template::SetPageData('forum_thread_title', WoW_Forums::GetThreadTitle()); WoW_Template::LoadTemplate('page_index'); }
<div> <div class="sidebar-title"> <h3 class="title-forums"> <a href="<?php echo WoW::GetWoWPath(); ?> /wow/forum/"><?php echo WoW_Locale::GetString('template_menu_forums'); ?> </a> </h3> </div> <div class="sidebar-content poptopic-list"> <?php $popular = WoW_Forums::GetPopularThreads(); if (is_array($popular)) { foreach ($popular as $thread) { echo sprintf('<a href="%s/wow/forum/topic/%d"> <span class="int"> <span class="title"> %s </span> <span class="desc"> %s <span class="loc">%s</span> </span> </span> </a>', WoW::GetWoWPath(), $thread['thread_id'], $thread['title'], WoW_Locale::GetString('template_forums_in'), $thread['categoryTitle']); } } ?>
} ?> </div> </div> </div> <div class="bt-mask-l"></div> <div class="bt-mask-r"></div> </div> </div> <div id="station-content"> <div class="station-content-wrapper"> <div class="station-inner-wrapper"> <div id="forum-list"> <div id="forum-list-interior"> <?php $forum_categories = WoW_Forums::GetForumCategories(); if (is_array($forum_categories)) { foreach ($forum_categories as $category) { $info = $category['category_info']; $subcats = $category['subcategories']; echo sprintf('<a id="forum%d" href="javascript:;" onclick="Cms.Station.parentToggle(\'%d\',this)" class="forum-parent">%s</a>', $info['cat_id'], $info['cat_id'], $info['title']); if (is_array($subcats)) { $realms_filter = '<div class="filter-options"> <a href="javascript:;" class="selected" onclick="Cms.Station.toggleFilter(this)">%s</a> <a href="javascript:;" onclick="Cms.Station.toggleFilter(this,true)">%s</a> </div>'; echo sprintf('<div class="child-forums%s%s" id="child%d">', $info['realm_cat'] == 1 ? ' filtered-parent' : null, $info['short'] == 1 ? ' non-verbose' : null, $info['cat_id']); if ($info['realm_cat'] == 1) { echo sprintf('<div class="child-filter"> <div class="forum-filter png-fix"> <img width="27" src="%s/wow/static/images/icons/mag-glass.png" />
?> </div> </div> <div id="posts-container"> <table id="posts" cellspacing="0" class="simple"> <thead> <tr class="post-th"> <td></td> <td colspan="2">Subject</td> <td>Author</td> </tr> </thead> <tbody class="bluetracker-body"> <?php $blizz_posts = WoW_Forums::GetLoadedBlizzPosts(WoW_Template::GetPageData('current_page')); if (is_array($blizz_posts)) { foreach ($blizz_posts as $post) { if ($post['post_days'] > 0) { $before_text = sprintf(WoW_Locale::getString('template_blizztracker_posted_before_days'), $post['post_days'], $post['post_hours']); } elseif ($post['post_days'] == 0 && $post['post_hours'] > 0) { $before_text = sprintf(WoW_Locale::getString('template_blizztracker_posted_before_hours'), $post['post_hours'], $post['post_minutes']); } elseif ($post['post_hours'] == 0) { $before_text = sprintf(WoW_Locale::getString('template_blizztracker_posted_before_minutes'), $post['post_minutes']); } echo sprintf('<tr id="postRow%d" class="blizzard"> <td class="post-icon"> <div class="forum-post-icon"> <div class="blizzard_icon"><a href="../topic/%d#%d" data-tooltip="%s"></a></div> </div> </td>
<div class="actions-panel"> <?php echo WoW_Paginator::Initialize(WoW_Template::GetPageData('current_page'), WoW_Forums::GetTotalThreadPosts(), 20, 'forum'); echo WoW_Template::NavigationMenu(); ?> <span class="clear"><!-- --></span> </div> </div> <div class="talkback"><a id="new-post"></a> <form method="post" onsubmit="return Cms.Topic.postValidate(this);" action="#new-post"> <div> <input type="hidden" name="xstoken" value="fbc9d52f-99bf-4639-b2b5-7a535e7f31fe"/> <input type="hidden" name="sessionPersist" value="forum.topic.post"/> <div class="post "> <?php if (WoW_Forums::IsClosedThread()) { echo sprintf('<table class="dynamic-center "><tr><td>%s</td></tr></table>', WoW_Locale::GetString('template_forum_topic_closed')); } elseif (!WoW_Account::IsLoggedIn()) { echo sprintf('<table class="dynamic-center "><tr><td><a class="ui-button button1 " href="?login" onclick="return Login.open(\'%s/login/login.frag\')"><span><span>%s</span></span></a></td></tr></table>', WoW::GetWoWPath(), WoW_Locale::GetString('template_forum_add_reply')); } elseif (WoW_Account::IsHaveActiveCharacter()) { WoW_Template::LoadTemplate('content_forum_new_post'); } else { echo sprintf('<table class="dynamic-center "><tr><td><div class="noCharacter"><p>%s</p></div></td></tr></table>', WoW_Locale::GetString('template_forum_need_char_to_post')); } ?> </div> </div> </form> <span class="clear"><!-- --></span> <div class="talkback-code">
public static function SetThreadId($thread_id) { if ($thread_id < 0) { WoW_Log::WriteError('%s : wrong thread ID (%d), unable to handle.', __METHOD__, $thread_id); return false; } $flags = DB::WoW()->selectCell("SELECT `flags` FROM `DBPREFIX_forum_threads` WHERE `thread_id` = %d", $thread_id); self::$active_thread_id = $thread_id; self::$active_thread_flags = $flags; return true; }
public static function NavigationMenu() { // Maybe breadcrumb content should be filled from appropriate page controller? // Shadez $navigationMenu[0] = WoW_Locale::$navigation; $url_data = WoW::GetUrlData(); $path_data = NULL; $path_search_data = NULL; $last = false; $dynamic_content = false; switch ($url_data[1]) { case '/zone/': $dynamic_content = true; @($zone_info = WoW_Game::GetZone()); $_data = array(0 => '/', 1 => '/game/', 2 => '/zone/', 3 => '/zone/#expansion=' . @$zone_info['expansion'] . '&type=' . @$zone_info['type'] . 's', 4 => '/zone/' . @$url_data[2], 5 => '/zone/' . @$url_data[2] . '/' . @$url_data[3]); for ($a = 0; $a <= count($url_data); ++$a) { $path_search_data[$a] = $_data[$a]; } if (isset($url_data[2])) { $path_search_data[4] = $_data[4]; } break; case '/faction/': $dynamic_content = true; /** * WoW_Game::GetFaction() is not defined * * TODO * Create function WoW_Game::GetFaction() with same rules as WoW_Game::GetZone() * and edit wow_content_faction.php template to load datas from DB same as wow_content_zones.php template * * Create template and DB data to load and display each faction details. */ //@$faction_info = WoW_Game::GetFaction(); $_data = array(0 => '/', 1 => '/game/', 2 => '/faction/', 3 => '/faction/#expansion=' . @$faction_info['expansion'], 4 => '/faction/' . @$url_data[2]); for ($a = 0; $a <= count($url_data); ++$a) { $path_search_data[$a] = $_data[$a]; } if (isset($url_data[2])) { $path_search_data[4] = $_data[4]; } break; case '/item/': $dynamic_content = true; //WoW_Items::GetBreadCrumbsForItem($_GET) is NOT needed now if (isset($url_data[2])) { $preg = preg_match('/\\/(\\?classId=([0-9]+)((&subClassId=([0-9]+))?(&invType=([0-9]+))?)?)|([0-9]+)\\/{0,1}/i', $url_data[2], $matches); } $_data = array(0 => '/', 1 => '/game/', 2 => '/item/', 3 => NULL, 4 => NULL, 5 => NULL); for ($a = 0; $a <= count($url_data); ++$a) { $path_search_data[$a] = $_data[$a]; } if (isset($matches) && array_key_exists(8, $matches)) { $proto = new WoW_ItemPrototype(); $proto->LoadItem($matches[8]); $matches[2] = $proto->class; $matches[5] = $proto->subclass; if ($matches[2] == 4 && in_array($matches[5], array(0, 1, 2, 3, 4))) { $matches[7] = $proto->InventoryType; $path_search_data[6] = '/item/' . $matches[8]; $label[6] = $proto->name; } else { unset($matches[7]); $path_search_data[5] = '/item/' . $matches[8]; $label[5] = $proto->name; } } if (isset($matches) && (array_key_exists(2, $matches) || array_key_exists(8, $matches))) { $path_search_data[3] = '/item/?classId=' . $matches[2]; } if (isset($matches) && (array_key_exists(5, $matches) || array_key_exists(8, $matches))) { $path_search_data[4] = '/item/?classId=' . $matches[2] . '&subClassId=' . $matches[5]; } if (isset($matches) && array_key_exists(7, $matches)) { $path_search_data[5] = '/item/?classId=' . $matches[2] . '&subClassId=' . $matches[5] . '&invType=' . $matches[7]; } break; case '/profession/': $dynamic_content = true; $_data = array(0 => '/', 1 => '/game/', 2 => '/profession/', 3 => '/profession/' . @$url_data[2]); for ($a = 0; $a <= count($url_data); ++$a) { $path_search_data[$a] = $_data[$a]; } break; case '/pvp/': $dynamic_content = true; $_data = array(0 => '/', 1 => '/game/', 2 => '/pvp/', 3 => '/pvp/' . @$url_data[2]); for ($a = 0; $a <= count($url_data); ++$a) { $path_search_data[$a] = $_data[$a]; } break; case '/status/': $dynamic_content = true; $_data = array(0 => '/', 1 => '/game/', 2 => '/status/', 3 => '/status/' . @$url_data[2]); for ($a = 0; $a <= count($url_data); ++$a) { $path_search_data[$a] = $_data[$a]; } break; case '/character/': $dynamic_content = true; $subdata4 = ''; $data3 = ''; $count = 0; @($url_data[3] = @urldecode($url_data[3])); if (isset($url_data[4])) { if (in_array($url_data[4], array('/simple/', '/advanced/'))) { $count = 2; $subdata4 = @$url_data[4]; } elseif ($url_data[4] == '/achievement/') { $count = 3; $data3 = '/character/' . @$url_data[2] . @$url_data[3] . @$url_data[4]; $label[3] = WoW_Locale::GetString('template_profile_achievements'); } elseif ($url_data[4] == '/statistic/') { $count = 3; $data3 = '/character/' . @$url_data[2] . @$url_data[3] . @$url_data[4]; $label[3] = WoW_Locale::GetString('template_profile_statistics'); } elseif ($url_data[4] == '/reputation/') { $count = 3; $data3 = '/character/' . @$url_data[2] . @$url_data[3] . @$url_data[4]; $label[3] = WoW_Locale::GetString('template_profile_reputation'); } elseif ($url_data[4] == '/pvp/') { $count = 3; $data3 = '/character/' . @$url_data[2] . @$url_data[3] . @$url_data[4]; $label[3] = 'PvP'; } elseif ($url_data[4] == '/feed/') { $count = 3; $data3 = '/character/' . @$url_data[2] . @$url_data[3] . @$url_data[4]; $label[3] = WoW_Locale::GetString('template_profile_feed'); } elseif ($url_data[4] == '/mount/') { $count = 3; $data3 = '/character/' . @$url_data[2] . @$url_data[3] . @$url_data[4]; $label[3] = WoW_Locale::GetString('template_profile_mounts'); } elseif ($url_data[4] == '/companion/') { $count = 3; $data3 = '/character/' . @$url_data[2] . @$url_data[3] . @$url_data[4]; $label[3] = WoW_Locale::GetString('template_profile_companions'); } } $label[2] = str_replace(array('/', '+'), array('', ' '), @$url_data[3] . ' @ ' . @$url_data[2]); $_data = array(0 => '/', 1 => '/game/', 2 => '/character/' . @$url_data[2] . @$url_data[3] . $subdata4, 3 => $data3, 4 => NULL, 5 => NULL); for ($a = 0; $a <= $count; ++$a) { $path_search_data[$a] = $_data[$a]; } break; case '/blog/': $dynamic_content = true; $_data = array(0 => '/', 1 => '/blog/' . @$url_data[2]); $label[1] = WoW::GetBlogData('title'); for ($a = 0; $a < count($_data); ++$a) { $path_search_data[$a] = $_data[$a]; } break; case '/forum/': $dynamic_content = true; $_data = array(0 => '/', 1 => '/forum/', 2 => '/forum/#forum' . WoW_Forums::GetGlobalCategoryId(), 3 => '/forum/' . WoW_Forums::GetCategoryId() . '/', 4 => '/forum/topic/' . WoW_Forums::GetThreadId() . '/', 5 => '/forum/topic/post/' . @$url_data[4] . '/edit', 6 => '/forum/topic/post/' . @$url_data[4] . '/delete', 7 => '/forum/blizztracker/'); for ($a = 0; $a < count($url_data); ++$a) { $path_search_data[$a] = $_data[$a]; } if (isset($url_data[2]) && $url_data[2] != '/topic/') { if (isset($url_data[2]) && $url_data[2] == '/blizztracker/') { $path_search_data[2] = $_data[7]; $label[2] = WoW_Locale::GetString('template_blizztracker_title'); unset($path_search_data[3]); } else { $path_search_data[3] = $_data[3]; } } if (isset($url_data[2]) && $url_data[2] == '/topic/') { if ($url_data[3] == '/post/') { $path_search_data[3] = $_data[3]; $path_search_data[4] = $_data[5]; $label[4] = WoW_Forums::GetThreadTitle(); unset($path_search_data[5]); unset($path_search_data[6]); } else { $path_search_data[3] = $_data[3]; $path_search_data[4] = $_data[4]; $label[4] = WoW_Forums::GetThreadTitle(); } } break; default: $path_search_data = $url_data; break; } /* * BUG!!! Need Rewritten and Reworked script... * Need This <span class="breadcrumb-arrow"></span> */ echo '<ol class="ui-breadcrumb">'; $path_data = ''; for ($i = 0; $i < count($path_search_data); ++$i) { if ($i == count($path_search_data) - 1) { $last = true; } if ($dynamic_content) { $path_data = $path_search_data[$i]; } else { $path_data .= $url_data[$i]; } $path_data = str_replace('//', '/', $path_data); if (!isset($label[$i])) { $menu = self::array_searchRecursive($path_data, $navigationMenu); } else { $menu['label'] = $label[$i]; } echo '<li' . ($last == true ? ' class="last"' : null) . '><a href="' . WoW::GetWoWPath() . '/wow/' . WoW_Locale::GetLocale() . $path_data . '" rel="np">' . $menu['label'] . '</a></li>'; } echo '</ol>'; }
<td class="post-views">%d</td> <td class="post-lastPost"><a href="../topic/%d%s#%s" data-tooltip="%s">%s</a>' . ($thread['last_blizzpost'] != 1 ? '<span class="more-arrow"></span>' : '') . '</td> </tr>', $thread['author'], $thread['replies'], $thread['views'], $thread['thread_id'], $thread['pages'] > 1 ? '?page=' . $thread['pages'] : NULL, $thread['replies'] > 0 ? $thread['replies'] + 1 : 1, $thread['last_formated_date'], $thread['last_author']); } } echo '</tbody>'; } } ?> </table> </div> <div class="forum-info"> <div class="forum-actions topic-bottom"> <div class="actions-panel"> <?php echo WoW_Paginator::Initialize(WoW_Template::GetPageData('current_page'), WoW_Forums::GetTotalCategoryThreads(), 20, 'forum'); ?> <a class="ui-button button1<?php echo WoW_Account::IsLoggedIn() && !WoW_Account::IsHaveActiveCharacter() ? ' disabled' : null; ?> " href="topic"<?php echo !WoW_Account::IsLoggedIn() ? ' onclick="return Login.open(\'' . WoW::GetWoWPath() . '/login/login.frag\');"' : null; ?> > <span> <span><?php echo WoW_Locale::GetString('template_forums_create_thread'); ?> </span> </span> </a>