home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / Services / ExchangeRates / Countries_UN.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  3.1 KB  |  79 lines

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available through the world-wide-web at                              |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Author: Marshall Roch <marshall@exclupen.com>                        |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Countries_UN.php,v 1.1.1.1 2003/09/13 15:03:53 mroch Exp $
  20.  
  21. /**
  22.  *
  23.  * @author Marshall Roch <marshall@exclupen.com>
  24.  * @copyright Copyright 2003 Marshall Roch
  25.  * @license http://www.php.net/license/2_02.txt PHP License 2.0
  26.  * @package Services_ExchangeRates
  27.  */
  28.  
  29. /**
  30.  * Include common functions to handle cache and fetch the file from the server
  31.  */
  32. require_once 'Services/ExchangeRates/Common.php';
  33.  
  34. /**
  35.  * United Nations country codes driver
  36.  *
  37.  * Retrieves the ISO 3166 country codes in XML format from the United 
  38.  * Nations Economic Commission for Europe.  This file is cached for 1 month
  39.  * by default, since it hardly ever changes.
  40.  *
  41.  * @link http://www.unece.org/etrades/unedocs/repository/codelists/xml/CountryCodeList.xml
  42.  * @package Services_ExchangeRates
  43.  */
  44. class Services_ExchangeRates_Countries_UN extends Services_ExchangeRates_Common {
  45.  
  46.    /**
  47.     * URL of XML feed
  48.     * @var string
  49.     */
  50.     var $feedUrl = 'http://www.unece.org/etrades/unedocs/repository/codelists/xml/CountryCodeList.xml';
  51.       
  52.    /**
  53.     * Retrieves currency codes and their associated names (e.g. USD => US Dollar)
  54.     * from the UN or the cache.  The default cache length is 1 month.
  55.     *
  56.     * @param int Optionally override default 1 month cache length (in seconds)
  57.     * @return array Array of currency codes to currency names
  58.     */   
  59.     function retrieve($cacheLength, $cacheDir) {
  60.         
  61.         // retrieve the feed from the server or cache
  62.         $root = $this->retrieveXML($this->feedUrl, $cacheLength, $cacheDir);
  63.     
  64.         foreach($root->children as $curr) {
  65.             // Filter out blank or unwanted elements
  66.             if ($curr->name == "Country") {
  67.                 // loop through and put them into an array
  68.                 $countries[$curr->children[0]->content] = $curr->children[1]->content;
  69.             }
  70.         }
  71.  
  72.         return $countries; 
  73.         
  74.     }
  75.  
  76. }
  77.  
  78. ?>
  79.