示例#1
0
 private static function GetFilterForNPCs()
 {
     $filter_string = null;
     $andOr = 1;
     $all_filters = WoW::GetFilters();
     if (is_array($all_filters)) {
         foreach ($all_filters as $filter) {
             if (!isset($filter['key']) || !isset($filter['values'])) {
                 continue;
             }
             $val_count = count($filter['values']);
             switch ($filter['key']) {
                 // Family
                 case 'fa':
                     if ($val_count == 1) {
                         $filter_string .= '{COND} `a`.`family` = ' . $filter['values'][0];
                     } else {
                         $filter_string .= '{COND} `a`.`family` IN (';
                         self::ApplyMultiFiltersToString($val_count, $filter, $filter_string);
                     }
                     break;
             }
         }
     }
     return str_replace('{COND}', $andOr == 2 ? 'OR' : 'AND', $filter_string);
 }
示例#2
0
 public function main()
 {
     WoW_Template::SetTemplateTheme('wow');
     WoW_Template::SetPageData('body_class', WoW_Locale::GetLocale(LOCALE_DOUBLE));
     // Check query
     $searchQuery = isset($_GET['q']) ? $_GET['q'] : null;
     if ($searchQuery != null && mb_strlen($searchQuery) < 3) {
         $searchQuery = null;
     }
     if (preg_match('/\\@/', $searchQuery)) {
         $fast_access = explode('@', $searchQuery);
         if (isset($fast_access[0], $fast_access[1])) {
             header('Location: ' . WoW::GetWoWPath() . '/wow/' . WoW_Locale::GetLocale() . '/character/' . trim($fast_access[1]) . trim($fast_access[0]) . '/');
             exit;
         }
     }
     WoW_Search::SetSearchQuery($searchQuery);
     // Perform Search
     WoW_Search::PerformSearch();
     // Set active page
     if (isset($_GET['f']) && in_array($_GET['f'], array('search', 'wowarenateam', 'article', 'wowcharacter', 'wowitem', 'post', 'wowguild'))) {
         $page = $_GET['f'];
     } else {
         $page = 'search';
     }
     WoW_Search::SetCurrentPage($page);
     WoW_Template::SetPageIndex('search');
     WoW_Template::SetPageData('page', 'search');
     WoW_Template::SetPageData('searchQuery', $searchQuery);
     WoW_Template::LoadTemplate('page_index');
 }
示例#3
0
 public function main()
 {
     $url_data = WoW::GetUrlData('discussion');
     $blog_id = $url_data['blog_id'];
     if (!$blog_id || !WoW_Account::IsLoggedIn()) {
         if (isset($_GET['d_ref'])) {
             header('Location: ' . $_GET['d_ref']);
         } else {
             header('Location: ' . WoW::GetWoWPath() . '/');
         }
         exit;
     }
     $replyToGuid = 0;
     $replyToComment = 0;
     $postDetail = isset($_POST['detail']) ? $_POST['detail'] : null;
     if (isset($_POST['replyTo'])) {
         // have reply
         $reply = explode(':', $_POST['replyTo']);
         if (is_array($reply) && isset($reply[1])) {
             $replyToGuid = $reply[0];
             $replyToComment = $reply[1];
         }
     }
     if ($postDetail != null) {
         DB::WoW()->query("INSERT INTO `DBPREFIX_blog_comments` (blog_id, account, character_guid, realm_id, postdate, comment_text, answer_to) VALUES (%d, %d, %d, %d, %d, '%s', %d)", $blog_id, WoW_Account::GetUserID(), WoW_Account::GetActiveCharacterInfo('guid'), WoW_Account::GetActiveCharacterInfo('realmId'), time(), $postDetail, $replyToComment);
     }
     if (isset($_GET['d_ref'])) {
         header('Location: ' . $_GET['d_ref']);
     } else {
         header('Location: ' . WoW::GetWoWPath() . '/');
     }
 }
