Location: PHPKode > projects > HikaShop > back/views/field/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 FieldViewField extends JView{
	function display($tpl = null){
		$function = $this->getLayout();
		$this->paramBase = HIKASHOP_COMPONENT.'.'.$this->getName();
		if(method_exists($this,$function)) $this->$function();
		parent::display($tpl);
	}
	function form(){
		$fieldid = hikashop::getCID('field_id');
		$fieldsClass = hikashop::get('class.field');
		if(!empty($fieldid)){
			$field = $fieldsClass->getField($fieldid);
		}else{
			$app =& JFactory::getApplication();
			$field = null;
			if(hikashop::level(1)){
				$field->field_table = $app->getUserStateFromRequest( $this->paramBase.".filter_table",'filter_table','product','string');
			}else{
				$field->field_table = 'address';
			}
			$field->field_published = 1;
			$field->field_type = 'text';
			$field->field_backend = 1;
		}
		if(!empty($field->field_id)) $fieldTitle = ' : '.$field->field_namekey;
		else $fieldTitle = '';
		hikashop::setTitle(JText::_('FIELD').$fieldTitle,'field','field&task=edit&field_id='.$fieldid);
		$script = 'function addLine(){
			var myTable=window.document.getElementById("tablevalues");
			var newline = document.createElement(\'tr\');
			var column = document.createElement(\'td\');
			var column2 = document.createElement(\'td\');
			var column3 = document.createElement(\'td\');
			var input = document.createElement(\'input\');
			var input2 = document.createElement(\'input\');
			var input3 = document.createElement(\'select\');
			var option1 = document.createElement(\'option\');
			var option2 = document.createElement(\'option\');
			input.type = \'text\';
			input2.type = \'text\';
			input3.class = \'inputbox\';
			option1.value= \'0\';
			option2.value= \'1\';
			input.name = \'field_values[title][]\';
			input2.name = \'field_values[value][]\';
			input3.name = \'field_values[disabled][]\';
			option1.text= \''.JText::_('HIKASHOP_NO',true).'\';
			option2.text= \''.JText::_('HIKASHOP_YES',true).'\';
			try { input3.add(option1, null); } catch(ex) { input3.add(option1); }
			try { input3.add(option2, null); } catch(ex) { input3.add(option2); }
			column.appendChild(input);
			column2.appendChild(input2);
			column3.appendChild(input3);
			newline.appendChild(column);
			newline.appendChild(column2);
			newline.appendChild(column3);
			myTable.appendChild(newline);
		}';
		$doc =& JFactory::getDocument();
		$doc->addScriptDeclaration( $script);
		$bar = & JToolBar::getInstance('toolbar');
		JToolBarHelper::save();
		JToolBarHelper::apply();
		JToolBarHelper::cancel();
		JToolBarHelper::divider();
		$bar->appendButton( 'Pophelp','field-form');
		$this->assignRef('fieldtype',hikashop::get('type.fields'));
		$this->assignRef('field',$field);
		$this->assignRef('fieldsClass',$fieldsClass);
		if(hikashop::level(1)){
			$this->assignRef('tabletype',hikashop::get('type.table'));
		}
		$this->assignRef('zoneType',hikashop::get('type.zone'));
		if(hikashop::level(2)){
			$this->assignRef('limitParent',hikashop::get('type.limitparent'));
			if(!empty($field->field_options['product_id'])){
				$product = hikashop::get('class.product');
				$element = $product->get($field->field_options['product_id']);
				$this->assignRef('element',$element);
			}
		}
		JHTML::_('behavior.modal');
	}
	function listing(){
		$db =& JFactory::getDBO();
		$filter = '';
		if(hikashop::level(1)){
			$app =& JFactory::getApplication();
			$selectedType = $app->getUserStateFromRequest( $this->paramBase.".filter_table",'filter_table','','string');
			if(!empty($selectedType)){
				$filter = ' WHERE a.field_table='.$db->Quote($selectedType);
			}
			$this->assignRef('tabletype',hikashop::get('type.table'));
		}else{
			$filter = ' WHERE a.field_table=\'address\'';
		}
		$db->setQuery('SELECT a.* FROM '.hikashop::table('field').' AS a'.$filter.' ORDER BY a.`field_table` ASC, a.`field_ordering` ASC');
		$rows = $db->loadObjectList();
		$bar = & JToolBar::getInstance('toolbar');
		JToolBarHelper::addNew();
		JToolBarHelper::editList();
		JToolBarHelper::deleteList(JText::_('HIKA_VALIDDELETEITEMS'));
		JToolBarHelper::divider();
		$bar->appendButton( 'Pophelp','field-listing');
		$bar->appendButton( 'Link', 'hikashop', JText::_('HIKASHOP_CPANEL'), hikashop::completeLink('dashboard') );
		jimport('joomla.html.pagination');
		$total = count($rows);
		$pagination = new JPagination($total, 0,$total);
		hikashop::setTitle(JText::_('FIELDS'),'field','field');
		$this->assignRef('rows',$rows);
		$this->assignRef('toggleClass',hikashop::get('helper.toggle'));
		$this->assignRef('pagination',$pagination);
		$this->assignRef('selectedType',$selectedType);
		$type = hikashop::get('type.fields');
		$type->load();
		$this->assignRef('fieldtype',$type);
		$this->assignRef('fieldsClass',hikashop::get('class.field'));
	}
	function state(){
		$namekey = JRequest::getCmd('namekey','');
		if(!empty($namekey)){
			$class = hikashop::get('type.country');
			$class->type = 'state';
			$class->published = true;
			$class->country_name = $namekey;
			$states = $class->load();
			if(!empty($states)){
				$obj = null;
				$obj->suffix = '';
				$obj->prefix = '';
				$obj->excludeValue = array();
				$fieldClass = hikashop::get('class.field');
				$dropdown = new hikashopSingledropdown($obj);
				$field = null;
				$field->field_namekey = 'address_state';
				$statesArray=array();
				foreach($states as $state){
					$title = $state->zone_name_english;
					if($state->zone_name_english != $state->zone_name){
						$title.=' ('.$state->zone_name.')';
					}
					$obj = null;
					$obj->disabled = '0';
					$obj->value = $title;
					$statesArray[$state->zone_namekey]=$obj;
				}
				$field->field_value = $statesArray;
				echo $dropdown->display($field,'','data[address][address_state]','','');
			}
		}
		exit;
	}
}
Return current item: HikaShop