<?php class ControllerModuleICustomFooter extends Controller {

	private $error = array();
	function findTextBetween($word1, $word2, $content) {
		$between=str_replace($word1, '',substr($content, strpos($content, $word1), strpos($content, $word2) - strpos($content, $word1)));
		return $between;
	}
	

	
	public function index() {
		
		//Language 
		$this->load->language('module/icustomfooter');
		
		$this->document->setTitle($this->language->get('heading_title'));
		
		$this->data['heading_title'] = $this->language->get('heading_title');
		$this->data['text_enabled'] = $this->language->get('text_enabled');
		$this->data['text_disabled'] = $this->language->get('text_disabled');
		$this->data['text_content_top'] = $this->language->get('text_content_top');
		$this->data['text_content_bottom'] = $this->language->get('text_content_bottom');		
		$this->data['text_column_left'] = $this->language->get('text_column_left');
		$this->data['text_column_right'] = $this->language->get('text_column_right');
		
		$this->data['entry_layout'] = $this->language->get('entry_layout');
		$this->data['entry_position'] = $this->language->get('entry_position');
		$this->data['entry_status'] = $this->language->get('entry_status');
		$this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
		
		$this->data['button_save'] = $this->language->get('button_save');
		$this->data['button_cancel'] = $this->language->get('button_cancel');
		$this->data['button_add_module'] = $this->language->get('button_add_module');
		$this->data['button_remove'] = $this->language->get('button_remove');
		
		$this->data['aboutus'] = $this->language->get('aboutus');
		$this->data['contactus'] = $this->language->get('contactus');
		$this->data['googlemaps'] = $this->language->get('googlemaps');
		$this->data['contactform'] = $this->language->get('contactform');
		$this->data['twitter'] = $this->language->get('twitter');
		$this->data['facebook'] = $this->language->get('facebook');
		$this->data['youtube'] = $this->language->get('youtube');
		$this->data['customcolumn'] = $this->language->get('customcolumn');
		$this->data['socialbuttons'] = $this->language->get('socialbuttons');
		$this->data['footercustomization'] = $this->language->get('footercustomization');
		$this->data['supportandsettings'] = $this->language->get('supportandsettings');
		$this->data['assistance'] = $this->language->get('assistance');
		$this->data['globalsettings'] = $this->language->get('globalsettings');

		$this->data['assistancetitle'] = $this->language->get('assistancetitle');
		$this->data['assistancetext'] = $this->language->get('assistancetext');
		$this->data['yes'] = $this->language->get('yes');
		$this->data['no'] = $this->language->get('no');
		$this->data['white'] = $this->language->get('white');
		$this->data['dark'] = $this->language->get('dark');
		$this->data['hidewhatunfits'] = $this->language->get('hidewhatunfits');
		$this->data['showscrollers'] = $this->language->get('showscrollers');
		$this->data['dashed'] = $this->language->get('dashed');
		$this->data['dotted'] = $this->language->get('dotted');
		$this->data['solid'] = $this->language->get('solid');
		$this->data['double'] = $this->language->get('double');
		$this->data['groove'] = $this->language->get('groove');
		$this->data['ridge'] = $this->language->get('ridge');
		$this->data['inset'] = $this->language->get('inset');
		$this->data['outset'] = $this->language->get('outset');
		$this->data['noline'] = $this->language->get('noline');
		$this->data['defaultfont'] = $this->language->get('defaultfont');
		$this->data['greenicons'] = $this->language->get('greenicons');
		$this->data['whiteicons'] = $this->language->get('whiteicons');
		$this->data['blueicons'] = $this->language->get('blueicons');
		$this->data['preview'] = $this->language->get('preview');
		$this->data['defaultforthefooter'] = $this->language->get('defaultforthefooter');

		$this->data['titleofthecolumn'] = $this->language->get('titleofthecolumn');
		$this->data['aboutus_text'] = $this->language->get('aboutus_text');
		$this->data['showcolumn'] = $this->language->get('showcolumn');
		$this->data['contactus_iconset'] = $this->language->get('contactus_iconset');
		$this->data['contactus_title'] = $this->language->get('contactus_title');
		$this->data['contactus_text'] = $this->language->get('contactus_text');
		$this->data['contactus_address'] = $this->language->get('contactus_address');
		$this->data['contactus_phone'] = $this->language->get('contactus_phone');
		$this->data['contactus_fax'] = $this->language->get('contactus_fax');
		$this->data['contactus_email'] = $this->language->get('contactus_email');
		$this->data['contactus_skype'] = $this->language->get('contactus_skype');
		$this->data['maps_longlat']    = $this->language->get('maps_longlat');
		$this->data['maps_preview']    = $this->language->get('maps_preview');
		$this->data['contactform_sendemailsto']  = $this->language->get('contactform_sendemailsto');
		$this->data['twitter_numberoftweets'] = $this->language->get('twitter_numberoftweets');
		$this->data['twitter_keyword']        = $this->language->get('twitter_keyword');
		$this->data['facebook_pageurl']        = $this->language->get('facebook_pageurl');
		$this->data['facebook_widgetheight']        = $this->language->get('facebook_widgetheight');
		$this->data['youtube_url']        = $this->language->get('youtube_url');
		$this->data['youtube_width']        = $this->language->get('youtube_width');
		$this->data['youtube_height']        = $this->language->get('youtube_height');
		$this->data['custom_text']        = $this->language->get('custom_text');
		$this->data['showsocialbuttons']        = $this->language->get('showsocialbuttons');
		$this->data['facebooklikebutton']        = $this->language->get('facebooklikebutton');
		$this->data['pinterestpin']        = $this->language->get('pinterestpin');
		$this->data['googleplusbutton']        = $this->language->get('googleplusbutton');
		$this->data['showcustomfooter']        = $this->language->get('showcustomfooter');
		$this->data['footerwidth']        = $this->language->get('footerwidth');
		$this->data['hideoriginalfooter']        = $this->language->get('hideoriginalfooter');
		$this->data['hidepoweredby']        = $this->language->get('hidepoweredby');
		$this->data['footerfontfamily']        = $this->language->get('footerfontfamily');
		$this->data['footerbackgroundstyle']        = $this->language->get('footerbackgroundstyle');
		$this->data['whencontentoverflows']        = $this->language->get('whencontentoverflows');
		$this->data['columnheight'] = $this->language->get('columnheight');
		$this->data['columntitlecolor'] = $this->language->get('columntitlecolor');
		$this->data['columnlinestyle'] = $this->language->get('columnlinestyle');

		//Settings and Layouts
		$this->load->model('setting/setting');
		
				
	
		$persistenceFile = '../image/cache/icustomfooter.json';

		if ($this->request->server['REQUEST_METHOD'] == 'POST') {		
			
			if (isset($this->request->post)) {
				$data = $this->request->post['data'];
				$footerwidth = (!empty($data['Settings']['Width'])) ? $data['Settings']['Width'] : 960;
				/*
				$module_array = array('icustomfooter_module' => array('0' => array(
					'width' => (int)$footerwidth,
					'position' => 'content_bottom',
					'layout_id' => '1',
					'status' => $data['Settings']['Show'],
					'sort_order' => '9999'
				)));
				$this->model_setting_setting->editSetting('icustomfooter', $module_array);
				*/
				file_put_contents($persistenceFile,json_encode($data));
				
			}

			
			//$this->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
		}
		
		$data = (file_exists($persistenceFile)) ? json_decode(file_get_contents($persistenceFile), true) : array();

		$this->data['data'] = $data; 
		$this->load->model('design/layout');
		
		$this->data['layouts'] = $this->model_design_layout->getLayouts();
						
		$this->template = 'module/icustomfooter.tpl';
		$this->children = array(
			'common/header',
			'common/footer'
		);
		
		if (isset($this->error['warning'])) {
			$this->data['error_warning'] = $this->error['warning'];
		} else {
			$this->data['error_warning'] = '';
		}

  		$this->data['breadcrumbs'] = array();

   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->language->get('text_home'),
			'href'      => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
      		'separator' => false
   		);

   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->language->get('text_module'),
			'href'      => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'),
      		'separator' => ' :: '
   		);
		
   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->language->get('heading_title'),
			'href'      => $this->url->link('module/icustomfooter', 'token=' . $this->session->data['token'], 'SSL'),
      		'separator' => ' :: '
   		);
		
		$this->data['action'] = $this->url->link('module/icustomfooter', 'token=' . $this->session->data['token'], 'SSL');
		
		$this->data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');
		
		$this->load->model('localisation/language');
		$data = array();
		$languages = $this->model_localisation_language->getLanguages($data);
		$this->data['systemlanguages'] = $languages;
	
		$this->response->setOutput($this->render());
		
		
		
 		
	}
} ?>