<?php
class ControllerextensionModuleyaccordion 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['acordionbj'] = $setting['acordionbj'];
		$data['acordionbjhover'] = $setting['acordionbjhover'];
		$data['acordiontit'] = $setting['acordiontit'];
		$data['acordiontithover'] = $setting['acordiontithover'];
		$data['buttonsize'] = $setting['buttonsize'];
		$data['buttoninset'] = $setting['buttoninset'];	       
        $data['buttonborder'] = $setting['buttonborder'];
        $data['buttonround'] = $setting['buttonround'];	
        $data['buttonhover'] = $setting['buttonhover'];
        $data['buttond'] = $setting['buttond'];	
		$data['buttonname1'] = $setting['buttonname1'];
		$data['buttonname2'] = $setting['buttonname2'];
		$data['qq1'] = $setting['qq1'];
		$data['qq2'] = $setting['qq2'];
		$data['alww1'] = $setting['alww1'];
		$data['alww2'] = $setting['alww2'];	
		$data['link1'] = $setting['link1'];
		$data['link2'] = $setting['link2'];
		$data['buttoncolor1'] = $setting['buttoncolor1'];
		$data['buttoncolor2'] = $setting['buttoncolor2'];
		$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['title1'][$this->config->get('config_language_id')])) {
					$service_info['title1'] = trim($service['title1'][$this->config->get('config_language_id')]);
				} else {
					$service_info['title1'] = '';
				}														
				if (isset($service['text1'][$this->config->get('config_language_id')])) {
					$service_info['text1'] = trim($service['text1'][$this->config->get('config_language_id')]);
				} else {
					$service_info['text1'] = '';
				}
				if (isset($service['qiehuan1'][$this->config->get('config_language_id')])) {
					$service_info['qiehuan1'] = trim($service['qiehuan1'][$this->config->get('config_language_id')]);
				} else {
					$service_info['qiehuan1'] = '';
				}				
				if (isset($service['icon1'][$this->config->get('config_language_id')])) {
					$service_info['icon1'] = trim($service['icon1'][$this->config->get('config_language_id')]);
				} else {
					$service_info['icon1'] = '';
				}

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

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

	}
}