<?php 
class ControllerModuleBossStaticblock extends Controller {
	private $error = array(); 
	 
	public function index() {   
		$this->load->language('module/boss_staticblock');

		$this->document->setTitle($this->language->get('heading_title'));
		
		$this->load->model('setting/setting');
				
		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
			$this->model_setting_setting->editSetting('boss_staticblock', $this->request->post);		
			
			$this->session->data['success'] = $this->language->get('text_success');
						
			$this->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
		}
				
		$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_header_top'] = $this->language->get('text_header_top');
		$this->data['text_header_bottom'] = $this->language->get('text_header_bottom');
		$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['text_footer_top'] = $this->language->get('text_footer_top');
		$this->data['text_footer_bottom'] = $this->language->get('text_footer_bottom');
        $this->data['text_alllayout'] = $this->language->get('text_alllayout');
		
		$this->data['entry_content'] = $this->language->get('entry_content');
		$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_new_block'] = $this->language->get('button_add_new_block');
		
		$this->data['tab_block'] = $this->language->get('tab_block');
		
		$this->data['token'] = $this->session->data['token'];

 		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/boss_staticblock', 'token=' . $this->session->data['token'], 'SSL'),
      		'separator' => ' :: '
   		);
		
		$this->data['action'] = $this->url->link('module/boss_staticblock', 'token=' . $this->session->data['token'], 'SSL');
		
		$this->data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');

		$this->data['modules'] = array();
		
		if (isset($this->request->post['boss_staticblock_module'])) {
			$this->data['modules'] = $this->request->post['boss_staticblock_module'];
		} elseif ($this->config->get('boss_staticblock_module')) { 
			$this->data['modules'] = $this->config->get('boss_staticblock_module');
		}	
				
		$this->load->model('design/layout');
		
		$this->data['layouts'] = $this->model_design_layout->getLayouts();
		
		$this->load->model('localisation/language');
		
		$this->data['languages'] = $this->model_localisation_language->getLanguages();

		$this->template = 'module/boss_staticblock.tpl';
		$this->children = array(
			'common/header',
			'common/footer'
		);
				
		$this->response->setOutput($this->render());
	}
	
	private function validate() {
		if (!$this->user->hasPermission('modify', 'module/boss_staticblock')) {
			$this->error['warning'] = $this->language->get('error_permission');
		}
		
		if (!$this->error) {
			return true;
		} else {
			return false;
		}	
	}
	
	private function getIdLayout($layout_name) {
		$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "layout WHERE LOWER(name) = LOWER('".$layout_name."')");
		return (int)$query->row['layout_id'];
	}
	
	public function install() 
	{
		$this->load->model('setting/setting');
		
		$this->load->model('localisation/language');
			
		$languages = $this->model_localisation_language->getLanguages();
		
		$array_description0 = array();
		$array_description1 = array();
		$array_description2 = array();
		$array_description3 = array();
		$array_description4 = array();
		$array_description5 = array();
						
		foreach($languages as $language){
			$array_description0{$language['language_id']} = '&lt;div class=&quot;boss_promotion&quot;&gt;
	&lt;ul&gt;
		&lt;li&gt;
			&lt;a href=&quot;&quot;&gt;&lt;img alt=&quot;Promotion1&quot; src=&quot; http://demo.bossthemes.com/campstore/image/data/campstore/qc1.png&quot; title=&quot;Promotion1&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;
			&lt;a href=&quot;&quot;&gt;&lt;img alt=&quot;Promotion2&quot; src=&quot; http://demo.bossthemes.com/campstore/image/data/campstore/qc2.png&quot; title=&quot;Promotion2&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;
			&lt;a href=&quot;&quot;&gt;&lt;img alt=&quot;Promotion3&quot; src=&quot; http://demo.bossthemes.com/campstore/image/data/campstore/qc3.png&quot; title=&quot;Promotion3&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;';
			$array_description1{$language['language_id']} = '&lt;div class=&quot;boss_ad&quot;&gt;
	&lt;a  href=&quot;&quot;&gt;&lt;img alt=&quot;ad-02&quot; src=&quot; http://demo.bossthemes.com/campstore/image/data/campstore/ad-03.jpg&quot; title=&quot;ad-03&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;&quot;&gt;&lt;img alt=&quot;ad-03&quot; src=&quot; http://demo.bossthemes.com/campstore/image/data/campstore/ad-02.jpg&quot; title=&quot;ad-02&quot; /&gt;&lt;/a&gt;&lt;a class=&quot;last&quot; href=&quot;&quot;&gt;&lt;img alt=&quot;ad-01&quot; src=&quot; http://demo.bossthemes.com/campstore/image/data/campstore/ad-01.jpg&quot; title=&quot;ad-01&quot; /&gt;&lt;/a&gt;&lt;/div&gt;';
			$array_description2{$language['language_id']} = '&lt;div id=&quot;service-information&quot;&gt;
	&lt;ul&gt;
		&lt;li class=&quot;first&quot;&gt;
			Any question? Call[+01]9999 999 999&lt;/li&gt;
		&lt;li class=&quot;second&quot;&gt;
			Free delivery &amp;amp; return&lt;/li&gt;
		&lt;li class=&quot;three&quot;&gt;
			Money back guarantee or unknown merchandise&lt;/li&gt;
		&lt;li class=&quot;last&quot;&gt;
			Sign up to get weekly newsletters or &lt;a href=&quot;index.php?route=account/login&quot;&gt;Sign in&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;';
			$array_description3{$language['language_id']} = '&lt;div class=&quot;column social&quot;&gt;
	&lt;ul&gt;
		&lt;li class=&quot;facebook&quot;&gt;
			&lt;a href=&quot;#&quot;&gt;Find us on Facebook&lt;/a&gt;&lt;/li&gt;
		&lt;li class=&quot;twitter&quot;&gt;
			&lt;a href=&quot;#&quot;&gt;Follow us on Twitter&lt;/a&gt;&lt;/li&gt;
		&lt;li class=&quot;google&quot;&gt;
			&lt;a href=&quot;#&quot;&gt;Plus us on Google+&lt;/a&gt;&lt;/li&gt;
		&lt;li class=&quot;rss&quot;&gt;
			&lt;a href=&quot;#&quot;&gt;RSS Feed&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;';
			$array_description4{$language['language_id']} = '&lt;div id=&quot;menu-footer&quot;&gt;
	&lt;ul&gt;
		&lt;li&gt;
			&lt;a class=&quot;cat-first&quot; href=&quot;#&quot;&gt;Camp &amp;amp; Hike&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;
			&lt;a class=&quot;cat&quot; href=&quot;#&quot;&gt;Climp&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;
			&lt;a class=&quot;cat&quot; href=&quot;#&quot;&gt;Cycle&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;
			&lt;a class=&quot;cat&quot; href=&quot;#&quot;&gt;Fitness&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;
			&lt;a class=&quot;cat&quot; href=&quot;#&quot;&gt;Paddle&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;
			&lt;a class=&quot;cat&quot; href=&quot;#&quot;&gt;Snowsports&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;
			&lt;a class=&quot;cat&quot; href=&quot;#&quot;&gt;Travel&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;
			&lt;a class=&quot;cat&quot; href=&quot;#&quot;&gt;Fishing&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;
			&lt;a class=&quot;cat&quot; href=&quot;#&quot;&gt;Horse Riding&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;
			&lt;a class=&quot;cat&quot; href=&quot;#&quot;&gt;Men&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;
			&lt;a class=&quot;cat&quot; href=&quot;#&quot;&gt;Women&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;
			&lt;a class=&quot;cat-last&quot; href=&quot;#&quot;&gt;Kid&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;';
			$array_description5{$language['language_id']} = '&lt;div id=&quot;footer-pay&quot;&gt;
	&lt;ul&gt;
		&lt;li class=&quot;paypal&quot;&gt;
			&lt;img alt=&quot;Pay pal&quot; src=&quot; http://demo.bossthemes.com/campstore/image/data/campstore/paypal.png&quot; title=&quot;Pay pal&quot; /&gt;&lt;/li&gt;
		&lt;li class=&quot;visa&quot;&gt;
			&lt;img alt=&quot;visa&quot; src=&quot; http://demo.bossthemes.com/campstore/image/data/campstore/visa.png&quot; title=&quot;visa&quot; /&gt;&lt;/li&gt;
		&lt;li&gt;
			&lt;img alt=&quot;card&quot; src=&quot; http://demo.bossthemes.com/campstore/image/data/campstore/card.png&quot; title=&quot;card&quot; /&gt;&lt;/li&gt;
		&lt;li&gt;
			&lt;img alt=&quot;card&quot; src=&quot; http://demo.bossthemes.com/campstore/image/data/campstore/card1.png&quot; title=&quot;card&quot; /&gt;&lt;/li&gt;
		&lt;li class=&quot;visa1&quot;&gt;
			&lt;img alt=&quot;card&quot; src=&quot; http://demo.bossthemes.com/campstore/image/data/campstore/card3.png&quot; title=&quot;card&quot; /&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;';
		}
		$boss_staticblock = array('boss_staticblock_module' => array ( 
			0 => array ( 'description' => $array_description0, 'layout_id' => $this->getIdLayout("home"), 'position' => 'content_top', 'status' => 1, 'sort_order' => 2),
			1 => array ( 'description' => $array_description1, 'layout_id' => $this->getIdLayout("home"), 'position' => 'content_top', 'status' => 1, 'sort_order' => 4),
			2 => array ( 'description' => $array_description2, 'layout_id' => 0, 'position' => 'footer_top', 'status' => 1, 'sort_order' => 1),
			3 => array ( 'description' => $array_description3, 'layout_id' => 0, 'position' => 'footer_bottom', 'status' => 1, 'sort_order' => 1),	
			4 => array ( 'description' => $array_description4, 'layout_id' => 0, 'position' => 'footer_bottom', 'status' => 1, 'sort_order' => 2),
			5 => array ( 'description' => $array_description5, 'layout_id' => 0, 'position' => 'footer_bottom', 'status' => 1, 'sort_order' => 3),	
		));

		$this->model_setting_setting->editSetting('boss_staticblock', $boss_staticblock);		
	}
}
?>