Location: PHPKode > projects > HikaShop > back/types/plugins.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 hikashopPluginsType{
	var $type = 'payment';
	function preload(){
		$pluginsClass = hikashop::get('class.plugins');
		$this->methods[$this->type] = $pluginsClass->getMethods($this->type);
		if($this->type=='shipping'){
			$unset=array();
			$add=array();
			foreach($this->methods[$this->type] as $k => $method){
				if($method->shipping_type!='manual'){
					$plugin = hikashop::import( 'hikashop'.$this->type, $method->shipping_type );
					if($plugin && method_exists($plugin,'shippingMethods')){
						$methods = $plugin->shippingMethods($method);
						if(is_array($methods) && !empty($methods)){
							$unset[]=$k;
							foreach($methods as $id=>$name){
								$new = clone($method);
								$new->shipping_id = $id;
								$new->shipping_name = $name;
								$add[]=$new;
							}
						}
					}
				}
			}
			foreach($unset as $k){
				unset($this->methods[$this->type][$k]);
			}
			foreach($add as $v){
				$this->methods[$this->type][]=$v;
			}
		}
	}
	function load($type,$id){
		$this->values = array();
		$found = false;
		if(!empty($this->methods[$this->type])){
			$type_name = $this->type.'_type';
			$id_name = $this->type.'_id';
			$name = $this->type.'_name';
			foreach($this->methods[$this->type] as $method){
				if($method->$type_name==$type && $method->$id_name==$id){
					$found = true;
				}
				if(empty($method->$name)){
					if(empty($method->$type_name)){
						$method->$name = '';
					}else{
						$method->$name = $method->$type_name.' '.$method->$id_name;
					}
				}
				$this->values[] = JHTML::_('select.option', $method->$type_name.'_'.$method->$id_name, $method->$name );
			}
		}
		if(!$found){
			$this->values[] = JHTML::_('select.option', $type.'_'.$id, $type.' '.$id );
		}
	}
	function getName($type,$id){
		if(empty($this->methods[$this->type])){
			$this->preload();
		}
		if(!empty($this->methods[$this->type])){
			$type_name = $this->type.'_type';
			$id_name = $this->type.'_id';
			$name = $this->type.'_name';
			foreach($this->methods[$this->type] as $method){
				if($method->$type_name==$type && $method->$id_name==$id){
					return $method->$name;
				}
			}
		}
		return '';
	}
	function display($map,$type,$id){
		if(empty($this->methods[$this->type])){
			$this->preload();
		}
		$this->load($type,$id);
		$attribute = ' onfocus="this.oldvalue = this.value;" onchange="var link = document.getElementById(\'plugin_change_link\');link.href = link.href+\'&plugin=\' +this.value+\'&type='.$this->type.'\'; this.value=this.oldvalue; SqueezeBox.fromElement(link,{parse: \'rel\'});"';
		return JHTML::_('select.genericlist', $this->values, $map, 'class="inputbox" size="1"'.$attribute, 'value', 'text', $type.'_'.$id );
	}
}
Return current item: HikaShop