Skip to content

Commit

Permalink
[456] Find realm ID in Armory::$realmData, not in DB. Drop `armory_re…
Browse files Browse the repository at this point in the history
…alm_data` table. Load only necessary data from DB in Characters::BuildCharacter(). Small code improvements.
  • Loading branch information
Shadez committed Jan 17, 2011
1 parent d2f61d1 commit adcc3c4
Show file tree
Hide file tree
Showing 31 changed files with 222 additions and 259 deletions.
8 changes: 4 additions & 4 deletions character-achievements.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 450
* @revision 456
* @copyright (c) 2009-2011 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -76,7 +76,7 @@
$characters->BuildCharacter($name, $realmId, true, true);
$isCharacter = $characters->CheckPlayer();
$achievements = $characters->GetAchievementMgr();
if($_GET['r'] === false || !Armory::$currentRealmInfo) {
if($_GET['r'] === false || !$characters->GetRealmName()) {
$isCharacter = false;
}
// Get page cache
Expand All @@ -86,15 +86,15 @@
$cache_id = $utils->GenerateCacheId('character-achievements-c'.$achievement_category, $utils->GenerateCacheIdForComparisons($comparisonData));
}
else {
$cache_id = $utils->GenerateCacheId('character-achievements-c'.$achievement_category, $characters->GetName(), Armory::$currentRealmInfo['name']);
$cache_id = $utils->GenerateCacheId('character-achievements-c'.$achievement_category, $characters->GetName(), $characters->GetRealmName());
}
}
else {
if(is_array($comparisonData)) {
$cache_id = $utils->GenerateCacheId('character-achievements', $utils->GenerateCacheIdForComparisons($comparisonData));
}
else {
$cache_id = $utils->GenerateCacheId('character-achievements', $characters->GetName(), Armory::$currentRealmInfo['name']);
$cache_id = $utils->GenerateCacheId('character-achievements', $characters->GetName(), $characters->GetRealmName());
}
}
if($cache_data = $utils->GetCache($cache_id)) {
Expand Down
6 changes: 3 additions & 3 deletions character-arenateams.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 450
* @revision 456
* @copyright (c) 2009-2011 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -47,12 +47,12 @@
$realmId = $utils->GetRealmIdByName($_GET['r']);
$characters->BuildCharacter($name, $realmId, true, true);
$isCharacter = $characters->CheckPlayer();
if($_GET['r'] === false || !Armory::$currentRealmInfo) {
if($_GET['r'] === false || !$characters->GetRealmName()) {
$isCharacter = false;
}
// Get page cache
if($characters->GetGUID() > 0 && $isCharacter && Armory::$armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) {
$cache_id = $utils->GenerateCacheId('character-arenateams', $characters->GetName(), Armory::$currentRealmInfo['name']);
$cache_id = $utils->GenerateCacheId('character-arenateams', $characters->GetName(), $characters->GetRealmName());
if($cache_data = $utils->GetCache($cache_id)) {
echo $cache_data;
echo sprintf('<!-- Restored from cache; id: %s -->', $cache_id);
Expand Down
6 changes: 3 additions & 3 deletions character-calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 450
* @revision 465
* @copyright (c) 2009-2011 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -45,12 +45,12 @@
$characters->BuildCharacter($name, $realmId, true, true);
$isCharacter = $characters->CheckPlayer();
$achievements = $characters->GetAchievementMgr();
if($_GET['r'] === false || !Armory::$currentRealmInfo) {
if($_GET['r'] === false || !$characters->GetRealmName()) {
$isCharacter = false;
}
// Get page cache
if($isCharacter && Armory::$armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) {
$cache_id = $utils->GenerateCacheId('character-calendar', $characters->GetName(), Armory::$currentRealmInfo['name']);
$cache_id = $utils->GenerateCacheId('character-calendar', $characters->GetName(), $characters->GetRealmName());
if($cache_data = $utils->GetCache($cache_id)) {
echo $cache_data;
echo sprintf('<!-- Restored from cache; id: %s -->', $cache_id);
Expand Down
6 changes: 4 additions & 2 deletions character-feed-atom.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 450
* @revision 456
* @copyright (c) 2009-2011 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -48,9 +48,11 @@
$_GET['r'] = false;
}
$realmId = $utils->GetRealmIdByName($_GET['r']);
$characters->SetOptions(LOAD_NOTHING);
$characters->SetOptions(array('load_feeds' => true));
$characters->BuildCharacter($name, $realmId, true, true);
$isCharacter = $characters->CheckPlayer();
if($_GET['r'] === false || !Armory::$currentRealmInfo) {
if($_GET['r'] === false || !$characters->GetRealmName()) {
$isCharacter = false;
}
header('Content-type: text/xml');
Expand Down
10 changes: 6 additions & 4 deletions character-feed-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 450
* @revision 456
* @copyright (c) 2009-2011 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -42,9 +42,11 @@
$_GET['r'] = false;
}
$realmId = $utils->GetRealmIdByName($_GET['r']);
$characters->SetOptions(LOAD_NOTHING);
$characters->SetOptions(array('load_feeds' => true));
$characters->BuildCharacter($name, $realmId, true, true);
$isCharacter = $characters->CheckPlayer();
if($_GET['r'] === false || !Armory::$currentRealmInfo) {
if($_GET['r'] === false || !$characters->GetRealmName()) {
$isCharacter = false;
}
// Get page cache
Expand All @@ -61,7 +63,7 @@
$cache_name = 'character-feed-data';
}
if($isCharacter && Armory::$armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) {
$cache_id = $utils->GenerateCacheId($cache_name, $characters->GetName(), Armory::$currentRealmInfo['name']);
$cache_id = $utils->GenerateCacheId($cache_name, $characters->GetName(), $characters->GetRealmName());
if($cache_data = $utils->GetCache($cache_id)) {
echo $cache_data;
echo sprintf('<!-- Restored from cache; id: %s -->', $cache_id);
Expand All @@ -83,7 +85,7 @@
}
$xml->XMLWriter()->startElement('character');
$xml->XMLWriter()->writeAttribute('name', $characters->GetName());
$xml->XMLWriter()->writeAttribute('characterUrl', sprintf('r=%s&cn=%s', urlencode(Armory::$currentRealmInfo['name']), urlencode($characters->GetName())));
$xml->XMLWriter()->writeAttribute('characterUrl', sprintf('r=%s&cn=%s', urlencode($characters->GetRealmName()), urlencode($characters->GetName())));
$xml->XMLWriter()->endElement(); //character
if(isset($feed_item['title'])) {
$xml->XMLWriter()->startElement('title');
Expand Down
4 changes: 2 additions & 2 deletions character-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 450
* @revision 456
* @copyright (c) 2009-2011 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -44,7 +44,7 @@
$realmId = $utils->GetRealmIdByName($_GET['r']);
$characters->BuildCharacter($name, $realmId, true, true);
$isCharacter = $characters->CheckPlayer();
if($_GET['r'] === false || !Armory::$currentRealmInfo) {
if($_GET['r'] === false || !$characters->GetRealmName()) {
$isCharacter = false;
}
$tabUrl = $characters->GetUrlString();
Expand Down
6 changes: 3 additions & 3 deletions character-model-embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 450
* @revision 456
* @copyright (c) 2009-2011 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -45,12 +45,12 @@
$characters->BuildCharacter($name, $realmId, true, true);
$isCharacter = $characters->CheckPlayer();
$achievements = $characters->GetAchievementMgr();
if($_GET['r'] === false || !Armory::$currentRealmInfo) {
if($_GET['r'] === false || !$characters->GetRealmName()) {
$isCharacter = false;
}
// Get page cache
if($isCharacter && Armory::$armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) {
$cache_id = $utils->GenerateCacheId('character-model-embed', $characters->GetName(), Armory::$currentRealmInfo['name']);
$cache_id = $utils->GenerateCacheId('character-model-embed', $characters->GetName(), $characters->GetRealmName());
if($cache_data = $utils->GetCache($cache_id)) {
echo $cache_data;
echo sprintf('<!-- Restored from cache; id: %s -->', $cache_id);
Expand Down
11 changes: 6 additions & 5 deletions character-model.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 450
* @revision 456
* @copyright (c) 2009-2011 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -42,14 +42,15 @@
$_GET['r'] = false;
}
$realmId = $utils->GetRealmIdByName($_GET['r']);
$characters->SetOptions(LOAD_NOTHING);
$characters->BuildCharacter($name, $realmId, true, true, 1);
$isCharacter = $characters->CheckPlayer();
if($_GET['r'] === false || !Armory::$currentRealmInfo) {
if($_GET['r'] === false || !$characters->GetRealmName()) {
$isCharacter = false;
}
// Get page cache
if($isCharacter && Armory::$armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) {
$cache_id = $utils->GenerateCacheId('character-model', $characters->GetName(), Armory::$currentRealmInfo['name']);
$cache_id = $utils->GenerateCacheId('character-model', $characters->GetName(), $characters->GetRealmName());
if($cache_data = $utils->GetCache($cache_id)) {
echo $cache_data;
echo sprintf('<!-- Restored from cache; id: %s -->', $cache_id);
Expand All @@ -64,7 +65,7 @@
$xml->XMLWriter()->startElement('tabInfo');
$xml->XMLWriter()->writeAttribute('tab', 'character');
$xml->XMLWriter()->writeAttribute('tabGroup', 'character');
$xml->XMLWriter()->writeAttribute('tabUrl', ($isCharacter) ? sprintf('r=%s&cn=%s', urlencode(Armory::$currentRealmInfo['name']), urlencode($characters->GetName())) : null);
$xml->XMLWriter()->writeAttribute('tabUrl', ($isCharacter) ? sprintf('r=%s&cn=%s', urlencode($characters->GetRealmName()), urlencode($characters->GetName())) : null);
$xml->XMLWriter()->endElement(); //tabInfo
if(!$isCharacter) {
$xml->XMLWriter()->startElement('characterInfo');
Expand Down Expand Up @@ -126,7 +127,7 @@
);

$xml->XMLWriter()->startElement('character');
if($utils->IsAccountHaveCurrentCharacter($characters->GetGUID(), Armory::$currentRealmInfo['id'])) {
if($utils->IsAccountHaveCurrentCharacter($characters->GetGUID(), $characters->GetRealmID())) {
$xml->XMLWriter()->writeAttribute('owned', 1);
}
$xml->XMLWriter()->startElement('models');
Expand Down
6 changes: 3 additions & 3 deletions character-reputation.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 450
* @revision 456
* @copyright (c) 2009-2011 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -45,12 +45,12 @@
$characters->BuildCharacter($name, $realmId, true, true);
$isCharacter = $characters->CheckPlayer();
$achievements = $characters->GetAchievementMgr();
if($_GET['r'] === false || !Armory::$currentRealmInfo) {
if($_GET['r'] === false || !$characters->GetRealmName()) {
$isCharacter = false;
}
// Get page cache
if($isCharacter && Armory::$armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) {
$cache_id = $utils->GenerateCacheId('character-reputation', $characters->GetName(), Armory::$currentRealmInfo['name']);
$cache_id = $utils->GenerateCacheId('character-reputation', $characters->GetName(), $characters->GetRealmName());
if($cache_data = $utils->GetCache($cache_id)) {
echo $cache_data;
echo sprintf('<!-- Restored from cache; id: %s -->', $cache_id);
Expand Down
7 changes: 4 additions & 3 deletions character-sheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 450
* @revision 456
* @copyright (c) 2009-2011 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -47,14 +47,15 @@
$_GET['r'] = false;
}
$realmId = $utils->GetRealmIdByName($_GET['r']);
$characters->SetOptions(LOAD_ALL);
$characters->BuildCharacter($name, $realmId, true, true);
$isCharacter = $characters->CheckPlayer();
if($_GET['r'] === false || !Armory::$currentRealmInfo) {
if($_GET['r'] === false || !$characters->GetRealmName()) {
$isCharacter = false;
}
// Get page cache
if($isCharacter && Armory::$armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) {
$cache_id = $utils->GenerateCacheId('character-sheet', $characters->GetName(), Armory::$currentRealmInfo['name']);
$cache_id = $utils->GenerateCacheId('character-sheet', $characters->GetName(), $characters->GetRealmName());
if($cache_data = $utils->GetCache($cache_id)) {
echo $cache_data;
echo sprintf('<!-- Restored from cache; id: %s -->', $cache_id);
Expand Down
9 changes: 4 additions & 5 deletions character-statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 450
* @revision 465
* @copyright (c) 2009-2011 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -67,14 +67,13 @@
$i++;
}
}
//
$name = $comparisonData[0]['name'];
}
$realmId = $utils->GetRealmIdByName($_GET['r']);
$characters->BuildCharacter($name, $realmId, true, true);
$isCharacter = $characters->CheckPlayer();
$achievements = $characters->GetAchievementMgr();
if($_GET['r'] === false || !Armory::$currentRealmInfo) {
if($_GET['r'] === false || !$characters->GetRealmName()) {
$isCharacter = false;
}
// Get page cache
Expand All @@ -84,15 +83,15 @@
$cache_id = $utils->GenerateCacheId('character-statistics-c'.$achievement_category, $utils->GenerateCacheIdForComparisons($comparisonData));
}
else {
$cache_id = $utils->GenerateCacheId('character-statistics-c'.$achievement_category, $characters->GetName(), Armory::$currentRealmInfo['name']);
$cache_id = $utils->GenerateCacheId('character-statistics-c'.$achievement_category, $characters->GetName(), $characters->GetRealmName());
}
}
else {
if(is_array($comparisonData)) {
$cache_id = $utils->GenerateCacheId('character-statistics', $utils->GenerateCacheIdForComparisons($comparisonData));
}
else {
$cache_id = $utils->GenerateCacheId('character-statistics', $characters->GetName(), Armory::$currentRealmInfo['name']);
$cache_id = $utils->GenerateCacheId('character-statistics', $characters->GetName(), $characters->GetRealmName());
}
}
if($cache_data = $utils->GetCache($cache_id)) {
Expand Down
4 changes: 2 additions & 2 deletions character-talents.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
$realmId = $utils->GetRealmIdByName($_GET['r']);
$characters->BuildCharacter($name, $realmId, true, true);
$isCharacter = $characters->CheckPlayer();
if($_GET['r'] === false || !Armory::$currentRealmInfo) {
if($_GET['r'] === false || !$characters->GetRealmName()) {
$isCharacter = false;
}
// Get page cache
if($isCharacter && Armory::$armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) {
$cache_id = $utils->GenerateCacheId('character-talents', $characters->GetName(), Armory::$currentRealmInfo['name']);
$cache_id = $utils->GenerateCacheId('character-talents', $characters->GetName(), $characters->GetRealmName());
if($cache_data = $utils->GetCache($cache_id)) {
echo $cache_data;
echo sprintf('<!-- Restored from cache; id: %s -->', $cache_id);
Expand Down
5 changes: 2 additions & 3 deletions guild-bank-contents.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 455
* @revision 456
* @copyright (c) 2009-2011 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -37,8 +37,7 @@
else {
$guilds->guildName = false;
}
$serverType = Armory::$aDB->selectCell("SELECT `type` FROM `ARMORYDBPREFIX_realm_data` WHERE `name` = '%s' LIMIT 1", $utils->escape($_GET['r']));
$isGuild = $guilds->InitGuild($serverType);
$isGuild = $guilds->InitGuild(Armory::$currentRealmInfo['type']);
if(!$isGuild) {
// Load XSLT template
$xml->LoadXSLT('error/error.xsl');
Expand Down
5 changes: 2 additions & 3 deletions guild-bank-log.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 455
* @revision 456
* @copyright (c) 2009-2011 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -36,8 +36,7 @@
else {
$guilds->guildName = false;
}
$serverType = Armory::$aDB->selectCell("SELECT `type` FROM `ARMORYDBPREFIX_realm_data` WHERE `name` = '%s' LIMIT 1", $utils->escape($_GET['r']));
$isGuild = $guilds->InitGuild($serverType);
$isGuild = $guilds->InitGuild(Armory::$currentRealmInfo['type']);
if(!$isGuild) {
// Load XSLT template
$xml->LoadXSLT('error/error.xsl');
Expand Down
5 changes: 2 additions & 3 deletions guild-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 450
* @revision 456
* @copyright (c) 2009-2011 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -36,8 +36,7 @@
else {
$guilds->guildName = false;
}
$serverType = Armory::$aDB->selectCell("SELECT `type` FROM `ARMORYDBPREFIX_realm_data` WHERE `name` = '%s' LIMIT 1", $utils->escape($_GET['r']));
$isGuild = $guilds->InitGuild($serverType);
$isGuild = $guilds->InitGuild(Armory::$currentRealmInfo['type']);
if(!$isGuild) {
// Load XSLT template
$xml->LoadXSLT('error/error.xsl');
Expand Down
Loading

0 comments on commit adcc3c4

Please sign in to comment.