Skip to content

Commit

Permalink
[95] Use $armory->_locale instead of in-functions checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadez committed Feb 28, 2010
1 parent d943670 commit d317ca9
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 238 deletions.
4 changes: 2 additions & 2 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 Candidate 1
* @revision 75
* @revision 95
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -108,7 +108,7 @@
}
$tp .= $characters->talentCounting($characters->getTabOrBuild($characters->class, 'tab', $i));
}
if($tp == ' / / ') {
if($tp == ' / / ' || $tp == '0 / 0 / 0') {
// No talents
$armory->tpl->assign('talents_builds', '');
$armory->tpl->assign('treeName', $armory->tpl->get_config_vars('armory_character_sheet_na_dualspec'));
Expand Down
5 changes: 2 additions & 3 deletions includes/armory_loader.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 94
* @revision 95
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -31,7 +31,7 @@
die('<b>Error:</b> can not load connector class!');
}

define('DB_VERSION', 'armory_r94');
define('DB_VERSION', 'armory_r95');
$armory = new Connector;
$armory->tpl->template_dir = 'includes/template/';
$armory->tpl->compile_dir = 'includes/cache/';
Expand Down Expand Up @@ -109,7 +109,6 @@
header('Location: '.$returnUrl);
}
$_locale = (isset($_SESSION['armoryLocale'])) ? $_SESSION['armoryLocale'] : $armory->armoryconfig['defaultLocale'];
$armory->_locale = $_locale;
$armory->tpl->assign('menu_file', 'overall_menu_'.$_locale);
$armory->tpl->config_load($_locale . '.conf');

