Skip to content

Commit

Permalink
[374] Add Armory Updates page (updates.xml)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadez committed Aug 27, 2010
1 parent 3c91133 commit b0b80d8
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 5 deletions.
113 changes: 113 additions & 0 deletions _layout/updates.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"/>

<xsl:include href="includes.xsl"/>

<xsl:template match="updates">

<script type="text/javascript">

function toggleUpdate(theId) {
elementId = document.getElementById('showHideUpdate'+theId);
if (elementId.style.display == "block") {
$("#replaceToggle"+theId).html("<xsl:value-of select="$loc/strs/unsorted/str[@id='armory.labels.open']"/>");
elementId.style.display = "none";
} else {
$("#replaceToggle"+theId).html("<xsl:value-of select="$loc/strs/unsorted/str[@id='armory.labels.close']"/>");
elementId.style.display = "block";
}
}
</script>

<div id="dataElement">
<div class="parchment-top" id="top">
<div class="parchment-content">
<div class="list">
<div class="full-list notab">
<div class="info-pane">
<div class="profile-wrapper">
<div class="generic-wrapper">
<div class="generic-right">
<div class="genericHeader">
<div class="update-content">
<xsl:call-template name="updatesContent" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>


</xsl:template>


<xsl:template name="updatesContent">

<h1><xsl:value-of select="$loc/strs/unsorted/str[@id='armory.updates.armoryupdates']"/></h1>
<b><em><xsl:value-of select="$loc/strs/unsorted/str[@id='armory.updates.cache']"/></em></b>

<xsl:for-each select="document(concat('../updates-feed.xml?lang=', $lang))/updates/update[not(contains(@exclude, $region))]">
<xsl:variable name="thePosition" select="position()" />

<h2>
<xsl:value-of select="@date" />
<a href="#top" class="updateTop staticTip" onmouseover="setTipText('{$loc/strs/unsorted/str[@id='armory.labels.top']}');"></a>
</h2>

<xsl:for-each select="entry">
<a name="anchor{@key}"></a>
<div class="update-item">
<div class="update-line-item" id="line{@key}">
<span><xsl:value-of select = "@title" /></span>
<em class="toggleUpdate">
[ <a href="javascript: toggleUpdate('{@key}');" id="replaceToggle{@key}">
<xsl:choose>
<xsl:when test="$thePosition = 1">
<xsl:value-of select="$loc/strs/unsorted/str[@id='armory.labels.close']"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$loc/strs/unsorted/str[@id='armory.labels.open']"/>
</xsl:otherwise>
</xsl:choose>
</a> ]
</em>
</div>
<div class="update-body" id="showHideUpdate{@key}" style="display: none;">
<xsl:if test="$thePosition = 1">
<xsl:attribute name="style">display: block;</xsl:attribute>
</xsl:if>
<p><xsl:apply-templates/></p>
<div class="clear"></div>
</div>
</div>
<div class="clear"></div>
</xsl:for-each>

</xsl:for-each>

<script type="text/javascript">
$("#replaceTogglepinprofile").html("<xsl:value-of select="$loc/strs/unsorted/str[@id='armory.labels.close']"/>");
$("#showHideUpdatepinprofile").attr("style","display:block");

$("#replaceToggledesiredby").html("<xsl:value-of select="$loc/strs/unsorted/str[@id='armory.labels.close']"/>");
$("#showHideUpdatedesiredby").attr("style","display:block");

$("#replaceTogglefindupgrade").html("<xsl:value-of select="$loc/strs/unsorted/str[@id='armory.labels.close']"/>");
$("#showHideUpdatefindupgrade").attr("style","display:block");

if(($.browser.msie) &amp;&amp; ($.browser.version == "6.0")){
$(".updateTop").hide();
}
</script>


</xsl:template>

