<?php
class ControllerextensionModulereasonright extends Controller {
	private $error = array();

	public function index() {
		$this->load->language('extension/module/reasonright');

		$this->document->setTitle(preg_replace('/<(.*?)strong>/i', '', $this->language->get('heading_title')));

		$this->load->model('extension/module');

		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
			if (!isset($this->request->get['module_id'])) {
				$this->model_extension_module->addModule('reasonright', $this->request->post);
			} else {
				$this->model_extension_module->editModule($this->request->get['module_id'], $this->request->post);
			}

			$this->session->data['success'] = $this->language->get('text_success');

			$this->response->redirect($this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=module', true));
		}

		$data['heading_title'] = preg_replace('/<(.*?)strong>/i', '', $this->language->get('heading_title'));

		$data['text_edit'] = $this->language->get('text_edit');
		$data['text_enabled'] = $this->language->get('text_enabled');
		$data['text_disabled'] = $this->language->get('text_disabled');
		$data['text_qq_open_signup'] = $this->language->get('text_qq_open_signup');
		$data['text_yes'] = $this->language->get('text_yes');
		$data['text_no'] = $this->language->get('text_no');
		$data['text_mainc'] = $this->language->get('text_mainc');
		$data['text_mainfw'] = $this->language->get('text_mainfw');
		$data['text_cwkj_wxts'] = $this->language->get('text_cwkj_wxts');
		
		$data['entry_status'] = $this->language->get('entry_status');
		$data['entry_sort_order'] = $this->language->get('entry_sort_order');
		$data['entry_name'] = $this->language->get('entry_name');
		$data['entry_titlename'] = $this->language->get('entry_titlename');
		$data['entry_describe'] = $this->language->get('entry_describe');
		$data['entry_wgdlg'] = $this->language->get('entry_wgdlg');
		$data['help_wgdlg'] = $this->language->get('help_wgdlg');
		$data['entry_wgdlg1'] = $this->language->get('entry_wgdlg1');
		$data['entry_wgdlg2'] = $this->language->get('entry_wgdlg2');
		$data['entry_bgcolortitle'] = $this->language->get('entry_bgcolortitle');
		$data['entry_bgcolor'] = $this->language->get('entry_bgcolor');
		$data['entry_bgcolorcss'] = $this->language->get('entry_bgcolorcss');
		$data['entry_titlejbcss'] = $this->language->get('entry_titlejbcss');
		$data['entry_titlejbsmcss'] = $this->language->get('entry_titlejbsmcss');
		$data['entry_titlecss'] = $this->language->get('entry_titlecss');
		$data['entry_titlesmcss'] = $this->language->get('entry_titlesmcss');
		$data['entry_image'] = $this->language->get('entry_image');
		$data['entry_width'] = $this->language->get('entry_width');
		$data['entry_height'] = $this->language->get('entry_height');
		$data['entry_video'] = $this->language->get('entry_video');
		$data['entry_widthsm'] = $this->language->get('entry_widthsm');
		$data['entry_heightsm'] = $this->language->get('entry_heightsm');
		$data['entry_namebig'] = $this->language->get('entry_namebig');
		$data['entry_namebigtwo'] = $this->language->get('entry_namebigtwo');
		$data['entry_namebigthree'] = $this->language->get('entry_namebigthree');
		$data['entry_namebigfour'] = $this->language->get('entry_namebigfour');
		$data['entry_titlename'] = $this->language->get('entry_titlename');
		$data['entry_section1'] = $this->language->get('entry_section1');
		$data['entry_section2'] = $this->language->get('entry_section2');
		$data['entry_section3'] = $this->language->get('entry_section3');
		$data['entry_section4'] = $this->language->get('entry_section4');
		$data['entry_title'] = $this->language->get('entry_title');
		$data['entry_title1'] = $this->language->get('entry_title1');
		$data['entry_text'] = $this->language->get('entry_text');
		$data['entry_text1'] = $this->language->get('entry_text1');
		$data['entry_text2'] = $this->language->get('entry_text2');
		$data['entry_icon'] = $this->language->get('entry_icon');
		$data['entry_icon1'] = $this->language->get('entry_icon1');
		$data['entry_imagepng'] = $this->language->get('entry_imagepng');
		$data['entry_tccolor'] = $this->language->get('entry_tccolor');
		$data['entry_titlezwzc'] = $this->language->get('entry_titlezwzc');
		$data['entry_pricecolor'] = $this->language->get('entry_pricecolor');
		$data['entry_iconcolor'] = $this->language->get('entry_iconcolor');
		$data['entry_tcbjcolor'] = $this->language->get('entry_tcbjcolor');
		$data['entry_pricetitleicolor'] = $this->language->get('entry_pricetitleicolor');
		$data['entry_boxcolorcss'] = $this->language->get('entry_boxcolorcss');
		$data['entry_miconbj'] = $this->language->get('entry_miconbj');
		$data['entry_miconjbbj'] = $this->language->get('entry_miconjbbj');
		$data['entry_miconcolor'] = $this->language->get('entry_miconcolor');
		$data['entry_miconround'] = $this->language->get('entry_miconround');
		$data['entry_miconsize'] = $this->language->get('entry_miconsize');
		$data['entry_miconborder'] = $this->language->get('entry_miconborder');
		$data['entry_miconbc'] = $this->language->get('entry_miconbc');
		$data['entry_iconstyle'] = $this->language->get('entry_iconstyle');
		$data['entry_columns'] = $this->language->get('entry_columns');
        $data['entry_column'] = $this->language->get('entry_column');
		$data['help_column'] = $this->language->get('help_column');
		$data['entry_imagepicstyle'] = $this->language->get('entry_imagepicstyle');
		$data['entry_miconwidth'] = $this->language->get('entry_miconwidth');
        $data['entry_miconheight'] = $this->language->get('entry_miconheight');
		$data['entry_rrp'] = $this->language->get('entry_rrp');
		$data['entry_rrb'] = $this->language->get('entry_rrb');
		$data['entry_segmentingline'] = $this->language->get('entry_segmentingline');
		$data['entry_rfourlw'] = $this->language->get('entry_rfourlw');
		$data['entry_rfourlh'] = $this->language->get('entry_rfourlh');
        $data['entry_rfourlc'] = $this->language->get('entry_rfourlc');
		$data['entry_autoplay'] = $this->language->get('entry_autoplay');
		$data['entry_main'] = $this->language->get('entry_main');
		$data['entry_speed'] = $this->language->get('entry_speed');
		$data['entry_scroll'] = $this->language->get('entry_scroll');
		$data['entry_rrmtp'] = $this->language->get('entry_rrmtp');
		$data['entry_rmaxwidth'] = $this->language->get('entry_rmaxwidth');
		$data['entry_rfontsize'] = $this->language->get('entry_rfontsize');
		$data['entry_rrbigt'] = $this->language->get('entry_rrbigt');
		$data['entry_rrsmt'] = $this->language->get('entry_rrsmt');
		$data['entry_rrsrow'] = $this->language->get('entry_rrsrow');
		$data['entry_button1'] = $this->language->get('entry_button1');
		$data['entry_button2'] = $this->language->get('entry_button2');
		$data['entry_buttonname'] = $this->language->get('entry_buttonname');
		$data['entry_buttonname1'] = $this->language->get('entry_buttonname1');
		$data['entry_buttonname2'] = $this->language->get('entry_buttonname2');
		$data['entry_qq1'] = $this->language->get('entry_qq1');
		$data['entry_qq2'] = $this->language->get('entry_qq2');
		$data['entry_alww1'] = $this->language->get('entry_alww1');
		$data['entry_alww2'] = $this->language->get('entry_alww2');
		$data['entry_link'] = $this->language->get('entry_link');
		$data['entry_link1'] = $this->language->get('entry_link1');
		$data['entry_link2'] = $this->language->get('entry_link2');
		$data['entry_icons1'] = $this->language->get('entry_icons1');
		$data['entry_icons2'] = $this->language->get('entry_icons2');
		$data['entry_buttoncolor1'] = $this->language->get('entry_buttoncolor1');
		$data['entry_buttoncolor2'] = $this->language->get('entry_buttoncolor2');
		$data['entry_buttoncolor2'] = $this->language->get('entry_buttoncolor2');
		$data['entry_rrption'] = $this->language->get('entry_rrption');
		$data['entry_layoutpx'] = $this->language->get('entry_layoutpx');
		$data['entry_layoutpy'] = $this->language->get('entry_layoutpy');
		$data['entry_fade'] = $this->language->get('entry_fade');
		$data['entry_buttonstyle'] = $this->language->get('entry_buttonstyle');
		$data['entry_buttonsize'] = $this->language->get('entry_buttonsize');
		$data['entry_buttoninset'] = $this->language->get('entry_buttoninset');
		$data['entry_buttonborder'] = $this->language->get('entry_buttonborder');
		$data['entry_buttonround'] = $this->language->get('entry_buttonround');
		$data['entry_buttonhover'] = $this->language->get('entry_buttonhover');
        $data['entry_buttond'] = $this->language->get('entry_buttond');	
        $data['entry_paddingbottom'] = $this->language->get('entry_paddingbottom');			
		$data['entry_hoverbj'] = $this->language->get('entry_hoverbj');
		$data['entry_hovertit'] = $this->language->get('entry_hovertit');
		$data['entry_imganimation'] = $this->language->get('entry_imganimation');
		$data['entry_sectionid'] = $this->language->get('entry_sectionid');
        $data['entry_sectiontab'] = $this->language->get('entry_sectiontab');	
		$data['entry_imgmm'] = $this->language->get('entry_imgmm');
		$data['entry_imground'] = $this->language->get('entry_imground');        
		$data['entry_imgthumb'] = $this->language->get('entry_imgthumb');	
		$data['entry_imgshadow'] = $this->language->get('entry_imgshadow');
		$data['entry_imgpadding'] = $this->language->get('entry_imgpadding');        
		$data['entry_imgborder'] = $this->language->get('entry_imgborder');	
		$data['entry_imgcolor'] = $this->language->get('entry_imgcolor');
		$data['entry_imagewidth'] = $this->language->get('entry_imagewidth');
		$data['entry_imageheight'] = $this->language->get('entry_imageheight');
		
		$data['button_save'] = $this->language->get('button_save');
		$data['button_cancel'] = $this->language->get('button_cancel');
		$data['button_add'] = $this->language->get('button_add');
		$data['button_remove'] = $this->language->get('button_remove');

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

		if (isset($this->error['warning'])) {
			$data['error_warning'] = $this->error['warning'];
		} else {
			$data['error_warning'] = '';
		}
		if (isset($this->error['sectionid'])) {
			$data['error_sectionid'] = $this->error['sectionid'];
		} else {
			$data['error_sectionid'] = '';
		}
		if (isset($this->error['name'])) {
			$data['error_name'] = $this->error['name'];
		} else {
			$data['error_name'] = '';
		}
		if (isset($this->error['column'])) {
			$data['error_column'] = $this->error['column'];
		} else {
			$data['error_column'] = '';
		}	

		if (isset($this->error['width'])) {
			$data['error_width'] = $this->error['width'];
		} else {
			$data['error_width'] = '';
		}

		if (isset($this->error['height'])) {
			$data['error_height'] = $this->error['height'];
		} else {
			$data['error_height'] = '';
		}
		if (isset($this->error['wgdlg1'])) {
			$data['error_wgdlg1'] = $this->error['wgdlg1'];
		} else {
			$data['error_wgdlg1'] = '';
		}
		if (isset($this->error['wgdlg2'])) {
			$data['error_wgdlg2'] = $this->error['wgdlg2'];
		} else {
			$data['error_wgdlg2'] = '';
		}
		if (isset($this->error['describe'])) {
			$data['error_describe'] = $this->error['describe'];
		} else {
			$data['error_describe'] = '';
		}
		$data['breadcrumbs'] = array();

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

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('text_module'),
			'href' => $this->url->link('extension/extension', 'token=' . $this->session->data['token'], 'SSL')
		);

