Skip to content

Commit

Permalink
[296] Use XMLWriter::writeRaw() for deDE, esES, esMX, frFR locales to…
Browse files Browse the repository at this point in the history
… properly display HTML special chars (partly update)
  • Loading branch information
Shadez committed Jul 7, 2010
1 parent 800ccef commit 753566e
Show file tree
Hide file tree
Showing 7 changed files with 541 additions and 191 deletions.
242 changes: 177 additions & 65 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 257
* @revision 296
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -87,72 +87,143 @@
if($achievement['display'] == 0) {
continue;
}
$xml->XMLWriter()->startElement('achievement');
if(isset($achievement['data'])) {
foreach($achievement['data'] as $a_data_key => $a_data_value) {
$xml->XMLWriter()->writeAttribute($a_data_key, $a_data_value);
if($utils->IsWriteRaw()) {
$xml->XMLWriter()->writeRaw('<achievement');
if(isset($achievement['data'])) {
foreach($achievement['data'] as $a_data_key => $a_data_value) {
$xml->XMLWriter()->writeRaw(' ' . $a_data_key . '="' . $a_data_value . '"');
}
}
}
if(isset($achievement['criteria']) && is_array($achievement['criteria'])) {
foreach($achievement['criteria'] as $criteria) {
$xml->XMLWriter()->startElement('criteria');
foreach($criteria as $c_key => $c_value) {
$xml->XMLWriter()->writeAttribute($c_key, $c_value);
$xml->XMLWriter()->writeRaw('>');
if(isset($achievement['criteria']) && is_array($achievement['criteria'])) {
foreach($achievement['criteria'] as $criteria) {
$xml->XMLWriter()->writeRaw('<criteria');
foreach($criteria as $c_key => $c_value) {
$xml->XMLWriter()->writeRaw(' ' . $c_key .'="' . $c_value .'"');
}
$xml->XMLWriter()->writeRaw('/>'); //criteria
}
}
if(isset($achievement['achievement_tree'])) {
foreach($achievement['achievement_tree'] as $achievement_tree) {
$xml->XMLWriter()->writeRaw('<achievement');
foreach($achievement_tree as $a_tree_key => $a_tree_value) {
$xml->XMLWriter()->writeRaw(' ' . $a_tree_key . '="' . $a_tree_value . '"');
}
$xml->XMLWriter()->writeRaw('/>'); //achievement
}
$xml->XMLWriter()->endElement(); //criteria
}
$xml->XMLWriter()->writeRaw('</achievement>'); //achievement
}
if(isset($achievement['achievement_tree'])) {
foreach($achievement['achievement_tree'] as $achievement_tree) {
$xml->XMLWriter()->startElement('achievement');
foreach($achievement_tree as $a_tree_key => $a_tree_value) {
$xml->XMLWriter()->writeAttribute($a_tree_key, $a_tree_value);
else {
$xml->XMLWriter()->startElement('achievement');
if(isset($achievement['data'])) {
foreach($achievement['data'] as $a_data_key => $a_data_value) {
$xml->XMLWriter()->writeAttribute($a_data_key, $a_data_value);
}
$xml->XMLWriter()->endElement(); //achievement
}
if(isset($achievement['criteria']) && is_array($achievement['criteria'])) {
foreach($achievement['criteria'] as $criteria) {
$xml->XMLWriter()->startElement('criteria');
foreach($criteria as $c_key => $c_value) {
$xml->XMLWriter()->writeAttribute($c_key, $c_value);
}
$xml->XMLWriter()->endElement(); //criteria
}
}
if(isset($achievement['achievement_tree'])) {
foreach($achievement['achievement_tree'] as $achievement_tree) {
$xml->XMLWriter()->startElement('achievement');
foreach($achievement_tree as $a_tree_key => $a_tree_value) {
$xml->XMLWriter()->writeAttribute($a_tree_key, $a_tree_value);
}
$xml->XMLWriter()->endElement(); //achievement
}
}
$xml->XMLWriter()->writeRaw('</achievement>'); //achievement
}
$xml->XMLWriter()->endElement(); //achievement
}
}
else {
$armory->Log()->writeLog('character-achievements.php : player %d (%s) does not have any completed achievements in %d category', $characters->GetGUID(), $characters->GetName(), $achievement_category);
}
if(isset($achievements_page['incompleted'])) {
foreach($achievements_page['incompleted'] as $achievement) {
if(isset($achievement['display']) && $achievement['display'] == 0) {
continue;
}
$xml->XMLWriter()->startElement('achievement');
if(isset($achievement['data'])) {
foreach($achievement['data'] as $a_data_key => $a_data_value) {
$xml->XMLWriter()->writeAttribute($a_data_key, $a_data_value);
if($utils->IsWriteRaw()) {
foreach($achievements_page['incompleted'] as $achievement) {
if(isset($achievement['display']) && $achievement['display'] == 0) {
continue;
}
}
else {
$armory->Log()->writeLog('character-achievements.php : achievement[data] not found (player: %d; %s)!', $characters->GetGUID(), $characters->GetName());
}
if(isset($achievement['criteria']) && is_array($achievement['criteria'])) {
foreach($achievement['criteria'] as $criteria) {
$xml->XMLWriter()->startElement('criteria');
foreach($criteria as $c_key => $c_value) {
$xml->XMLWriter()->writeAttribute($c_key, $c_value);
$xml->XMLWriter()->writeRaw('<achievement');
if(isset($achievement['data'])) {
foreach($achievement['data'] as $a_data_key => $a_data_value) {
$xml->XMLWriter()->writeRaw(' ' . $a_data_key . '="' . $a_data_value . '"');
}
$xml->XMLWriter()->endElement(); //criteria
}
else {
$armory->Log()->writeLog('character-achievements.php : achievement[data] not found (player: %d; %s)!', $characters->GetGUID(), $characters->GetName());
}
$xml->XMLWriter()->writeRaw('>');
if(isset($achievement['criteria']) && is_array($achievement['criteria'])) {
foreach($achievement['criteria'] as $criteria) {
$xml->XMLWriter()->writeRaw('<criteria');
foreach($criteria as $c_key => $c_value) {
$xml->XMLWriter()->writeRaw(' ' . $c_key . '="' . $c_value . '"');
}
$xml->XMLWriter()->writeRaw('/>'); //criteria
}
}
else {
$armory->Log()->writeLog('character-achievements.php : achievement[critera] not found (player: %d; %s)!', $characters->GetGUID(), $characters->GetName());
}
if(isset($achievement['achievement_tree'])) {
foreach($achievement['achievement_tree'] as $achievement_tree) {
$xml->XMLWriter()->writeRaw('<achievement');
foreach($achievement_tree as $a_tree_key => $a_tree_value) {
$xml->XMLWriter()->writeRaw(' ' . $a_tree_key . '="' . $a_tree_value . '"');
}
$xml->XMLWriter()->writeRaw('/>'); //achievement
}
}
$xml->XMLWriter()->writeRaw('</achievement>'); //achievement
}
else {
$armory->Log()->writeLog('character-achievements.php : achievement[critera] not found (player: %d; %s)!', $characters->GetGUID(), $characters->GetName());
}
if(isset($achievement['achievement_tree'])) {
foreach($achievement['achievement_tree'] as $achievement_tree) {
$xml->XMLWriter()->startElement('achievement');
foreach($achievement_tree as $a_tree_key => $a_tree_value) {
$xml->XMLWriter()->writeAttribute($a_tree_key, $a_tree_value);
}
else {
foreach($achievements_page['incompleted'] as $achievement) {
if(isset($achievement['display']) && $achievement['display'] == 0) {
continue;
}
$xml->XMLWriter()->startElement('achievement');
if(isset($achievement['data'])) {
foreach($achievement['data'] as $a_data_key => $a_data_value) {
$xml->XMLWriter()->writeAttribute($a_data_key, $a_data_value);
}
}
else {
$armory->Log()->writeLog('character-achievements.php : achievement[data] not found (player: %d; %s)!', $characters->GetGUID(), $characters->GetName());
}
if(isset($achievement['criteria']) && is_array($achievement['criteria'])) {
foreach($achievement['criteria'] as $criteria) {
$xml->XMLWriter()->startElement('criteria');
foreach($criteria as $c_key => $c_value) {
$xml->XMLWriter()->writeAttribute($c_key, $c_value);
}
$xml->XMLWriter()->endElement(); //criteria
}
$xml->XMLWriter()->endElement(); //achievement
}
else {
$armory->Log()->writeLog('character-achievements.php : achievement[critera] not found (player: %d; %s)!', $characters->GetGUID(), $characters->GetName());
}
if(isset($achievement['achievement_tree'])) {
foreach($achievement['achievement_tree'] as $achievement_tree) {
$xml->XMLWriter()->startElement('achievement');
foreach($achievement_tree as $a_tree_key => $a_tree_value) {
$xml->XMLWriter()->writeAttribute($a_tree_key, $a_tree_value);
}
$xml->XMLWriter()->endElement(); //achievement
}
}
$xml->XMLWriter()->endElement(); //achievement
}
$xml->XMLWriter()->endElement(); //achievement
}
}
else {
Expand Down Expand Up @@ -215,11 +286,20 @@
$xml->XMLWriter()->startElement('category');
$current_category = $achievements->GetSummaryAchievementData($achievement_category);
if($current_category) {
$xml->XMLWriter()->startElement('c');
foreach($current_category as $category_key => $category_value) {
$xml->XMLWriter()->writeAttribute($category_key, $category_value);
if($utils->IsWriteRaw()) {
$xml->XMLWriter()->writeRaw('<c');
foreach($current_category as $category_key => $category_value) {
$xml->XMLWriter()->writeRaw(' ' . $category_key .'="' . $category_value . '"');
}
$xml->XMLWriter()->writeRaw('/>'); //c
}
else {
$xml->XMLWriter()->startElement('c');
foreach($current_category as $category_key => $category_value) {
$xml->XMLWriter()->writeAttribute($category_key, $category_value);
}
$xml->XMLWriter()->endElement(); //c
}
$xml->XMLWriter()->endElement(); //c
}
$xml->XMLWriter()->endElement(); //category
}
Expand All @@ -228,11 +308,20 @@
if(is_array($last_achievements)) {
foreach($last_achievements as $l_achievement) {
if(is_array($l_achievement)) {
$xml->XMLWriter()->startElement('achievement');
foreach($l_achievement as $l_a_key => $l_a_value) {
$xml->XMLWriter()->writeAttribute($l_a_key, $l_a_value);
if($utils->IsWriteRaw()) {
$xml->XMLWriter()->writeRaw('<achievement');
foreach($l_achievement as $l_a_key => $l_a_value) {
$xml->XMLWriter()->writeRaw(' ' . $l_a_key .'="' . $l_a_value . '"');
}
$xml->XMLWriter()->writeRaw('/>'); //achievement
}
else {
$xml->XMLWriter()->startElement('achievement');
foreach($l_achievement as $l_a_key => $l_a_value) {
$xml->XMLWriter()->writeAttribute($l_a_key, $l_a_value);
}
$xml->XMLWriter()->endElement(); //achievement
}
$xml->XMLWriter()->endElement(); //achievement
}
}
}
Expand All @@ -242,18 +331,41 @@
$root_categories = $achievements->BuildCategoriesTree();
if($root_categories && is_array($root_categories)) {
foreach($root_categories as $category) {
$xml->XMLWriter()->startElement('category');
$xml->XMLWriter()->writeAttribute('id', $category['id']);
$xml->XMLWriter()->writeAttribute('name', $category['name']);
if(isset($category['child']) && is_array($category['child'])) {
foreach($category['child'] as $category_child) {
$xml->XMLWriter()->startElement('category');
$xml->XMLWriter()->writeAttribute('name', $category_child['name']);
$xml->XMLWriter()->writeAttribute('id', $category_child['id']);
$xml->XMLWriter()->endElement(); //category
if($utils->IsWriteRaw()) {
$xml->XMLWriter()->writeRaw('<category');
$xml->XMLWriter()->writeRaw(' id="' . $category['id'] . '"');
if($category['id'] == 168) {
$xml->XMLWriter()->writeRaw(' name="' . htmlspecialchars($category['name']) . '"');
}
else {
$xml->XMLWriter()->writeRaw(' name="' . $category['name'] . '"');
}

$xml->XMLWriter()->writeRaw('>');
if(isset($category['child']) && is_array($category['child'])) {
foreach($category['child'] as $category_child) {
$xml->XMLWriter()->writeRaw('<category');
$xml->XMLWriter()->writeRaw(' name="' . $category_child['name'] . '"');
$xml->XMLWriter()->writeRaw(' id="' . htmlspecialchars($category_child['id']) . '"');
$xml->XMLWriter()->writeRaw('/>'); //category
}
}
$xml->XMLWriter()->writeRaw('</category>'); //category
}
else {
$xml->XMLWriter()->startElement('category');
$xml->XMLWriter()->writeAttribute('id', $category['id']);
$xml->XMLWriter()->writeAttribute('name', $category['name']);
if(isset($category['child']) && is_array($category['child'])) {
foreach($category['child'] as $category_child) {
$xml->XMLWriter()->startElement('category');
$xml->XMLWriter()->writeAttribute('name', $category_child['name']);
$xml->XMLWriter()->writeAttribute('id', $category_child['id']);
$xml->XMLWriter()->endElement(); //category
}
}
$xml->XMLWriter()->endElement(); //category
}
$xml->XMLWriter()->endElement(); //category
}
}
$xml->XMLWriter()->endElement(); //rootCategories
Expand Down
42 changes: 31 additions & 11 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 257
* @revision 296
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -91,21 +91,41 @@
$xml->XMLWriter()->startElement('reputationTab');
$character_reputation = $characters->GetCharacterReputation();
if($character_reputation) {
$xml->XMLWriter()->startElement('faction');
$header_faction = array(
'header' => 1, 'iconKey' => 'classic', 'id' => 1118, 'key' => 'classic', 'name' => 'World of Warcraft' // hack
);
foreach($header_faction as $head_key => $head_value) {
$xml->XMLWriter()->writeAttribute($head_key, $head_value);
if($utils->IsWriteRaw()) {
$xml->XMLWriter()->writeRaw('<faction');
$header_faction = array(
'header' => 1, 'iconKey' => 'classic', 'id' => 1118, 'key' => 'classic', 'name' => 'World of Warcraft' // hack
);
foreach($header_faction as $head_key => $head_value) {
$xml->XMLWriter()->writeRaw(' ' . $head_key .'="' . $head_value .'"');
}
$xml->XMLWriter()->writeRaw('>');
foreach($character_reputation as $faction) {
$xml->XMLWriter()->writeRaw('<faction');
foreach($faction as $rep_key => $rep_value) {
$xml->XMLWriter()->writeRaw(' ' . $rep_key .'="' . $rep_value .'"');
}
$xml->XMLWriter()->writeRaw('/>');
}
$xml->XMLWriter()->writeRaw('</faction>');
}
foreach($character_reputation as $faction) {
else {
$xml->XMLWriter()->startElement('faction');
foreach($faction as $rep_key => $rep_value) {
$xml->XMLWriter()->writeAttribute($rep_key, $rep_value);
$header_faction = array(
'header' => 1, 'iconKey' => 'classic', 'id' => 1118, 'key' => 'classic', 'name' => 'World of Warcraft' // hack
);
foreach($header_faction as $head_key => $head_value) {
$xml->XMLWriter()->writeAttribute($head_key, $head_value);
}
foreach($character_reputation as $faction) {
$xml->XMLWriter()->startElement('faction');
foreach($faction as $rep_key => $rep_value) {
$xml->XMLWriter()->writeAttribute($rep_key, $rep_value);
}
$xml->XMLWriter()->endElement(); //faction
}
$xml->XMLWriter()->endElement(); //faction
}
$xml->XMLWriter()->endElement(); //faction
}
$xml->XMLWriter()->endElement(); //reputationTab
$xml->XMLWriter()->endElement(); //page
Expand Down
Loading

0 comments on commit 753566e

Please sign in to comment.