Location: PHPKode > projects > HikaShop > back/helpers/volume.php
<?php
/**
 * @package		HikaShop for Joomla!
 * @version		1.4.3
 * @author		hikashop.com
 * @copyright	(C) 2010 HIKARI SOFTWARE. All rights reserved.
 * @license		GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?>
<?php
class hikashopVolumeHelper{
	var $conversion = array(
		'm'=>array('dm'=>1000,'cm'=>1000000,'mm'=>1000000000,'ft'=>35.31466672,'in'=>61023.74409473,'yd'=>1.30795062),
		'dm'=>array('m'=>0.001,'cm'=>1000,'mm'=>1000000,'ft'=>0.03531466672,'in'=>61.02374409473,'yd'=>0.00130795062),
		'cm'=>array('m'=>0.000001,'dm'=>0.001,'mm'=>1000,'ft'=>0.00003531,'in'=>0.06102374,'yd'=>0.00000131),
		'mm'=>array('m'=>0.000000001,'dm'=>0.000001,'cm'=>0.001,'ft'=>0.000000035312274,'in'=>0.00006102,'yd'=>0.0000000013078621),
		'in'=>array('m'=>0.00001639,'dm'=>0.016387064,'cm'=>16.387064,'mm'=>16387.064,'ft'=>0.0005787,'yd'=>0.00002143),
		'ft'=>array('m'=>0.02831685,'dm'=>28.316846592,'cm'=>28316.846592,'mm'=>28316846.592,'in'=>1728,'yd'=>0.03703704),
		'yd'=>array('m'=>0.76455486,'dm'=>764.554857984,'cm'=>764554.857984,'mm'=>764554857.9839998,'in'=>46656,'ft'=>27),
	);
	function hikashopVolumeHelper(){
		$this->getSymbol();
	}	
	function convert($weight,$symbol_used='',$target=''){
		if(empty($target)){
			$target=$this->main_symbol;
		}
		if(empty($symbol_used)){
			$symbol_used=$this->main_symbol;
		}
		if($symbol_used != $target){
			$convert = $this->conversion[$symbol_used][$target];
			return $weight*$convert;
		}
		return $weight;
	}
	function getSymbol(){
		if(empty($this->main_symbol)){
			$config =& hikashop::config();
			$this->symbols = explode(',',$config->get('volume_symbols','m,dm,cm,mm'));
			foreach($this->symbols as $k => $symbol){
				$this->symbols[$k] = trim($symbol);
			}
			$this->main_symbol = array_shift($this->symbols);
		}
		return $this->main_symbol;
	}
}
Return current item: HikaShop