</xsl:stylesheet>
13 changes: 10 additions & 3 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 373
* @revision 375
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -1256,9 +1256,10 @@ public function GetFactionId($raceID) {
* See SQL update for 240 rev. (sql/updates/armory_r240_armory_news.sql) for example news.
* @category Utils class
* @access public
* @param bool $feed = false
* @return array
**/
public function GetArmoryNews() {
public function GetArmoryNews($feed = false) {
$news = $this->aDB->select("SELECT `id`, `date`, `title_en_gb` AS `titleOriginal`, `title_%s` AS `titleLoc`, `text_en_gb` AS `textOriginal`, `text_%s` AS `textLoc` FROM `ARMORYDBPREFIX_news` WHERE `display`=1 ORDER BY `date` DESC", $this->GetLocale(), $this->GetLocale());
if(!$news) {
return false;
Expand All @@ -1267,7 +1268,12 @@ public function GetArmoryNews() {
$i = 0;
foreach($news as $new) {
$allNews[$i] = array();
$allNews[$i]['posted'] = date('Y-m-d\TH:i:s\Z', $new['date']);
if($feed == true) {
$allNews[$i]['date'] = date('d m Y', $new['date']);
}
else {
$allNews[$i]['posted'] = date('Y-m-d\TH:i:s\Z', $new['date']);
}
if(!isset($new['titleLoc']) || empty($new['titleLoc'])) {
$allNews[$i]['title'] = (!empty($new['titleOriginal'])) ? $new['titleOriginal'] : null;
}
Expand All @@ -1280,6 +1286,7 @@ public function GetArmoryNews() {
else {
$allNews[$i]['text'] = (!empty($new['textLoc'])) ? $new['textLoc'] : null;
}
$allNews[$i]['key'] = $i;
$i++;
}
if($allNews) {
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', 374);
define('ARMORY_REVISION', 375);
define('DB_VERSION', 'armory_r361');
define('CONFIG_VERSION', '0708201001');
?>
5 changes: 4 additions & 1 deletion newsfeed.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 345
* @revision 375
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -40,6 +40,9 @@
$xml->XMLWriter()->startElement('story');
$xml->XMLWriter()->writeAttribute('permalink', null);
$xml->XMLWriter()->writeAttribute('title', $news['title']);
if(preg_match('/&/', $news_item['text'])) {
$news_item['text'] = str_replace('&', '&amp;', $news_item['text']);
}
$xml->XMLWriter()->text($news['text']);
$xml->XMLWriter()->endElement(); //story
$xml->XMLWriter()->endElement(); //news
Expand Down
50 changes: 50 additions & 0 deletions updates-feed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/**
* @package World of Warcraft Armory
* @version Release Candidate 1
* @revision 375
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**/

define('__ARMORY__', true);
if(!@include('includes/armory_loader.php')) {
die('<b>Fatal error:</b> unable to load system files.');
}
header('Content-type: text/xml');
$xml->XMLWriter()->startElement('updates');
$armory_news = $utils->GetArmoryNews(true);
if(is_array($armory_news)) {
foreach($armory_news as $news_item) {
$xml->XMLWriter()->startElement('update');
$xml->XMLWriter()->writeAttribute('date', $news_item['date']);
$xml->XMLWriter()->startElement('entry');
$xml->XMLWriter()->writeAttribute('key', $news_item['key']);
$xml->XMLWriter()->writeAttribute('title', $news_item['title']);
if(preg_match('/&/', $news_item['text'])) {
$news_item['text'] = str_replace('&', '&amp;', $news_item['text']);
}
$xml->XMLWriter()->writeRaw( $news_item['text'] );
$xml->XMLWriter()->endElement(); //entry
$xml->XMLWriter()->endElement(); //update
}
}
$xml->XMLWriter()->endElement(); //updates
echo $xml->StopXML();
exit;
?>
42 changes: 42 additions & 0 deletions updates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/**
* @package World of Warcraft Armory
* @version Release Candidate 1
* @revision 375
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**/

define('__ARMORY__', true);
if(!@include('includes/armory_loader.php')) {
die('<b>Fatal error:</b> unable to load system files.');
}
header('Content-type: text/xml');
// Load XSLT template
$xml->LoadXSLT('updates.xsl');
$xml->XMLWriter()->startElement('page');
$xml->XMLWriter()->writeAttribute('globalSearch', 1);
$xml->XMLWriter()->writeAttribute('lang', $armory->GetLocale());
$xml->XMLWriter()->startElement('updates');
$xml->XMLWriter()->startElement('related-info');
$xml->XMLWriter()->endElement(); //related-info
$xml->XMLWriter()->endElement(); //updates
$xml->XMLWriter()->endElement(); //page
echo $xml->StopXML();
exit;
?>

0 comments on commit b0b80d8

Please sign in to comment.