Пример #1
0
 public function main()
 {
     WoW_Template::SetTemplateTheme('wow');
     WoW_Template::SetPageIndex('item_info');
     WoW_Template::SetPageData('page', 'item_info');
     WoW_Template::SetMenuIndex('menu-game');
     $url_data = WoW::GetUrlData('item');
     if (!$url_data) {
         if (!isset($_GET['t'])) {
             WoW_Template::ErrorPage(404);
         }
         exit;
     }
     $item_entry = $url_data['item_entry'];
     if ($item_entry == 0) {
         $breadcrumbs = WoW_Items::GetBreadCrumbsForItem($_GET);
         WoW_Template::SetPageIndex('item_list');
         WoW_Template::SetPageData('body_class', 'item-index');
         WoW_Template::SetPageData('page', 'item_list');
         WoW_Template::SetPageData('breadcrumbs', $breadcrumbs);
         WoW_Template::SetPageData('last-crumb', is_array($breadcrumbs) ? $breadcrumbs[sizeof($breadcrumbs) - 1]['caption'] : WoW_Locale::GetString('template_menu_items'));
         WoW_Template::LoadTemplate('page_index');
         exit;
     }
     // Load proto
     $proto = new WoW_ItemPrototype();
     $proto->LoadItem($item_entry);
     if (!$proto->IsCorrect()) {
         if (!isset($_GET['t']) && (!isset($url_data['action0']) || $url_data['action0'] != 'tooltip')) {
             WoW_Template::ErrorPage(404);
         }
         exit;
     }
     WoW_Template::SetPageData('item_entry', $item_entry);
     // SSD and SSV data
     $ssd = DB::WoW()->selectRow("SELECT * FROM `DBPREFIX_ssd` WHERE `entry` = %d", $proto->ScalingStatDistribution);
     $ssd_level = MAX_PLAYER_LEVEL;
     if (isset($_GET['pl'])) {
         $ssd_level = (int) $_GET['pl'];
         if (is_array($ssd) && $ssd_level > $ssd['MaxLevel']) {
             $ssd_level = $ssd['MaxLevel'];
         }
     }
     $ssv = DB::WoW()->selectRow("SELECT * FROM `DBPREFIX_ssv` WHERE `level` = %d", $ssd_level);
     if (isset($_GET['t'])) {
         $url_data['tooltip'] = true;
     }
     if ($url_data['tooltip'] == true) {
         WoW_Template::SetPageIndex('item_tooltip');
         WoW_Template::SetPageData('tooltip', true);
         WoW_Template::SetPageData('page', 'item_tooltip');
         WoW_Template::SetPageData('proto', $proto);
         WoW_Template::SetPageData('ssd', $ssd);
         WoW_Template::SetPageData('ssd_level', $ssd_level);
         WoW_Template::SetPageData('ssv', $ssv);
         WoW_Template::LoadTemplate('page_item_tooltip');
     } else {
         if (isset($url_data['action0']) && $url_data['action0'] != null) {
             WoW_Template::SetPageData('tab_type', $url_data['action0']);
             WoW_Template::LoadTemplate('page_item_tab');
             exit;
         }
         WoW_Template::SetPageIndex('item');
         WoW_Template::SetPageData('tooltip', false);
         WoW_Template::SetPageData('itemName', $proto->name);
         WoW_Template::SetPageData('page', 'item');
         WoW_Template::SetPageData('proto', $proto);
         WoW_Template::SetPageData('ssd', $ssd);
         WoW_Template::SetPageData('ssd_level', $ssd_level);
         WoW_Template::SetPageData('ssv', $ssv);
         WoW_Template::LoadTemplate('page_index');
     }
     unset($proto);
 }
 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>';
 }