Skip to content

Commit

Permalink
[366] Implement achievement comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadez committed Aug 21, 2010
1 parent c3b1e4f commit 8f2b649
Show file tree
Hide file tree
Showing 6 changed files with 291 additions and 132 deletions.
2 changes: 1 addition & 1 deletion _layout/character/achievements-async.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
<xsl:choose>
<xsl:when test="@dateCompleted">
<div class="comp_points"><xsl:value-of select="../@points"/></div>
<div class="comp_date">[<xsl:apply-templates select="@dateCompleted" mode="format-date"/>]</div>
<div class="comp_date">[<xsl:value-of select="@dateCompleted"/>]</div>
</xsl:when>
<xsl:otherwise>
&#8212;
Expand Down
389 changes: 268 additions & 121 deletions character-achievements.php

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions includes/classes/class.armory.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 357
* @revision 366
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -83,7 +83,14 @@ public function Armory() {
$this->aDB = new ArmoryDatabaseHandler($this->mysqlconfig['host_armory'], $this->mysqlconfig['user_armory'], $this->mysqlconfig['pass_armory'], $this->mysqlconfig['name_armory'], $this->mysqlconfig['charset_armory'], $this->Log(), $this->armoryconfig['db_prefix']);
$this->rDB = new ArmoryDatabaseHandler($this->mysqlconfig['host_realmd'], $this->mysqlconfig['user_realmd'], $this->mysqlconfig['pass_realmd'], $this->mysqlconfig['name_realmd'], $this->mysqlconfig['charset_realmd'], $this->Log());
if(isset($_GET['r'])) {
$realmName = urldecode($_GET['r']);
if(preg_match('/,/', $_GET['r'])) {
// Achievements/statistics comparison
$rData = explode(',', $_GET['r']);
$realmName = urldecode($rData[0]);
}
else {
$realmName = urldecode($_GET['r']);
}
$realm_info = $this->aDB->selectRow("SELECT `id`, `version` FROM `ARMORYDBPREFIX_realm_data` WHERE `name`='%s'", $realmName);
if(isset($this->realmData[$realm_info['id']])) {
$this->connectionData = $this->realmData[$realm_info['id']];
Expand All @@ -102,10 +109,10 @@ public function Armory() {
$this->wDB = new ArmoryDatabaseHandler($realm_info['host_world'], $realm_info['user_world'], $realm_info['pass_world'], $realm_info['name_world'], $realm_info['charset_world'], $this->Log());
}
if(!$this->currentRealmInfo) {
$this->currentRealmInfo = array('name' => $this->realmData[1]['name'], 'id' => 1, 'type' => $this->realmData[1]['type'], 'connected' => true);
$this->currentRealmInfo = array('name' => $realm_info['name'], 'id' => 1, 'type' => $realm_info['type'], 'connected' => true);
}
if(!$this->connectionData) {
$this->connectionData = $this->realmData[1];
$this->connectionData = $realm_info;
}
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$user_locale = strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2));
Expand Down
6 changes: 5 additions & 1 deletion includes/classes/class.characters.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 365
* @revision 366
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -669,6 +669,10 @@ public function GetMoney() {
}

public function GetAchievementMgr() {
if(!is_object($this->m_achievementMgr)) {
$this->m_achievementMgr = new Achievements;
$this->m_achievementMgr->InitAchievements($this->GetGUID(), $this->db, true);
}
return $this->m_achievementMgr;
}

Expand Down
9 changes: 5 additions & 4 deletions includes/classes/class.utils.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 365
* @revision 366
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -901,6 +901,9 @@ public function IsRealm($rName) {
* @return array
**/
public function GetRealmIdByName($rName) {
if($realms = explode(',', $rName)) {
$rName = $realms[0];
}
return self::IsRealm($rName);
}

Expand Down Expand Up @@ -1034,7 +1037,6 @@ public function IsWriteRaw() {

public function IsAchievementsComparison($returnFirstRealmName = false) {
if(!isset($_GET['r']) || (!isset($_GET['cn']) && !isset($_GET['n']))) {
$this->Log()->writeError('%s : realms names or characters names not provided', __METHOD__);
return false;
}
$realms = explode(',', $_GET['r']);
Expand All @@ -1045,7 +1047,6 @@ public function IsAchievementsComparison($returnFirstRealmName = false) {
$chars = explode(',', $_GET['cn']);
}
if(!is_array($realms) || !is_array($chars)) {
$this->Log()->writeError('%s : wrong data', __METHOD__);
return false;
}
$countR = count($realms);
Expand All @@ -1061,7 +1062,7 @@ public function IsAchievementsComparison($returnFirstRealmName = false) {
$data = array();
for($i = 0; $i < $totalCount; $i++) {
if(!isset($realms[$i]) || !isset($chars[$i])) {
$this->Log()->writeError('%s : missed data for %d count, ignore.', __METHOD__, $i);
$this->Log()->writeError('%s : missed data for %d loop, ignore.', __METHOD__, $i);
continue;
}
$data[$i] = array('name' => $chars[$i], 'realm' => $realms[$i]);
Expand Down
2 changes: 1 addition & 1 deletion includes/revision_nr.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
define('ARMORY_REVISION', 365);
define('ARMORY_REVISION', 366);
define('DB_VERSION', 'armory_r361');
define('CONFIG_VERSION', '0708201001');
?>

0 comments on commit 8f2b649

Please sign in to comment.