示例#4
0
 public function main()
 {
     WoW_Template::SetPageIndex('login');
     if (WoW_Account::IsLoggedIn()) {
         header('Location: ' . WoW::GetWoWPath() . '/');
         exit;
     }
     if (isset($_POST['accountName'])) {
         $username = $_POST['accountName'];
         $password = $_POST['password'];
         $persistLogin = isset($_POST['persistLogin']) ? true : false;
         WoW_Account::DropLastErrorCode();
         if (mb_strlen($password) <= 7) {
             WoW_Account::SetLastErrorCode(ERORR_INVALID_PASSWORD_FORMAT);
         }
         if ($username == null) {
             WoW_Account::SetLastErrorCode(ERROR_EMPTY_USERNAME);
         }
         if ($password == null) {
             WoW_Account::SetLastErrorCode(ERROR_EMPTY_PASSWORD);
         }
         if (WoW_Account::PerformLogin($username, $password, $persistLogin)) {
             if (isset($_POST['ref'])) {
                 header('Location: ' . $_POST['ref']);
                 exit;
             }
             header('Location: ' . WoW::GetWoWPath() . '/');
             exit;
         }
         // Other error messages will appear automaticaly.
     }
     WoW_Template::LoadTemplate('page_login', true);
 }
 protected function getInternalData()
 {
     try {
         $result = WoW::getInstance()->getAdapter('WorldOfLogs')->getData($this->params->module->get('guild'));
     } catch (Exception $e) {
         return $e->getMessage();
     }
     foreach ($result->body->rows as $key => $row) {
         $row->duration = $this->duration($row->duration);
         if (!empty($row->zones)) {
             $row->name = isset($this->zones[$row->zones[0]->id]) ? $this->zones[$row->zones[0]->id] : $row->zones[0]->name;
             $row->limit = $row->zones[0]->playerLimit;
             $row->mode = $row->zones[0]->difficulty;
         } else {
             $row->name = 'Unknown';
             $row->lmit = 0;
             $row->mode = 0;
         }
         if ($key >= $this->params->module->get('raids')) {
             unset($result->body->rows[$key]);
             continue;
         }
     }
     return $result->body->rows;
 }
 protected function getInternalData()
 {
     $wow = WoW::getInstance();
     try {
         $adapter = $wow->getAdapter('WoWAPI');
         $result = $adapter->getData('guild');
     } catch (Exception $e) {
         return $e->getMessage();
     }
     $achievements = array();
     foreach ($result->body->achievements->achievementsCompleted as $key => $achievement) {
         $achievements[$achievement] = new stdClass();
         $achievements[$achievement]->timestamp = $result->body->achievements->achievementsCompletedTimestamp[$key];
     }
     arsort($achievements);
     $achievements = array_slice($achievements, 0, $this->params->module->get('rows', 10) ? $this->params->module->get('rows', 10) : count($achievements), true);
     foreach ($achievements as $key => $achievement) {
         try {
             $result = $adapter->getAchievement($key);
         } catch (Exception $e) {
             unset($achievements[$key]);
             continue;
         }
         $achievements[$key]->id = $key;
         $achievements[$key]->name = $result->body->title;
         $achievements[$key]->image = 'http://media.blizzard.com/wow/icons/18/' . $result->body->icon . '.jpg';
         $achievements[$key]->link = $wow->getBattleNetUrl() . 'achievement#15080:a' . $key;
         // TODO 15080 ??
         $achievements[$key]->link = $this->link($achievements[$key]);
         $achievements[$key]->raw = $result->body;
     }
     return $achievements;
 }
 public function GetTopTeams($format, $bg_id, $limit = 3, $offset = 0, $count = false)
 {
     if (!isset(WoWConfig::$BattleGroups[$bg_id])) {
         WoW_Log::WriteError('%s : battleGroupd #%d was not found!', __METHOD__, $bg_id);
         return false;
     }
     $realms = WoWConfig::$BattleGroups[$bg_id]['realms'];
     if (!$realms) {
         WoW_Log::WriteError('%s : no realms found for battleGroup #%d, using first available bg instead.', __METHOD__, $bg_id);
         $realms = WoWConfig::$BattleGroups[1]['realms'];
         if (!$realms) {
             WoW_Log::WriteError('%s : default BG has no realms, unable to continue.', __METHOD__);
             return false;
         }
     }
     $top_teams_data = array();
     $counter = 0;
     foreach ($realms as $realmId) {
         DB::ConnectToDB(DB_CHARACTERS, $realmId);
         if (!DB::Characters()->TestLink()) {
             continue;
         }
         if (WoW::GetServerType($realmId) == SERVER_MANGOS) {
             if ($count) {
                 $counter += DB::Characters()->selectCell("\n                    SELECT COUNT(*)\n                    FROM `arena_team` AS `a`\n                    LEFT JOIN `arena_team_stats` AS `b` ON `b`.`arenateamid` = `a`.`arenateamid`\n                    WHERE `a`.`type` = %d\n                    AND `b`.`rank` > 0 AND `b`.`rank` < 4", $format);
                 continue;
             }
             $teams = DB::Characters()->select("SELECT\n                `a`.`arenateamid` AS `id`,\n                `a`.`rank`,\n                `a`.`rating`,\n                '%d' AS `realmId`,\n                `b`.`type`\n                FROM `arena_team_stats` AS `a`\n                LEFT JOIN `arena_team` AS `b` ON `b`.`arenateamid` = `a`.`arenateamid`\n                WHERE `a`.`rank` > 0 AND `a`.`rank` < 4 AND `b`.`type` = %d ORDER BY `rank`, `rating` LIMIT %d, %d", $realmId, $format, $offset, $limit);
         } else {
             $teams = DB::Characters()->select("SELECT `arenaTeamId` AS `id`, `rank`, `rating`, '%d' AS `realmId`, `type` FROM `arena_team` WHERE `rank` > 0 AND `rank` < 4 AND `type` = %d ORDER BY `rank`, `rating` LIMIT %d, %d", $realmId, $format, $offset, $limit);
         }
         if (!$teams) {
             continue;
         }
         $top_teams_data[] = array('realmId' => $realmId, 'teamsId' => $teams);
     }
     if ($count) {
         return $counter;
     }
     // Find top 3 teams
     $top_teams = array();
     foreach ($top_teams_data as &$teams) {
         foreach ($teams['teamsId'] as &$team) {
             if (!isset($top_teams[$team['rank']])) {
                 $top_teams[$team['rank']] = $team;
             }
             if ($top_teams[$team['rank']]['rating'] < $team['rating']) {
                 $top_teams[$team['rank']] = $team;
             }
         }
     }
     // Create objects
     $top_teams_objects = array();
     foreach ($top_teams as &$team) {
         $top_teams_objects[] = new WoW_ArenaTeam($team['realmId'], '', $team['id']);
     }
     unset($top_teams, $top_teams_data, $team, $teams);
     return $top_teams_objects;
 }
