<?php
class ControllerExtensionModuleduotuwen extends Controller {
	public function index($setting) {
		$data['duotuwenname'] = $setting['duotuwenname'];
		$data['bgcolor'] = $setting['bgcolor'];
		$data['bgcolorcss'] = $setting['bgcolorcss'];
		$data['titlecss'] = $setting['titlecss'];
		$data['boxtitlecss'] = $setting['boxtitlecss'];
		$data['describe'] = $setting['describe'];
		$data['ptduotuwen'] = $setting['ptduotuwen'];
		$data['pbduotuwen'] = $setting['pbduotuwen'];
		$data['duotuwenlinew'] = $setting['duotuwenlinew'];
		$data['duotuwenlineh'] = $setting['duotuwenlineh'];
		$data['duotuwenlinec'] = $setting['duotuwenlinec'];
		$data['main'] = $setting['main'];
		$data['autoplay'] = $setting['autoplay'];
		$data['fade'] = $setting['fade'];
		$data['speed'] = $setting['speed'];
		$data['column'] = $setting['column'];
		$data['wapcolumn'] = $setting['wapcolumn'];
		$data['rows'] = $setting['rows'];
		$data['scroll'] = $setting['scroll'];	
		$data['boxbg'] = $setting['boxbg'];
		$data['boxtitle'] = $setting['boxtitle'];
		$data['boxzhiwei'] = $setting['boxzhiwei'];
		$data['boxdescribe'] = $setting['boxdescribe'];
		$data['boxmagin'] = $setting['boxmagin'];
		$data['boxpd'] = $setting['boxpd'];
		$data['boxpadding'] = $setting['boxpadding'];
		$data['boxptpadding'] = $setting['boxptpadding'];
		$data['boxborder'] = $setting['boxborder'];
		$data['boxcolor'] = $setting['boxcolor'];	       
        $data['boxround'] = $setting['boxround'];
        $data['boxposition'] = $setting['boxposition'];	
        $data['boxshadow'] = $setting['boxshadow'];
        $data['boxshadowhover'] = $setting['boxshadowhover'];	
        $data['boxbjhover'] = $setting['boxbjhover'];
        $data['boxcolorhover'] = $setting['boxcolorhover'];		
        $data['miconbj'] = $setting['miconbj'];		
		$data['miconcolor'] = $setting['miconcolor'];
        $data['hoverbj'] = $setting['hoverbj'];
        $data['hovertit'] = $setting['hovertit'];	
		$data['miconround'] = $setting['miconround'];
		$data['miconsize'] = $setting['miconsize'];
		$data['miconborder'] = $setting['miconborder'];
		$data['miconbc'] = $setting['miconbc'];
		$data['miconwidth'] = $setting['miconwidth'];
		$data['miconheight'] = $setting['miconheight'];	
		$data['imagepicstyle'] = $setting['imagepicstyle'];
        $data['imagetext'] = $setting['imagetext'];	
        $data['boxwzbj'] = $setting['boxwzbj'];			
		$data['buttonname1'] = $setting['buttonname1'];
		$data['link1'] = $setting['link1'];
		$data['buttonname2'] = $setting['buttonname2'];
		$data['link2'] = $setting['link2'];
		$data['qq1'] = $setting['qq1'];
		$data['alww1'] = $setting['alww1'];
		$data['qq2'] = $setting['qq2'];
		$data['alww2'] = $setting['alww2'];	
		$data['icons1'] = $setting['icons1'];
		$data['icons2'] = $setting['icons2'];
		$data['buttoncolor1'] = $setting['buttoncolor1'];
		$data['buttoncolor2'] = $setting['buttoncolor2'];
		$data['imgcbj'] = $setting['imgcbj'];
		$data['imground'] = $setting['imground'];
        $data['imgthumb'] = $setting['imgthumb'];	
        $data['imgshadow'] = $setting['imgshadow'];	
		$data['imgpadding'] = $setting['imgpadding'];
        $data['imgborder'] = $setting['imgborder'];	
        $data['imgcolor'] = $setting['imgcolor'];	

		$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['slidename'] = $setting['slidename'];
        $data['boxnum'] = $setting['boxnum'];
        $data['sectionnum'] = $setting['sectionnum'];		
		$data['slidewidthtwo'] = $setting['slidewidthtwo'];	       
        $data['slideheighttwo'] = $setting['slideheighttwo'];
        $data['slideradiustwo'] = $setting['slideradiustwo'];	
        $data['slidebackgroundtwo'] = $setting['slidebackgroundtwo'];
        $data['slidecolortwo'] = $setting['slidecolortwo'];
        $data['sliderbordertwo'] = $setting['sliderbordertwo'];	
        $data['sliderhkctwo'] = $setting['sliderhkctwo'];
        $data['slideformtwo'] = $setting['slideformtwo'];
        $data['sectionid'] = $setting['sectionid'];
        $data['sectiontab'] = $setting['sectiontab'];
		static $module = 0;

		$this->load->model('tool/image');

		if (is_file(DIR_IMAGE . $setting['image'])) {
			$image = $setting['image'];
		} else {
			$image = '';
		}

		$data['image'] = $this->model_tool_image->resize($image, $setting['width'], $setting['height']);		
		$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['text'][$this->config->get('config_language_id')])) {
					$service_info['text'] = trim($service['text'][$this->config->get('config_language_id')]);
				} else {
					$service_info['text'] = '';
				}
				if (isset($service['introduce'][$this->config->get('config_language_id')])) {
					$service_info['introduce'] = trim($service['introduce'][$this->config->get('config_language_id')]);
				} else {
					$service_info['introduce'] = '';
				}
				if (isset($service['boxbottonn1'][$this->config->get('config_language_id')])) {
					$service_info['boxbottonn1'] = trim($service['boxbottonn1'][$this->config->get('config_language_id')]);
				} else {
					$service_info['boxbottonn1'] = '';
				}
				if (isset($service['boxbottonn2'][$this->config->get('config_language_id')])) {
					$service_info['boxbottonn2'] = trim($service['boxbottonn2'][$this->config->get('config_language_id')]);
				} else {
					$service_info['boxbottonn2'] = '';
				}
				if (isset($service['color'][$this->config->get('config_language_id')])) {
					$service_info['color'] = trim($service['color'][$this->config->get('config_language_id')]);
				} else {
					$service_info['color'] = '';
				}
				if (isset($service['weblink'][$this->config->get('config_language_id')])) {
					$service_info['weblink'] = trim($service['weblink']);
				} else {
					$service_info['weblink'] = '';
				}
				if (isset($service['weibolink'][$this->config->get('config_language_id')])) {
					$service_info['weibolink'] = trim($service['weibolink']);
				} else {
					$service_info['weibolink'] = '';
				}
				if (isset($service['image']) && is_file(DIR_IMAGE . $service['image'])) {
					$service_info['image'] = $this->model_tool_image->resize($service['image'], $setting['imagewidth'], $setting['imageheight']);
				} else {
					$service_info['image'] = $this->model_tool_image->resize('', $setting['imagewidth'], $setting['imageheight']);
				}

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

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

	}
}