<?php
class ControllerCommonFooter extends Controller {
	public function index() {
		$this->load->language('common/footer');

		$this->load->model('catalog/information');

		$data['informations'] = array();

		foreach ($this->model_catalog_information->getInformations() as $result) {
			if ($result['bottom']) {
				$data['informations'][] = array(
					'title' => $result['title'],
					'href'  => $this->url->link('information/information', 'information_id=' . $result['information_id'])
				);
			}
		}

		$data['contact'] = $this->url->link('information/contact');
		$data['return'] = $this->url->link('account/return/add', '', true);
		$data['sitemap'] = $this->url->link('information/sitemap');
		$data['tracking'] = $this->url->link('information/tracking');
		$data['manufacturer'] = $this->url->link('product/manufacturer');
		$data['voucher'] = $this->url->link('account/voucher', '', true);
		$data['affiliate'] = $this->url->link('affiliate/login', '', true);
		$data['special'] = $this->url->link('product/special');
		$data['account'] = $this->url->link('account/account', '', true);
		$data['order'] = $this->url->link('account/order', '', true);
		$data['wishlist'] = $this->url->link('account/wishlist', '', true);
		$data['newsletter'] = $this->url->link('account/newsletter', '', true);

		$data['container'] = $this->config->get('mart_container');
		$data['contact_title'] = $this->config->get('mart_contact_title');
		$data['social_title'] = $this->config->get('mart_social_title');
		$data['newsletter_enabled'] = $this->config->get('mart_newsletter');
		$data['newsletter_title'] = $this->config->get('mart_newsletter_title');
		$data['newsletter_description'] = $this->config->get('mart_newsletter_description');
		$data['newsletter_placeholder'] = $this->config->get('mart_newsletter_placeholder');
		$data['newsletter_button'] = $this->config->get('mart_newsletter_button');
		$data['powered'] = $this->config->get('mart_powered');
		$data['backtop'] = $this->config->get('mart_backtop');
		$data['customer_service'] = $this->config->get('mart_customer_service');
		$data['extras'] = $this->config->get('mart_extras');
		$data['my_account'] = $this->config->get('mart_my_account');

		$data['contacts'] = array();

		if ($this->config->get('mart_contact')) {
			foreach ($this->config->get('mart_contact') as $key => $value) {
				if (!empty($value)) {
					$data['contacts'][$key] = $value;
				}
			}
		}

		$data['social'] = array();

		if ($this->config->get('mart_social')) {
			foreach ($this->config->get('mart_social') as $key => $value) {
				if (!empty($value)) {
					$data['social'][$key] = $value;
				}
			}
		}

		$data['blog_enabled'] = $this->config->get('mart_blog');

		$data['blog'] = array(
			'name' => $this->config->get('mart_blog_name'),
			'href' => $this->url->link('extension/module/mart_blog', '', true)
		);
      

		
      

		// Whos Online
		if ($this->config->get('config_customer_online')) {
			$this->load->model('tool/online');

			if (isset($this->request->server['REMOTE_ADDR'])) {
				$ip = $this->request->server['REMOTE_ADDR'];
			} else {
				$ip = '';
			}

			if (isset($this->request->server['HTTP_HOST']) && isset($this->request->server['REQUEST_URI'])) {
				$url = ($this->request->server['HTTPS'] ? 'https://' : 'http://') . $this->request->server['HTTP_HOST'] . $this->request->server['REQUEST_URI'];
			} else {
				$url = '';
			}

			if (isset($this->request->server['HTTP_REFERER'])) {
				$referer = $this->request->server['HTTP_REFERER'];
			} else {
				$referer = '';
			}

			$this->model_tool_online->addOnline($ip, $this->customer->getId(), $url, $referer);
		}

		$data['scripts'] = $this->document->getScripts('footer');
		
		return $this->load->view('common/footer', $data);
	}
}
