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

		$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('config', $this->request->post);

			if ($this->config->get('config_currency_auto')) {
				$this->load->model('localisation/currency');
		
				$this->model_localisation_currency->updateCurrencies();
			}	
			
			$this->session->data['success'] = $this->language->get('text_success');

			$this->redirect($this->url->link('setting/store', 'token=' . $this->session->data['token'], 'SSL'));
		}

		$this->data['heading_title'] = $this->language->get('heading_title');
		$this->data['heading_title_settings'] = $this->language->get('heading_title_settings');

		$this->data['text_select'] = $this->language->get('text_select');
		$this->data['text_none'] = $this->language->get('text_none');
		$this->data['text_yes'] = $this->language->get('text_yes');
		$this->data['text_no'] = $this->language->get('text_no');
		$this->data['text_menu'] = $this->language->get('text_menu');
		$this->data['text_items'] = $this->language->get('text_items');
		$this->data['text_data_display'] = $this->language->get('text_data_display');
		$this->data['text_product'] = $this->language->get('text_product');
		$this->data['text_voucher'] = $this->language->get('text_voucher');
		$this->data['text_tax'] = $this->language->get('text_tax');
		$this->data['text_account'] = $this->language->get('text_account');
		$this->data['text_checkout'] = $this->language->get('text_checkout');
		$this->data['text_stock'] = $this->language->get('text_stock');
		$this->data['text_affiliate'] = $this->language->get('text_affiliate');
		$this->data['text_return'] = $this->language->get('text_return');
		$this->data['text_image_manager'] = $this->language->get('text_image_manager');
 		$this->data['text_browse'] = $this->language->get('text_browse');
		$this->data['text_clear'] = $this->language->get('text_clear');	
		$this->data['text_shipping'] = $this->language->get('text_shipping');	
		$this->data['text_payment'] = $this->language->get('text_payment');					
		$this->data['text_mail'] = $this->language->get('text_mail');
		$this->data['text_smtp'] = $this->language->get('text_smtp');
		$this->data['text_menu_default'] = $this->language->get('text_menu_default');
		$this->data['text_menu_advanted'] = $this->language->get('text_menu_advanted');
		$this->data['text_bnews_order'] = $this->language->get('text_bnews_order');
		$this->data['text_yess'] = $this->language->get('text_bysort');
		$this->data['text_noo'] = $this->language->get('text_latest');
		$this->data['text_bnews_image'] = $this->language->get('text_bnews_image');
		$this->data['text_bnews_thumb'] = $this->language->get('text_bnews_thumb');
		$this->data['text_mod_news'] = $this->language->get('text_mod_news');
		$this->data['text_mod_news_side'] = $this->language->get('text_mod_news_side');
		$this->data['text_symbols_headlines'] = $this->language->get('text_symbols_headlines');
		$this->data['text_symbols_ncategory'] = $this->language->get('text_symbols_ncategory');
		$this->data['text_symbols_nsearch'] = $this->language->get('text_symbols_nsearch');
		
		$this->data['entry_name'] = $this->language->get('entry_name');
		$this->data['entry_owner'] = $this->language->get('entry_owner');
		$this->data['entry_address'] = $this->language->get('entry_address');
		$this->data['entry_email'] = $this->language->get('entry_email');
		$this->data['entry_telephone'] = $this->language->get('entry_telephone');
		$this->data['entry_fax'] = $this->language->get('entry_fax');		
		$this->data['entry_title'] = $this->language->get('entry_title');
		$this->data['entry_meta_description'] = $this->language->get('entry_meta_description');
		$this->data['entry_meta_keyword'] = $this->language->get('entry_meta_keyword');
		$this->data['entry_layout'] = $this->language->get('entry_layout');
		$this->data['entry_template'] = $this->language->get('entry_template');
		$this->data['entry_country'] = $this->language->get('entry_country');
		$this->data['entry_zone'] = $this->language->get('entry_zone');		
		$this->data['entry_language'] = $this->language->get('entry_language');
		$this->data['entry_admin_language'] = $this->language->get('entry_admin_language');
		$this->data['entry_currency'] = $this->language->get('entry_currency');
		$this->data['entry_display_weight'] = $this->language->get('entry_display_weight');
		$this->data['entry_display_location'] = $this->language->get('entry_display_location');
		$this->data['entry_display_sku'] = $this->language->get('entry_display_sku');
		$this->data['entry_display_ups'] = $this->language->get('entry_display_ups');
		$this->data['entry_display_ean'] = $this->language->get('entry_display_ean');
		$this->data['entry_display_jan'] = $this->language->get('entry_display_jan');
		$this->data['entry_display_isbn'] = $this->language->get('entry_display_isbn');
		$this->data['entry_display_mpn'] = $this->language->get('entry_display_mpn');
		$this->data['entry_currency_auto'] = $this->language->get('entry_currency_auto');
		$this->data['entry_length_class'] = $this->language->get('entry_length_class');
		$this->data['entry_weight_class'] = $this->language->get('entry_weight_class');
		$this->data['entry_type_menu'] = $this->language->get('entry_type_menu');
		$this->data['entry_catalog_limit'] = $this->language->get('entry_catalog_limit');
		$this->data['entry_admin_limit'] = $this->language->get('entry_admin_limit');
		$this->data['entry_product_count'] = $this->language->get('entry_product_count');
		$this->data['entry_review'] = $this->language->get('entry_review');
		$this->data['entry_download'] = $this->language->get('entry_download');
		$this->data['entry_upload_allowed'] = $this->language->get('entry_upload_allowed');
		$this->data['entry_voucher_min'] = $this->language->get('entry_voucher_min');
		$this->data['entry_voucher_max'] = $this->language->get('entry_voucher_max');
		$this->data['entry_tax'] = $this->language->get('entry_tax');
		$this->data['entry_vat'] = $this->language->get('entry_vat');
		$this->data['entry_tax_default'] = $this->language->get('entry_tax_default');
		$this->data['entry_tax_customer'] = $this->language->get('entry_tax_customer');
		$this->data['entry_customer_online'] = $this->language->get('entry_customer_online');
		$this->data['entry_customer_group'] = $this->language->get('entry_customer_group');
		$this->data['entry_customer_group_display'] = $this->language->get('entry_customer_group_display');
		$this->data['entry_customer_price'] = $this->language->get('entry_customer_price');
		$this->data['entry_account'] = $this->language->get('entry_account');
		$this->data['entry_cart_weight'] = $this->language->get('entry_cart_weight');
		$this->data['entry_guest_checkout'] = $this->language->get('entry_guest_checkout');
		$this->data['entry_checkout'] = $this->language->get('entry_checkout');
		$this->data['entry_order_edit'] = $this->language->get('entry_order_edit');
		$this->data['entry_invoice_prefix'] = $this->language->get('entry_invoice_prefix');
		$this->data['entry_order_status'] = $this->language->get('entry_order_status');
		$this->data['entry_complete_status'] = $this->language->get('entry_complete_status');	
		$this->data['entry_stock_display'] = $this->language->get('entry_stock_display');
		$this->data['entry_stock_warning'] = $this->language->get('entry_stock_warning');
		$this->data['entry_stock_checkout'] = $this->language->get('entry_stock_checkout');
		$this->data['entry_stock_status'] = $this->language->get('entry_stock_status');
		$this->data['entry_affiliate'] = $this->language->get('entry_affiliate');	
		$this->data['entry_commission'] = $this->language->get('entry_commission');	
		$this->data['entry_return_status'] = $this->language->get('entry_return_status');
		$this->data['entry_logo'] = $this->language->get('entry_logo');
		$this->data['entry_icon'] = $this->language->get('entry_icon');
		$this->data['entry_image_category'] = $this->language->get('entry_image_category');
		$this->data['entry_image_ncategory'] = $this->language->get('entry_image_ncategory');
		$this->data['entry_image_thumb'] = $this->language->get('entry_image_thumb');
		$this->data['entry_image_popup'] = $this->language->get('entry_image_popup');
		$this->data['entry_image_product'] = $this->language->get('entry_image_product');
		$this->data['entry_image_additional'] = $this->language->get('entry_image_additional');
		$this->data['entry_image_related'] = $this->language->get('entry_image_related');
		$this->data['entry_image_compare'] = $this->language->get('entry_image_compare');
		$this->data['entry_image_wishlist'] = $this->language->get('entry_image_wishlist');
		$this->data['entry_image_cart'] = $this->language->get('entry_image_cart');		
		$this->data['entry_mail_protocol'] = $this->language->get('entry_mail_protocol');
		$this->data['entry_mail_parameter'] = $this->language->get('entry_mail_parameter');
		$this->data['entry_smtp_host'] = $this->language->get('entry_smtp_host');
		$this->data['entry_smtp_username'] = $this->language->get('entry_smtp_username');
		$this->data['entry_smtp_password'] = $this->language->get('entry_smtp_password');
		$this->data['entry_smtp_port'] = $this->language->get('entry_smtp_port');
		$this->data['entry_smtp_timeout'] = $this->language->get('entry_smtp_timeout');
		$this->data['entry_alert_mail'] = $this->language->get('entry_alert_mail');
		$this->data['entry_account_mail'] = $this->language->get('entry_account_mail');
		$this->data['entry_alert_emails'] = $this->language->get('entry_alert_emails');
		$this->data['entry_fraud_detection'] = $this->language->get('entry_fraud_detection');
		$this->data['entry_fraud_key'] = $this->language->get('entry_fraud_key');
		$this->data['entry_fraud_score'] = $this->language->get('entry_fraud_score');
		$this->data['entry_fraud_status'] = $this->language->get('entry_fraud_status');
		$this->data['entry_use_ssl'] = $this->language->get('entry_use_ssl');
		$this->data['entry_maintenance'] = $this->language->get('entry_maintenance');

		$this->data['entry_encryption'] = $this->language->get('entry_encryption');
		$this->data['entry_seo_url'] = $this->language->get('entry_seo_url');
		$this->data['entry_seo_url_type'] = $this->language->get('entry_seo_url_type');
		$this->data['entry_seo_url_include_path'] = $this->language->get('entry_seo_url_include_path');
		$this->data['entry_seo_url_postfix'] = $this->language->get('entry_seo_url_postfix');
		$this->data['entry_compression'] = $this->language->get('entry_compression');
		$this->data['entry_error_display'] = $this->language->get('entry_error_display');
		$this->data['entry_error_log'] = $this->language->get('entry_error_log');
		$this->data['entry_error_filename'] = $this->language->get('entry_error_filename');
		$this->data['entry_google_analytics'] = $this->language->get('entry_google_analytics');
		$this->data['entry_sms_gatename'] = $this->language->get('entry_sms_gatename');
		$this->data['entry_sms_to'] = $this->language->get('entry_sms_to');
		$this->data['entry_sms_from'] = $this->language->get('entry_sms_from');
		$this->data['entry_sms_message'] = $this->language->get('entry_sms_message');
		$this->data['entry_sms_gate_username'] = $this->language->get('entry_sms_gate_username');
		$this->data['entry_sms_gate_password'] = $this->language->get('entry_sms_gate_password');
		$this->data['entry_sms_alert'] = $this->language->get('entry_sms_alert');
		$this->data['entry_sms_copy'] = $this->language->get('entry_sms_copy');
		$this->data['entry_registred_group'] = $this->language->get('entry_registred_group');
		
		$this->data['info_currency'] = $this->language->get('info_currency');
		$this->data['info_currency_auto'] = $this->language->get('info_currency_auto');
		$this->data['info_meta_description'] = $this->language->get('info_meta_description');
		$this->data['info_meta_keyword'] = $this->language->get('info_meta_keyword');
		$this->data['info_type_menu'] = $this->language->get('info_type_menu');
		$this->data['info_product_count'] = $this->language->get('info_product_count');
		$this->data['info_catalog_limit'] = $this->language->get('info_catalog_limit');
		$this->data['info_admin_limit'] = $this->language->get('info_admin_limit');
		$this->data['info_review'] = $this->language->get('info_review');
		$this->data['info_upload_allowed'] = $this->language->get('info_upload_allowed');
		$this->data['info_voucher_min'] = $this->language->get('info_voucher_min');
		$this->data['info_voucher_max'] = $this->language->get('info_voucher_max');
		$this->data['info_vat'] = $this->language->get('info_vat');
		$this->data['info_tax_default'] = $this->language->get('info_tax_default');
		$this->data['info_tax_customer'] = $this->language->get('info_tax_customer');
		$this->data['info_customer_online'] = $this->language->get('info_customer_online');
		$this->data['info_customer_group'] = $this->language->get('info_customer_group');
		$this->data['info_customer_group_display'] = $this->language->get('info_customer_group_display');
		$this->data['info_account'] = $this->language->get('info_account');
		$this->data['info_cart_weight'] = $this->language->get('info_cart_weight');
		$this->data['info_guest_checkout'] = $this->language->get('info_guest_checkout');
		$this->data['info_checkout'] = $this->language->get('info_checkout');
		$this->data['info_order_edit'] = $this->language->get('info_order_edit');
		$this->data['info_invoice_prefix'] = $this->language->get('info_invoice_prefix');
		$this->data['info_order_status'] = $this->language->get('info_order_status');
		$this->data['info_complete_status'] = $this->language->get('info_complete_status');
		$this->data['info_stock_display'] = $this->language->get('info_stock_display');
		$this->data['info_stock_warning'] = $this->language->get('info_stock_warning');
		$this->data['info_stock_checkout'] = $this->language->get('info_stock_checkout');
		$this->data['info_stock_status'] = $this->language->get('info_stock_status');
		$this->data['info_affiliate'] = $this->language->get('info_affiliate');
		$this->data['info_commission'] = $this->language->get('info_commission');
		$this->data['info_return_status'] = $this->language->get('info_return_status');
		$this->data['info_mail_protocol'] = $this->language->get('info_mail_protocol');
		$this->data['info_mail_parameter'] = $this->language->get('info_mail_parameter');
		$this->data['info_alert_mail'] = $this->language->get('info_alert_mail');
		$this->data['info_account_mail'] = $this->language->get('info_account_mail');
		$this->data['info_alert_emails'] = $this->language->get('info_alert_emails');
		$this->data['info_fraud_detection'] = $this->language->get('info_fraud_detection');
		$this->data['info_fraud_score'] = $this->language->get('info_fraud_score');
		$this->data['info_fraud_status'] = $this->language->get('info_fraud_status');
		$this->data['info_sms_from'] = $this->language->get('info_sms_from');
		$this->data['info_sms_to'] = $this->language->get('info_sms_to');
		$this->data['info_sms_copy'] = $this->language->get('info_sms_copy');
		$this->data['info_sms_message'] = $this->language->get('info_sms_message');
		$this->data['info_bnews_order'] = $this->language->get('info_bnews_order');
		$this->data['info_use_ssl'] = $this->language->get('info_use_ssl');
		$this->data['info_maintenance'] = $this->language->get('info_maintenance');
		$this->data['info_seo_url'] = $this->language->get('info_seo_url');
		$this->data['info_seo_url_include_path'] = $this->language->get('info_seo_url_include_path');
		$this->data['info_seo_url_postfix'] = $this->language->get('info_seo_url_postfix');
		$this->data['info_encryption'] = $this->language->get('info_encryption');
		$this->data['info_compression'] = $this->language->get('info_compression');
		$this->data['info_google_analytics'] = $this->language->get('info_google_analytics');
		$this->data['info_icon'] = $this->language->get('info_icon');		
		$this->data['info_display_address'] = $this->language->get('info_display_address');	
		$this->data['info_display_email'] = $this->language->get('info_display_email');	
		$this->data['info_display_telephone'] = $this->language->get('info_display_telephone');	
		$this->data['info_display_fax'] = $this->language->get('info_display_fax');	
		
		$this->data['button_save'] = $this->language->get('button_save');
		$this->data['button_cancel'] = $this->language->get('button_cancel');

		$this->data['tab_general'] = $this->language->get('tab_general');
		$this->data['tab_store'] = $this->language->get('tab_store');
		$this->data['tab_local'] = $this->language->get('tab_local');
		$this->data['tab_option'] = $this->language->get('tab_option');
		$this->data['tab_image'] = $this->language->get('tab_image');
		$this->data['tab_mail'] = $this->language->get('tab_mail');
		$this->data['tab_fraud'] = $this->language->get('tab_fraud');
		$this->data['tab_server'] = $this->language->get('tab_server');
		$this->data['tab_sms'] = $this->language->get('tab_sms');
		$this->data['tab_news'] = $this->language->get('tab_news');

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

		$files = glob(DIR_SYSTEM . 'smsgate/*.php');

		foreach ($files as $file) {
			$this->data['sms_gatenames'][] =  basename($file, '.php');
		}

 		if (isset($this->error['warning'])) {
			$this->data['error_warning'] = $this->error['warning'];
		} else {
			$this->data['error_warning'] = '';
		}
		
 		if (isset($this->error['name'])) {
			$this->data['error_name'] = $this->error['name'];
		} else {
			$this->data['error_name'] = '';
		}
		
 		if (isset($this->error['owner'])) {
			$this->data['error_owner'] = $this->error['owner'];
		} else {
			$this->data['error_owner'] = '';
		}

 		if (isset($this->error['address'])) {
			$this->data['error_address'] = $this->error['address'];
		} else {
			$this->data['error_address'] = '';
		}
		
 		if (isset($this->error['email'])) {
			$this->data['error_email'] = $this->error['email'];
		} else {
			$this->data['error_email'] = '';
		}

		if (isset($this->error['telephone'])) {
			$this->data['error_telephone'] = $this->error['telephone'];
		} else {
			$this->data['error_telephone'] = '';
		}
 
  		if (isset($this->error['title'])) {
			$this->data['error_title'] = $this->error['title'];
		} else {
			$this->data['error_title'] = '';
		}
		
		
		if (isset($this->error['image_ncategory'])) {
			$this->data['error_image_ncategory'] = $this->error['image_ncategory'];
		} else {
			$this->data['error_image_ncategory'] = '';
		}
		
		if (isset($this->error['image_bnews'])) {
			$this->data['error_image_bnews'] = $this->error['image_bnews'];
		} else {
			$this->data['error_image_bnews'] = '';
		}
		
		if (isset($this->error['thumb_bnews'])) {
			$this->data['error_thumb_bnews'] = $this->error['thumb_bnews'];
		} else {
			$this->data['error_thumb_bnews'] = '';
		}
		
		if (isset($this->error['mod_news'])) {
			$this->data['error_mod_news'] = $this->error['mod_news'];
		} else {
			$this->data['error_mod_news'] = '';
		}
		
		if (isset($this->error['mod_news_side'])) {
			$this->data['error_mod_news_side'] = $this->error['mod_news_side'];
		} else {
			$this->data['error_mod_news_side'] = '';
		}
		
		if (isset($this->error['symbols_headlines'])) {
			$this->data['error_symbols_headlines'] = $this->error['symbols_headlines'];
		} else {
			$this->data['error_symbols_headlines'] = '';
		}
		
		if (isset($this->error['symbols_ncategory'])) {
			$this->data['error_symbols_ncategory'] = $this->error['symbols_ncategory'];
		} else {
			$this->data['error_symbols_ncategory'] = '';
		}
		
		if (isset($this->error['customer_group_display'])) {
			$this->data['error_customer_group_display'] = $this->error['customer_group_display'];
		} else {
			$this->data['error_customer_group_display'] = '';
		}
				
  		if (isset($this->error['voucher_min'])) {
			$this->data['error_voucher_min'] = $this->error['voucher_min'];
		} else {
			$this->data['error_voucher_min'] = '';
		}	
			
  		if (isset($this->error['voucher_max'])) {
			$this->data['error_voucher_max'] = $this->error['voucher_max'];
		} else {
			$this->data['error_voucher_max'] = '';
		}
		
		if (isset($this->error['symbols_nsearch'])) {
			$this->data['error_symbols_nsearch'] = $this->error['symbols_nsearch'];
		} else {
			$this->data['error_symbols_nsearch'] = '';
		}
		
		if (isset($this->error['image_category'])) {
			$this->data['error_image_category'] = $this->error['image_category'];
		} else {
			$this->data['error_image_category'] = '';
		}
				
 		if (isset($this->error['image_thumb'])) {
			$this->data['error_image_thumb'] = $this->error['image_thumb'];
		} else {
			$this->data['error_image_thumb'] = '';
		}
		
 		if (isset($this->error['image_popup'])) {
			$this->data['error_image_popup'] = $this->error['image_popup'];
		} else {
			$this->data['error_image_popup'] = '';
		}
		
 		if (isset($this->error['image_product'])) {
			$this->data['error_image_product'] = $this->error['image_product'];
		} else {
			$this->data['error_image_product'] = '';
		}
		
 		if (isset($this->error['image_additional'])) {
			$this->data['error_image_additional'] = $this->error['image_additional'];
		} else {
			$this->data['error_image_additional'] = '';
		}	
		
 		if (isset($this->error['image_related'])) {
			$this->data['error_image_related'] = $this->error['image_related'];
		} else {
			$this->data['error_image_related'] = '';
		}
		
 		if (isset($this->error['image_compare'])) {
			$this->data['error_image_compare'] = $this->error['image_compare'];
		} else {
			$this->data['error_image_compare'] = '';
		}
		
  		if (isset($this->error['image_wishlist'])) {
			$this->data['error_image_wishlist'] = $this->error['image_wishlist'];
		} else {
			$this->data['error_image_wishlist'] = '';
		}
				
		if (isset($this->error['image_cart'])) {
			$this->data['error_image_cart'] = $this->error['image_cart'];
		} else {
			$this->data['error_image_cart'] = '';
		}
				
		if (isset($this->error['error_filename'])) {
			$this->data['error_error_filename'] = $this->error['error_filename'];
		} else {
			$this->data['error_error_filename'] = '';
		}		
		
		if (isset($this->error['catalog_limit'])) {
			$this->data['error_catalog_limit'] = $this->error['catalog_limit'];
		} else {
			$this->data['error_catalog_limit'] = '';
		}
		
		if (isset($this->error['admin_limit'])) {
			$this->data['error_admin_limit'] = $this->error['admin_limit'];
		} else {
			$this->data['error_admin_limit'] = '';
		}
		
  		$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('heading_title'),
			'href'      => $this->url->link('setting/setting', 'token=' . $this->session->data['token'], 'SSL'),
      		'separator' => ' :: '
   		);
		
		if (isset($this->session->data['success'])) {
			$this->data['success'] = $this->session->data['success'];
		
			unset($this->session->data['success']);
		} else {
			$this->data['success'] = '';
		}

		$this->data['action'] = $this->url->link('setting/setting', 'token=' . $this->session->data['token'], 'SSL');
		
		$this->data['cancel'] = $this->url->link('setting/store', 'token=' . $this->session->data['token'], 'SSL');

		$this->data['token'] = $this->session->data['token'];

		if (isset($this->request->post['config_name'])) {
			$this->data['config_name'] = $this->request->post['config_name'];
		} else {
			$this->data['config_name'] = $this->config->get('config_name');
		}
		
		if (isset($this->request->post['config_owner'])) {
			$this->data['config_owner'] = $this->request->post['config_owner'];
		} else {
			$this->data['config_owner'] = $this->config->get('config_owner');
		}

		if (isset($this->request->post['config_address'])) {
			$this->data['config_address'] = $this->request->post['config_address'];
		} else {
			$this->data['config_address'] = $this->config->get('config_address');
		}
		
		if (isset($this->request->post['config_display_address'])) {
			$this->data['config_display_address'] = $this->request->post['config_display_address'];
		} else {
			$this->data['config_display_address'] = $this->config->get('config_display_address');
		}
		
		if (isset($this->request->post['config_email'])) {
			$this->data['config_email'] = $this->request->post['config_email'];
		} else {
			$this->data['config_email'] = $this->config->get('config_email');
		}
		
		if (isset($this->request->post['config_display_email'])) {
			$this->data['config_display_email'] = $this->request->post['config_display_email'];
		} else {
			$this->data['config_display_email'] = $this->config->get('config_display_email');
		}
		
		if (isset($this->request->post['config_telephone'])) {
			$this->data['config_telephone'] = $this->request->post['config_telephone'];
		} else {
			$this->data['config_telephone'] = $this->config->get('config_telephone');
		}
		
		if (isset($this->request->post['config_display_telephone'])) {
			$this->data['config_display_telephone'] = $this->request->post['config_display_telephone'];
		} else {
			$this->data['config_display_telephone'] = $this->config->get('config_display_telephone');
		}

		if (isset($this->request->post['config_fax'])) {
			$this->data['config_fax'] = $this->request->post['config_fax'];
		} else {
			$this->data['config_fax'] = $this->config->get('config_fax');
		}
		
		if (isset($this->request->post['config_display_fax'])) {
			$this->data['config_display_fax'] = $this->request->post['config_display_fax'];
		} else {
			$this->data['config_display_fax'] = $this->config->get('config_display_fax');
		}

		if (isset($this->request->post['config_title'])) {
			$this->data['config_title'] = $this->request->post['config_title'];
		} else {
			$this->data['config_title'] = $this->config->get('config_title');
		}
		
		if (isset($this->request->post['config_meta_description'])) {
			$this->data['config_meta_description'] = $this->request->post['config_meta_description'];
		} else {
			$this->data['config_meta_description'] = $this->config->get('config_meta_description');
		}
		
		if (isset($this->request->post['config_meta_keyword'])) {
			$this->data['config_meta_keyword'] = $this->request->post['config_meta_keyword'];
		} else {
			$this->data['config_meta_keyword'] = $this->config->get('config_meta_keyword');
		}
		
		if (isset($this->request->post['config_layout_id'])) {
			$this->data['config_layout_id'] = $this->request->post['config_layout_id'];
		} else {
			$this->data['config_layout_id'] = $this->config->get('config_layout_id');
		}
				
		$this->load->model('design/layout');
		
		$this->data['layouts'] = $this->model_design_layout->getLayouts();
				
		if (isset($this->request->post['config_template'])) {
			$this->data['config_template'] = $this->request->post['config_template'];
		} else {
			$this->data['config_template'] = $this->config->get('config_template');
		}
		
		$this->data['templates'] = array();

		$directories = glob(DIR_CATALOG . 'view/theme/*', GLOB_ONLYDIR);
		
		foreach ($directories as $directory) {
			$this->data['templates'][] = basename($directory);
		}					
				
		if (isset($this->request->post['config_country_id'])) {
			$this->data['config_country_id'] = $this->request->post['config_country_id'];
		} else {
			$this->data['config_country_id'] = $this->config->get('config_country_id');
		}
		
		$this->load->model('localisation/country');
		
		$this->data['countries'] = $this->model_localisation_country->getCountries();

		if (isset($this->request->post['config_zone_id'])) {
			$this->data['config_zone_id'] = $this->request->post['config_zone_id'];
		} else {
			$this->data['config_zone_id'] = $this->config->get('config_zone_id');
		}		
		
		if (isset($this->request->post['config_language'])) {
			$this->data['config_language'] = $this->request->post['config_language'];
		} else {
			$this->data['config_language'] = $this->config->get('config_language');
		}

		$this->load->model('localisation/language');
		
		$this->data['languages'] = $this->model_localisation_language->getLanguages();
				
		if (isset($this->request->post['config_admin_language'])) {
			$this->data['config_admin_language'] = $this->request->post['config_admin_language'];
		} else {
			$this->data['config_admin_language'] = $this->config->get('config_admin_language');
		}

		if (isset($this->request->post['config_currency'])) {
			$this->data['config_currency'] = $this->request->post['config_currency'];
		} else {
			$this->data['config_currency'] = $this->config->get('config_currency');
		}

		if (isset($this->request->post['config_currency_auto'])) {
			$this->data['config_currency_auto'] = $this->request->post['config_currency_auto'];
		} else {
			$this->data['config_currency_auto'] = $this->config->get('config_currency_auto');
		}
		
		$this->load->model('localisation/currency');
		
		$this->data['currencies'] = $this->model_localisation_currency->getCurrencies();
		
		if (isset($this->request->post['config_length_class_id'])) {
			$this->data['config_length_class_id'] = $this->request->post['config_length_class_id'];
		} else {
			$this->data['config_length_class_id'] = $this->config->get('config_length_class_id');
		}
		
		$this->load->model('localisation/length_class');
		
		$this->data['length_classes'] = $this->model_localisation_length_class->getLengthClasses();
		
		if (isset($this->request->post['config_weight_class_id'])) {
			$this->data['config_weight_class_id'] = $this->request->post['config_weight_class_id'];
		} else {
			$this->data['config_weight_class_id'] = $this->config->get('config_weight_class_id');
		}
		
		$this->load->model('localisation/weight_class');
		
		$this->data['weight_classes'] = $this->model_localisation_weight_class->getWeightClasses();
		
		if (isset($this->request->post['config_main_menu'])) {
			$this->data['config_main_menu'] = $this->request->post['config_main_menu'];
		} else {
			$this->data['config_main_menu'] = $this->config->get('config_main_menu');			
		}
		
		if (isset($this->request->post['config_catalog_limit'])) {
			$this->data['config_catalog_limit'] = $this->request->post['config_catalog_limit'];
		} else {
			$this->data['config_catalog_limit'] = $this->config->get('config_catalog_limit');
		}	
						
		if (isset($this->request->post['config_admin_limit'])) {
			$this->data['config_admin_limit'] = $this->request->post['config_admin_limit'];
		} else {
			$this->data['config_admin_limit'] = $this->config->get('config_admin_limit');
		}
		
		if (isset($this->request->post['config_product_count'])) {
			$this->data['config_product_count'] = $this->request->post['config_product_count'];
		} else {
			$this->data['config_product_count'] = $this->config->get('config_product_count');
		}
	
		if (isset($this->request->post['config_review_status'])) {
			$this->data['config_review_status'] = $this->request->post['config_review_status'];
		} else {
			$this->data['config_review_status'] = $this->config->get('config_review_status');
		}
		
		if (isset($this->request->post['config_download'])) {
			$this->data['config_download'] = $this->request->post['config_download'];
		} else {
			$this->data['config_download'] = $this->config->get('config_download');
		}
		
		if (isset($this->request->post['config_upload_allowed'])) {
			$this->data['config_upload_allowed'] = $this->request->post['config_upload_allowed'];
		} else {
			$this->data['config_upload_allowed'] = $this->config->get('config_upload_allowed');
		}
		
		if (isset($this->request->post['config_voucher_min'])) {
			$this->data['config_voucher_min'] = $this->request->post['config_voucher_min'];
		} else {
			$this->data['config_voucher_min'] = $this->config->get('config_voucher_min');
		}	
		
		if (isset($this->request->post['config_voucher_max'])) {
			$this->data['config_voucher_max'] = $this->request->post['config_voucher_max'];
		} else {
			$this->data['config_voucher_max'] = $this->config->get('config_voucher_max');
		}			

		if (isset($this->request->post['config_tax'])) {
			$this->data['config_tax'] = $this->request->post['config_tax'];
		} else {
			$this->data['config_tax'] = $this->config->get('config_tax');			
		}
		
		if (isset($this->request->post['config_vat'])) {
			$this->data['config_vat'] = $this->request->post['config_vat'];
		} else {
			$this->data['config_vat'] = $this->config->get('config_vat');			
		}
			
		if (isset($this->request->post['config_tax_default'])) {
			$this->data['config_tax_default'] = $this->request->post['config_tax_default'];
		} else {
			$this->data['config_tax_default'] = $this->config->get('config_tax_default');			
		}	
			
		if (isset($this->request->post['config_tax_customer'])) {
			$this->data['config_tax_customer'] = $this->request->post['config_tax_customer'];
		} else {
			$this->data['config_tax_customer'] = $this->config->get('config_tax_customer');			
		}	
								
		if (isset($this->request->post['config_customer_online'])) {
			$this->data['config_customer_online'] = $this->request->post['config_customer_online'];
		} else {
			$this->data['config_customer_online'] = $this->config->get('config_customer_online');			
		}
		
		if (isset($this->request->post['config_customer_group_id'])) {
			$this->data['config_customer_group_id'] = $this->request->post['config_customer_group_id'];
		} else {
			$this->data['config_customer_group_id'] = $this->config->get('config_customer_group_id');			
		}
				
		$this->load->model('sale/customer_group');
		
		$this->data['customer_groups'] = $this->model_sale_customer_group->getCustomerGroups();
		
		if (isset($this->request->post['config_customer_group_display'])) {
			$this->data['config_customer_group_display'] = $this->request->post['config_customer_group_display'];
		} elseif ($this->config->get('config_customer_group_display')) {
			$this->data['config_customer_group_display'] = $this->config->get('config_customer_group_display');	
		} else {
			$this->data['config_customer_group_display'] = array();			
		}
		
		if (isset($this->request->post['config_customer_price'])) {
			$this->data['config_customer_price'] = $this->request->post['config_customer_price'];
		} else {
			$this->data['config_customer_price'] = $this->config->get('config_customer_price');			
		}
		
		if (isset($this->request->post['config_account_id'])) {
			$this->data['config_account_id'] = $this->request->post['config_account_id'];
		} else {
			$this->data['config_account_id'] = $this->config->get('config_account_id');			
		}
		
		$this->load->model('catalog/information');

		$this->data['informations'] = $this->model_catalog_information->getInformations();

		if (isset($this->request->post['config_cart_weight'])) {
			$this->data['config_cart_weight'] = $this->request->post['config_cart_weight'];
		} else {
			$this->data['config_cart_weight'] = $this->config->get('config_cart_weight');
		}	
		
		if (isset($this->request->post['config_guest_checkout'])) {
			$this->data['config_guest_checkout'] = $this->request->post['config_guest_checkout'];
		} else {
			$this->data['config_guest_checkout'] = $this->config->get('config_guest_checkout');		
		}
		
		if (isset($this->request->post['config_checkout_id'])) {
			$this->data['config_checkout_id'] = $this->request->post['config_checkout_id'];
		} else {
			$this->data['config_checkout_id'] = $this->config->get('config_checkout_id');		
		}
		
		if (isset($this->request->post['config_order_edit'])) {
			$this->data['config_order_edit'] = $this->request->post['config_order_edit'];
		} elseif ($this->config->get('config_order_edit')) {
			$this->data['config_order_edit'] = $this->config->get('config_order_edit');			
		} else {
			$this->data['config_order_edit'] = 7;
		}
		
		if (isset($this->request->post['config_invoice_prefix'])) {
			$this->data['config_invoice_prefix'] = $this->request->post['config_invoice_prefix'];
		} elseif ($this->config->get('config_invoice_prefix')) {
			$this->data['config_invoice_prefix'] = $this->config->get('config_invoice_prefix');			
		} else {
			$this->data['config_invoice_prefix'] = 'INV-' . date('Y') . '-00';
		}
		
		if (isset($this->request->post['config_order_status_id'])) {
			$this->data['config_order_status_id'] = $this->request->post['config_order_status_id'];
		} else {
			$this->data['config_order_status_id'] = $this->config->get('config_order_status_id');		
		}
		
		if (isset($this->request->post['config_complete_status_id'])) {
			$this->data['config_complete_status_id'] = $this->request->post['config_complete_status_id'];
		} else {
			$this->data['config_complete_status_id'] = $this->config->get('config_complete_status_id');
		}
		
		$this->load->model('localisation/order_status');
		
		$this->data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();		
	
		if (isset($this->request->post['config_stock_display'])) {
			$this->data['config_stock_display'] = $this->request->post['config_stock_display'];
		} else {
			$this->data['config_stock_display'] = $this->config->get('config_stock_display');			
		}
		
		if (isset($this->request->post['config_stock_warning'])) {
			$this->data['config_stock_warning'] = $this->request->post['config_stock_warning'];
		} else {
			$this->data['config_stock_warning'] = $this->config->get('config_stock_warning');		
		}

		if (isset($this->request->post['config_stock_checkout'])) {
			$this->data['config_stock_checkout'] = $this->request->post['config_stock_checkout'];
		} else {
			$this->data['config_stock_checkout'] = $this->config->get('config_stock_checkout');		
		}

		if (isset($this->request->post['config_stock_status_id'])) {
			$this->data['config_stock_status_id'] = $this->request->post['config_stock_status_id'];
		} else {
			$this->data['config_stock_status_id'] = $this->config->get('config_stock_status_id');			
		}
		
		if (isset($this->request->post['config_display_sku'])) {
			$this->data['config_display_sku'] = $this->request->post['config_display_sku'];
		} else {
			$this->data['config_display_sku'] = $this->config->get('config_display_sku');
		}
		
		if (isset($this->request->post['config_display_weight'])) {
			$this->data['config_display_weight'] = $this->request->post['config_display_weight'];
		} else {
			$this->data['config_display_weight'] = $this->config->get('config_display_weight');
		}
		
		if (isset($this->request->post['config_display_location'])) {
			$this->data['config_display_location'] = $this->request->post['config_display_location'];
		} else {
			$this->data['config_display_location'] = $this->config->get('config_display_location');
		}
		
		if (isset($this->request->post['config_display_ean'])) {
			$this->data['config_display_ean'] = $this->request->post['config_display_ean'];
		} else {
			$this->data['config_display_ean'] = $this->config->get('config_display_ean');
		}
		
		if (isset($this->request->post['config_display_upc'])) {
			$this->data['config_display_upc'] = $this->request->post['config_display_upc'];
		} else {
			$this->data['config_display_upc'] = $this->config->get('config_display_upc');
		}
		
		if (isset($this->request->post['config_display_isbn'])) {
			$this->data['config_display_isbn'] = $this->request->post['config_display_isbn'];
		} else {
			$this->data['config_display_isbn'] = $this->config->get('config_display_isbn');
		}
		
		if (isset($this->request->post['config_display_jan'])) {
			$this->data['config_display_jan'] = $this->request->post['config_display_jan'];
		} else {
			$this->data['config_display_jan'] = $this->config->get('config_display_jan');
		}
		
		if (isset($this->request->post['config_display_mpn'])) {
			$this->data['config_display_mpn'] = $this->request->post['config_display_mpn'];
		} else {
			$this->data['config_display_mpn'] = $this->config->get('config_display_mpn');
		}
		
		$this->load->model('localisation/stock_status');
		
		$this->data['stock_statuses'] = $this->model_localisation_stock_status->getStockStatuses();
		
		if (isset($this->request->post['config_affiliate_id'])) {
			$this->data['config_affiliate_id'] = $this->request->post['config_affiliate_id'];
		} else {
			$this->data['config_affiliate_id'] = $this->config->get('config_affiliate_id');		
		}
		
		if (isset($this->request->post['config_commission'])) {
			$this->data['config_commission'] = $this->request->post['config_commission'];
		} elseif ($this->config->has('config_commission')) {
			$this->data['config_commission'] = $this->config->get('config_commission');		
		} else {
			$this->data['config_commission'] = '5.00';
		}
				
		if (isset($this->request->post['config_return_status_id'])) {
			$this->data['config_return_status_id'] = $this->request->post['config_return_status_id'];
		} else {
			$this->data['config_return_status_id'] = $this->config->get('config_return_status_id');		
		}
		
		$this->load->model('localisation/return_status');
		
		$this->data['return_statuses'] = $this->model_localisation_return_status->getReturnStatuses();	
					
		$this->load->model('tool/image');

		if (isset($this->request->post['config_logo'])) {
			$this->data['config_logo'] = $this->request->post['config_logo'];
		} else {
			$this->data['config_logo'] = $this->config->get('config_logo');			
		}

		if ($this->config->get('config_logo') && file_exists(DIR_IMAGE . $this->config->get('config_logo')) && is_file(DIR_IMAGE . $this->config->get('config_logo'))) {
			$this->data['logo'] = $this->model_tool_image->resize($this->config->get('config_logo'), 100, 100);		
		} else {
			$this->data['logo'] = $this->model_tool_image->resize('no_image.jpg', 100, 100);
		}

		if (isset($this->request->post['config_icon'])) {
			$this->data['config_icon'] = $this->request->post['config_icon'];
		} else {
			$this->data['config_icon'] = $this->config->get('config_icon');			
		}
		
		if ($this->config->get('config_icon') && file_exists(DIR_IMAGE . $this->config->get('config_icon')) && is_file(DIR_IMAGE . $this->config->get('config_icon'))) {
			$this->data['icon'] = $this->model_tool_image->resize($this->config->get('config_icon'), 100, 100);		
		} else {
			$this->data['icon'] = $this->model_tool_image->resize('no_image.jpg', 100, 100);
		}
		
		$this->data['no_image'] = $this->model_tool_image->resize('no_image.jpg', 100, 100);

		if (isset($this->request->post['config_image_category_width'])) {
			$this->data['config_image_category_width'] = $this->request->post['config_image_category_width'];
		} else {
			$this->data['config_image_category_width'] = $this->config->get('config_image_category_width');
		}
		
		if (isset($this->request->post['config_image_category_height'])) {
			$this->data['config_image_category_height'] = $this->request->post['config_image_category_height'];
		} else {
			$this->data['config_image_category_height'] = $this->config->get('config_image_category_height');
		}
						
		if (isset($this->request->post['config_image_thumb_width'])) {
			$this->data['config_image_thumb_width'] = $this->request->post['config_image_thumb_width'];
		} else {
			$this->data['config_image_thumb_width'] = $this->config->get('config_image_thumb_width');
		}
		
		if (isset($this->request->post['config_image_thumb_height'])) {
			$this->data['config_image_thumb_height'] = $this->request->post['config_image_thumb_height'];
		} else {
			$this->data['config_image_thumb_height'] = $this->config->get('config_image_thumb_height');
		}
		
		if (isset($this->request->post['config_image_popup_width'])) {
			$this->data['config_image_popup_width'] = $this->request->post['config_image_popup_width'];
		} else {
			$this->data['config_image_popup_width'] = $this->config->get('config_image_popup_width');
		}
		
		if (isset($this->request->post['config_image_popup_height'])) {
			$this->data['config_image_popup_height'] = $this->request->post['config_image_popup_height'];
		} else {
			$this->data['config_image_popup_height'] = $this->config->get('config_image_popup_height');
		}
		
		if (isset($this->request->post['config_image_product_width'])) {
			$this->data['config_image_product_width'] = $this->request->post['config_image_product_width'];
		} else {
			$this->data['config_image_product_width'] = $this->config->get('config_image_product_width');
		}
		
		if (isset($this->request->post['config_image_product_height'])) {
			$this->data['config_image_product_height'] = $this->request->post['config_image_product_height'];
		} else {
			$this->data['config_image_product_height'] = $this->config->get('config_image_product_height');
		}

		if (isset($this->request->post['config_image_additional_width'])) {
			$this->data['config_image_additional_width'] = $this->request->post['config_image_additional_width'];
		} else {
			$this->data['config_image_additional_width'] = $this->config->get('config_image_additional_width');
		}
		
		if (isset($this->request->post['config_image_additional_height'])) {
			$this->data['config_image_additional_height'] = $this->request->post['config_image_additional_height'];
		} else {
			$this->data['config_image_additional_height'] = $this->config->get('config_image_additional_height');
		}
		
		if (isset($this->request->post['config_image_related_width'])) {
			$this->data['config_image_related_width'] = $this->request->post['config_image_related_width'];
		} else {
			$this->data['config_image_related_width'] = $this->config->get('config_image_related_width');
		}
		
		if (isset($this->request->post['config_image_related_height'])) {
			$this->data['config_image_related_height'] = $this->request->post['config_image_related_height'];
		} else {
			$this->data['config_image_related_height'] = $this->config->get('config_image_related_height');
		}
		
		if (isset($this->request->post['config_image_compare_width'])) {
			$this->data['config_image_compare_width'] = $this->request->post['config_image_compare_width'];
		} else {
			$this->data['config_image_compare_width'] = $this->config->get('config_image_compare_width');
		}
		
		if (isset($this->request->post['config_image_compare_height'])) {
			$this->data['config_image_compare_height'] = $this->request->post['config_image_compare_height'];
		} else {
			$this->data['config_image_compare_height'] = $this->config->get('config_image_compare_height');
		}	
		
		if (isset($this->request->post['config_image_wishlist_width'])) {
			$this->data['config_image_wishlist_width'] = $this->request->post['config_image_wishlist_width'];
		} else {
			$this->data['config_image_wishlist_width'] = $this->config->get('config_image_wishlist_width');
		}
		
		if (isset($this->request->post['config_image_wishlist_height'])) {
			$this->data['config_image_wishlist_height'] = $this->request->post['config_image_wishlist_height'];
		} else {
			$this->data['config_image_wishlist_height'] = $this->config->get('config_image_wishlist_height');
		}	
						
		if (isset($this->request->post['config_image_cart_width'])) {
			$this->data['config_image_cart_width'] = $this->request->post['config_image_cart_width'];
		} else {
			$this->data['config_image_cart_width'] = $this->config->get('config_image_cart_width');
		}
		
		if (isset($this->request->post['config_image_cart_height'])) {
			$this->data['config_image_cart_height'] = $this->request->post['config_image_cart_height'];
		} else {
			$this->data['config_image_cart_height'] = $this->config->get('config_image_cart_height');
		}		
		
		if (isset($this->request->post['config_mail_protocol'])) {
			$this->data['config_mail_protocol'] = $this->request->post['config_mail_protocol'];
		} else {
			$this->data['config_mail_protocol'] = $this->config->get('config_mail_protocol');
		}
		
		if (isset($this->request->post['config_mail_parameter'])) {
			$this->data['config_mail_parameter'] = $this->request->post['config_mail_parameter'];
		} else {
			$this->data['config_mail_parameter'] = $this->config->get('config_mail_parameter');
		}
				
		if (isset($this->request->post['config_smtp_host'])) {
			$this->data['config_smtp_host'] = $this->request->post['config_smtp_host'];
		} else {
			$this->data['config_smtp_host'] = $this->config->get('config_smtp_host');
		}		

		if (isset($this->request->post['config_smtp_username'])) {
			$this->data['config_smtp_username'] = $this->request->post['config_smtp_username'];
		} else {
			$this->data['config_smtp_username'] = $this->config->get('config_smtp_username');
		}	
		
		if (isset($this->request->post['config_smtp_password'])) {
			$this->data['config_smtp_password'] = $this->request->post['config_smtp_password'];
		} else {
			$this->data['config_smtp_password'] = $this->config->get('config_smtp_password');
		}	
		
		if (isset($this->request->post['config_smtp_port'])) {
			$this->data['config_smtp_port'] = $this->request->post['config_smtp_port'];
		} elseif ($this->config->get('config_smtp_port')) {
			$this->data['config_smtp_port'] = $this->config->get('config_smtp_port');
		} else {
			$this->data['config_smtp_port'] = 25;
		}	
		
		if (isset($this->request->post['config_smtp_timeout'])) {
			$this->data['config_smtp_timeout'] = $this->request->post['config_smtp_timeout'];
		} elseif ($this->config->get('config_smtp_timeout')) {
			$this->data['config_smtp_timeout'] = $this->config->get('config_smtp_timeout');
		} else {
			$this->data['config_smtp_timeout'] = 5;	
		}	
		
		if (isset($this->request->post['config_alert_mail'])) {
			$this->data['config_alert_mail'] = $this->request->post['config_alert_mail'];
		} else {
			$this->data['config_alert_mail'] = $this->config->get('config_alert_mail');
		}

		if (isset($this->request->post['config_account_mail'])) {
			$this->data['config_account_mail'] = $this->request->post['config_account_mail'];
		} else {
			$this->data['config_account_mail'] = $this->config->get('config_account_mail');
		}
		
		if (isset($this->request->post['config_alert_emails'])) {
			$this->data['config_alert_emails'] = $this->request->post['config_alert_emails'];
		} else {
			$this->data['config_alert_emails'] = $this->config->get('config_alert_emails');
		}
		// News
		if (isset($this->request->post['config_image_ncategory_width'])) {
			$this->data['config_image_ncategory_width'] = $this->request->post['config_image_ncategory_width'];
		} else {
			$this->data['config_image_ncategory_width'] = $this->config->get('config_image_ncategory_width');
		}
		
		if (isset($this->request->post['config_image_ncategory_height'])) {
			$this->data['config_image_ncategory_height'] = $this->request->post['config_image_ncategory_height'];
		} else {
			$this->data['config_image_ncategory_height'] = $this->config->get('config_image_ncategory_height');
		}
		
		if (isset($this->request->post['config_bnews_image_width'])) {
			$this->data['config_bnews_image_width'] = $this->request->post['config_bnews_image_width'];
		} else {
			$this->data['config_bnews_image_width'] = $this->config->get('config_bnews_image_width');
		}
		
		if (isset($this->request->post['config_bnews_image_height'])) {
			$this->data['config_bnews_image_height'] = $this->request->post['config_bnews_image_height'];
		} else {
			$this->data['config_bnews_image_height'] = $this->config->get('config_bnews_image_height');
		}
		
		if (isset($this->request->post['config_bnews_thumb_width'])) {
			$this->data['config_bnews_thumb_width'] = $this->request->post['config_bnews_thumb_width'];
		} else {
			$this->data['config_bnews_thumb_width'] = $this->config->get('config_bnews_thumb_width');
		}
		
		if (isset($this->request->post['config_bnews_thumb_height'])) {
			$this->data['config_bnews_thumb_height'] = $this->request->post['config_bnews_thumb_height'];
		} else {
			$this->data['config_bnews_thumb_height'] = $this->config->get('config_bnews_thumb_height');
		}
		
		if (isset($this->request->post['config_bnews_order'])) {
			$this->data['config_bnews_order'] = $this->request->post['config_bnews_order'];
		} else {
			$this->data['config_bnews_order'] = $this->config->get('config_bnews_order');
		}
		
		if (isset($this->request->post['config_mod_news'])) {
			$this->data['config_mod_news'] = $this->request->post['config_mod_news'];
		} else {
			$this->data['config_mod_news'] = $this->config->get('config_mod_news');
		}
		
		if (isset($this->request->post['config_mod_news_side'])) {
			$this->data['config_mod_news_side'] = $this->request->post['config_mod_news_side'];
		} else {
			$this->data['config_mod_news_side'] = $this->config->get('config_mod_news_side');
		}
		
		if (isset($this->request->post['config_symbols_headlines'])) {
			$this->data['config_symbols_headlines'] = $this->request->post['config_symbols_headlines'];
		} else {
			$this->data['config_symbols_headlines'] = $this->config->get('config_symbols_headlines');
		}
		
		if (isset($this->request->post['config_symbols_ncategory'])) {
			$this->data['config_symbols_ncategory'] = $this->request->post['config_symbols_ncategory'];
		} else {
			$this->data['config_symbols_ncategory'] = $this->config->get('config_symbols_ncategory');
		}
		
		if (isset($this->request->post['config_symbols_nsearch'])) {
			$this->data['config_symbols_nsearch'] = $this->request->post['config_symbols_nsearch'];
		} else {
			$this->data['config_symbols_nsearch'] = $this->config->get('config_symbols_nsearch');
		}
		
		// End News
		if (isset($this->request->post['config_fraud_detection'])) {
			$this->data['config_fraud_detection'] = $this->request->post['config_fraud_detection']; 
		} else {
			$this->data['config_fraud_detection'] = $this->config->get('config_fraud_detection');
		}	
				
		if (isset($this->request->post['config_fraud_key'])) {
			$this->data['config_fraud_key'] = $this->request->post['config_fraud_key']; 
		} else {
			$this->data['config_fraud_key'] = $this->config->get('config_fraud_key');
		}		

		if (isset($this->request->post['config_fraud_score'])) {
			$this->data['config_fraud_score'] = $this->request->post['config_fraud_score']; 
		} else {
			$this->data['config_fraud_score'] = $this->config->get('config_fraud_score');
		}	
			
		if (isset($this->request->post['config_fraud_status_id'])) {
			$this->data['config_fraud_status_id'] = $this->request->post['config_fraud_status_id']; 
		} else {
			$this->data['config_fraud_status_id'] = $this->config->get('config_fraud_status_id');
		}		
				
		if (isset($this->request->post['config_use_ssl'])) {
			$this->data['config_use_ssl'] = $this->request->post['config_use_ssl'];
		} else {
			$this->data['config_use_ssl'] = $this->config->get('config_use_ssl');
		}
		
		if (isset($this->request->post['config_seo_url'])) {
			$this->data['config_seo_url'] = $this->request->post['config_seo_url'];
		} else {
			$this->data['config_seo_url'] = $this->config->get('config_seo_url');
		}
		
		if (isset($this->request->post['config_seo_url_type'])) {
			$this->data['config_seo_url_type'] = $this->request->post['config_seo_url_type'];
		} elseif ($this->config->get('config_seo_url_type')) {
			$this->data['config_seo_url_type'] = $this->config->get('config_seo_url_type');
		} else {
			$this->data['config_seo_url_type'] = 'seo_url';
		}

		$this->data['seo_types'] = array();
		$this->data['seo_types'][] = array('type' => 'seo_url', 'name' => $this->language->get('text_seo_url'));
		$this->data['seo_types'][] = array('type' => 'seo_pro', 'name' => $this->language->get('text_seo_pro'));

		if (isset($this->request->post['config_seo_url_include_path'])) {
			$this->data['config_seo_url_include_path'] = $this->request->post['config_seo_url_include_path'];
		} else {
			$this->data['config_seo_url_include_path'] = $this->config->get('config_seo_url_include_path');
		}

		if (isset($this->request->post['config_seo_url_postfix'])) {
			$this->data['config_seo_url_postfix'] = $this->request->post['config_seo_url_postfix'];
		} else {
			$this->data['config_seo_url_postfix'] = $this->config->get('config_seo_url_postfix');
		}

		if (isset($this->request->post['config_maintenance'])) {
			$this->data['config_maintenance'] = $this->request->post['config_maintenance'];
		} else {
			$this->data['config_maintenance'] = $this->config->get('config_maintenance');
		}
		
		if (isset($this->request->post['config_encryption'])) {
			$this->data['config_encryption'] = $this->request->post['config_encryption'];
		} else {
			$this->data['config_encryption'] = $this->config->get('config_encryption');
		}
		
		if (isset($this->request->post['config_compression'])) {
			$this->data['config_compression'] = $this->request->post['config_compression']; 
		} else {
			$this->data['config_compression'] = $this->config->get('config_compression');
		}

		if (isset($this->request->post['config_error_display'])) {
			$this->data['config_error_display'] = $this->request->post['config_error_display']; 
		} else {
			$this->data['config_error_display'] = $this->config->get('config_error_display');
		}

		if (isset($this->request->post['config_error_log'])) {
			$this->data['config_error_log'] = $this->request->post['config_error_log']; 
		} else {
			$this->data['config_error_log'] = $this->config->get('config_error_log');
		}

		if (isset($this->request->post['config_error_filename'])) {
			$this->data['config_error_filename'] = $this->request->post['config_error_filename']; 
		} else {
			$this->data['config_error_filename'] = $this->config->get('config_error_filename');
		}
				
		if (isset($this->request->post['config_google_analytics'])) {
			$this->data['config_google_analytics'] = $this->request->post['config_google_analytics']; 
		} else {
			$this->data['config_google_analytics'] = $this->config->get('config_google_analytics');
		}
		
		if (isset($this->request->post['config_sms_gatename'])) {
			$this->data['config_sms_gatename'] = $this->request->post['config_sms_gatename'];
		} else {
			$this->data['config_sms_gatename'] = $this->config->get('config_sms_gatename');
		}

		if (isset($this->request->post['config_sms_to'])) {
			$this->data['config_sms_to'] = $this->request->post['config_sms_to'];
		} else {
			$this->data['config_sms_to'] = $this->config->get('config_sms_to');
		}

		if (isset($this->request->post['config_sms_from'])) {
			$this->data['config_sms_from'] = $this->request->post['config_sms_from'];
		} else {
			$this->data['config_sms_from'] = $this->config->get('config_sms_from');
		}

		if (isset($this->request->post['config_sms_message'])) {
			$this->data['config_sms_message'] = $this->request->post['config_sms_message'];
		} else {
			$this->data['config_sms_message'] = $this->config->get('config_sms_message');
		}

		if (isset($this->request->post['config_sms_gate_username'])) {
			$this->data['config_sms_gate_username'] = $this->request->post['config_sms_gate_username'];
		} else {
			$this->data['config_sms_gate_username'] = $this->config->get('config_sms_gate_username');
		}

		if (isset($this->request->post['config_sms_gate_password'])) {
			$this->data['config_sms_gate_password'] = $this->request->post['config_sms_gate_password'];
		} else {
			$this->data['config_sms_gate_password'] = $this->config->get('config_sms_gate_password');
		}

		if (isset($this->request->post['config_sms_alert'])) {
			$this->data['config_sms_alert'] = $this->request->post['config_sms_alert'];
		} else {
			$this->data['config_sms_alert'] = $this->config->get('config_sms_alert');
		}

		if (isset($this->request->post['config_sms_copy'])) {
			$this->data['config_sms_copy'] = $this->request->post['config_sms_copy'];
		} else {
			$this->data['config_sms_copy'] = $this->config->get('config_sms_copy');
		}

		$this->template = 'setting/setting.tpl';
		$this->children = array(
			'common/header',
			'common/footer'
		);
				
		$this->response->setOutput($this->render());
	}

	private function validate() {
		if (!$this->user->hasPermission('modify', 'setting/setting')) {
			$this->error['warning'] = $this->language->get('error_permission');
		}

		if (!$this->request->post['config_name']) {
			$this->error['name'] = $this->language->get('error_name');
		}	
		
		if ((utf8_strlen($this->request->post['config_owner']) < 3) || (utf8_strlen($this->request->post['config_owner']) > 64)) {
			$this->error['owner'] = $this->language->get('error_owner');
		}

		if ((utf8_strlen($this->request->post['config_address']) < 3) || (utf8_strlen($this->request->post['config_address']) > 256)) {
			$this->error['address'] = $this->language->get('error_address');
		}
		
    	if ((utf8_strlen($this->request->post['config_email']) > 96) || !preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $this->request->post['config_email'])) {
      		$this->error['email'] = $this->language->get('error_email');
    	}

    	if ((utf8_strlen($this->request->post['config_telephone']) < 3) || (utf8_strlen($this->request->post['config_telephone']) > 32)) {
      		$this->error['telephone'] = $this->language->get('error_telephone');
    	}

		if (!$this->request->post['config_title']) {
			$this->error['title'] = $this->language->get('error_title');
		}	
		
		
		if (!$this->request->post['config_image_ncategory_width'] || !$this->request->post['config_image_ncategory_height']) {
			$this->error['image_ncategory'] = $this->language->get('error_image_ncategory');
		} 
		
		if (!$this->request->post['config_bnews_image_width'] || !$this->request->post['config_bnews_image_height']) {
			$this->error['image_bnews'] = $this->language->get('error_image_bnews');
		} 
		
		if (!$this->request->post['config_bnews_thumb_width'] || !$this->request->post['config_bnews_thumb_height']) {
			$this->error['thumb_bnews'] = $this->language->get('error_thumb_bnews');
		} 
		
		if (!$this->request->post['config_mod_news']) {
			$this->error['mod_news'] = $this->language->get('error_mod_news');
		} 
		
		if (!$this->request->post['config_mod_news_side']) {
			$this->error['mod_news_side'] = $this->language->get('error_mod_news_side');
		}
		
		if (!$this->request->post['config_symbols_headlines']) {
			$this->error['symbols_headlines'] = $this->language->get('error_symbols_headlines');
		}
		
		if (!$this->request->post['config_symbols_ncategory']) {
			$this->error['symbols_ncategory'] = $this->language->get('error_symbols_ncategory');
		}
		
		if (!$this->request->post['config_symbols_nsearch']) {
			$this->error['symbols_nsearch'] = $this->language->get('error_symbols_nsearch');
		}
		
		if (!empty($this->request->post['config_customer_group_display']) && !in_array($this->request->post['config_customer_group_id'], $this->request->post['config_customer_group_display'])) {
			$this->error['customer_group_display'] = $this->language->get('error_customer_group_display');
		}	
		
		if (!$this->request->post['config_voucher_min']) {
			$this->error['voucher_min'] = $this->language->get('error_voucher_min');
		}	
		
		if (!$this->request->post['config_voucher_max']) {
			$this->error['voucher_max'] = $this->language->get('error_voucher_max');
		}	
		
		if (!$this->request->post['config_image_category_width'] || !$this->request->post['config_image_category_height']) {
			$this->error['image_category'] = $this->language->get('error_image_category');
		} 
				
		if (!$this->request->post['config_image_thumb_width'] || !$this->request->post['config_image_thumb_height']) {
			$this->error['image_thumb'] = $this->language->get('error_image_thumb');
		}	
		
		if (!$this->request->post['config_image_popup_width'] || !$this->request->post['config_image_popup_height']) {
			$this->error['image_popup'] = $this->language->get('error_image_popup');
		}	
		
		if (!$this->request->post['config_image_product_width'] || !$this->request->post['config_image_product_height']) {
			$this->error['image_product'] = $this->language->get('error_image_product');
		}
				
		if (!$this->request->post['config_image_additional_width'] || !$this->request->post['config_image_additional_height']) {
			$this->error['image_additional'] = $this->language->get('error_image_additional');
		}
		
		if (!$this->request->post['config_image_related_width'] || !$this->request->post['config_image_related_height']) {
			$this->error['image_related'] = $this->language->get('error_image_related');
		}
		
		if (!$this->request->post['config_image_compare_width'] || !$this->request->post['config_image_compare_height']) {
			$this->error['image_compare'] = $this->language->get('error_image_compare');
		}
		
		if (!$this->request->post['config_image_wishlist_width'] || !$this->request->post['config_image_wishlist_height']) {
			$this->error['image_wishlist'] = $this->language->get('error_image_wishlist');
		}			
		
		if (!$this->request->post['config_image_cart_width'] || !$this->request->post['config_image_cart_height']) {
			$this->error['image_cart'] = $this->language->get('error_image_cart');
		}
		
		if (!$this->request->post['config_error_filename']) {
			$this->error['error_filename'] = $this->language->get('error_error_filename');
		}
		
		if (!$this->request->post['config_admin_limit']) {
			$this->error['admin_limit'] = $this->language->get('error_limit');
		}
		
		if (!$this->request->post['config_catalog_limit']) {
			$this->error['catalog_limit'] = $this->language->get('error_limit');
		}
		
		if ($this->error && !isset($this->error['warning'])) {
			$this->error['warning'] = $this->language->get('error_warning');
		}
			
		if (!$this->error) {
			return true;
		} else {
			return false;
		}
	}
	
	public function template() {
		if (file_exists(DIR_IMAGE . 'templates/' . basename($this->request->get['template']) . '.png')) {
			$image = HTTPS_IMAGE . 'templates/' . basename($this->request->get['template']) . '.png';
		} else {
			$image = HTTPS_IMAGE . 'no_image.jpg';
		}
		
		$this->response->setOutput('<img src="' . $image . '" alt="" title="" style="border: 1px solid #EEEEEE;" />');
	}		
		
	public function country() {
		$json = array();
		
		$this->load->model('localisation/country');

    	$country_info = $this->model_localisation_country->getCountry($this->request->get['country_id']);
		
		if ($country_info) {
			$this->load->model('localisation/zone');

			$json = array(
				'country_id'        => $country_info['country_id'],
				'name'              => $country_info['name'],
				'iso_code_2'        => $country_info['iso_code_2'],
				'iso_code_3'        => $country_info['iso_code_3'],
				'address_format'    => $country_info['address_format'],
				'postcode_required' => $country_info['postcode_required'],
				'zone'              => $this->model_localisation_zone->getZonesByCountryId($this->request->get['country_id']),
				'status'            => $country_info['status']		
			);
		}
		
		$this->response->setOutput(json_encode($json));
	}
}
?>