示例#8
0
 public function main()
 {
     if (!WoWConfig::$Maintenance) {
         WoW::RedirectTo();
         return;
     }
     WoW_Template::LoadTemplate('page_maintenance', true);
 }
示例#9
0
 public function main()
 {
     WoW_Template::SetPageData('body_class', sprintf('%s  game-index', WoW_Locale::GetLocale(LOCALE_DOUBLE)));
     WoW_Template::SetTemplateTheme('wow');
     $url_data = WoW::GetUrlData('game');
     if (empty($url_data['action1'])) {
         WoW_Template::SetPageIndex('game');
         WoW_Template::SetPageData('page', 'game');
     } elseif ($url_data['action1'] == 'guide') {
         switch ($url_data['action2']) {
             case 'getting-started':
             case 'how-to-play':
             case 'playing-together':
             case 'late-game':
                 WoW_Template::SetPageIndex('game_guide_' . str_replace('-', '_', $url_data['action2']));
                 WoW_Template::SetPageData('body_class', 'game-guide-' . $url_data['action2']);
                 WoW_Template::SetPageData('page', 'game_guide_' . str_replace('-', '_', $url_data['action2']));
                 break;
             default:
                 WoW_Template::SetPageIndex('game_guide_what_is_wow');
                 WoW_Template::SetPageData('body_class', 'game-guide-what-is-wow');
                 WoW_Template::SetPageData('page', 'game_guide_what_is_wow');
                 break;
         }
     } elseif ($url_data['action1'] == 'race') {
         $race_id = WoW_Utils::GetRaceIDByKey($url_data['action2']);
         if ($race_id > 0) {
             WoW_Game::LoadRace($race_id);
             WoW_Template::SetPageIndex('game_race');
             WoW_Template::SetPageData('body_class', 'race-' . $url_data['action2']);
             WoW_Template::SetPageData('race', $url_data['action2']);
             WoW_Template::SetPageData('page', 'game_race');
             WoW_Template::SetPageData('raceId', $race_id);
         } else {
             WoW_Template::SetPageIndex('game_race_index');
             WoW_Template::SetPageData('body_class', 'game-race-index');
             WoW_Template::SetPageData('page', 'game_race_index');
         }
     } elseif ($url_data['action1'] == 'class') {
         $class_id = WoW_Utils::GetClassIDByKey($url_data['action2']);
         if ($class_id > 0) {
             WoW_Game::LoadClass($class_id);
             WoW_Template::SetPageIndex('game_class');
             WoW_Template::SetPageData('body_class', 'class-' . $url_data['action2']);
             WoW_Template::SetPageData('class', $url_data['action2']);
             WoW_Template::SetPageData('classId', $class_id);
             WoW_Template::SetPageData('page', 'game_class');
         } else {
             WoW_Template::SetPageIndex('game_class_index');
             WoW_Template::SetPageData('body_class', 'game-classes-index');
             WoW_Template::SetPageData('page', 'game_class_index');
         }
     } else {
         WoW_Template::ErrorPage(404);
     }
     WoW_Template::SetMenuIndex('menu-game');
     WoW_Template::LoadTemplate('page_index');
 }
