Browse Source

CurrencyLib

euromark 12 years ago
parent
commit
8d7537c7e0

+ 396 - 0
Lib/CurrencyLib.php

@@ -0,0 +1,396 @@
+<?php
+/**
+ * other webservices:
+ * - http://www.webservicex.net/WS/WSDetails.aspx?WSID=10 (XML)
+ * - http://www.webserviceshare.com/business/financial/currency/service/Noon-Foreign-Exchange-Rates.htm (XML)
+ */
+App::uses('HttpSocket', 'Network/Http');
+App::uses('Xml', 'Utility');
+
+/**
+ * Component to retreive calculate currencies
+ *
+ * example:
+ * $result = $this->Currency->convert(2.5, 'EUR', 'USD');
+ *
+ * from: http://www.studiocanaria.com/articles/cakephp_currency_conversion_component
+ * alternativly: http://www.currencyserver.de/webservice/CurrencyServerWebService.asmx/getXmlStream?provider=AVERAGE
+ *
+ * @author Mark Scherer
+ * @license MIT
+ * @cakephp 2.x
+ * 2009-11-23 ms
+ */
+class CurrencyLib {
+
+	const URL = 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml';
+
+	const URL_HISTORY = 'http://www.ecb.int/stats/eurofxref/eurofxref-hist.xml';
+
+	//TODO: get information about a currency (name, ...)
+	const URL_TABLE = 'http://www.ecb.int/rss/fxref-{currency}.html';
+
+	public $baseCurrency = 'EUR';
+
+	public $includeBitcoin = true;
+
+	public $cacheFileUsed = false;
+
+	public $cacheTime = DAY;
+
+	/**
+	* convert
+	*
+	* Converts the $amount from $fromCurrency to $toCurrency, formatted to
+	* $decimals decimal places
+	*
+	* @return float [Converted Currency Amount] or boolean FALSE on failure
+	* @param $amount float
+	* @param $fromCurrency string
+	* @param $toCurrency string
+	* @param $decimals integer[optional]default=2
+	*/
+	public function convert($amount, $fromCurrency, $toCurrency, $decimals = 2) {
+		//Get the rate table
+		$rates = $this->_retrieveCurrencies();
+
+		//Return result of conversion
+		if (!array_key_exists($fromCurrency, $rates) || !array_key_exists($toCurrency, $rates)) {
+			return false;
+		}
+		return number_format($amount/$rates[$fromCurrency]*$rates[$toCurrency], $decimals);
+	}
+
+	/**
+	* table
+	*
+	* Returns an array of rates in comparison the the $base currency given to $decimals
+	* number of decimal places
+	*
+	* @return array $table or boolean FALSE on failure
+	* @param $base string[optional]default='EUR'
+	* @param $decimals integer[optional]default=2
+	*/
+	public function table($base = 'EUR', $decimals = 2) {
+		//Create array to holds rates
+		$rateTable = array();
+		//Get rate table array
+		$rates = $this->_retrieveCurrencies();
+
+		if (!array_key_exists($base, $rates)) {
+			return false;
+		}
+
+		//Iterate throught each rate converting it against $base
+		foreach ($rates as $key => $value) {
+			$rate = 0;
+			if ($value > 0) {
+				$rate = 1 / $rates[$base] * $rates[$key];
+			}
+			$rateTable[$key] = number_format($rate, $decimals);
+		}
+		//Return result array
+		return $rateTable;
+	}
+
+	/**
+	 * CurrencyComponent::isAvailable()
+	 *
+	 * @param mixed $currency
+	 * @return bool Success
+	 */
+	public function isAvailable($currency) {
+		$rates = $this->_retrieveCurrencies();
+		return array_key_exists($currency, $rates);
+	}
+
+	/**
+	 * @param string $name: "" (none), "history", "full" (both)
+	 * 2010-09-19 ms
+	 */
+	public function reset($name = 'full') {
+		if ($name === 'full') {
+			$name = '';
+			Cache::delete('currencyListHistory');
+		}
+		return Cache::delete('currencyList'.ucfirst($name));
+	}
+
+	public function cacheFileUsed() {
+		return $this->cacheFileUsed;
+	}
+
+	/**
+	 * @param string $code (3digit - e.g. EUR)
+	 * @param mixed $default (defaults to bool false)
+	 */
+	public function getName($currency, $default = false) {
+		if (empty($currency)) {
+			return $default;
+		}
+		$currency = strtoupper($currency);
+		$currencies = $this->currencies;
+		if ($this->includeBitcoin) {
+			$currencies['BTC'] = 'Bitcoin';
+		}
+
+		if (array_key_exists($currency, $currencies)) {
+			return $currencies[$currency];
+		}
+		return $default;
+	}
+
+	/**
+	 * CurrencyComponent::_retrieveHistory()
+	 *
+	 * @return array
+	 */
+	protected function _retrieveHistory() {
+		if ($historyList = $this->_retrieve('history')) {
+			return $historyList;
+		}
+
+		//Create an http socket
+		$http = new HttpSocket();
+		$currencies = new XML($http->get(self::URL_HISTORY));
+		$currencies = Set::reverse($currencies);
+		//Filter down to just the rates
+		$currencies = $currencies['Envelope']['Cube']['Cube']['Cube'];
+
+		$historyList = array();
+		//European Central bank gives us everything against Euro so add this manually
+		$historyList[$this->baseCurrency] = 1;
+		//Now iterate through and add the rates provided
+		foreach ($currencies as $currency) {
+			$historyList[$currency['currency']] = $currency['rate'];
+		}
+
+		//Cache
+		$this->_store($historyList, 'history');
+		return $currencyList;
+	}
+
+	/**
+	 * CurrencyComponent::_retrieveCurrencies()
+	 *
+	 * @return array
+	 */
+	protected function _retrieveCurrencies() {
+		//Check whther we have already cached the currencies
+		if ($currencyList = $this->_retrieve()) {
+			return $currencyList;
+		}
+		//...we haven't, so load utility classes needed
+
+		//Create an http socket
+		$Http = new HttpSocket();
+		$res = $Http->get(self::URL);
+		//And retrieve rates as an XML object
+		$currencyXml = Xml::build($res->body);
+		$currencies = Xml::toArray($currencyXml);
+
+		//Filter down to just the rates
+		$currencies = $currencies['Envelope']['Cube']['Cube']['Cube'];
+
+		//Create an array to hold the rates
+		$currencyList = array();
+		//European Central bank gives us everything against Euro so add this manually
+		$currencyList[$this->baseCurrency] = 1;
+		//Now iterate through and add the rates provided
+		foreach ($currencies as $currency) {
+			$currencyList[$currency['@currency']] = $currency['@rate'];
+		}
+
+		if ($this->includeBitcoin && ($res = $this->_getBitcoin())) {
+			$currencyList['BTC'] = $res;
+		}
+
+		//Cache
+		$this->_store($currencyList);
+		return $currencyList;
+	}
+
+	protected function _getBitcoin() {
+		App::uses('CurrencyBitcoinLib', 'Tools.Lib');
+		$Btc = new CurrencyBitcoinLib();
+		return $Btc->rate(array('currency'=>$this->baseCurrency));
+	}
+
+
+	/**
+	 * @param string $name: "" (none), "history", "full" (both)
+	 * 2010-09-19 ms
+	 */
+	protected function _store($currencyList, $name = '') {
+		$this->cacheFileUsed = false;
+		Cache::write('currencyList'.ucfirst($name), serialize($currencyList));
+	}
+
+	/**
+	 * @param string $name: "" (none), "history", "full" (both)
+	 * 2010-09-19 ms
+	 */
+	protected function _retrieve($name = '') {
+		$res = Cache::read('currencyList'.ucfirst($name));
+		if ($res !== false) {
+			$this->cacheFileUsed = true;
+			return unserialize($res);
+		}
+		return false;
+	}
+
+	public $currencies = array(
+		'AFA' => 'Afghanistan Afghani',
+		'ALL' => 'Albanian Lek',
+		'DZD' => 'Algerian Dinar',
+		'ARS' => 'Argentine Peso',
+		'AWG' => 'Aruba Florin',
+		'AUD' => 'Australian Dollar',
+		'BSD' => 'Bahamian Dollar',
+		'BHD' => 'Bahraini Dinar',
+		'BDT' => 'Bangladesh Taka',
+		'BBD' => 'Barbados Dollar',
+		'BZD' => 'Belize Dollar',
+		'BMD' => 'Bermuda Dollar',
+		'BTN' => 'Bhutan Ngultrum',
+		'BOB' => 'Bolivian Boliviano',
+		'BWP' => 'Botswana Pula',
+		'BRL' => 'Brazilian Real',
+		'GBP' => 'British Pound',
+		'BND' => 'Brunei Dollar',
+		'BIF' => 'Burundi Franc',
+		'XOF' => 'CFA Franc (BCEAO)',
+		'XAF' => 'CFA Franc (BEAC)',
+		'KHR' => 'Cambodia Riel',
+		'CAD' => 'Canadian Dollar',
+		'CVE' => 'Cape Verde Escudo',
+		'KYD' => 'Cayman Islands Dollar',
+		'CLP' => 'Chilean Peso',
+		'CNY' => 'Chinese Yuan',
+		'COP' => 'Colombian Peso',
+		'KMF' => 'Comoros Franc',
+		'CRC' => 'Costa Rica Colon',
+		'HRK' => 'Croatian Kuna',
+		'CUP' => 'Cuban Peso',
+		'CYP' => 'Cyprus Pound',
+		'CZK' => 'Czech Koruna',
+		'DKK' => 'Danish Krone',
+		'DJF' => 'Dijibouti Franc',
+		'DOP' => 'Dominican Peso',
+		'XCD' => 'East Caribbean Dollar',
+		'EGP' => 'Egyptian Pound',
+		'SVC' => 'El Salvador Colon',
+		'EEK' => 'Estonian Kroon',
+		'ETB' => 'Ethiopian Birr',
+		'EUR' => 'Euro',
+		'FKP' => 'Falkland Islands Pound',
+		'GMD' => 'Gambian Dalasi',
+		'GHC' => 'Ghanian Cedi',
+		'GIP' => 'Gibraltar Pound',
+		'XAU' => 'Gold Ounces',
+		'GTQ' => 'Guatemala Quetzal',
+		'GNF' => 'Guinea Franc',
+		'GYD' => 'Guyana Dollar',
+		'HTG' => 'Haiti Gourde',
+		'HNL' => 'Honduras Lempira',
+		'HKD' => 'Hong Kong Dollar',
+		'HUF' => 'Hungarian Forint',
+		'ISK' => 'Iceland Krona',
+		'INR' => 'Indian Rupee',
+		'IDR' => 'Indonesian Rupiah',
+		'IQD' => 'Iraqi Dinar',
+		'ILS' => 'Israeli Shekel',
+		'JMD' => 'Jamaican Dollar',
+		'JPY' => 'Japanese Yen',
+		'JOD' => 'Jordanian Dinar',
+		'KZT' => 'Kazakhstan Tenge',
+		'KES' => 'Kenyan Shilling',
+		'KRW' => 'Korean Won',
+		'KWD' => 'Kuwaiti Dinar',
+		'LAK' => 'Lao Kip',
+		'LVL' => 'Latvian Lat',
+		'LBP' => 'Lebanese Pound',
+		'LSL' => 'Lesotho Loti',
+		'LRD' => 'Liberian Dollar',
+		'LYD' => 'Libyan Dinar',
+		'LTL' => 'Lithuanian Lita',
+		'MOP' => 'Macau Pataca',
+		'MKD' => 'Macedonian Denar',
+		'MGF' => 'Malagasy Franc',
+		'MWK' => 'Malawi Kwacha',
+		'MYR' => 'Malaysian Ringgit',
+		'MVR' => 'Maldives Rufiyaa',
+		'MTL' => 'Maltese Lira',
+		'MRO' => 'Mauritania Ougulya',
+		'MUR' => 'Mauritius Rupee',
+		'MXN' => 'Mexican Peso',
+		'MDL' => 'Moldovan Leu',
+		'MNT' => 'Mongolian Tugrik',
+		'MAD' => 'Moroccan Dirham',
+		'MZM' => 'Mozambique Metical',
+		'MMK' => 'Myanmar Kyat',
+		'NAD' => 'Namibian Dollar',
+		'NPR' => 'Nepalese Rupee',
+		'ANG' => 'Neth Antilles Guilder',
+		'NZD' => 'New Zealand Dollar',
+		'NIO' => 'Nicaragua Cordoba',
+		'NGN' => 'Nigerian Naira',
+		'KPW' => 'North Korean Won',
+		'NOK' => 'Norwegian Krone',
+		'OMR' => 'Omani Rial',
+		'XPF' => 'Pacific Franc',
+		'PKR' => 'Pakistani Rupee',
+		'XPD' => 'Palladium Ounces',
+		'PAB' => 'Panama Balboa',
+		'PGK' => 'Papua New Guinea Kina',
+		'PYG' => 'Paraguayan Guarani',
+		'PEN' => 'Peruvian Nuevo Sol',
+		'PHP' => 'Philippine Peso',
+		'XPT' => 'Platinum Ounces',
+		'PLN' => 'Polish Zloty',
+		'QAR' => 'Qatar Rial',
+		'ROL' => 'Romanian Leu',
+		'RUB' => 'Russian Rouble',
+		'WST' => 'Samoa Tala',
+		'STD' => 'Sao Tome Dobra',
+		'SAR' => 'Saudi Arabian Riyal',
+		'SCR' => 'Seychelles Rupee',
+		'SLL' => 'Sierra Leone Leone',
+		'XAG' => 'Silver Ounces',
+		'SGD' => 'Singapore Dollar',
+		'SKK' => 'Slovak Koruna',
+		'SIT' => 'Slovenian Tolar',
+		'SBD' => 'Solomon Islands Dollar',
+		'SOS' => 'Somali Shilling',
+		'ZAR' => 'South African Rand',
+		'LKR' => 'Sri Lanka Rupee',
+		'SHP' => 'St Helena Pound',
+		'SDD' => 'Sudanese Dinar',
+		'SRG' => 'Surinam Guilder',
+		'SZL' => 'Swaziland Lilageni',
+		'SEK' => 'Swedish Krona',
+		'TRY' => 'Turkey Lira',
+		'CHF' => 'Swiss Franc',
+		'SYP' => 'Syrian Pound',
+		'TWD' => 'Taiwan Dollar',
+		'TZS' => 'Tanzanian Shilling',
+		'THB' => 'Thai Baht',
+		'TOP' => 'Tonga Pa\'anga',
+		'TTD' => 'Trinidad & Tobago Dollar',
+		'TND' => 'Tunisian Dinar',
+		'TRL' => 'Turkish Lira',
+		'USD' => 'U.S. Dollar',
+		'AED' => 'UAE Dirham',
+		'UGX' => 'Ugandan Shilling',
+		'UAH' => 'Ukraine Hryvnia',
+		'UYU' => 'Uruguayan New Peso',
+		'VUV' => 'Vanuatu Vatu',
+		'VEB' => 'Venezuelan Bolivar',
+		'VND' => 'Vietnam Dong',
+		'YER' => 'Yemen Riyal',
+		'YUM' => 'Yugoslav Dinar',
+		'ZMK' => 'Zambian Kwacha',
+		'ZWD' => 'Zimbabwe Dollar',
+	);
+
+}

