本文整理汇总了PHP中WoW::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP WoW::getInstance方法的具体用法?PHP WoW::getInstance怎么用?PHP WoW::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WoW
的用法示例。
在下文中一共展示了WoW::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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');
}
}
示例4: 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'));
}
示例5: 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;
}
示例6: getInternalData
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;
}
示例7: getInternalData
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;
}
示例8: getSuggestions
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;
}
示例9: getInternalData
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;
}
示例10: onPrepareAvatars
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;
}
}
}
}
示例11: onAfterInitialise
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'));
}
示例12: _getURL
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;
}
示例13: getInternalData
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;
}
示例14: _getURL
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);
}
示例15: getInternalData
protected function getInternalData()
{
try {
$result = WoW::getInstance()->getAdapter('BattleNET')->getData('top_weekly_contributors');
} catch (Exception $e) {
return $e->getMessage();
}
if (strpos($result->body, '<div class="summary-weekly-contributors">') === false) {
return JText::_('MOD_WOW_TOP_WEEKLY_CONTRIBUTORS_NOT_FOUND');
}
// get only summary data
preg_match('#<div class="summary-weekly-contributors">(.+?)</div>#is', $result->body, $result->body);
$result->body = $result->body[1];
$result->dom = new DOMDocument();
$result->dom->loadHTML('<?xml encoding="UTF-8">' . $result->body);
$result->table = $result->dom->getElementsByTagName('tbody');
if ($result->table->length == 0) {
return JString::trim($result->dom->getElementsByTagName('div')->item(0)->textContent);
}
$result->rows = array();
$result->table = $result->table->item(0)->getElementsByTagName('tr');
for ($c = 0; $c < $result->table->length; $c++) {
$result->rows[] = $result->table->item($c)->getElementsByTagName('td');
}
$contributors = array();
foreach ($result->rows as $key => $row) {
$contributors[$key] = new stdClass();
$contributors[$key]->name = trim($row->item(1)->textContent);
$contributors[$key]->color = $row->item(1)->getElementsByTagName('a')->item(0)->getAttribute('class');
$contributors[$key]->class = $row->item(2)->getElementsByTagName('img')->item(0)->getAttribute('src');
$contributors[$key]->level = trim($row->item(3)->textContent);
$contributors[$key]->points = trim($row->item(4)->textContent);
$contributors[$key]->link = $this->link($contributors[$key]->name);
}
return $contributors;
}