示例#10
0
 public function main()
 {
     WoW_Template::SetPageData('carousel', WoW::GetCarouselData());
     WoW_Template::SetPageData('wow_news', WoW::GetLastNews(20, isset($_GET['page']) ? (int) ($_GET['page'] - 1) : 0));
     WoW_Template::SetPageData('body_class', sprintf('%s homepage', WoW_Locale::GetLocale(LOCALE_DOUBLE)));
     WoW_Template::SetTemplateTheme('wow');
     WoW_Template::SetPageIndex('index');
     WoW_Template::SetMenuIndex('menu-home');
     WoW_Template::LoadTemplate('page_index');
 }
示例#11
0
 public function onAfterInitialise()
 {
     JLoader::register('WoW', JPATH_LIBRARIES . '/WoW/WoW.php');
     if (class_exists('WoW')) {
         WoW::getInstance($this->params);
         // define instance with params
     } else {
         JFactory::getApplication()->enqueueMessage(JText::_('PLG_SYSTEM_WOW_LIBRARY_MISSING'), 'error');
     }
 }
 protected function getInternalData()
 {
     try {
         $result = WoW::getInstance()->getAdapter('BattleNET')->getData('guild_news');
     } catch (Exception $e) {
         return $e->getMessage();
     }
     if (strpos($result->body, '<div id="news-list">') === false) {
         return JText::_('MOD_WOW_ARMORY_GUILD_NEWS_NO_NEWS');
     }
     // get only news data
     preg_match('#<ul class="activity-feed activity-feed-wide">(.+?)</ul>#si', $result->body, $result->body);
     $result->body = $result->body[1];
     // remove unnecessary whitespaces
     $search[] = '#\\s{2,10}#';
     $replace[] = '';
     // would disable wowhead tooltips?!
     $search[] = '#rel="np"#';
     $replace[] = '';
     // remove unnecessary li object
     $search[] = '#<li data-id="[0-9]+" class=".*?">#';
     $replace[] = '';
     // add link target
     $search[] = '#href="#';
     $replace[] = 'target="_blank" href="';
     // replace item icon with img tag
     $search[] = '#<span.*?style=\'background-image: url\\("(.*?)"\\);\'.*?>.*?</span>#i';
     $replace[] = '<img src="$1" width="18" height="18" alt="" />';
     $result->body = preg_replace($search, $replace, $result->body);
     $links[] = '#/wow/' . $this->params->global->get('locale') . '/character/[^/]+/[^/]+/(achievement)\\#([[:digit:]:a]+)#i';
     $links[] = '#/wow/' . $this->params->global->get('locale') . '/(item)/(\\d+)#i';
     $links[] = '#/wow/' . $this->params->global->get('locale') . '/guild/[^/]+/[^/]+/(achievement)\\#([[:digit:]:a]+)#i';
     $links[] = '#/wow/' . $this->params->global->get('locale') . '/(character)/[^/]+/(\\S[[:graph:]]+)/"#i';
     $result->body = preg_replace_callback($links, array(&$this, 'link'), $result->body);
     // at last split data at </li>
     $result->body = explode('</li>', $result->body);
     if (empty($result->body)) {
         return JText::_('MOD_WOW_ARMORY_GUILD_NEWS_NO_NEWS');
     }
     $result->body = array_filter($result->body);
     // remove empty items
     if ($filter = $this->params->module->get('filter')) {
         $filter = array_filter(array_map('trim', explode(';', $filter)));
         if (!empty($filter)) {
             foreach ($result->body as $key => $row) {
                 foreach ($filter as $search) {
                     if (strpos($row, $search) !== false) {
                         unset($result->body[$key]);
                     }
                 }
             }
         }
     }
     return array_slice($result->body, 0, $this->params->module->get('rows'));
 }
