<?php
class ControllerExtensionModulenavmenuten extends Controller {
	public function index($setting) {
		$data['name'] = $setting['name'];
		$data['bgcolor'] = $setting['bgcolor'];
		$data['minheight'] = $setting['minheight'];
		$data['htx'] = $setting['htx'];
		$data['titlecss'] = $setting['titlecss'];
		$data['navp'] = $setting['navp'];
		$data['icon1'] = $setting['icon1'];
		$data['nametitle1'] = $setting['nametitle1'];
		$data['xinxims1'] = $setting['xinxims1'];
		$data['icon2'] = $setting['icon2'];
		$data['nametitle2'] = $setting['nametitle2'];
		$data['xinxims2'] = $setting['xinxims2'];
		$data['icon3'] = $setting['icon3'];
		$data['nametitle3'] = $setting['nametitle3'];
		$data['xinxims3'] = $setting['xinxims3'];
		$data['icon4'] = $setting['icon4'];
		$data['nametitle4'] = $setting['nametitle4'];
		$data['xinxims4'] = $setting['xinxims4'];
		$data['iconsizes'] = $setting['iconsizes'];
		$data['iconcolors'] = $setting['iconcolors'];
		$data['tncolors'] = $setting['tncolors'];
		$data['xxmscolors'] = $setting['xxmscolors'];
		$data['blog'] = $setting['blog'];
		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['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'] = '';
				}

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

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

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

	}
}