<?php
class ControllerExtensionModulenavbfooter extends Controller {
	public function index($setting) {
		$data['name'] = $setting['name'];
		$data['bgcolor'] = $setting['bgcolor'];
		$data['titlecss'] = $setting['titlecss'];
		$data['powered'] = $setting['powered'];
		$data['poweredlink'] = $setting['poweredlink'];
		$data['miit'] = $setting['miit'];
		$data['ftnameone'] = $setting['ftnameone'];
		$data['ftnametwo'] = $setting['ftnametwo'];
		$data['ftnamethree'] = $setting['ftnamethree'];
		$data['ftnamefour'] = $setting['ftnamefour'];
		$data['ftnamefive'] = $setting['ftnamefive'];
		$data['ftnamesix'] = $setting['ftnamesix'];		
		$data['fticonone'] = $setting['fticonone'];
		$data['fticontwo'] = $setting['fticontwo'];
		$data['fticonthree'] = $setting['fticonthree'];
		$data['fticonfour'] = $setting['fticonfour'];
		$data['fticonfive'] = $setting['fticonfive'];
		$data['fticonsix'] = $setting['fticonsix'];
		$data['ftlinkone'] = $setting['ftlinkone'];
		$data['ftlinktwo'] = $setting['ftlinktwo'];
		$data['ftlinkthree'] = $setting['ftlinkthree'];
		$data['ftlinkfour'] = $setting['ftlinkfour'];
		$data['ftlinkfive'] = $setting['ftlinkfive'];
		$data['ftlinksix'] = $setting['ftlinksix'];
		$data['ftbj'] = $setting['ftbj'];
		$data['ftcolor'] = $setting['ftcolor'];
		$data['ftround'] = $setting['ftround'];
		$data['ftsize'] = $setting['ftsize'];
		$data['ftborder'] = $setting['ftborder'];
		$data['ftbc'] = $setting['ftbc'];		
		$data['ftwidth'] = $setting['ftwidth'];
		$data['ftheight'] = $setting['ftheight'];	
		$data['footerpy'] = $setting['footerpy'];
		$data['footerpx'] = $setting['footerpx'];
		$data['columnone'] = $setting['columnone'];	
		$data['columntwo'] = $setting['columntwo'];
		$data['columnthree'] = $setting['columnthree'];	
		$data['mobilestyle'] = $setting['mobilestyle'];	
		$data['blog'] = $setting['blog'];
		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['fticon'])) {
					$service_info['fticon'] = trim($service['fticon']);
				} else {
					$service_info['fticon'] = '';
				}

				if (isset($service['image']) && is_file(DIR_IMAGE . $service['image'])) {
					$service_info['image'] = $this->model_tool_image->resize($service['image'], 430, 430);
				} else {
					$service_info['image'] = $this->model_tool_image->resize('placeholder.png', 430, 430);
				}

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

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

	}
}