<?php
class ControllerExtensionModulepriceborder extends Controller {
	public function index($setting) {
		$data['titlename'] = $setting['titlename'];
		$data['linew'] = $setting['linew'];
		$data['lineh'] = $setting['lineh'];
		$data['linec'] = $setting['linec'];
		$data['describe'] = $setting['describe'];
		$data['sectionbj'] = $setting['sectionbj'];		
		$data['sectionjbbj'] = $setting['sectionjbbj'];
		$data['sectiontitle'] = $setting['sectiontitle'];
		$data['sectiondescribe'] = $setting['sectiondescribe'];
		$data['sectionptop'] = $setting['sectionptop'];
		$data['sectionpbuttom'] = $setting['sectionpbuttom'];
		$data['boxlinewidth'] = $setting['boxlinewidth'];
		$data['boxline'] = $setting['boxline'];	
		$data['boxbs'] = $setting['boxbs'];	
		$data['listtitle'] = $setting['listtitle'];
		$data['listms'] = $setting['listms'];
		$data['listprice'] = $setting['listprice'];	
		$data['listdemo'] = $setting['listdemo'];	
		$data['contentqq'] = $setting['contentqq'];
		$data['contentww'] = $setting['contentww'];
		$data['contenttel'] = $setting['contenttel'];	
		$data['contentlink'] = $setting['contentlink'];			
		$data['services'] = array();

		if (isset($setting['service']) && $setting['service']) {
			$this->load->model('tool/image');

			$services = $setting['service'];

			$sort_order = array();

			foreach ($services as $key => $value) {
				$sort_order[$key] = $value['sort_order'];
			}

			array_multisort($sort_order, SORT_ASC, $services);

			foreach ($services as $service) {
				$service_info = array();
				if (isset($service['title'][$this->config->get('config_language_id')])) {
					$service_info['title'] = trim($service['title'][$this->config->get('config_language_id')]);
				} else {
					$service_info['title'] = '';
				}
				if (isset($service['miaoshu'][$this->config->get('config_language_id')])) {
					$service_info['miaoshu'] = trim($service['miaoshu'][$this->config->get('config_language_id')]);
				} else {
					$service_info['miaoshu'] = '';
				}
				if (isset($service['jiage'][$this->config->get('config_language_id')])) {
					$service_info['jiage'] = trim($service['jiage'][$this->config->get('config_language_id')]);
				} else {
					$service_info['jiage'] = '';
				}				


				$data['services'][] = $service_info;
			}
		}

		if ($data['services']) {
			if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . 'extension/module/priceborder.tpl')) {
				return $this->load->view($this->config->get('config_template') . 'extension/module/priceborder.tpl', $data);
			} else {
				return $this->load->view('extension/module/priceborder.tpl', $data);
			}
		}

	}
}