Feature Request: armory.class.php

Posts from previous Beta sessions

Feature Request: armory.class.php

Postby poetter » Fri Sep 14, 2007 6:46 am

Hi ds,

i've got a problem with our friends from UK. As the normaly choose lang en_US the function _makeURL leeds them to www.wowarmory.com. As they are UK guilds the are not found on the us servers.

Can you add an additional parameter for the fetch... function named f.e. $region witch you pass to _makeURL an choose the server from this parameter?

Here is a patch that would do the thing:
Code: Select all
--- C:/Dokumente und Einstellungen/Daniel/Lokale Einstellungen/Temp/armory.class.php-revBASE.svn001.tmp.php   Fri Sep 14 00:42:32 2007
+++ D:/xampp/roster.com/test/trunk/lib/armory.class.php   Fri Sep 14 00:33:39 2007
@@ -65,11 +65,11 @@
     * @param string $fetch_type
     * @return array
     */
-   function fetchItemTooltip( $item_id, $locale, $character=false, $realm=false, $fetch_type='array' )
+   function fetchItemTooltip( $item_id, $locale, $character=false, $realm=false, $region=false, $fetch_type='array' )
    {
       global $roster;
       $locale = substr($locale, 0, 2);
-      $cache_tag = $item_id.$locale.$character.$realm.$fetch_type;
+      $cache_tag = $item_id.$locale.$character.$realm.$region.$fetch_type;
       
       if( $roster->cache->check($cache_tag) )
       {
@@ -82,7 +82,7 @@
       }
       else
       {
-         $url = $this->_makeUrl( 0, $locale, $item_id, $character, $realm );
+         $url = $this->_makeUrl( 0, $locale, $item_id, $character, $realm, $region );
          if( $this->_requestXml($url) )
          {
             // unparsed fetches
@@ -113,15 +113,15 @@
     * @param string $item_id
     * @return string
     */
-   function fetchItemTooltipXML( $item_id, $locale, $character=false, $realm=false )
+   function fetchItemTooltipXML( $item_id, $locale, $character=false, $realm=false, $region=false )
    {
-      return $this->fetchItemTooltip( $item_id, $locale, $character, $realm, 'xml' );
+      return $this->fetchItemTooltip( $item_id, $locale, $character, $realm, $region, 'xml' );
    }
    
    function fetchItemTooltipHTML( $item_id, $locale, $character=false, $realm=false )
    {
       $this->setUserAgent('Opera/9.22 (X11; Linux i686; U; en)');
-      return $this->fetchItemTooltip( $item_id, $locale, $character, $realm, 'html' );
+      return $this->fetchItemTooltip( $item_id, $locale, $character, $realm, $region, 'html' );
    }
    /**
     * Fetches $item_id General Information from the Armory
@@ -132,11 +132,11 @@
     * @param string $fetch_type
     * @return string
     */
-   function fetchItemInfo( $item_id, $locale, $fetch_type='array' )
+   function fetchItemInfo( $item_id, $locale, $region, $fetch_type='array' )
    {
       global $roster;
       $locale = substr($locale, 0, 2);
-      $cache_tag = $item_id.$locale.$fetch_type;
+      $cache_tag = $item_id.$locale.$region.$region.$fetch_type;
       
       if( $roster->cache->check($cache_tag) )
       {
@@ -181,7 +181,7 @@
     */
    function fetchItemInfoXML( $item_id, $locale )
    {
-      return $this->fetchItemInfo($item_id, $locale, 'xml');
+      return $this->fetchItemInfo($item_id, $locale, $region, 'xml');
    }
    
    /**
@@ -192,7 +192,7 @@
     * @param string $locale
     * @return string
     */
-   function fetchItemInfoHTML( $item_id, $locale )
+   function fetchItemInfoHTML( $item_id, $locale, $region )
    {
       $this->setUserAgent('Opera/9.22 (X11; Linux i686; U; en)');
       return $this->fetchItemInfo($item_id, $locale, 'html');
@@ -210,12 +210,12 @@
     * @param string $fetch_type
     * @return array
     */
-   function fetchCharacter( $character, $locale, $realm, $fetch_type='array' )
+   function fetchCharacter( $character, $locale, $realm, $region, $fetch_type='array' )
    {
       global $roster;
       
       $locale = substr($locale, 0, 2);
-      $cache_tag = $character.$locale.$realm.$fetch_type;
+      $cache_tag = $character.$locale.$realm.$region.$fetch_type;
       
       if( $roster->cache->check($cache_tag) )
       {
@@ -227,7 +227,7 @@
       }
       else
       {
-         $url = $this->_makeUrl( 2, $locale, false, $character, $realm );
+         $url = $this->_makeUrl( 2, $locale, false, $character, $realm, $region );
          if( $this->_requestXml($url) )
          {
             // unparsed fetches
@@ -262,9 +262,9 @@
     * @param string $realm
     * @return string | xml string
     */   
-   function fetchCharacterXML( $character, $locale, $realm )
+   function fetchCharacterXML( $character, $locale, $realm, $region )
    {
-      return $this->fetchCharacter($character, $locale, $realm, 'xml');
+      return $this->fetchCharacter($character, $locale, $realm, $region, 'xml');
    }
    
    /**
@@ -282,7 +282,7 @@
    function fetchCharacterHTML( $character, $locale, $realm )
    {
       $this->setUserAgent('Opera/9.22 (X11; Linux i686; U; en)');
-      return $this->fetchCharacter($character, $locale, $realm, 'html');
+      return $this->fetchCharacter($character, $locale, $realm, $region, 'html');
    }
 
    /**
@@ -296,12 +296,12 @@
     * @param string $fetch_type
     * @return array
     */
-   function fetchGuild( $guild, $locale, $realm, $fetch_type='array' )
+   function fetchGuild( $guild, $locale, $realm, $region, $fetch_type='array' )
    {
       global $roster;
       
       $locale = substr($locale, 0, 2);
-      $cache_tag = $guild.$locale.$realm.$fetch_type;
+      $cache_tag = $guild.$locale.$realm.$region.$fetch_type;
       
       if( $roster->cache->check($cache_tag) )
       {
@@ -313,7 +313,7 @@
       }
       else
       {
-         $url = $this->_makeUrl( 3, $locale, false, false, $realm, $guild );
+         $url = $this->_makeUrl( 3, $locale, false, false, $realm, $region, $guild );
          if( $this->_requestXml($url) )
          {
             //unparsed fetches
@@ -347,9 +347,9 @@
     * @param string $realm
     * @return string | xml string
     */   
-   function fetchGuildXML( $guild, $locale, $realm )
+   function fetchGuildXML( $guild, $locale, $realm, $region )
    {
-      return $this->fetchGuild($guild, $locale, $realm, 'xml');
+      return $this->fetchGuild($guild, $locale, $realm, $region, 'xml');
    }
 
    /**
@@ -363,10 +363,10 @@
     * @param string $realm
     * @return string | html string
     */   
-   function fetchGuildHTML( $guild, $locale, $realm )
+   function fetchGuildHTML( $guild, $locale, $realm, $region )
    {
       $this->setUserAgent('Opera/9.22 (X11; Linux i686; U; en)');
-      return $this->fetchGuild($guild, $locale, $realm, 'html');
+      return $this->fetchGuild($guild, $locale, $realm, $region, 'html');
    }
 
    /**
@@ -379,12 +379,12 @@
     * @param bool $fetch_type
     * @return array
     */
-   function fetchCharacterTalents( $character, $locale, $realm, $fetch_type='array' )
+   function fetchCharacterTalents( $character, $locale, $realm, $region, $fetch_type='array' )
    {
       global $roster;
       
       $locale = substr($locale, 0, 2);
-      $cache_tag = $character.$locale.$realm.$fetch_type.'talents';
+      $cache_tag = $character.$locale.$realm.$region.$fetch_type.'talents';
       
       if( $roster->cache->check($cache_tag) )
       {
@@ -396,7 +396,7 @@
       }
       else
       {
-         $url = $this->_makeUrl( 4, $locale, false, $character, $realm );
+         $url = $this->_makeUrl( 4, $locale, false, $character, $realm, $region );
          if( $this->_requestXml($url) )
          {
             //unparsed fetches
@@ -429,9 +429,9 @@
     * @param string $realm
     * @return string | xml string
     */
-   function fetchCharacterTalentsXML( $character, $locale, $realm )
+   function fetchCharacterTalentsXML( $character, $locale, $realm, $region )
    {
-      return $this->fetchCharacterTalents($character, $locale, $realm, 'xml');
+      return $this->fetchCharacterTalents($character, $locale, $realm, $region, 'xml');
    }
    
    /**
@@ -444,10 +444,10 @@
     * @param string $realm
     * @return string | html string
     */
-   function fetchCharacterTalentsHTML( $character, $locale, $realm )
+   function fetchCharacterTalentsHTML( $character, $locale, $realm, $region )
    {
       $this->setUserAgent('Opera/9.22 (X11; Linux i686; U; en)');
-      return $this->fetchCharacterTalents($character, $locale, $realm, 'html');
+      return $this->fetchCharacterTalents($character, $locale, $realm, $region, 'html');
    }
    
    /**
@@ -461,12 +461,12 @@
     * @param string $fetch_type
     * @return array
     */
-   function fetchCharacterSkills( $character, $locale, $realm, $fetch_type='array' )
+   function fetchCharacterSkills( $character, $locale, $realm, $region, $fetch_type='array' )
    {
       global $roster;
       
       $locale = substr($locale, 0, 2);
-      $cache_tag = $character.$locale.$realm.$fetch_type.'skills';
+      $cache_tag = $character.$locale.$realm.$region.$fetch_type.'skills';
       
       if( $roster->cache->check($cache_tag) )
       {
@@ -478,7 +478,7 @@
       }
       else
       {
-         $url = $this->_makeUrl( 5, $locale, false, $character, $realm );
+         $url = $this->_makeUrl( 5, $locale, false, $character, $realm, $region );
          if( $this->_requestXml($url) )
          {
             //unparsed fetches
@@ -512,9 +512,9 @@
     * @param string $realm
     * @return string | xml string
     */   
-   function fetchCharacterSkillsXML( $character, $locale, $realm )
+   function fetchCharacterSkillsXML( $character, $locale, $realm, $region )
    {
-      return $this->fetchCharacterSkills($character, $locale, $realm, 'xml');
+      return $this->fetchCharacterSkills($character, $locale, $realm, $region, 'xml');
    }
 
    /**
@@ -528,10 +528,10 @@
     * @param string $realm
     * @return string | html string
     */   
-   function fetchCharacterSkillsHTML( $character, $locale, $realm )
+   function fetchCharacterSkillsHTML( $character, $locale, $realm, $region )
    {
       $this->setUserAgent('Opera/9.22 (X11; Linux i686; U; en)');
-      return $this->fetchCharacterSkills($character, $locale, $realm, 'html');
+      return $this->fetchCharacterSkills($character, $locale, $realm, $region, 'html');
    }
 
    /**
@@ -545,12 +545,12 @@
     * @param bool $fetch_type
     * @return array
     */
-   function fetchCharacterReputation( $character, $locale, $realm, $fetch_type='array' )
+   function fetchCharacterReputation( $character, $locale, $realm, $region, $fetch_type='array' )
    {
       global $roster;
       
       $locale = substr($locale, 0, 2);
-      $cache_tag = $character.$locale.$realm.$fetch_type.'reputation';
+      $cache_tag = $character.$locale.$realm.$region.$fetch_type.'reputation';
       
       if( $roster->cache->check($cache_tag) )
       {
@@ -562,7 +562,7 @@
       }
       else
       {
-         $url = $this->_makeUrl( 6, $locale, false, $character, $realm );
+         $url = $this->_makeUrl( 6, $locale, false, $character, $realm, $region );
          if( $this->_requestXml($url) )
          {
             // unparsed fetches
@@ -596,9 +596,9 @@
     * @param string $realm
     * @return string | xml string
     */   
-   function fetchCharacterReputationXML( $character, $locale, $realm )
+   function fetchCharacterReputationXML( $character, $locale, $realm, $region )
    {
-      return $this->fetchCharacterReputation($character, $locale, $realm, 'xml');
+      return $this->fetchCharacterReputation($character, $locale, $realm, $region, 'xml');
    }
 
    /**
@@ -612,10 +612,10 @@
     * @param string $realm
     * @return string | html string
     */   
-   function fetchCharacterReputationHTML( $character, $locale, $realm )
+   function fetchCharacterReputationHTML( $character, $locale, $realm, $region )
    {
       $this->setUserAgent('Opera/9.22 (X11; Linux i686; U; en)');
-      return $this->fetchCharacterReputation($character, $locale, $realm, 'html');
+      return $this->fetchCharacterReputation($character, $locale, $realm, $region, 'html');
    }
 
    /**
@@ -678,7 +678,7 @@
     * @param string $realm |
     * @param string $guild |
     */
-   function _makeUrl($mode, $locale, $id=false, $char=false, $realm=false, $guild=false )
+   function _makeUrl($mode, $locale, $id=false, $char=false, $realm=false, $region=false, $guild=false )
    {
       //build base url
       if( $locale )
@@ -690,7 +690,7 @@
          $locale = substr($this->locale, 0, 2);
       }
 
-      if( $locale == 'en' )
+      if( $region == 'US' )
       {
          $base_url = 'http://www.wowarmory.com/';
       }
Last edited by poetter on Fri Sep 14, 2007 1:25 pm, edited 1 time in total.
User avatar
poetter
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 462
Joined: Sat Jun 30, 2007 9:41 pm
Location: Germany/Hamburg

Feature Request: armory.class.php

Postby ds » Fri Sep 14, 2007 7:13 am

Yeah, I can add that. It might have made more sense to make $region a class property rather then having to pass it with every fetch method. I will get it added ASAP. 8)
Image
ds
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 297
Joined: Sat Jul 08, 2006 9:58 am

Re: Feature Request: armory.class.php

Postby poetter » Fri Sep 14, 2007 7:17 am

I can live with both solutions. Do it as you like. Thx for quick response
Image
User avatar
poetter
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 462
Joined: Sat Jun 30, 2007 9:41 pm
Location: Germany/Hamburg

Feature Request: armory.class.php

Postby zanix » Fri Sep 14, 2007 7:34 am

Hehe, I like your avatar poetter

But yeah, good idea :thumleft:
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Feature Request: armory.class.php

Postby ds » Fri Sep 14, 2007 1:24 pm

Added your request.

Added in SVN: 1332

setRegion( $region )

You can also set the $region when you create an instance of the class:

Code: Select all
$armory = new RosterArmory( 'EU' );
Image
ds
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 297
Joined: Sat Jul 08, 2006 9:58 am


Return to Archived

Who is online

Users browsing this forum: No registered users and 1 guest

cron