示例#13
0
 public function main()
 {
     $url_data = WoW::GetUrlData('management');
     if (!is_array($url_data) || !isset($url_data['action1']) || $url_data['action1'] != 'management') {
         header('Location: ' . WoW::GetWoWPath() . '/account/management/');
         exit;
     }
     if (!WoW_Account::IsLoggedIn()) {
         header('Location: ' . WoW::GetWoWPath() . '/login/');
         exit;
     }
     WoW_Template::SetTemplateTheme('account');
     WoW_Account::UserGames();
     WoW_Template::SetPageIndex('management');
     WoW_Template::SetMenuIndex('management');
     WoW_Template::SetPageData('page', 'management');
     if ($url_data['action2'] == 'wow' && preg_match('/dashboard.html/i', $url_data['action3'])) {
         WoW_Account::InitializeAccount($_GET['accountName']);
         WoW_Template::SetPageIndex('dashboard');
         WoW_Template::SetMenuIndex('games');
         WoW_Template::SetPageData('page', 'dashboard');
     } elseif ($url_data['action2'] == 'wow-account-conversion.html') {
         WoW_Template::SetPageData('conversion_page', 1);
         if (isset($_POST['targetpage'])) {
             switch ($_POST['targetpage']) {
                 case '2':
                     if (isset($_POST['username']) && isset($_POST['password'])) {
                         if (WoW_Account::PerformConversionStep(1, array('username' => $_POST['username'], 'password' => $_POST['password']))) {
                             WoW_Template::SetPageData('conversion_page', 2);
                         } else {
                             WoW_Template::SetPageData('conversion_page', 1);
                         }
                     } else {
                         WoW_Template::SetPageData('conversion_page', 1);
                     }
                     break;
                 case '3':
                     WoW_Template::SetPageData('conversion_page', 3);
                     break;
                 case 'finish':
                     if (!WoW_Account::PerformConversionStep(3)) {
                         WoW_Template::SetPageData('conversion_page', 2);
                     }
                     break;
                 default:
                     break;
             }
         }
         WoW_Template::SetPageIndex('account_conversion');
         Wow_Template::SetMenuIndex('games');
         WoW_Template::SetPageData('page', 'account_conversion');
     }
     WoW_Template::LoadTemplate('page_index');
 }
示例#14
0
 public function main()
 {
     if (!WoWConfig::$EnableBNPage && !isset($_GET['skipRedirect'])) {
         WoW::RedirectTo('wow/' . WoW_Locale::GetLocale());
     }
     WoW_Template::SetTemplateTheme('bn');
     WoW_Template::SetMenuIndex('index');
     WoW_Account::UserGames();
     WoW_Template::SetPageIndex('index');
     WoW_Template::LoadTemplate('page_index');
 }
示例#15
0
 public function main()
 {
     WoW_Template::SetPageData('body_class', WoW_Locale::GetLocale(LOCALE_DOUBLE));
     WoW_Template::SetTemplateTheme('wow');
     $url_data = WoW::GetUrlData('guild');
     $guild_error = false;
     if (!$url_data) {
         WoW_Template::ErrorPage(404);
     } elseif (!WoW_Guild::LoadGuild($url_data['name'], WoW_Utils::GetRealmIDByName($url_data['realmName']))) {
         WoW_Template::ErrorPage(404);
     } else {
         $primary = WoW_Account::GetActiveCharacter();
         WoW_Template::SetPageData('guild-authorized', false);
         if (is_array($primary) && isset($primary['realmName'])) {
             if ($primary['realmName'] == WoW_Guild::GetGuildRealmName() && $primary['guildId'] == WoW_Guild::GetGuildID()) {
                 WoW_Template::SetPageData('guild-authorized', true);
             }
         }
         switch ($url_data['action0']) {
             default:
                 WoW_Template::SetPageData('guild-page', 'summary');
                 WoW_Template::SetPageIndex('guild_page');
                 WoW_Template::SetPageData('page', 'guild_page');
                 break;
             case 'perk':
                 WoW_Template::SetPageData('guild-page', 'perks');
                 WoW_Template::SetPageIndex('guild_perks');
                 WoW_Template::SetPageData('page', 'guild_perks');
                 break;
             case 'roster':
                 switch ($url_data['action1']) {
                     default:
                         WoW_Template::SetPageIndex('guild_roster');
                         WoW_Template::SetPageData('page', 'guild_roster');
                         break;
                     case 'professions':
                         WoW_Guild::InitProfessions();
                         WoW_Template::SetPageIndex('guild_professions');
                         WoW_Template::SetPageData('page', 'guild_professions');
                         break;
                 }
                 WoW_Template::SetPageData('guild-page', 'roster');
                 break;
         }
         WoW_Template::SetPageData('guildName', $url_data['name']);
         WoW_Template::SetPageData('realmName', $url_data['realmName']);
         WoW_Template::SetMenuIndex('menu-game');
     }
     WoW_Template::LoadTemplate('page_index');
 }
示例#16
0
 public function main()
 {
     WoW_Template::SetPageData('body_class', sprintf('%s  media-content', WoW_Locale::GetLocale(LOCALE_DOUBLE)));
     WoW_Template::SetTemplateTheme('wow');
     $url_data = WoW::GetUrlData('media');
     if (empty($url_data['action1'])) {
         WoW_Template::SetPageIndex('media');
         WoW_Template::SetPageData('page', 'media');
     } else {
         WoW_Template::ErrorPage(404);
     }
     WoW_Template::SetMenuIndex('menu-media');
     WoW_Template::LoadTemplate('page_index');
 }
