本文整理汇总了PHP中WoW类的典型用法代码示例。如果您正苦于以下问题:PHP WoW类的具体用法?PHP WoW怎么用?PHP WoW使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WoW类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetFilterForNPCs
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: main
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: main
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: main
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);
}
示例5: getInternalData
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;
}
示例6: getInternalData
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;
}
示例7: GetTopTeams
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: main
public function main()
{
if (!WoWConfig::$Maintenance) {
WoW::RedirectTo();
return;
}
WoW_Template::LoadTemplate('page_maintenance', true);
}
示例9: main
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: onAfterInitialise
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');
}
}
示例11: getInternalData
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'));
}
示例12: main
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');
}
示例13: main
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');
}
示例14: main
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');
}
示例15: checkGuildExists
/**
* @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;
}