Location: PHPKode > projects > HikaShop > front/views/address/view.html.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 addressViewAddress extends JView{
	function display($tpl = null){
		$function = $this->getLayout();
		if(method_exists($this,$function)) $this->$function();
		parent::display($tpl);
	}
	function listing(){
		$user_id = hikashop::loadUser();
		$addresses = array();
		$fields = null;
		if($user_id){
			$addressClass = hikashop::get('class.address');
			$addresses = $addressClass->getByUser($user_id);
			if(!empty($addresses)){
				$addressClass->loadZone($addresses);
				$fields =& $addressClass->fields;
			}
		}
		$this->assignRef('user_id',$user_id);
		$this->assignRef('fields',$fields);
		$this->assignRef('addresses',$addresses);
		$fieldsClass = hikashop::get('class.field');
		$this->assignRef('fieldsClass',$fieldsClass);
		JHTML::_('behavior.modal');
	}
	function form(){
		$user_id = hikashop::loadUser();
		$this->assignRef('user_id',$user_id);
		$address_id = hikashop::getCID('address_id');
		$address = null;
		if(!empty($address_id)){
			$class=hikashop::get('class.address');
			$address = $class->get($address_id);
			if($address->address_user_id!=$user_id){
				$address = null;
				$address_id = 0;
			}
		}else{
			$userCMS =& JFactory::getUser();
			if(!$userCMS->guest){
				$name = $userCMS->get('name');
				$pos = strpos($name,' ');
				if($pos!==false){
					$address->address_firstname = substr($name,0,$pos);
					$name = substr($name,$pos+1);
				}
				$address->address_lastname = $name;
			}
		}
		$extraFields=array();
		$fieldsClass = hikashop::get('class.field');
		$this->assignRef('fieldsClass',$fieldsClass);
		$fieldsClass->skipAddressName=true;
		$extraFields['address'] = $fieldsClass->getFields('frontcomp',$address,'address');
		$this->assignRef('extraFields',$extraFields);
		$this->assignRef('address',$address);
		$module = hikashop::get('helper.module');
		$module->initialize($this);
		$requiredFields = array();
		$validMessages = array();
		$values = array('address'=>$address);
		$fieldsClass->checkFieldsForJS($extraFields,$requiredFields,$validMessages,$values);
		$fieldsClass->addJS($requiredFields,$validMessages,array('address'));
		$cart=hikashop::get('helper.cart');
		$this->assignRef('cart',$cart);
		JHTML::_('behavior.mootools');
	}
}
Return current item: HikaShop