示例#17
0
 /**
  * @param Joomla\Registry\Registry $params
  * @return JHttpResponse|string
  */
 public static function checkGuildExists(Joomla\Registry\Registry $params)
 {
     try {
         $result = WoW::getInstance($params)->getAdapter('WoWAPI')->getData('guild', true);
     } catch (Exception $e) {
         return $e->getMessage();
     }
     if (isset($result->body->name) && isset($result->body->realm)) {
         $db = JFactory::getDbo();
         $sql = 'REPLACE INTO `#__wow_demo` SET `guild` = ' . $db->quote($result->body->name) . ', `realm` = ' . $db->quote($result->body->realm) . ', `region` = ' . $db->quote($params->get('region'));
         $db->setQuery($sql)->execute();
     }
     return $result;
 }
 protected function getInternalData()
 {
     try {
         $result = WoW::getInstance()->getAdapter('WoWAPI')->getData('guild');
     } catch (Exception $e) {
         return $e->getMessage();
     }
     $tabard = new stdClass();
     $tabard->ring = $result->body->side == 1 ? 'horde' : 'alliance';
     $tabard->staticUrl = JUri::base(true) . '/media/mod_wow_guild_tabard/images/';
     $tabard->emblem = $this->AlphaHexToRGB($result->body->emblem->iconColor, $result->body->emblem->icon);
     $tabard->border = $this->AlphaHexToRGB($result->body->emblem->borderColor, $result->body->emblem->border);
     $tabard->bg = $this->AlphaHexToRGB($result->body->emblem->backgroundColor, 0);
     return $tabard;
 }
 protected function getInternalData()
 {
     try {
         if (!$this->params->module->get('public_api_key')) {
             return JText::_('MOD_WOW_WARCRAFTLOGS_API_KEY_MISSING');
         }
         $result = WoW::getInstance()->getAdapter('WarcraftLogs')->getData($this->params->module->get('public_api_key'));
     } catch (Exception $e) {
         return $e->getMessage();
     }
     $result->body = array_slice(array_reverse($result->body), 0, $this->params->module->get('raids', 10));
     foreach ($result->body as $log) {
         $log->duration = $this->duration($log->end - $log->start);
     }
     return $result->body;
 }
示例#20
0
 public static function getInstance(Registry $params = null)
 {
     // $instance set, but $params given -> return new instance
     if (self::$instance && $params != null) {
         return new self($params);
     }
     // create and get first $instance
     if (!self::$instance && $params) {
         self::$instance = new self($params);
     }
     // no $instance and $params set, cant work!
     if (!self::$instance && !$params) {
         throw new InvalidArgumentException(__CLASS__ . ' must be instanced with params!');
     }
     // return $instance
     return self::$instance;
 }
示例#21
0
 protected function getSuggestions()
 {
     $realms = array();
     if (!class_exists('WoW')) {
         return $realms;
     }
     try {
         $result = WoW::getInstance()->getAdapter('WoWAPI')->getData('realms', true);
     } catch (Exception $e) {
         return $realms;
     }
     foreach ($result->body->realms as $key => $realm) {
         $realms[$key] = new stdClass();
         $realms[$key]->name = $realm->slug;
         $realms[$key]->value = $realm->name;
     }
     return $realms;
 }