		$data['breadcrumbs'][] = array(
			'text' => preg_replace('/<(.*?)strong>/i', '', $this->language->get('heading_title')),
			'href' => $this->url->link('extension/module/services', 'token=' . $this->session->data['token'], 'SSL')
		);

		if (!isset($this->request->get['module_id'])) {
			$data['action'] = $this->url->link('extension/module/reasonright', 'token=' . $this->session->data['token'], 'SSL');
		} else {
			$data['action'] = $this->url->link('extension/module/reasonright', 'token=' . $this->session->data['token'] . '&module_id=' . $this->request->get['module_id'], 'SSL');
		}

		$data['cancel'] = $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=module', true);

		if (isset($this->request->get['module_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
			$module_info = $this->model_extension_module->getModule($this->request->get['module_id']);
		}

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

		if (isset($this->request->post['status'])) {
			$data['status'] = $this->request->post['status'];
		} elseif (!empty($module_info)) {
			$data['status'] = $module_info['status'];
		} else {
			$data['status'] = '';
		}

		if (isset($this->request->post['name'])) {
			$data['name'] = $this->request->post['name'];
		} elseif (!empty($module_info)) {
			$data['name'] = $module_info['name'];
		} else {
			$data['name'] = '';
		}
		if (isset($this->request->post['sectionid'])) {
			$data['sectionid'] = $this->request->post['sectionid'];
		} elseif (!empty($module_info)) {
			$data['sectionid'] = $module_info['sectionid'];
		} else {
			$data['sectionid'] = '';
		}
		if (isset($this->request->post['sectiontab'])) {
			$data['sectiontab'] = $this->request->post['sectiontab'];
		} elseif (!empty($module_info)) {
			$data['sectiontab'] = $module_info['sectiontab'];
		} else {
			$data['sectiontab'] = '';
		}
		if (isset($this->request->post['column'])) {
			$data['column'] = $this->request->post['column'];
		} elseif (!empty($module_info)) {
			$data['column'] = $module_info['column'];
		} else {
			$data['column'] = '2';
		}
		if (isset($this->request->post['titlename'])) {
			$data['titlename'] = $this->request->post['titlename'];
		} elseif (!empty($module_info)) {
			$data['titlename'] = $module_info['titlename'];
		} else {
			$data['titlename'] = '';
		}
		if (isset($this->request->post['bgcolor'])) {
			$data['bgcolor'] = $this->request->post['bgcolor'];
		} elseif (!empty($module_info)) {
			$data['bgcolor'] = $module_info['bgcolor'];
		} else {
			$data['bgcolor'] = '';
		}
		if (isset($this->request->post['bgcolorcss'])) {
			$data['bgcolorcss'] = $this->request->post['bgcolorcss'];
		} elseif (!empty($module_info)) {
			$data['bgcolorcss'] = $module_info['bgcolorcss'];
		} else {
			$data['bgcolorcss'] = '';
		}
		if (isset($this->request->post['titlecss'])) {
			$data['titlecss'] = $this->request->post['titlecss'];
		} elseif (!empty($module_info)) {
			$data['titlecss'] = $module_info['titlecss'];
		} else {
			$data['titlecss'] = '';
		}
		if (isset($this->request->post['titlesmcss'])) {
			$data['titlesmcss'] = $this->request->post['titlesmcss'];
		} elseif (!empty($module_info)) {
			$data['titlesmcss'] = $module_info['titlesmcss'];
		} else {
			$data['titlesmcss'] = '';
		}	
		if (isset($this->request->post['titlename'])) {
			$data['titlename'] = $this->request->post['titlename'];
		} elseif (!empty($module_info)) {
			$data['titlename'] = $module_info['titlename'];
		} else {
			$data['titlename'] = '';
		}
		if (isset($this->request->post['describe'])) {
			$data['describe'] = $this->request->post['describe'];
		} elseif (!empty($module_info)) {
			$data['describe'] = $module_info['describe'];
		} else {
			$data['describe'] = '';
		}
		if (isset($this->request->post['wgdlg1'])) {
			$data['wgdlg1'] = $this->request->post['wgdlg1'];
		} elseif (!empty($module_info)) {
			$data['wgdlg1'] = $module_info['wgdlg1'];
		} else {
			$data['wgdlg1'] = '6';
		}
		if (isset($this->request->post['wgdlg2'])) {
			$data['wgdlg2'] = $this->request->post['wgdlg2'];
		} elseif (!empty($module_info)) {
			$data['wgdlg2'] = $module_info['wgdlg2'];
		} else {
			$data['wgdlg2'] = '6';
		}		
		$this->load->model('tool/image');

		if (isset($this->request->post['image'])) {
			$data['image'] = $this->request->post['image'];
		} elseif (isset($module_info['image'])) {
			$data['image'] = $module_info['image'];
		} else {
			$data['image'] = '';
		}

		if (is_file(DIR_IMAGE . $data['image'])) {
			$thumb = $data['image'];
		} else {
			$thumb = 'no_image.png';
		}

		$data['thumb'] = $this->model_tool_image->resize($thumb, 100, 100);

		if (isset($this->request->post['width'])) {
			$data['width'] = $this->request->post['width'];
		} elseif (!empty($module_info)) {
			$data['width'] = $module_info['width'];
		} else {
			$data['width'] = '500';
		}

		if (isset($this->request->post['height'])) {
			$data['height'] = $this->request->post['height'];
		} elseif (!empty($module_info)) {
			$data['height'] = $module_info['height'];
		} else {
			$data['height'] = '500';
		}	
		if (isset($this->request->post['video'])) {
			$data['video'] = $this->request->post['video'];
		} elseif (!empty($module_info)) {
			$data['video'] = $module_info['video'];
		} else {
			$data['video'] = '';
		}		
		if (isset($this->request->post['namebig'])) {
			$data['namebig'] = $this->request->post['namebig'];
		} elseif (!empty($module_info)) {
			$data['namebig'] = $module_info['namebig'];
		} else {
			$data['namebig'] = '';
		}
		if (isset($this->request->post['namebigfour'])) {
			$data['namebigfour'] = $this->request->post['namebigfour'];
		} elseif (!empty($module_info)) {
			$data['namebigfour'] = $module_info['namebigfour'];
		} else {
			$data['namebigfour'] = '';
		}
		if (isset($this->request->post['namebigtwo'])) {
			$data['namebigtwo'] = $this->request->post['namebigtwo'];
		} elseif (!empty($module_info)) {
			$data['namebigtwo'] = $module_info['namebigtwo'];
		} else {
			$data['namebigtwo'] = '';
		}
		if (isset($this->request->post['namebigthree'])) {
			$data['namebigthree'] = $this->request->post['namebigthree'];
		} elseif (!empty($module_info)) {
			$data['namebigthree'] = $module_info['namebigthree'];
		} else {
			$data['namebigthree'] = '';
		}
		if (isset($this->request->post['section1'])) {
			$data['section1'] = $this->request->post['section1'];
		} elseif (!empty($module_info)) {
			$data['section1'] = $module_info['section1'];
		} else {
			$data['section1'] = '';
		}				
		if (isset($this->request->post['section2'])) {
			$data['section2'] = $this->request->post['section2'];
		} elseif (!empty($module_info)) {
			$data['section2'] = $module_info['section2'];
		} else {
			$data['section2'] = '';
		}

		if (isset($this->request->post['section3'])) {
			$data['section3'] = $this->request->post['section3'];
		} elseif (!empty($module_info)) {
			$data['section3'] = $module_info['section3'];
		} else {
			$data['section3'] = '';
		}
		if (isset($this->request->post['section4'])) {
			$data['section4'] = $this->request->post['section4'];
		} elseif (!empty($module_info)) {
			$data['section4'] = $module_info['section4'];
		} else {
			$data['section4'] = '';
		}
		if (isset($this->request->post['titlezwzc'])) {
			$data['titlezwzc'] = $this->request->post['titlezwzc'];
		} elseif (!empty($module_info)) {
			$data['titlezwzc'] = $module_info['titlezwzc'];
		} else {
			$data['titlezwzc'] = '';
		}
		if (isset($this->request->post['tccolor'])) {
			$data['tccolor'] = $this->request->post['tccolor'];
		} elseif (!empty($module_info)) {
			$data['tccolor'] = $module_info['tccolor'];
		} else {
			$data['tccolor'] = '';
		}
		if (isset($this->request->post['pricecolor'])) {
			$data['pricecolor'] = $this->request->post['pricecolor'];
		} elseif (!empty($module_info)) {
			$data['pricecolor'] = $module_info['pricecolor'];
		} else {
			$data['pricecolor'] = '';
		}
		if (isset($this->request->post['pricetitleicolor'])) {
			$data['pricetitleicolor'] = $this->request->post['pricetitleicolor'];
		} elseif (!empty($module_info)) {
			$data['pricetitleicolor'] = $module_info['pricetitleicolor'];
		} else {
			$data['pricetitleicolor'] = '';
		}	
		if (isset($this->request->post['miconbj'])) {
			$data['miconbj'] = $this->request->post['miconbj'];
		} elseif (!empty($module_info)) {
			$data['miconbj'] = $module_info['miconbj'];
		} else {
			$data['miconbj'] = '';
		}
		if (isset($this->request->post['miconjbbj'])) {
			$data['miconjbbj'] = $this->request->post['miconjbbj'];
		} elseif (!empty($module_info)) {
			$data['miconjbbj'] = $module_info['miconjbbj'];
		} else {
			$data['miconjbbj'] = '';
		}			
		if (isset($this->request->post['miconcolor'])) {
			$data['miconcolor'] = $this->request->post['miconcolor'];
		} elseif (!empty($module_info)) {
			$data['miconcolor'] = $module_info['miconcolor'];
		} else {
			$data['miconcolor'] = '';
		}
		if (isset($this->request->post['miconround'])) {
			$data['miconround'] = $this->request->post['miconround'];
		} elseif (!empty($module_info)) {
			$data['miconround'] = $module_info['miconround'];
		} else {
			$data['miconround'] = '';
		}
		if (isset($this->request->post['miconsize'])) {
			$data['miconsize'] = $this->request->post['miconsize'];
		} elseif (!empty($module_info)) {
			$data['miconsize'] = $module_info['miconsize'];
		} else {
			$data['miconsize'] = '18';
		}	
		if (isset($this->request->post['miconborder'])) {
			$data['miconborder'] = $this->request->post['miconborder'];
		} elseif (!empty($module_info)) {
			$data['miconborder'] = $module_info['miconborder'];
		} else {
			$data['miconborder'] = '';
		}
		if (isset($this->request->post['miconbc'])) {
			$data['miconbc'] = $this->request->post['miconbc'];
		} elseif (!empty($module_info)) {
			$data['miconbc'] = $module_info['miconbc'];
		} else {
			$data['miconbc'] = '';
		}
		if (isset($this->request->post['miconwidth'])) {
			$data['miconwidth'] = $this->request->post['miconwidth'];
		} elseif (!empty($module_info)) {
			$data['miconwidth'] = $module_info['miconwidth'];
		} else {
			$data['miconwidth'] = '50';
		}
		if (isset($this->request->post['miconheight'])) {
			$data['miconheight'] = $this->request->post['miconheight'];
		} elseif (!empty($module_info)) {
			$data['miconheight'] = $module_info['miconheight'];
		} else {
			$data['miconheight'] = '50';
		}
		if (isset($this->request->post['rrp'])) {
			$data['rrp'] = $this->request->post['rrp'];
		} elseif (!empty($module_info)) {
			$data['rrp'] = $module_info['rrp'];
		} else {
			$data['rrp'] = '70';
		}
		if (isset($this->request->post['rrb'])) {
			$data['rrb'] = $this->request->post['rrb'];
		} elseif (!empty($module_info)) {
			$data['rrb'] = $module_info['rrb'];
		} else {
			$data['rrb'] = '70';
		}
		if (isset($this->request->post['rfourlw'])) {
			$data['rfourlw'] = $this->request->post['rfourlw'];
		} elseif (!empty($module_info)) {
			$data['rfourlw'] = $module_info['rfourlw'];
		} else {
			$data['rfourlw'] = '';
		}	
		if (isset($this->request->post['rfourlh'])) {
			$data['rfourlh'] = $this->request->post['rfourlh'];
		} elseif (!empty($module_info)) {
			$data['rfourlh'] = $module_info['rfourlh'];
		} else {
			$data['rfourlh'] = '';
		}
		if (isset($this->request->post['rfourlc'])) {
			$data['rfourlc'] = $this->request->post['rfourlc'];
		} elseif (!empty($module_info)) {
			$data['rfourlc'] = $module_info['rfourlc'];
		} else {
			$data['rfourlc'] = '';
		}
		if (isset($this->request->post['autoplay'])) {
			$data['autoplay'] = $this->request->post['autoplay'];
		} elseif (!empty($module_info)) {
			$data['autoplay'] = $module_info['autoplay'];
		} else {
			$data['autoplay'] = '';
		}
		if (isset($this->request->post['main'])) {
			$data['main'] = $this->request->post['main'];
		} elseif (!empty($module_info)) {
			$data['main'] = $module_info['main'];
		} else {
			$data['main'] = '';
		}
		if (isset($this->request->post['speed'])) {
			$data['speed'] = $this->request->post['speed'];
		} elseif (!empty($module_info)) {
			$data['speed'] = $module_info['speed'];
		} else {
			$data['speed'] = '3000';
		}
		if (isset($this->request->post['scroll'])) {
			$data['scroll'] = $this->request->post['scroll'];
		} elseif (!empty($module_info)) {
			$data['scroll'] = $module_info['scroll'];
		} else {
			$data['scroll'] = '1';
		} 	
		if (isset($this->request->post['rrmtp'])) {
			$data['rrmtp'] = $this->request->post['rrmtp'];
		} elseif (!empty($module_info)) {
			$data['rrmtp'] = $module_info['rrmtp'];
		} else {
			$data['rrmtp'] = '20';
		}
		if (isset($this->request->post['rrbigt'])) {
			$data['rrbigt'] = $this->request->post['rrbigt'];
		} elseif (!empty($module_info)) {
			$data['rrbigt'] = $module_info['rrbigt'];
		} else {
			$data['rrbigt'] = '';
		} 
		if (isset($this->request->post['rmaxwidth'])) {
			$data['rmaxwidth'] = $this->request->post['rmaxwidth'];
		} elseif (!empty($module_info)) {
			$data['rmaxwidth'] = $module_info['rmaxwidth'];
		} else {
			$data['rmaxwidth'] = '';
		}
		if (isset($this->request->post['rfontsize'])) {
			$data['rfontsize'] = $this->request->post['rfontsize'];
		} elseif (!empty($module_info)) {
			$data['rfontsize'] = $module_info['rfontsize'];
		} else {
			$data['rfontsize'] = '15';
		} 		
		if (isset($this->request->post['rrsmt'])) {
			$data['rrsmt'] = $this->request->post['rrsmt'];
		} elseif (!empty($module_info)) {
			$data['rrsmt'] = $module_info['rrsmt'];
		} else {
			$data['rrsmt'] = '';
		} 
		if (isset($this->request->post['rrsrow'])) {
			$data['rrsrow'] = $this->request->post['rrsrow'];
		} elseif (!empty($module_info)) {
			$data['rrsrow'] = $module_info['rrsrow'];
		} else {
			$data['rrsrow'] = '3';
		} 
		if (isset($this->request->post['buttonname1'])) {
			$data['buttonname1'] = $this->request->post['buttonname1'];
		} elseif (!empty($module_info)) {
			$data['buttonname1'] = $module_info['buttonname1'];
		} else {
			$data['buttonname1'] = '';
		}
		if (isset($this->request->post['buttonname2'])) {
			$data['buttonname2'] = $this->request->post['buttonname2'];
		} elseif (!empty($module_info)) {
			$data['buttonname2'] = $module_info['buttonname2'];
		} else {
			$data['buttonname2'] = '';
		}
		if (isset($this->request->post['qq1'])) {
			$data['qq1'] = $this->request->post['qq1'];
		} elseif (!empty($module_info)) {
			$data['qq1'] = $module_info['qq1'];
		} else {
			$data['qq1'] = '';
		}
		if (isset($this->request->post['qq2'])) {
			$data['qq2'] = $this->request->post['qq2'];
		} elseif (!empty($module_info)) {
			$data['qq2'] = $module_info['qq2'];
		} else {
			$data['qq2'] = '';
		}
		if (isset($this->request->post['alww1'])) {
			$data['alww1'] = $this->request->post['alww1'];
		} elseif (!empty($module_info)) {
			$data['alww1'] = $module_info['alww1'];
		} else {
			$data['alww1'] = '';
		}
		if (isset($this->request->post['alww2'])) {
			$data['alww2'] = $this->request->post['alww2'];
		} elseif (!empty($module_info)) {
			$data['alww2'] = $module_info['alww2'];
		} else {
			$data['alww2'] = '';
		}
		if (isset($this->request->post['link1'])) {
			$data['link1'] = $this->request->post['link1'];
		} elseif (!empty($module_info)) {
			$data['link1'] = $module_info['link1'];
		} else {
			$data['link1'] = '';
		}
		if (isset($this->request->post['link2'])) {
			$data['link2'] = $this->request->post['link2'];
		} elseif (!empty($module_info)) {
			$data['link2'] = $module_info['link2'];
		} else {
			$data['link2'] = '';
		}
		if (isset($this->request->post['icons1'])) {
			$data['icons1'] = $this->request->post['icons1'];
		} elseif (!empty($module_info)) {
			$data['icons1'] = $module_info['icons1'];
		} else {
			$data['icons1'] = 'fa fa-apple';
		}
		if (isset($this->request->post['icons2'])) {
			$data['icons2'] = $this->request->post['icons2'];
		} elseif (!empty($module_info)) {
			$data['icons2'] = $module_info['icons2'];
		} else {
			$data['icons2'] = 'fa fa-android';
		}
		if (isset($this->request->post['buttoncolor1'])) {
			$data['buttoncolor1'] = $this->request->post['buttoncolor1'];
		} elseif (!empty($module_info)) {
			$data['buttoncolor1'] = $module_info['buttoncolor1'];
		} else {
			$data['buttoncolor1'] = 'black';
		}
		if (isset($this->request->post['buttoncolor2'])) {
			$data['buttoncolor2'] = $this->request->post['buttoncolor2'];
		} elseif (!empty($module_info)) {
			$data['buttoncolor2'] = $module_info['buttoncolor2'];
		} else {
			$data['buttoncolor2'] = 'black';
		}
		if (isset($this->request->post['rrption'])) {
			$data['rrption'] = $this->request->post['rrption'];
		} elseif (!empty($module_info)) {
			$data['rrption'] = $module_info['rrption'];
		} else {
			$data['rrption'] = 'left';
		}
		if (isset($this->request->post['layoutpy'])) {
			$data['layoutpy'] = $this->request->post['layoutpy'];
		} elseif (!empty($module_info)) {
			$data['layoutpy'] = $module_info['layoutpy'];
		} else {
			$data['layoutpy'] = '';
		}
		if (isset($this->request->post['layoutpx'])) {
			$data['layoutpx'] = $this->request->post['layoutpx'];
		} elseif (!empty($module_info)) {
			$data['layoutpx'] = $module_info['layoutpx'];
		} else {
			$data['layoutpx'] = '';
		}
		if (isset($this->request->post['fade'])) {
			$data['fade'] = $this->request->post['fade'];
		} elseif (!empty($module_info)) {
			$data['fade'] = $module_info['fade'];
		} else {
			$data['fade'] = '';
		} 
		if (isset($this->request->post['buttonsize'])) {
			$data['buttonsize'] = $this->request->post['buttonsize'];
		} elseif (!empty($module_info)) {
			$data['buttonsize'] = $module_info['buttonsize'];
		} else {
			$data['buttonsize'] = 'md';
		}		
		if (isset($this->request->post['buttoninset'])) {
			$data['buttoninset'] = $this->request->post['buttoninset'];
		} elseif (!empty($module_info)) {
			$data['buttoninset'] = $module_info['buttoninset'];
		} else {
			$data['buttoninset'] = '';
		}	
		if (isset($this->request->post['buttonborder'])) {
			$data['buttonborder'] = $this->request->post['buttonborder'];
		} elseif (!empty($module_info)) {
			$data['buttonborder'] = $module_info['buttonborder'];
		} else {
			$data['buttonborder'] = '';
		}		
		if (isset($this->request->post['buttonround'])) {
			$data['buttonround'] = $this->request->post['buttonround'];
		} elseif (!empty($module_info)) {
			$data['buttonround'] = $module_info['buttonround'];
		} else {
			$data['buttonround'] = '';
		}
		if (isset($this->request->post['buttonhover'])) {
			$data['buttonhover'] = $this->request->post['buttonhover'];
		} elseif (!empty($module_info)) {
			$data['buttonhover'] = $module_info['buttonhover'];
		} else {
			$data['buttonhover'] = '';
		}
		if (isset($this->request->post['buttond'])) {
			$data['buttond'] = $this->request->post['buttond'];
		} elseif (!empty($module_info)) {
			$data['buttond'] = $module_info['buttond'];
		} else {
			$data['buttond'] = '';
		}
		if (isset($this->request->post['paddingbottom'])) {
			$data['paddingbottom'] = $this->request->post['paddingbottom'];
		} elseif (!empty($module_info)) {
			$data['paddingbottom'] = $module_info['paddingbottom'];
		} else {
			$data['paddingbottom'] = '15';
		}
		if (isset($this->request->post['hoverbj'])) {
			$data['hoverbj'] = $this->request->post['hoverbj'];
		} elseif (!empty($module_info)) {
			$data['hoverbj'] = $module_info['hoverbj'];
		} else {
			$data['hoverbj'] = '';
		}
		if (isset($this->request->post['hovertit'])) {
			$data['hovertit'] = $this->request->post['hovertit'];
		} elseif (!empty($module_info)) {
			$data['hovertit'] = $module_info['hovertit'];
		} else {
			$data['hovertit'] = '';
		}
		if (isset($this->request->post['imground'])) {
			$data['imground'] = $this->request->post['imground'];
		} elseif (!empty($module_info)) {
			$data['imground'] = $module_info['imground'];
		} else {
			$data['imground'] = '';
		}
		if (isset($this->request->post['imgthumb'])) {
			$data['imgthumb'] = $this->request->post['imgthumb'];
		} elseif (!empty($module_info)) {
			$data['imgthumb'] = $module_info['imgthumb'];
		} else {
			$data['imgthumb'] = 'img-thumbnail';
		}
		if (isset($this->request->post['imgshadow'])) {
			$data['imgshadow'] = $this->request->post['imgshadow'];
		} elseif (!empty($module_info)) {
			$data['imgshadow'] = $module_info['imgshadow'];
		} else {
			$data['imgshadow'] = '';
		}
		if (isset($this->request->post['imgpadding'])) {
			$data['imgpadding'] = $this->request->post['imgpadding'];
		} elseif (!empty($module_info)) {
			$data['imgpadding'] = $module_info['imgpadding'];
		} else {
			$data['imgpadding'] = '';
		}
		if (isset($this->request->post['imgborder'])) {
			$data['imgborder'] = $this->request->post['imgborder'];
		} elseif (!empty($module_info)) {
			$data['imgborder'] = $module_info['imgborder'];
		} else {
			$data['imgborder'] = '';
		}
		if (isset($this->request->post['imgcolor'])) {
			$data['imgcolor'] = $this->request->post['imgcolor'];
		} elseif (!empty($module_info)) {
			$data['imgcolor'] = $module_info['imgcolor'];
		} else {
			$data['imgcolor'] = '';
		}
		if (isset($this->request->post['imagewidth'])) {
			$data['imagewidth'] = $this->request->post['imagewidth'];
		} elseif (!empty($module_info)) {
			$data['imagewidth'] = $module_info['imagewidth'];
		} else {
			$data['imagewidth'] = '40';
		}
		if (isset($this->request->post['imageheight'])) {
			$data['imageheight'] = $this->request->post['imageheight'];
		} elseif (!empty($module_info)) {
			$data['imageheight'] = $module_info['imageheight'];
		} else {
			$data['imageheight'] = '40';
		}
		if (isset($this->request->post['imganimation'])) {
			$data['imganimation'] = $this->request->post['imganimation'];
		} elseif (!empty($module_info)) {
			$data['imganimation'] = $module_info['imganimation'];
		} else {
			$data['imganimation'] = '';
		}
		if (isset($this->request->post['imagepicstyle'])) {
			$data['imagepicstyle'] = $this->request->post['imagepicstyle'];
		} elseif (!empty($module_info)) {
			$data['imagepicstyle'] = $module_info['imagepicstyle'];
		} else {
			$data['imagepicstyle'] = '';
		}		
		$this->load->model('localisation/language');

		$data['languages'] = $this->model_localisation_language->getLanguages();

		$this->load->model('tool/image');

		if (isset($this->request->post['service'])) {
			$services = $this->request->post['service'];
		} elseif (isset($module_info['service'])) {
			$services = $module_info['service'];
		} else {
			$services = array();
		}

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

		foreach ($services as $service) {
			if (is_file(DIR_IMAGE . $service['image'])) {
				$image = $service['image'];
				$thumb = $service['image'];
			} else {
				$image = '';
				$thumb = 'no_image.png';
			}
		
			$data['services'][] = array(
				'title1'       => $service['title1'],
				'text1'        => $service['text1'],
				'icon1'        => $service['icon1'],
				'image'       => $image,
				'thumb'       => $this->model_tool_image->resize($thumb, 40, 40),
                'sort_order'  => $service['sort_order']
			);
		}

		$data['placeholder'] = $this->model_tool_image->resize('no_image.png', 40, 40);

		$data['header'] = $this->load->controller('common/header');
		$data['column_left'] = $this->load->controller('common/column_left');
		$data['footer'] = $this->load->controller('common/footer');

		$this->response->setOutput($this->load->view('extension/module/reasonright.tpl', $data));
	}

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

		if ((utf8_strlen($this->request->post['name']) < 2) || (utf8_strlen($this->request->post['name']) > 64)) {
			$this->error['name'] = $this->language->get('error_name');
		}

		if (!$this->request->post['width']) {
			$this->error['width'] = $this->language->get('error_width');
		}

		if (!$this->request->post['height']) {
			$this->error['height'] = $this->language->get('error_height');
		}
		if ((utf8_strlen($this->request->post['column']) < 1) || (utf8_strlen($this->request->post['column']) > 64)) {
			$this->error['column'] = $this->language->get('error_column');
		}
		if ((utf8_strlen($this->request->post['wgdlg1']) < 1) || (utf8_strlen($this->request->post['wgdlg1']) > 64)) {
			$this->error['wgdlg1'] = $this->language->get('error_wgdlg1');
		}
		if ((utf8_strlen($this->request->post['wgdlg2']) < 1) || (utf8_strlen($this->request->post['wgdlg2']) > 64)) {
			$this->error['wgdlg2'] = $this->language->get('error_wgdlg2');
		}
		if ((utf8_strlen($this->request->post['sectionid']) < 1) || (utf8_strlen($this->request->post['sectionid']) > 64)) {
			$this->error['sectionid'] = $this->language->get('error_name');
		}
		return !$this->error;
	}
}