<?php
class ControllerextensionModuleservicethree extends Controller {
	public function index($setting) {
		$data['titlename'] = $setting['titlename'];
		$data['bgcolor'] = $setting['bgcolor'];
		$data['bgcolorcss'] = $setting['bgcolorcss'];
		$data['titlecss'] = $setting['titlecss'];
		$data['titlesmcss'] = $setting['titlesmcss'];
		$data['describe'] = $setting['describe'];
		$data['mtitle'] = $setting['mtitle'];
		$data['mdescribe'] = $setting['mdescribe'];
		$data['mbgcolor'] = $setting['mbgcolor'];
		$data['mpa'] = $setting['mpa'];
		$data['mborder'] = $setting['mborder'];
		$data['mbcolor'] = $setting['mbcolor'];
		$data['npadding'] = $setting['npadding'];
		$data['stp'] = $setting['stp'];
		$data['sbp'] = $setting['sbp'];
		$data['position'] = $setting['position'];
		$data['column'] = $setting['column'];
		$data['srow'] = $setting['srow'];
		$data['sdtitle'] = $setting['sdtitle'];
		$data['sdone'] = $setting['sdone'];
		$data['sdtwo'] = $setting['sdtwo'];
		$data['sdthree'] = $setting['sdthree'];
		$data['wgdlg1'] = $setting['wgdlg1'];
		$data['wgdlg2'] = $setting['wgdlg2'];
		$data['buttonname1'] = $setting['buttonname1'];
		$data['link1'] = $setting['link1'];
		$data['buttonname2'] = $setting['buttonname2'];
		$data['link2'] = $setting['link2'];
		$data['buttoncolor1'] = $setting['buttoncolor1'];
		$data['buttoncolor2'] = $setting['buttoncolor2'];
		$data['qq1'] = $setting['qq1'];
		$data['alww1'] = $setting['alww1'];
		$data['qq2'] = $setting['qq2'];
		$data['alww2'] = $setting['alww2'];		
		$data['sdione'] = $setting['sdione'];
		$data['sditwo'] = $setting['sditwo'];
		$data['sdithree'] = $setting['sdithree'];
		$data['sdifour'] = $setting['sdifour'];
		$data['sdifive'] = $setting['sdifive'];
		$data['sdisix'] = $setting['sdisix'];		
		$data['sdtnone'] = $setting['sdtnone'];
		$data['sdtntwo'] = $setting['sdtntwo'];
		$data['sdtnthree'] = $setting['sdtnthree'];
		$data['sdtnfour'] = $setting['sdtnfour'];
		$data['sdtnfive'] = $setting['sdtnfive'];
		$data['sdtnsix'] = $setting['sdtnsix'];
		$data['sddone'] = $setting['sddone'];
		$data['sddtwo'] = $setting['sddtwo'];
		$data['sddthree'] = $setting['sddthree'];
		$data['sddfour'] = $setting['sddfour'];
		$data['sddfive'] = $setting['sddfive'];
		$data['sddsix'] = $setting['sddsix'];
		$data['stcolumn'] = $setting['stcolumn'];
		$data['stmiconbj'] = $setting['stmiconbj'];
		$data['stmiconcolor'] = $setting['stmiconcolor'];
		$data['stmiconround'] = $setting['stmiconround'];
		$data['stmiconsize'] = $setting['stmiconsize'];
		$data['stmiconborder'] = $setting['stmiconborder'];
		$data['stmiconbc'] = $setting['stmiconbc'];		
		$data['sttccolor'] = $setting['sttccolor'];
		$data['stpricecolor'] = $setting['stpricecolor'];	
		$data['stmiconwidth'] = $setting['stmiconwidth'];
		$data['stmiconheight'] = $setting['stmiconheight'];	
        $data['strgba'] = $setting['strgba'];
		$data['slinew'] = $setting['slinew'];
		$data['slineh'] = $setting['slineh'];
		$data['slinec'] = $setting['slinec'];	
		$data['autoplay'] = $setting['autoplay'];
		$data['main'] = $setting['main'];
		$data['imagepicstyle'] = $setting['imagepicstyle'];
		$data['speed'] = $setting['speed'];
		$data['scroll'] = $setting['scroll'];
		$data['strppa'] = $setting['strppa'];	
		$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['stwzc'] = $setting['stwzc'];	
        $data['sectionid'] = $setting['sectionid'];
        $data['sectiontab'] = $setting['sectiontab'];
		
		$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['link'])) {
					$service_info['link'] = trim($service['link']);
				} else {
					$service_info['link'] = '';
				}
				if (isset($service['image']) && is_file(DIR_IMAGE . $service['image'])) {
					$service_info['image'] = $this->model_tool_image->resize($service['image'], $setting['width'], $setting['height']);
				} else {
					$service_info['image'] = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
				}

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

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

	}
}