示例#22
0
 public function main()
 {
     WoW_Template::SetTemplateTheme('wow');
     WoW_Template::SetPageData('body_class', WoW_Locale::GetLocale(LOCALE_DOUBLE));
     $url_data = WoW::GetUrlData('blog');
     $blog_id = $url_data['blog_id'];
     if (!$blog_id || !WoW::LoadBlog($blog_id)) {
         WoW_Template::ErrorPage(404);
     } else {
         WoW_Template::SetPageData('wow_news', WoW::GetLastNews());
         WoW_Template::SetPageData('blog_title', WoW::GetBlogData('title'));
         WoW_Template::SetPageData('overall_meta_title', WoW::GetBlogData('title'));
         WoW_Template::SetPageData('overall_meta_img', '/cms/blog_thumbnail/' . WoW::GetBlogData('image'));
         WoW_Template::SetPageIndex('blog');
         WoW_Template::SetPageData('page', 'blog');
     }
     WoW_Template::SetMenuIndex('menu-home');
     WoW_Template::LoadTemplate('page_index');
 }
 protected function getInternalData()
 {
     try {
         $result = WoW::getInstance()->getAdapter($this->params->module->get('source'))->getData();
     } catch (Exception $e) {
         return $e->getMessage();
     }
     $retval = new stdClass();
     switch ($this->params->module->get('source', 'wowprogress')) {
         case 'guildox':
             foreach ($result->body->rank as $option) {
                 if (strtolower($option->name) == 'raid') {
                     $retval->realm = $option->rank->realm;
                     $retval->region = $option->rank->region;
                     break;
                 }
             }
             $retval->world = $result->body->guild->world_rank;
             $retval->url = 'http://www.guildox.com/wow/guild/' . $this->params->global->get('region') . '/' . $this->params->global->get('realm') . '/' . $this->params->global->get('guild');
             break;
         case 'wowprogress':
             $retval->realm = $result->body->realm_rank;
             $retval->world = $result->body->world_rank;
             $retval->region = $result->body->area_rank;
             $retval->url = 'http://www.wowprogress.com/guild/' . $this->params->global->get('region') . '/' . $this->params->global->get('realm') . '/' . $this->params->global->get('guild');
             break;
     }
     $retval->display = $retval->{$this->params->module->get('display', 'realm')};
     switch ($retval->display) {
         case $retval->display <= 9:
             $retval->size = 'size9';
             break;
         case $retval->display <= 99:
             $retval->size = 'size99';
             break;
         case $retval->display <= 999:
             $retval->size = 'size999';
             break;
     }
     return $retval;
 }
 public function onPrepareAvatars(&$comments)
 {
     $wow = WoW::getInstance();
     try {
         $result = $wow->getAdapter('WoWAPI')->getData('members');
     } catch (Exception $e) {
         JFactory::getApplication()->enqueueMessage('JComments - WOW Avatar: ' . $e->getMessage(), 'error');
         return;
     }
     foreach ($comments as &$comment) {
         $name = $comment->{$this->params->get('mapping', 'name')};
         $name = JString::strtolower($name);
         foreach ($result->body->members as $member) {
             if ($name == JString::strtolower($member->character->name)) {
                 $url = 'http://' . $wow->params->get('region') . '.battle.net/static-render/' . $wow->params->get('region') . '/' . $member->character->thumbnail;
                 $comment->avatar = JHtml::_('image', $url, '');
                 break;
             }
         }
     }
 }
示例#25
0
 public function GetTopTeams($format, $bg_id)
 {
     if (!isset(WoWConfig::$BattleGroups[$bg_id])) {
         WoW_Log::WriteError('%s : battleGroupd #%d was not found!', __METHOD__, $bg_id);
         return false;
     }
     $realms = WoWConfig::$BattleGroups[$bg_id]['realms'];
     if (!$realms) {
         WoW_Log::WriteError('%s : no realms found for battleGroup #%d, using first available bg instead.', __METHOD__, $bg_id);
         $realms = WoWConfig::$BattleGroups[1]['realms'];
         if (!$realms) {
             WoW_Log::WriteError('%s : default BG has no realms, unable to continue.', __METHOD__);
             return false;
         }
     }
     $top_teams_data = array();
     foreach ($realms as $realmId) {
         DB::ConnectToDB(DB_CHARACTERS, $realmId);
         if (!DB::Characters()->TestLink()) {
             continue;
         }
         $teams = DB::Characters()->select("SELECT `%s`, `rank`, `rating` FROM `arena_team` ORDER BY `rank` LIMIT 3", WoW::GetServerType($realmId) == SERVER_MANGOS ? 'arenateamid' : 'arenaTeamId');
         if (!$teams) {
             continue;
         }
         $top_teams_data[] = array('realmId' => $realmId, 'teamsId' => $teams);
     }
     // Find top 3 teams
     foreach ($top_teams_data as &$teams) {
         foreach ($teams['teamsId'] as &$team) {
             if (!isset($top_teams[$team['rank']])) {
                 $top_teams[$team['rank']] = $team;
             }
             if ($top_teams[$team['rank']]['rating'] < $team['rating']) {
                 $top_teams[$team['rank']] = $team;
             }
         }
     }
     print_r($top_teams);
 }
示例#26
0
 public function onAfterInitialise()
 {
     $data = JFactory::getSession()->get('wow_demo', new Joomla\Registry\Registry());
     if (!class_exists('WoW')) {
         return false;
     }
     if (!$data->get('guild') || !$data->get('realm') || !$data->get('region') || !$data->get('locale') || !$data->get('link')) {
         $params = new Joomla\Registry\Registry(JPluginHelper::getPlugin('system', 'wow')->params);
         $data = new Joomla\Registry\Registry();
         $data->set('guild', $params->get('guild'));
         $data->set('realm', $params->get('realm'));
         $data->set('region', $params->get('region'));
         $data->set('locale', $params->get('locale'));
         $data->set('link', $params->get('link'));
         JFactory::getSession()->set('wow_demo', $data);
     }
     WoW::getInstance()->params->set('guild', $data->get('guild'));
     WoW::getInstance()->params->set('realm', $data->get('realm'));
     WoW::getInstance()->params->set('region', $data->get('region'));
     WoW::getInstance()->params->set('locale', $data->get('locale'));
     WoW::getInstance()->params->set('link', $data->get('link'));
 }
