<?php
class ControllerExtensionModuleocarouselthree extends Controller {
	public function index($setting) {
		$data['titlename'] = $setting['titlename'];
		$data['describe'] = $setting['describe'];
		$data['section2'] = $setting['section2'];
		$data['dpl'] = $setting['dpl'];
     	$data['wgdlg1'] = $setting['wgdlg1'];
		$data['wgdlg2'] = $setting['wgdlg2'];		
     	$data['bgcolorcss'] = $setting['bgcolorcss'];
		$data['titlecss'] = $setting['titlecss'];
		$data['titlecsstwo'] = $setting['titlecsstwo'];
		$data['octrgba'] = $setting['octrgba'];
		$data['buttoncss'] = $setting['buttoncss'];
		$data['buttonbjcss'] = $setting['buttonbjcss'];
		$data['buttontitcss'] = $setting['buttontitcss'];
		$data['buttontithover'] = $setting['buttontithover'];
		$data['buttonradius'] = $setting['buttonradius'];
		$data['autoplay'] = $setting['autoplay'];
		$data['speed'] = $setting['speed'];
		$data['fade'] = $setting['fade'];
		$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['icons1'] = $setting['icons1'];
		$data['icons2'] = $setting['icons2'];
		$data['buttoncolor1'] = $setting['buttoncolor1'];
		$data['buttoncolor2'] = $setting['buttoncolor2'];
		$data['buttonsize'] = $setting['buttonsize'];
		$data['buttoninset'] = $setting['buttoninset'];	       
        $data['buttonborder'] = $setting['buttonborder'];
        $data['buttonround'] = $setting['buttonround'];	
        $data['buttonhover'] = $setting['buttonhover'];
		$data['imagepicstyle'] = $setting['imagepicstyle'];
        $data['buttond'] = $setting['buttond'];
        $data['topmagin'] = $setting['topmagin'];
        $data['btmagin'] = $setting['btmagin'];	
        $data['maxwidth'] = $setting['maxwidth'];			
		$data['bannerbgc'] = $setting['bannerbgc'];
		$data['bannerbgcjb'] = $setting['bannerbgcjb'];
		$data['titleposition'] = $setting['titleposition'];
		$data['titlefontsize'] = $setting['titlefontsize'];	
		$data['msonefontsize'] = $setting['msonefontsize'];
		$data['mstwofontsize'] = $setting['mstwofontsize'];	
        $data['imganimation'] = $setting['imganimation'];
        $data['sectiontab'] = $setting['sectiontab'];	
		
		static $module = 0;

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

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

		$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['link1'])) {
					$service_info['link1'] = trim($service['link1']);
				} else {
					$service_info['link1'] = '';
				}
				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/ocarouselthree.tpl')) {
				return $this->load->view($this->config->get('config_template') . 'extension/module/ocarouselthree.tpl', $data);
			} else {
				return $this->load->view('extension/module/ocarouselthree.tpl', $data);
			}
		}

	}
}