Skip to content

Commit

Permalink
[168] Implemented multi realms support. For more info read comments i…
Browse files Browse the repository at this point in the history
…n configuration.php
  • Loading branch information
Shadez committed Apr 29, 2010
1 parent c7ad6cc commit 7ccce63
Show file tree
Hide file tree
Showing 20 changed files with 352 additions and 201 deletions.
21 changes: 12 additions & 9 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 Candidate 1
* @revision 149
* @revision 168
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -55,13 +55,16 @@
$isCharacter = $characters->IsCharacter();
$characters->_structCharacter();
$achievements->guid = $characters->guid;
if(!isset($_GET['r']) || !$armory->currentRealmInfo) {
$isCharacter = false;
}
// Get page cache
if($characters->guid > 0 && $isCharacter && $armory->armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) {
if($achievement_category > 0) {
$cache_id = $utils->GenerateCacheId('character-achievements-c'.$achievement_category, $characters->name, $armory->armoryconfig['defaultRealmName']);
$cache_id = $utils->GenerateCacheId('character-achievements-c'.$achievement_category, $characters->name, $armory->currentRealmInfo['name']);
}
else {
$cache_id = $utils->GenerateCacheId('character-achievements', $characters->name, $armory->armoryconfig['defaultRealmName']);
$cache_id = $utils->GenerateCacheId('character-achievements', $characters->name, $armory->currentRealmInfo['name']);
}
if($cache_data = $utils->GetCache($cache_id)) {
echo $cache_data;
Expand Down Expand Up @@ -162,12 +165,12 @@
$tabUrl = false;
$guilds->guid = $characters->guid;
if($isCharacter && $guilds->extractPlayerGuildId()) {
$tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName()));
$charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName()));
$tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName()));
$charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName()));
}
elseif($isCharacter) {
$tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name));
$charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name));
$tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name));
$charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name));
}
/** Header **/
$xml->XMLWriter()->startElement('page');
Expand Down Expand Up @@ -201,15 +204,15 @@
'gender' => '',
'genderId' => $characters->gender,
'guildName' => ($guilds->guid) ? $guilds->guildName : '',
'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($guilds->guildName)) : '',
'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($guilds->guildName)) : '',
'lastModified' => '',
'level' => $characters->level,
'name' => $characters->name,
'points' => $achievements->CalculateAchievementPoints(),
'prefix' => $characters->character_title['prefix'],
'race' => $characters->returnRaceText(),
'raceId' => $characters->race,
'realm' => $armory->armoryconfig['defaultRealmName'],
'realm' => $armory->currentRealmInfo['name'],
'suffix' => $characters->character_title['suffix'],
'titeId' => $characters->character_title['titleId'],
);
Expand Down
19 changes: 11 additions & 8 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 Candidate 1
* @revision 149
* @revision 168
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -44,9 +44,12 @@
}
$characters->GetCharacterGuid();
$isCharacter = $characters->IsCharacter();
if(!isset($_GET['r']) || !$armory->currentRealmInfo) {
$isCharacter = false;
}
// Get page cache
if($characters->guid > 0 && $isCharacter && $armory->armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) {
$cache_id = $utils->GenerateCacheId('character-arenateams', $characters->name, $armory->armoryconfig['defaultRealmName']);
$cache_id = $utils->GenerateCacheId('character-arenateams', $characters->name, $armory->currentRealmInfo['name']);
if($cache_data = $utils->GetCache($cache_id)) {
echo $cache_data;
echo sprintf('<!-- Restored from cache; id: %s -->', $cache_id);
Expand All @@ -59,12 +62,12 @@
$arenateams->guid = $characters->guid;
$tabUrl = false;
if($isCharacter && $guilds->extractPlayerGuildId()) {
$tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName()));
$charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName()));
$tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName()));
$charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName()));
}
elseif($isCharacter) {
$tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name));
$charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name));
$tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name));
$charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name));
}
/** Header **/
$xml->XMLWriter()->startElement('page');
Expand Down Expand Up @@ -99,15 +102,15 @@
'gender' => '',
'genderId' => $characters->gender,
'guildName' => ($guilds->guildName) ? $guilds->guildName : '',
'guildUrl' => ($guilds->guildName) ? sprintf('r=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($guilds->guildName)) : '',
'guildUrl' => ($guilds->guildName) ? sprintf('r=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($guilds->guildName)) : '',
'lastModified' => '',
'level' => $characters->level,
'name' => $characters->name,
'points' => $achievements->CalculateAchievementPoints(),
'prefix' => (isset($characters->character_title['prefix'])) ? $characters->character_title['prefix'] : null,
'race' => $characters->returnRaceText(),
'raceId' => $characters->race,
'realm' => $armory->armoryconfig['defaultRealmName'],
'realm' => $armory->currentRealmInfo['name'],
'suffix' => (isset($characters->character_title['suffix'])) ? $characters->character_title['suffix'] : null,
'titeId' => (isset($characters->character_title['titleId'])) ? $characters->character_title['titleId'] : null,
);
Expand Down
19 changes: 11 additions & 8 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 Candidate 1
* @revision 149
* @revision 168
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -43,9 +43,12 @@
$isCharacter = $characters->IsCharacter();
$characters->_structCharacter();
$achievements->guid = $characters->guid;
if(!isset($_GET['r']) || !$armory->currentRealmInfo) {
$isCharacter = false;
}
// Get page cache
if($characters->guid > 0 && $isCharacter && $armory->armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) {
$cache_id = $utils->GenerateCacheId('character-calendar', $characters->name, $armory->armoryconfig['defaultRealmName']);
$cache_id = $utils->GenerateCacheId('character-calendar', $characters->name, $armory->currentRealmInfo['name']);
if($cache_data = $utils->GetCache($cache_id)) {
echo $cache_data;
echo sprintf('<!-- Restored from cache; id: %s -->', $cache_id);
Expand All @@ -56,12 +59,12 @@
$tabUrl = false;
$guilds->guid = $characters->guid;
if($isCharacter && $guilds->extractPlayerGuildId()) {
$tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName()));
$charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName()));
$tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName()));
$charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName()));
}
elseif($isCharacter) {
$tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name));
$charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name));
$tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name));
$charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name));
}
/** Header **/
// Load XSLT template
Expand Down Expand Up @@ -98,15 +101,15 @@
'gender' => '',
'genderId' => $characters->gender,
'guildName' => ($guilds->guid) ? $guilds->guildName : '',
'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($guilds->guildName)) : '',
'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($guilds->guildName)) : '',
'lastModified' => '',
'level' => $characters->level,
'name' => $characters->name,
'points' => $achievements->CalculateAchievementPoints(),
'prefix' => $characters->character_title['prefix'],
'race' => $characters->returnRaceText(),
'raceId' => $characters->race,
'realm' => $armory->armoryconfig['defaultRealmName'],
'realm' => $armory->currentRealmInfo['name'],
'suffix' => $characters->character_title['suffix'],
'titeId' => $characters->character_title['titleId'],
);
Expand Down
7 changes: 5 additions & 2 deletions character-feed-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
}
$characters->GetCharacterGuid();
$isCharacter = $characters->IsCharacter();
if(!isset($_GET['r']) || !$armory->currentRealmInfo) {
$isCharacter = false;
}
// Get page cache
if(isset($_GET['full'])) {
if($isCharacter) {
Expand All @@ -54,7 +57,7 @@
$cache_name = 'character-feed-data';
}
if($characters->guid > 0 && $isCharacter && $armory->armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) {
$cache_id = $utils->GenerateCacheId($cache_name, $characters->name, $armory->armoryconfig['defaultRealmName']);
$cache_id = $utils->GenerateCacheId($cache_name, $characters->name, $armory->currentRealmInfo['name']);
if($cache_data = $utils->GetCache($cache_id)) {
echo $cache_data;
echo sprintf('<!-- Restored from cache; id: %s -->', $cache_id);
Expand All @@ -76,7 +79,7 @@
}
$xml->XMLWriter()->startElement('character');
$xml->XMLWriter()->writeAttribute('name', $characters->name);
$xml->XMLWriter()->writeAttribute('characterUrl', sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)));
$xml->XMLWriter()->writeAttribute('characterUrl', sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)));
$xml->XMLWriter()->endElement(); //character
if(isset($feed_item['title'])) {
$xml->XMLWriter()->startElement('title');
Expand Down
17 changes: 10 additions & 7 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 Candidate 1
* @revision 160
* @revision 168
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -42,18 +42,21 @@
$characters->GetCharacterGuid();
$isCharacter = $characters->IsCharacter();
$characters->_structCharacter();
if(!isset($_GET['r']) || !$armory->currentRealmInfo) {
$isCharacter = false;
}
/** Basic info **/
$tabUrl = false;
$achievements->guid = $characters->guid;
$guilds->guid = $characters->guid;
$arenateams->guid = $characters->guid;
if($isCharacter && $guilds->extractPlayerGuildId()) {
$tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName()));
$charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName()));
$tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName()));
$charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName()));
}
elseif($isCharacter) {
$tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name));
$charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name));
$tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name));
$charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name));
}
$xml->LoadXSLT('character/feed.xsl');
/** Header **/
Expand Down Expand Up @@ -90,15 +93,15 @@
'gender' => null,
'genderId' => $characters->gender,
'guildName' => ($guilds->guid) ? $guilds->guildName : null,
'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($guilds->guildName)) : null,
'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($guilds->guildName)) : null,
'lastModified' => null,
'level' => $characters->level,
'name' => $characters->name,
'points' => $achievements->CalculateAchievementPoints(),
'prefix' => $characters->character_title['prefix'],
'race' => $characters->returnRaceText(),
'raceId' => $characters->race,
'realm' => $armory->armoryconfig['defaultRealmName'],
'realm' => $armory->currentRealmInfo['name'],
'suffix' => $characters->character_title['suffix'],
'titeId' => $characters->character_title['titleId'],
);
Expand Down
9 changes: 6 additions & 3 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 Candidate 1
* @revision 146
* @revision 168
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -40,9 +40,12 @@
}
$characters->GetCharacterGuid();
$isCharacter = $characters->IsCharacter();
if(!isset($_GET['r']) || !$armory->currentRealmInfo) {
$isCharacter = false;
}
// Get page cache
if($characters->guid > 0 && $isCharacter && $armory->armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) {
$cache_id = $utils->GenerateCacheId('character-model', $characters->name, $armory->armoryconfig['defaultRealmName']);
$cache_id = $utils->GenerateCacheId('character-model', $characters->name, $armory->currentRealmInfo['name']);
if($cache_data = $utils->GetCache($cache_id)) {
echo $cache_data;
echo sprintf('<!-- Restored from cache; id: %s -->', $cache_id);
Expand All @@ -57,7 +60,7 @@
$xml->XMLWriter()->startElement('tabInfo');
$xml->XMLWriter()->writeAttribute('tab', 'character');
$xml->XMLWriter()->writeAttribute('tabGroup', 'character');
$xml->XMLWriter()->writeAttribute('tabUrl', ($characters->IsCharacter()) ? sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name)) : '' );
$xml->XMLWriter()->writeAttribute('tabUrl', ($characters->IsCharacter()) ? sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name)) : '' );
$xml->XMLWriter()->endElement(); //tabInfo
if(!$isCharacter) {
$xml->XMLWriter()->startElement('characterInfo');
Expand Down
19 changes: 11 additions & 8 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 Candidate 1
* @revision 149
* @revision 168
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -43,9 +43,12 @@
$isCharacter = $characters->IsCharacter();
$characters->_structCharacter();
$achievements->guid = $characters->guid;
if(!isset($_GET['r']) || !$armory->currentRealmInfo) {
$isCharacter = false;
}
// Get page cache
if($characters->guid > 0 && $isCharacter && $armory->armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) {
$cache_id = $utils->GenerateCacheId('character-reputation', $characters->name, $armory->armoryconfig['defaultRealmName']);
$cache_id = $utils->GenerateCacheId('character-reputation', $characters->name, $armory->currentRealmInfo['name']);
if($cache_data = $utils->GetCache($cache_id)) {
echo $cache_data;
echo sprintf('<!-- Restored from cache; id: %s -->', $cache_id);
Expand All @@ -58,12 +61,12 @@
$tabUrl = false;
$guilds->guid = $characters->guid;
if($isCharacter && $guilds->extractPlayerGuildId()) {
$tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName()));
$charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name), urlencode($guilds->getGuildName()));
$tabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName()));
$charTabUrl = sprintf('r=%s&cn=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name), urlencode($guilds->getGuildName()));
}
elseif($isCharacter) {
$tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name));
$charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($characters->name));
$tabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name));
$charTabUrl = sprintf('r=%s&cn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($characters->name));
}
/** Header **/
$xml->XMLWriter()->startElement('page');
Expand Down Expand Up @@ -98,15 +101,15 @@
'gender' => '',
'genderId' => $characters->gender,
'guildName' => ($guilds->guid) ? $guilds->guildName : '',
'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->armoryconfig['defaultRealmName']), urlencode($guilds->guildName)) : '',
'guildUrl' => ($guilds->guid) ? sprintf('r=%s&gn=%s', urlencode($armory->currentRealmInfo['name']), urlencode($guilds->guildName)) : '',
'lastModified' => '',
'level' => $characters->level,
'name' => $characters->name,
'points' => $achievements->CalculateAchievementPoints(),
'prefix' => $characters->character_title['prefix'],
'race' => $characters->returnRaceText(),
'raceId' => $characters->race,
'realm' => $armory->armoryconfig['defaultRealmName'],
'realm' => $armory->currentRealmInfo['name'],
'suffix' => $characters->character_title['suffix'],
'titeId' => $characters->character_title['titleId'],
);
Expand Down
Loading

1 comment on commit 7ccce63

@Shadez
Copy link
Owner Author

@Shadez Shadez commented on 7ccce63 Apr 29, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For users who has realm names with Cyrillic or some language-specific chars: configuration.php should be saved in UTF8 charset (without BOM)

Please sign in to comment.