示例#27
0
 public function main()
 {
     WoW_Template::SetPageData('body_class', sprintf('%s zone-index expansion-3', WoW_Locale::GetLocale(LOCALE_DOUBLE)));
     WoW_Template::SetTemplateTheme('wow');
     WoW_Template::SetPageIndex('zones');
     WoW_Template::SetPageData('page', 'zones');
     $url_data = WoW::GetUrlData('zone');
     if (isset($url_data['action3'])) {
         exit;
     }
     if (isset($url_data['action1']) && $url_data['action1'] != null) {
         // Try to find zone
         if (WoW_Game::IsZone($url_data['action1'])) {
             WoW_Template::SetPageData('zoneKey', $url_data['action1']);
             if (isset($url_data['action2']) && $url_data['action2'] != null) {
                 if (in_array($url_data['action2'], array('loot', 'quests', 'quest-rewards', 'achievements', 'comments'))) {
                     die('NYI');
                 }
                 if (WoW_Game::IsBoss($url_data['action2'])) {
                     WoW_Template::SetPageIndex('boss');
                     WoW_Template::SetPageData('page', 'boss');
                     WoW_Template::SetPageData('bossKey', $url_data['action2']);
                     WoW_Game::LoadBoss($url_data['action2']);
                     // save in memory
                     WoW_Template::SetPageData('body_class', sprintf('%s zone-%s boss-%s', WoW_Locale::GetLocale(LOCALE_DOUBLE), $url_data['action1'], $url_data['action2']));
                 }
             } else {
                 WoW_Template::SetPageIndex('zone');
                 WoW_Template::SetPageData('page', 'zone');
                 WoW_Game::LoadZone($url_data['action1']);
                 // save in memory
                 WoW_Template::SetPageData('body_class', sprintf('%s zone-%s', WoW_Locale::GetLocale(LOCALE_DOUBLE), $url_data['action1']));
             }
         }
     }
     WoW_Template::SetMenuIndex('menu-game');
     WoW_Template::LoadTemplate('page_index');
 }
 protected function _getURL($user, $sizex, $sizey)
 {
     $user = KunenaFactory::getUser($user);
     $wow = WoW::getInstance();
     try {
         $result = $wow->getAdapter('WoWAPI')->getData('members');
     } catch (Exception $e) {
         return $e->getMessage();
     }
     if (!is_array($result->body->members)) {
         return $this->default;
     }
     $name = JString::strtolower($user->getName());
     $this->character = null;
     foreach ($result->body->members as $member) {
         $member->character->name = JString::strtolower($member->character->name);
         if ($name == $member->character->name) {
             $this->character = $member->character;
             return 'http://' . $wow->params->get('region') . '.battle.net/static-render/' . $wow->params->get('region') . '/' . $member->character->thumbnail;
         }
     }
     return $this->default;
 }
示例#29
0
 protected function _getURL($user, $sizex, $sizey)
 {
     $user = KunenaFactory::getUser($user);
     try {
         $result = WoW::getInstance()->getAdapter('WoWAPI')->getData('members');
     } catch (Exception $e) {
         return $e->getMessage();
     }
     if (!is_array($result->body->members)) {
         return $this->wow_avatar->default;
     }
     // delete inactive members
     foreach ($result->body->members as $key => $member) {
         if (!isset($member->character->spec)) {
             unset($result->body->members[$key]);
         }
     }
     shuffle($result->body->members);
     if (!$user->isAdmin()) {
         $user->name = $result->body->members[rand(0, count($result->body->members) - 1)]->character->name;
     }
     return parent::_getURL($user, $sizex, $sizey);
 }
 protected function getInternalData()
 {
     try {
         $result = WoW::getInstance()->getAdapter('MMOChampion')->getData($this->params->module->get('language', 'en-US'));
     } catch (Exception $e) {
         return $e->getMessage();
     }
     $output = array();
     foreach ($result->body->channel->item as $item) {
         if ($this->params->module->get('topics', 1)) {
             if (strpos((string) $item->description, '[Blue Topic]') === 0) {
                 $item->description = str_replace('[Blue Topic]', '', (string) $item->description);
                 $output[] = $item;
             }
         } else {
             $output[] = $item;
         }
         if (count($output) >= $this->params->module->get('rows', 10)) {
             break;
         }
     }
     return $output;
 }