<?php  
class ControllerModuleCustompagebackground extends Controller {
	private $data = array();
	private $moduleVersion;
	private $modulePath;
	private $moduleModel;
	private $callModel;
	private $moduleName;
	private $extensionLink;


	public function __construct($register) {
		parent::__construct($register);
		$this->config->load('isenselabs/custompagebackground');

		$this->modulePath = $this->config->get('custompagebackground_modulePath');
		$this->moduleName = $this->config->get('custompagebackground_moduleName');
		$this->callModel = $this->config->get('custompagebackground_modulePath');

		$this->load->language($this->modulePath);
	}



	public function index() {
		$this->document->addScript('view/javascript/summernote/summernote.min.js');
		$this->document->addStyle('view/javascript/summernote/summernote.css');

      	$this->data['heading_title'] = $this->language->get('heading_title');
		
      	if(version_compare(VERSION, '2.2.0.0', '<')) {
			$curent_template = $this->config->get('config_template');
		} else {
			$curent_template = $this->config->get($this->config->get('config_theme') . '_directory');
		}

		if (file_exists(DIR_TEMPLATE . $curent_template . '/stylesheet/custompagebackground.css')) {
			$this->document->addStyle('catalog/view/theme/' . $curent_template . '/stylesheet/custompagebackground.css');
		} else {
			$this->document->addStyle('catalog/view/theme/default/stylesheet/custompagebackground.css');
		}
		
		if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
			$this->data['data']['customPageBackground'] = str_replace('http', 'https', $this->config->get($this->moduleName));
		} else {
			$this->data['data']['customPageBackground'] = $this->config->get($this->moduleName);
		}
		if(version_compare(VERSION, '2.2.0.0', "<")) {
		   	if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/'.$this->modulePath.'.tpl')) {
				return $this->load->view($this->config->get('config_template') . '/template/'.$this->modulePath.'.tpl', $this->data);
			} else {
				return $this->load->view('default/template/'.$this->modulePath.'.tpl', $this->data);
			}
		} else {
		       return $this->load->view($this->modulePath, $this->data);
		 }


		
	}
}
?>