here is a patch that will implement fetching arena data from the Armory. I think we will need that when zanix finished roster arena structures.
- Code: Select all
--- D:/xampp/roster.com/htdocs/lib/armory.class.php.org Mon Sep 24 10:41:04 2007
+++ D:/xampp/roster.com/htdocs/lib/armory.class.php Tue Oct 09 20:23:52 2007
@@ -620,6 +620,90 @@
return $this->fetchCharacterReputation($character, $locale, $realm, 'html');
}
+ /**
+ * Fetch arena teams of $character from the Armory
+ * $realm is required
+ * $locale is reqired
+ *
+ * @param string $character
+ * @param string $locale
+ * @param string $realm
+ * @param bool $fetch_type
+ * @return array
+ */
+ function fetchCharacterArenaTeams( $character, $locale, $realm, $fetch_type='array' )
+ {
+ global $roster;
+
+ $locale = substr($locale, 0, 2);
+ $cache_tag = $character.$locale.$realm.$fetch_type.'arenateams';
+
+ if( $roster->cache->check($cache_tag) )
+ {
+ if( $this->debug_cachehits )
+ {
+ trigger_error(__FUNCTION__ . " ::: Cache Hit: [ $cache_tag ]", E_NOTICE);
+ }
+ return $roster->cache->get($cache_tag);
+ }
+ else
+ {
+ $url = $this->_makeUrl( 7, $locale, false, $character, $realm );
+ if( $this->_requestXml($url) )
+ {
+ // unparsed fetches
+ if( $fetch_type != 'array' )
+ {
+ $roster->cache->put($cache_tag);
+ return $this->xml;
+ }
+ // else parse and return array
+ $this->xmlParser->Parse($this->xml);
+ $char = $this->xmlParser->getParsedData();
+ $roster->cache->put($char, $cache_tag);
+ return $char;
+ }
+ else
+ {
+ trigger_error('RosterArmory:: Failed to fetch ' . $url);
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Fetch arena teams of $character from the Armory
+ * $realm is required
+ * $locale is reqired
+ * Returns XML string
+ *
+ * @param string $character
+ * @param string $locale
+ * @param string $realm
+ * @return string | xml string
+ */
+ function fetchCharacterArenaTeamsXML( $character, $locale, $realm )
+ {
+ return $this->fetchCharacterArenaTeams($character, $locale, $realm, 'xml');
+ }
+
+ /**
+ * Fetch arena teams of $character from the Armory
+ * $realm is required
+ * $locale is reqired
+ * Returns HTML string
+ *
+ * @param string $character
+ * @param string $locale
+ * @param string $realm
+ * @return string | html string
+ */
+ function fetchCharacterArenaTeamsHTML( $character, $locale, $realm )
+ {
+ $this->setUserAgent('Opera/9.22 (X11; Linux i686; U; en)');
+ return $this->fetchCharacterArenaTeams($character, $locale, $realm, 'html');
+ }
+
function fetchStrings( $locale, $fetch_type='array' )
{
global $roster;
@@ -637,7 +721,7 @@
}
else
{
- $url = $this->_makeUrl( 7, $locale );
+ $url = $this->_makeUrl( 8, $locale );
if( $this->_requestXml($url) )
{
// unparsed fetches
@@ -793,6 +877,10 @@
$mode = 'character-reputation.xml?n=' . urlencode($char) . '&r=' . urlencode($realm);
break;
case 7:
+ case 'character-arenateams':
+ $mode = 'character-arenateams.xml?n=' . urlencode($char) . '&r=' . urlencode($realm);
+ break;
+ case 8:
case 'strings':
switch( $locale )
{