Expand Down
72 changes: 7 additions & 65 deletions includes/classes/class.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 65
* @revision 95
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -172,7 +172,6 @@ public function GetLastAchievements() {
if(!$this->guid) {
return false;
}
$locale = (isset($_SESSION['armoryLocale'])) ? $_SESSION['armoryLocale'] : $this->armoryconfig['defaultLocale'];
$achievements = $this->cDB->select("SELECT `achievement`, `date` FROM `character_achievement` WHERE `guid`=? ORDER BY `date` DESC LIMIT 5", $this->guid);
$aCount = count($achievements);
for($i=0;$i<$aCount;$i++) {
Expand Down Expand Up @@ -305,8 +304,7 @@ public function AchievementProgress() {
if($i%2) {
$tmp_str .= " style='float:left;'";
}
$_locale = (isset($_SESSION['armoryLocale'])) ? $_SESSION['armoryLocale'] : $this->armoryconfig['defaultLocale'];
$tmp_str .= '>'.$criteria['name_'.$_locale].'</li>';
$tmp_str .= '>'.$criteria['name_'.$this->_locale].'</li>';
$i++;
}
$string_return = str_replace("{CRITERIA_LIST}", $tmp_str, $progress_list_string);
Expand Down Expand Up @@ -365,18 +363,17 @@ public function CountAchievementPercent($sum, $achType) {
* @return string
**/
public function buildAchievementsTree() {
$locale = (isset($_SESSION['armoryLocale'])) ? $_SESSION['armoryLocale'] : $this->armoryconfig['defaultLocale'];
$categoryIds = $this->aDB->select("SELECT `id`, `name_".$locale."` FROM `armory_achievement_category` WHERE `parentCategory`=-1");
$categoryIds = $this->aDB->select("SELECT `id`, `name_".$this->_locale."` FROM `armory_achievement_category` WHERE `parentCategory`=-1");
$achievementTree = '';
foreach($categoryIds as $cat) {
$i = 0;
$achievementTree .= '<div>
<a href="javascript:void(0)" onclick="Armory.Achievements.toggleCategory(this.parentNode, \''.$cat['id'].'\'); loadAchievements(\''.Characters::GetCharacterName($this->guid).'\', '.$cat['id'].')">'.$cat['name_'.$locale].'</a>';
$child = $this->aDB->select("SELECT `id`, `name_".$locale."` FROM `armory_achievement_category` WHERE `parentCategory`=?", $cat['id']);
<a href="javascript:void(0)" onclick="Armory.Achievements.toggleCategory(this.parentNode, \''.$cat['id'].'\'); loadAchievements(\''.Characters::GetCharacterName($this->guid).'\', '.$cat['id'].')">'.$cat['name_'.$this->_locale].'</a>';
$child = $this->aDB->select("SELECT `id`, `name_".$this->_locale."` FROM `armory_achievement_category` WHERE `parentCategory`=?", $cat['id']);
if($child) {
$achievementTree .= '<div class="cat_list">';
foreach($child as $childcat) {
$achievementTree .= '<div class="nav-subcat"><a href="javascript:void(0)" onclick="Armory.Achievements.toggleCategory(this.parentNode, \''.$i.'\'); loadAchievements(\''.Characters::GetCharacterName($this->guid).'\', '.$childcat['id'].')">'.$childcat['name_'.$locale].'</a></div>';
$achievementTree .= '<div class="nav-subcat"><a href="javascript:void(0)" onclick="Armory.Achievements.toggleCategory(this.parentNode, \''.$i.'\'); loadAchievements(\''.Characters::GetCharacterName($this->guid).'\', '.$childcat['id'].')">'.$childcat['name_'.$this->_locale].'</a></div>';
$i++;
}
$achievementTree .= '</div>';
Expand All @@ -397,8 +394,7 @@ public function GetAchievementInfo(&$achievementData) {
if(!is_array($achievementData)) {
return false;
}
$locale = (isset($_SESSION['armoryLocale'])) ? $_SESSION['armoryLocale'] : $this->armoryconfig['defaultLocale'];
$achievementinfo = $this->aDB->selectRow("SELECT `id`, `name_".$locale."` AS `name`, `description_".$locale."` AS `description`, `points` FROM `armory_achievement` WHERE `id`=? LIMIT 1", $achievementData['achievement']);
$achievementinfo = $this->aDB->selectRow("SELECT `id`, `name_".$this->_locale."` AS `name`, `description_".$this->_locale."` AS `description`, `points` FROM `armory_achievement` WHERE `id`=? LIMIT 1", $achievementData['achievement']);
if(!$achievementinfo) {
return false;
}
Expand Down Expand Up @@ -437,59 +433,5 @@ public function IsAchievementExists($achId) {
}
return false;
}
/*
public function MergeCompletedAchievements($check = false) {
if(!$this->guid || !$this->achId) {
return false;
}
if($check == true) {
$tmp_data = $this->aDB->selectCell("SELECT `parentAchievement` FROM `armory_achievement` WHERE `id`=?", $achId);
if($tmp_data) {
if($this->IsAchievementCompleted($tmp_data)) {
return true;
}
return false;
}
}
$loop = true;
$achievementsArray = array();
$i = 0;
$achId = $this->achId;
$macro = false;
$locale = (isset($_SESSION['armoryLocale'])) ? $_SESSION['armoryLocale'] : $this->armoryconfig['defaultLocale'];
while($loop == true) {
$tmp_data = $this->aDB->selectCell("SELECT `parentAchievement` FROM `armory_achievement` WHERE `id`=?", $achId);
if($tmp_data) {
if($this->IsAchievementCompleted($tmp_data)) {
$achievementsArray[$i] = $this->cDB->selectRow("SELECT `id`, `name_".$locale."` AS `name`, `points` FROM `armory_achievement` WHERE `id`=?", $tmp_data);
$achId = $tmp_data;
$macro = true;
}
}
else {
$loop = false;
}
$i++;
}
if($macro == true) {
$returnString = "<ul class='criteria c_list'>";
$i = 0;
foreach($achievementsArray as $achievement) {
$returnString .= "<li class='c_list_col criteriamet' id='ach".$achievement['id']."'";
if($i%2) {
$returnString .= ">";
}
else {
$returnString .= " style='float:left'>";
}
$returnString .= $achievement['name'].' ('.$achievement['points'].')'.'</li>';
$i++;
}
$returnString .= '</ul>';
return $achievementsArray;
}
return false;
}
*/
}
?>
72 changes: 13 additions & 59 deletions 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 86
* @revision 95
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -185,16 +185,15 @@ public function GetCharacterTitle($guid=false) {
$this->guid = $guid;
}
$this->GetCharacterGender();
$locale = (isset($_SESSION['armoryLocale'])) ? $_SESSION['armoryLocale'] : $this->armoryconfig['defaultLocale'];
$title = $this->aDB->selectRow("SELECT * FROM `armory_titles` WHERE `id`=?", $this->cDB->selectCell("SELECT `chosenTitle` FROM `characters` WHERE `guid`=? LIMIT 1", $this->guid));
$data = array();
if($title) {
switch($this->gender) {
case 1:
$data['title'] = $title['title_F_'.$locale];
$data['title'] = $title['title_F_'.$this->_locale];
break;
case 0:
$data['title'] = $title['title_M_'.$locale];
$data['title'] = $title['title_M_'.$this->_locale];
break;
}
$data['place'] = $title['place'];
Expand Down Expand Up @@ -300,7 +299,7 @@ public function returnClassText($class='') {
$class = $this->class;
}
$text = $this->aDB->selectCell("
SELECT `name_" . (isset($_SESSION['armoryLocale']) ? $_SESSION['armoryLocale'] : $this->armoryconfig['defaultLocale']) . "`
SELECT `name_" . $this->_locale . "`
FROM `armory_classes`
WHERE `id`=?", $class);
return $text;
Expand All @@ -320,7 +319,7 @@ public function returnRaceText($race='') {
$race = $this->race;
}
$text = $this->aDB->selectCell("
SELECT `name_" . (isset($_SESSION['armoryLocale']) ? $_SESSION['armoryLocale'] : $this->armoryconfig['defaultLocale']) . "`
SELECT `name_" . $this->_locale . "`
FROM `armory_races`
WHERE `id`=?", $race);
return $text;
Expand Down Expand Up @@ -592,16 +591,15 @@ public function getCharacterEnchant($slot, $guid='') {

//get a tab from TalentTab
public function getTabOrBuild($class, $type, $tabnum) {
$locale = (isset($_SESSION['armoryLocale'])) ? $_SESSION['armoryLocale'] : $this->armoryconfig['defaultLocale'];
if($type == "tab") {
if($type == "tab") {
$field = $this->aDB->selectCell("
SELECT `id`
FROM `armory_talenttab`
WHERE `refmask_chrclasses` = ? AND `tab_number` = ? LIMIT 1", pow(2,($class-1)), $tabnum);
}
else {
$field = $this->aDB->selectCell("
SELECT `name_" . $locale . "`
SELECT `name_" . $this->_locale . "`
FROM `armory_talenttab`
WHERE `refmask_chrclasses` = ? AND `tab_number` = ? LIMIT 1", pow(2,($class-1)), $tabnum);
}
Expand Down Expand Up @@ -682,15 +680,14 @@ public function extractCharacterGlyphs() {
if(!$this->guid) {
return false;
}
$locale = (isset($_SESSION['armoryLocale'])) ? $_SESSION['armoryLocale'] : $this->armoryconfig['defaultLocale'];
$glyphData = array();
$glyphData['big'] = array();
$glyphData['small'] = array();
$glyphFields = array('0' => 1319, '1' => 1320, '2' => 1321, '3' => 1322, '4' => 1323, '5' => 1324);
for($i=0;$i<6;$i++) {
$glyph_id = $this->GetDataField($glyphFields[$i]);
$glyph_info = $this->aDB->selectRow("
SELECT `type`, `name_".$locale."` AS `name`, `description_".$locale."` AS `description`
SELECT `type`, `name_".$this->_locale."` AS `name`, `description_".$this->_locale."` AS `description`
FROM `armory_glyphproperties` WHERE `id`=?", $glyph_id);
if(!$glyph_info) {
continue;
Expand All @@ -709,50 +706,10 @@ public function extractCharacterGlyphs() {
* Returns talent tree name for selected class
* @category Character class
* @example Characters::ReturnTalentTreeNames(6, 2)
* @todo Move this function to Utils class & store trees names in DB
* @return string
**/
public function ReturnTalentTreesNames($class, $key) {
switch($class) {
case 1:
$trees = array('Оружие|Arms', 'Неистовство|Fury', 'Защита|Protection');
break;
case 2:
$trees = array('Свет|Holy', 'Защита|Protection', 'Воздаяние|Retribution');
break;
case 3:
$trees = array('Чувство зверя|Beast mastery', 'Стрельба|Marksmanship', 'Выживание|Survival');
break;
case 4:
$trees = array('Ликвидация|Assassination', 'Бой|Combat', 'Скрытность|Subletly');
break;
case 5:
$trees = array('Послушание|Discipline', 'Свет|Holy', 'Тьма|Shadow');
break;
case 6:
$trees = array('Кровь|Blood', 'Лед|Frost', 'Нечестивость|Unholy');
break;
case 7:
$trees = array('Стихии|Elemental', 'Совершенствование|Enhancement', 'Исцеление|Restoration');
break;
case 8:
$trees = array('Тайная магия|Arcane', 'Огонь|Fire', 'Лед|Frost');
break;
case 9:
$trees = array('Колдовство|Affliction', 'Демонология|Demonology', 'Разрушение|Destruction');
break;
case 11:
$trees = array('Баланс|Balance', 'Сила зверя|Feral Combat', 'Исцеление|Restoration');
break;
default:
$trees = array('Неизвестно|Unknown');
break;
}
$name_locales = array ('en_gb' => 1, 'ru_ru' => 0);
$name = $trees[$key];
$name_exp = explode('|', $name);
$tree = (isset($_SESSION['armoryLocale'])) ? $name_exp[$name_locales[$_SESSION['armoryLocale']]] : $name_exp[$name_locales[$this->armoryconfig['defaultLocale']]];
return $tree;
public function ReturnTalentTreesNames($class, $spec) {
return $this->aDB->selectCell("SELECT `name_".$this->_locale."` FROM `armory_talent_icons` WHERE `class`=? AND `spec`=?", $class, $spec);
}

/**
Expand Down Expand Up @@ -787,20 +744,18 @@ public function getCharacterHonorKills() {
* @return array
**/
public function extractCharacterProfessions() {
// Извлекаем только 2 основные профессии. Первая помощь, кулинария и пр. сюда не входят
$professions = $this->cDB->select("
SELECT * FROM `character_skills`
WHERE `skill` IN (164, 165, 171, 182, 186, 197, 202, 333, 393, 755, 773)
AND `guid`=? LIMIT 2", $this->guid);
if(!$professions) {
return false;
}
$locale = (isset($_SESSION['armoryLocale'])) ? $_SESSION['armoryLocale'] : $this->armoryconfig['defaultLocale'];
$p = array();
$i = 0;
foreach($professions as $prof) {
$p[$i] = array(
'name' => $this->aDB->selectCell("SELECT `name_" . $locale . "` FROM `armory_professions` WHERE `id`=? LIMIT 1", $prof['skill']),
'name' => $this->aDB->selectCell("SELECT `name_" . $this->_locale . "` FROM `armory_professions` WHERE `id`=? LIMIT 1", $prof['skill']),
'icon' => $this->aDB->selectCell("SELECT `icon` FROM `armory_professions` WHERE `id`=? LIMIT 1", $prof['skill']),
'value' => $prof['value']
);
Expand All @@ -821,7 +776,6 @@ public function getCharacterReputation() {
if(!$this->guid) {
return false;
}
$locale = (isset($_SESSION['armoryLocale'])) ? $_SESSION['armoryLocale'] : $this->armoryconfig['defaultLocale'];
$repData = $this->cDB->select("SELECT `faction`, `standing`, `flags` FROM `character_reputation` WHERE `guid`=?", $this->guid);
if(!$repData) {
return false;
Expand All @@ -832,8 +786,8 @@ public function getCharacterReputation() {
continue;
}
$factionReputation[$i] = array(
'name' => $this->aDB->selectCell("SELECT `name_".$locale."` FROM `armory_faction` WHERE `id`=?", $faction['faction']),
'descr' => $this->aDB->selectCell("SELECT `description_".$locale."` FROM `armory_faction` WHERE `id`=?", $faction['faction']),
'name' => $this->aDB->selectCell("SELECT `name_".$this->_locale."` FROM `armory_faction` WHERE `id`=?", $faction['faction']),
'descr' => $this->aDB->selectCell("SELECT `description_".$this->_locale."` FROM `armory_faction` WHERE `id`=?", $faction['faction']),
'standings' => Utils::getReputation($faction['standing']),
'standing' => $faction['standing']
);
Expand Down
Loading

0 comments on commit d317ca9

Please sign in to comment.