shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

google.php (3431B)


      1 <?php
      2 class ControllerExtensionAnalyticsGoogle extends Controller {
      3 	private $error = array();
      4 
      5 	public function index() {
      6 		$this->load->language('extension/analytics/google');
      7 
      8 		$this->document->setTitle($this->language->get('heading_title'));
      9 
     10 		$this->load->model('setting/setting');
     11 		
     12 		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
     13 			$this->model_setting_setting->editSetting('analytics_google', $this->request->post, $this->request->get['store_id']);
     14 
     15 			$this->session->data['success'] = $this->language->get('text_success');
     16 
     17 			$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=analytics', true));
     18 		}
     19 
     20 		if (isset($this->error['warning'])) {
     21 			$data['error_warning'] = $this->error['warning'];
     22 		} else {
     23 			$data['error_warning'] = '';
     24 		}
     25 
     26 		if (isset($this->error['code'])) {
     27 			$data['error_code'] = $this->error['code'];
     28 		} else {
     29 			$data['error_code'] = '';
     30 		}
     31 
     32 		$data['breadcrumbs'] = array();
     33 
     34 		$data['breadcrumbs'][] = array(
     35 			'text' => $this->language->get('text_home'),
     36 			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
     37 		);
     38 
     39 		$data['breadcrumbs'][] = array(
     40 			'text' => $this->language->get('text_extension'),
     41 			'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=analytics', true)
     42 		);
     43 
     44 		$data['breadcrumbs'][] = array(
     45 			'text' => $this->language->get('heading_title'),
     46 			'href' => $this->url->link('extension/analytics/google', 'user_token=' . $this->session->data['user_token'] . '&store_id=' . $this->request->get['store_id'], true)
     47 		);
     48 
     49 		$data['action'] = $this->url->link('extension/analytics/google', 'user_token=' . $this->session->data['user_token'] . '&store_id=' . $this->request->get['store_id'], true);
     50 
     51 		$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=analytics', true);
     52 		
     53 		$data['user_token'] = $this->session->data['user_token'];
     54 				
     55 		if (isset($this->request->post['analytics_google_code'])) {
     56 			$data['analytics_google_code'] = $this->request->post['analytics_google_code'];
     57 		} else {
     58 			$data['analytics_google_code'] = $this->model_setting_setting->getSettingValue('analytics_google_code', $this->request->get['store_id']);
     59 		}
     60 		
     61 		if (isset($this->request->post['analytics_google_status'])) {
     62 			$data['analytics_google_status'] = $this->request->post['analytics_google_status'];
     63 		} else {
     64 			$data['analytics_google_status'] = $this->model_setting_setting->getSettingValue('analytics_google_status', $this->request->get['store_id']);
     65 		}
     66 		
     67 		$data['header'] = $this->load->controller('common/header');
     68 		$data['column_left'] = $this->load->controller('common/column_left');
     69 		$data['footer'] = $this->load->controller('common/footer');
     70 
     71 		$this->response->setOutput($this->load->view('extension/analytics/google', $data));
     72 	}
     73 
     74 	protected function validate() {
     75 		if (!$this->user->hasPermission('modify', 'extension/analytics/google')) {
     76 			$this->error['warning'] = $this->language->get('error_permission');
     77 		}
     78 
     79 		if (!$this->request->post['analytics_google_code']) {
     80 			$this->error['code'] = $this->language->get('error_code');
     81 		}			
     82 
     83 		return !$this->error;
     84 	}
     85 }