+ 1 - 1
Lib/EmailLib.php

@@ -647,7 +647,7 @@ class EmailLib extends CakeEmail {
 			'||S:'.$this->_log['subject'];
 			'||S:'.$this->_log['subject'];
 		$type = 'email';
 		$type = 'email';
 		if (!empty($this->_error)) {
 		if (!empty($this->_error)) {
-		 	$type = 'email_error';
+			$type = 'email_error';
 			$res .= '||ERROR:' . $this->_error;
 			$res .= '||ERROR:' . $this->_error;
 		}
 		}
 		if ($append) {
 		if ($append) {

+ 1 - 1
Lib/Utility/ChmodLib.php

@@ -20,7 +20,7 @@ class ChmodLib {
 
 
 /*** calc octal ***/
 /*** calc octal ***/
 
 
-	 	/**
+		/**
 	 * from Octal 0xxx back to STRING with leading zero added on leading zero = true
 	 * from Octal 0xxx back to STRING with leading zero added on leading zero = true
 	 * e.g. 0777 => 0777, '755' => 0755
 	 * e.g. 0777 => 0777, '755' => 0755
 	 * @access static Chmod::convertFromOctal(mode, leadingZero)
 	 * @access static Chmod::convertFromOctal(mode, leadingZero)

+ 1 - 1
Model/Qlogin.php

@@ -95,7 +95,7 @@ class Qlogin extends ToolsAppModel {
 			$uid = CakeSession::read('Auth.User.id');
 			$uid = CakeSession::read('Auth.User.id');
 		}
 		}
 		$key = $this->generate($url, $uid);
 		$key = $this->generate($url, $uid);
-	 	return $this->urlByKey($key);
+		return $this->urlByKey($key);
 	}
 	}
 
 
 }
 }

+ 1 - 1
Model/Qurl.php

@@ -118,7 +118,7 @@ class Qurl extends ToolsAppModel {
 		if (!$key) {
 		if (!$key) {
 			return false;
 			return false;
 		}
 		}
-	 	return $this->urlByKey($key);
+		return $this->urlByKey($key);
 	}
 	}
 
 
 	/**
 	/**

+ 1 - 1
Model/Token.php

@@ -84,7 +84,7 @@ class Token extends ToolsAppModel {
 			$this->set($data);
 			$this->set($data);
 			$max--;
 			$max--;
 			if ($max === 0) { //die('Exeption in Token');
 			if ($max === 0) { //die('Exeption in Token');
-			 	return false;
+				return false;
 			}
 			}
 		}
 		}
 
 

+ 56 - 0
Test/Case/Lib/CurrencyLibTest.php

@@ -0,0 +1,56 @@
+<?php
+App::uses('CurrencyLib', 'Tools.Lib');
+App::uses('MyCakeTestCase', 'Tools.TestSuite');
+
+class CurrencyLibTest extends MyCakeTestCase {
+
+	public function setUp() {
+		parent::setUp();
+
+		$this->CurrencyLib = new CurrencyLib();
+	}
+
+	public function testStartReset() {
+		$this->CurrencyLib->reset();
+	}
+
+	/**
+	 * test
+	 * 2010-06-05 ms
+	 */
+	public function testConvert() {
+		$this->out('<h2>30 EUR in USD</h2>', true);
+		$is = $this->CurrencyLib->convert(30, 'EUR', 'USD');
+		$this->debug($is);
+		$this->assertTrue($is > 30 && $is < 60);
+
+		$this->assertFalse($this->CurrencyLib->cacheFileUsed());
+	}
+
+	public function testIsAvailable() {
+		$is = $this->CurrencyLib->isAvailable('EUR');
+		$this->assertTrue($is);
+
+		$is = $this->CurrencyLib->isAvailable('XYZ');
+		$this->assertFalse($is);
+	}
+
+
+	public function testTable() {
+		$this->out('<h2>Currency Table</h2>', true);
+		$is = $this->CurrencyLib->table();
+		$this->debug($is);
+		$this->assertTrue(is_array($is) && !empty($is));
+
+		$is = $this->CurrencyLib->table('XYZ');
+		$this->assertFalse($is);
+
+		$this->assertTrue($this->CurrencyLib->cacheFileUsed());
+	}
+
+	public function testReset() {
+		$res = $this->CurrencyLib->reset();
+		$this->assertTrue($res === null || $res === true);
+	}
+
+}

+ 7 - 7
Test/Case/Model/Behavior/GeocoderBehaviorTest.php

@@ -125,7 +125,7 @@ class GeocoderBehaviorTest extends CakeTestCase {
 
 
 		# inconclusive
 		# inconclusive
 		$data = array(
 		$data = array(
-	 		//'street' => 'Leopoldstraße',
+			//'street' => 'Leopoldstraße',
 			'city' => 'München'
 			'city' => 'München'
 		);
 		);
 		$res = $this->Comment->save($data);
 		$res = $this->Comment->save($data);
@@ -151,7 +151,7 @@ class GeocoderBehaviorTest extends CakeTestCase {
 		$this->Comment->Behaviors->load('Tools.Geocoder', array('real'=>false, 'min_accuracy'=>0));
 		$this->Comment->Behaviors->load('Tools.Geocoder', array('real'=>false, 'min_accuracy'=>0));
 		// accuracy = 1
 		// accuracy = 1
 		$data = array(
 		$data = array(
-	 		//'street' => 'Leopoldstraße',
+			//'street' => 'Leopoldstraße',
 			'city' => 'Deutschland'
 			'city' => 'Deutschland'
 		);
 		);
 		$res = $this->Comment->save($data);
 		$res = $this->Comment->save($data);
@@ -171,7 +171,7 @@ class GeocoderBehaviorTest extends CakeTestCase {
 		$this->Comment->Behaviors->load('Tools.Geocoder', array('real'=>false, 'min_accuracy'=>4));
 		$this->Comment->Behaviors->load('Tools.Geocoder', array('real'=>false, 'min_accuracy'=>4));
 		// accuracy = 1
 		// accuracy = 1
 		$data = array(
 		$data = array(
-	 		//'street' => 'Leopoldstraße',
+			//'street' => 'Leopoldstraße',
 			'city' => 'Deutschland'
 			'city' => 'Deutschland'
 		);
 		);
 		$res = $this->Comment->save($data);
 		$res = $this->Comment->save($data);
@@ -195,7 +195,7 @@ class GeocoderBehaviorTest extends CakeTestCase {
 
 
 		// accuracy = 1
 		// accuracy = 1
 		$data = array(
 		$data = array(
-	 		//'street' => 'Leopoldstraße',
+			//'street' => 'Leopoldstraße',
 			'city' => 'Neustadt'
 			'city' => 'Neustadt'
 		);
 		);
 		$res = $this->Comment->save($data);
 		$res = $this->Comment->save($data);
@@ -217,7 +217,7 @@ class GeocoderBehaviorTest extends CakeTestCase {
 		$this->Comment->Behaviors->load('Tools.Geocoder', array('real'=>false, 'allow_inconclusive'=>true));
 		$this->Comment->Behaviors->load('Tools.Geocoder', array('real'=>false, 'allow_inconclusive'=>true));
 		// accuracy = 1
 		// accuracy = 1
 		$data = array(
 		$data = array(
-	 		//'street' => 'Leopoldstraße',
+			//'street' => 'Leopoldstraße',
 			'city' => 'Neustadt'
 			'city' => 'Neustadt'
 		);
 		);
 		$res = $this->Comment->save($data);
 		$res = $this->Comment->save($data);
@@ -239,7 +239,7 @@ class GeocoderBehaviorTest extends CakeTestCase {
 		$this->Comment->Behaviors->load('Tools.Geocoder', array('real'=>false, 'expect'=>array('postal_code')));
 		$this->Comment->Behaviors->load('Tools.Geocoder', array('real'=>false, 'expect'=>array('postal_code')));
 		// accuracy = 1
 		// accuracy = 1
 		$data = array(
 		$data = array(
-	 		//'street' => 'Leopoldstraße',
+			//'street' => 'Leopoldstraße',
 			'city' => 'Bibersfeld'
 			'city' => 'Bibersfeld'
 		);
 		);
 		$res = $this->Comment->save($data);
 		$res = $this->Comment->save($data);
@@ -251,7 +251,7 @@ class GeocoderBehaviorTest extends CakeTestCase {
 		$this->assertTrue(empty($res['Comment']['lat']) && empty($res['Comment']['lng']));
 		$this->assertTrue(empty($res['Comment']['lat']) && empty($res['Comment']['lng']));
 
 
 		$data = array(
 		$data = array(
-	 		//'street' => 'Leopoldstraße',
+			//'street' => 'Leopoldstraße',
 			'city' => '74523'
 			'city' => '74523'
 		);
 		);
 		$res = $this->Comment->save($data);
 		$res = $this->Comment->save($data);

+ 1 - 1
Test/Case/View/Helper/TreeHelperTest.php

@@ -349,7 +349,7 @@ TEXT;
 		$tree = $this->Model->find('threaded');
 		$tree = $this->Model->find('threaded');
 		$id = 6;
 		$id = 6;
 		$path = $this->Model->getPath($id);
 		$path = $this->Model->getPath($id);
-	 	//$this->_hideUnrelated($tree, $path);
+		//$this->_hideUnrelated($tree, $path);
 
 
 		$output = $this->Tree->generate($tree, array('autoPath' => array(6, 11), 'hideUnrelated' => true, 'treePath' => $path, 'callback'=>array($this, '_myCallback'))); // Two-SubA
 		$output = $this->Tree->generate($tree, array('autoPath' => array(6, 11), 'hideUnrelated' => true, 'treePath' => $path, 'callback'=>array($this, '_myCallback'))); // Two-SubA
 		//debug($output);
 		//debug($output);

+ 11 - 11
View/Helper/CommonHelper.php

@@ -128,16 +128,16 @@ class CommonHelper extends AppHelper {
 		$res = array();
 		$res = array();
 		foreach ($lang as $language => $countries) {
 		foreach ($lang as $language => $countries) {
 			if (is_numeric($language)) {
 			if (is_numeric($language)) {
-		 		$language = '';
+				$language = '';
  			} else {
  			} else {
  				$language .= '-';
  				$language .= '-';
  			}
  			}
  			$countries = (array)$countries;
  			$countries = (array)$countries;
-	 		foreach ($countries as $country) {
-	 			$l = $language . $country;
-	 			$options = array('rel' => 'alternate', 'hreflang' => $l, 'type' => null, 'title' => null);
-	 			$res[] = $this->Html->meta('alternate', $url, $options).PHP_EOL;
-	 		}
+			foreach ($countries as $country) {
+				$l = $language . $country;
+				$options = array('rel' => 'alternate', 'hreflang' => $l, 'type' => null, 'title' => null);
+				$res[] = $this->Html->meta('alternate', $url, $options).PHP_EOL;
+			}
 		}
 		}
 		return implode('', $res);
 		return implode('', $res);
 	}
 	}
@@ -250,7 +250,7 @@ class CommonHelper extends AppHelper {
 
 
 			$time = date('YmdHis', filemtime(APP . 'webroot' . DS . CSS_URL . $path . '.css'));
 			$time = date('YmdHis', filemtime(APP . 'webroot' . DS . CSS_URL . $path . '.css'));
 			$url = "{$this->request->webroot}" . (COMPRESS_CSS ? 'c' : '') . CSS_URL . $this->themeWeb . $path . ".css?" . $time;
 			$url = "{$this->request->webroot}" . (COMPRESS_CSS ? 'c' : '') . CSS_URL . $this->themeWeb . $path . ".css?" . $time;
-	 	return $url;
+		return $url;
 	}
 	}
 
 
 
 
@@ -362,7 +362,7 @@ class CommonHelper extends AppHelper {
 		if ((int)$c !== 1) {
 		if ((int)$c !== 1) {
 			$p = Inflector::pluralize($s);
 			$p = Inflector::pluralize($s);
 		} else {
 		} else {
-		 	$p = null; # no pluralization necessary
+			$p = null; # no pluralization necessary
 		}
 		}
 		return $this->sp($s, $p, $c, $autoTranslate);
 		return $this->sp($s, $p, $c, $autoTranslate);
 	}
 	}
@@ -381,7 +381,7 @@ class CommonHelper extends AppHelper {
 		if ((int)$c !== 1) {
 		if ((int)$c !== 1) {
 			$ret = $p;
 			$ret = $p;
 		} else {
 		} else {
-		 		$ret = $s;
+				$ret = $s;
 		}
 		}
 
 
 		if ($autoTranslate) {
 		if ($autoTranslate) {
@@ -516,7 +516,7 @@ class CommonHelper extends AppHelper {
 	 * 2009-01-08 ms
 	 * 2009-01-08 ms
 	 */
 	 */
 	public function framebuster() {
 	public function framebuster() {
-	 	return $this->Html->scriptBlock('
+		return $this->Html->scriptBlock('
 if (top!=self) top.location.ref=self.location.href;
 if (top!=self) top.location.ref=self.location.href;
 ');
 ');
 	}
 	}
@@ -535,7 +535,7 @@ if (top!=self) top.location.ref=self.location.href;
 		if (!isset($options['escape']) || $options['escape'] !== false) {
 		if (!isset($options['escape']) || $options['escape'] !== false) {
 				$message = h($message);
 				$message = h($message);
 		}
 		}
-	 	return $this->Html->scriptBlock('
+		return $this->Html->scriptBlock('
 // Returns the version of Internet Explorer or a -1
 // Returns the version of Internet Explorer or a -1
 function getInternetExplorerVersion() {
 function getInternetExplorerVersion() {
 	var rv = -1; // Return value assumes failure.
 	var rv = -1; // Return value assumes failure.

+ 1 - 1
View/Helper/FormExtHelper.php

@@ -1062,7 +1062,7 @@ jQuery(\''.$selector.'\').maxlength('.$this->Js->object($settings, array('quoteK
 	 */
 	 */
 	public function _checkbox($id, $group = null, $options = array()) {
 	public function _checkbox($id, $group = null, $options = array()) {
 		$defaults = array(
 		$defaults = array(
-	 		'class' => 'checkboxToggle'
+			'class' => 'checkboxToggle'
 		);
 		);
 		$options = array_merge($defaults, $options);
 		$options = array_merge($defaults, $options);
 		return $script . parent::checkbox($fieldName, $options);
 		return $script . parent::checkbox($fieldName, $options);

+ 1 - 1
View/Helper/FormatHelper.php

@@ -736,7 +736,7 @@ class FormatHelper extends TextHelper {
 		}
 		}
 		if (!file_exists($folder.DS.$file)) {
 		if (!file_exists($folder.DS.$file)) {
 			$command = 'convert -background '.(!empty($options['background'])?'"'.$options['background'].'"':'transparent').' -font '.$options['font'].' -fill '.(!empty($options['color'])?'"'.$options['color'].'"':'transparent').' -pointsize '.$options['size'].' label:"'.$text.'" '.$folder.DS.$file;
 			$command = 'convert -background '.(!empty($options['background'])?'"'.$options['background'].'"':'transparent').' -font '.$options['font'].' -fill '.(!empty($options['color'])?'"'.$options['color'].'"':'transparent').' -pointsize '.$options['size'].' label:"'.$text.'" '.$folder.DS.$file;
-		 	exec($command, $a, $r);
+			exec($command, $a, $r);
 			if ($r !== 0) {
 			if ($r !== 0) {
 				return '';
 				return '';
 			}
 			}