<?php
class ControllerextensionModuleydohang extends Controller {
	public function index($setting) {
		$data['titlename'] = $setting['titlename'];
		$data['bgcolor'] = $setting['bgcolor'];
		$data['bgcolorcss'] = $setting['bgcolorcss'];
		$data['titlecss'] = $setting['titlecss'];
		$data['bordercss'] = $setting['bordercss'];
		$data['describe'] = $setting['describe'];
		$data['column'] = $setting['column'];
		$data['mtitle'] = $setting['mtitle'];
		$data['mbgcolor'] = $setting['mbgcolor'];
		$data['mpa'] = $setting['mpa'];
		$data['mborder'] = $setting['mborder'];
		$data['mbcolor'] = $setting['mbcolor'];
		$data['rptop'] = $setting['rptop'];
		$data['rpbuttom'] = $setting['rpbuttom'];
		$data['linkcolor'] = $setting['linkcolor'];
		$data['rtwolw'] = $setting['rtwolw'];
		$data['rtwolh'] = $setting['rtwolh'];
		$data['rtwolc'] = $setting['rtwolc'];
		$data['autoplay'] = $setting['autoplay'];
		$data['main'] = $setting['main'];
		$data['speed'] = $setting['speed'];
		$data['scroll'] = $setting['scroll'];
		$data['rorow'] = $setting['rorow'];
		$data['mpppa'] = $setting['mpppa'];	
        $data['fade'] = $setting['fade'];
        $data['mbgcolorjb'] = $setting['mbgcolorjb'];	

        $data['boxround'] = $setting['boxround'];
        $data['boxposition'] = $setting['boxposition'];	
        $data['boxshadow'] = $setting['boxshadow'];
        $data['boxshadowhover'] = $setting['boxshadowhover'];		
		
		$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['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['link'])) {
					$service_info['link'] = trim($service['link']);
				} else {
					$service_info['link'] = '';
				}

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

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

	}
}