Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

199
 
386
 
386
 
currencies.php
_> 11 <?php
  22 /*
<> 3 -  $Id: currencies.php 199 2005-09-22 15:56:13Z hpdl $
   3+  $Id: currencies.php 386 2006-01-12 11:36:39Z hpdl $
44 
  55   osCommerce, Open Source E-Commerce Solutions
  66   http://www.oscommerce.com
  77 
<> 8 -  Copyright (c) 2004 osCommerce
   8+  Copyright (c) 2006 osCommerce
99 
  1010   Released under the GNU General Public License
  1111 */
  1212 
  1313   class osC_Currencies {
<> 14 -    var $currencies;
   14+    var $currencies = array();
1515 
  1616 // class constructor
  1717     function osC_Currencies() {
  1818       global $osC_Database;
  1919 
<> 20 -      $this->currencies = array();
  21 -
  22 -      $Qcurrencies = $osC_Database->query('select code, title, symbol_left, symbol_right, decimal_places, value from :table_currencies');
  23 -      $Qcurrencies->bindRaw(':table_currencies', TABLE_CURRENCIES);
   20+      $Qcurrencies = $osC_Database->query('select * from :table_currencies');
   21+      $Qcurrencies->bindTable(':table_currencies', TABLE_CURRENCIES);
   22+      $Qcurrencies->setCache('currencies');
2423       $Qcurrencies->execute();
  2524 
  2625       while ($Qcurrencies->next()) {
<> 27 -        $this->currencies[$Qcurrencies->value('code')] = array('title' => $Qcurrencies->value('title'),
   26+        $this->currencies[$Qcurrencies->value('code')] = array('id' => $Qcurrencies->valueInt('currencies_id'),
   27+                                                               'title' => $Qcurrencies->value('title'),
2828                                                                'symbol_left' => $Qcurrencies->value('symbol_left'),
  2929                                                                'symbol_right' => $Qcurrencies->value('symbol_right'),
  3030                                                                'decimal_places' => $Qcurrencies->valueInt('decimal_places'),
  3131                                                                'value' => $Qcurrencies->valueDecimal('value'));
  3232       }
<>  33+
   34+      $Qcurrencies->freeResult();
3335     }
  3436 
  3537 // class methods
  3638     function format($number, $currency_code = '', $currency_value = '') {
<>  39+      global $osC_Language;
   40+
3741       if (empty($currency_code) || ($this->exists($currency_code) == false)) {
  3842         $currency_code = (isset($_SESSION['currency']) ? $_SESSION['currency'] : DEFAULT_CURRENCY);
  3943       }
     
 !
4246         $currency_value = $this->currencies[$currency_code]['value'];
  4347       }
  4448 
<> 45 -      return $this->currencies[$currency_code]['symbol_left'] . number_format(tep_round($number * $currency_value, $this->currencies[$currency_code]['decimal_places']), $this->currencies[$currency_code]['decimal_places'], NUMERIC_DECIMAL_SEPARATOR, NUMERIC_THOUSANDS_SEPARATOR) . $this->currencies[$currency_code]['symbol_right'];
   49+      return $this->currencies[$currency_code]['symbol_left'] . number_format(tep_round($number * $currency_value, $this->currencies[$currency_code]['decimal_places']), $this->currencies[$currency_code]['decimal_places'], $osC_Language->getNumericDecimalSeparator(), $osC_Language->getNumericThousandsSeparator()) . $this->currencies[$currency_code]['symbol_right'];
4650     }
  4751 
  4852     function displayPrice($price, $tax_class_id, $quantity = 1) {
     
 !
8084 
  8185       return false;
  8286     }
<>  87+
   88+    function getCode($id = '') {
   89+      if (is_numeric($id)) {
   90+        foreach ($this->currencies as $key => $value) {
   91+          if ($value['currencies_id'] == $id) {
   92+            return $key;
   93+          }
   94+        }
   95+      } else {
   96+        return $_SESSION['currency'];
   97+      }
   98+    }
<_ 8399   }
  84100 ?>