shop.balmet.com

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

carousel.php (5465B)


      1 <?php
      2 class ControllerExtensionModuleCarousel extends Controller {
      3 	private $error = array();
      4 
      5 	public function index() {
      6 		$this->load->language('extension/module/carousel');
      7 
      8 		$this->document->setTitle($this->language->get('heading_title'));
      9 
     10 		$this->load->model('setting/module');
     11 
     12 		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
     13 			if (!isset($this->request->get['module_id'])) {
     14 				$this->model_setting_module->addModule('carousel', $this->request->post);
     15 			} else {
     16 				$this->model_setting_module->editModule($this->request->get['module_id'], $this->request->post);
     17 			}
     18 
     19 			$this->session->data['success'] = $this->language->get('text_success');
     20 
     21 			$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true));
     22 		}
     23 
     24 		if (isset($this->error['warning'])) {
     25 			$data['error_warning'] = $this->error['warning'];
     26 		} else {
     27 			$data['error_warning'] = '';
     28 		}
     29 
     30 		if (isset($this->error['name'])) {
     31 			$data['error_name'] = $this->error['name'];
     32 		} else {
     33 			$data['error_name'] = '';
     34 		}
     35 
     36 		if (isset($this->error['width'])) {
     37 			$data['error_width'] = $this->error['width'];
     38 		} else {
     39 			$data['error_width'] = '';
     40 		}
     41 
     42 		if (isset($this->error['height'])) {
     43 			$data['error_height'] = $this->error['height'];
     44 		} else {
     45 			$data['error_height'] = '';
     46 		}
     47 
     48 		$data['breadcrumbs'] = array();
     49 
     50 		$data['breadcrumbs'][] = array(
     51 			'text' => $this->language->get('text_home'),
     52 			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
     53 		);
     54 
     55 		$data['breadcrumbs'][] = array(
     56 			'text' => $this->language->get('text_extension'),
     57 			'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true)
     58 		);
     59 
     60 		if (!isset($this->request->get['module_id'])) {
     61 			$data['breadcrumbs'][] = array(
     62 				'text' => $this->language->get('heading_title'),
     63 				'href' => $this->url->link('extension/module/carousel', 'user_token=' . $this->session->data['user_token'], true)
     64 			);
     65 		} else {
     66 			$data['breadcrumbs'][] = array(
     67 				'text' => $this->language->get('heading_title'),
     68 				'href' => $this->url->link('extension/module/carousel', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id'], true)
     69 			);
     70 		}
     71 
     72 		if (!isset($this->request->get['module_id'])) {
     73 			$data['action'] = $this->url->link('extension/module/carousel', 'user_token=' . $this->session->data['user_token'], true);
     74 		} else {
     75 			$data['action'] = $this->url->link('extension/module/carousel', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id'], true);
     76 		}
     77 
     78 		$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true);
     79 
     80 		if (isset($this->request->get['module_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
     81 			$module_info = $this->model_setting_module->getModule($this->request->get['module_id']);
     82 		}
     83 
     84 		if (isset($this->request->post['name'])) {
     85 			$data['name'] = $this->request->post['name'];
     86 		} elseif (!empty($module_info)) {
     87 			$data['name'] = $module_info['name'];
     88 		} else {
     89 			$data['name'] = '';
     90 		}
     91 
     92 		if (isset($this->request->post['banner_id'])) {
     93 			$data['banner_id'] = $this->request->post['banner_id'];
     94 		} elseif (!empty($module_info)) {
     95 			$data['banner_id'] = $module_info['banner_id'];
     96 		} else {
     97 			$data['banner_id'] = '';
     98 		}
     99 
    100 		$this->load->model('design/banner');
    101 
    102 		$data['banners'] = $this->model_design_banner->getBanners();
    103 
    104 		if (isset($this->request->post['width'])) {
    105 			$data['width'] = $this->request->post['width'];
    106 		} elseif (!empty($module_info)) {
    107 			$data['width'] = $module_info['width'];
    108 		} else {
    109 			$data['width'] = 130;
    110 		}
    111 
    112 		if (isset($this->request->post['height'])) {
    113 			$data['height'] = $this->request->post['height'];
    114 		} elseif (!empty($module_info)) {
    115 			$data['height'] = $module_info['height'];
    116 		} else {
    117 			$data['height'] = 100;
    118 		}
    119 
    120 		if (isset($this->request->post['status'])) {
    121 			$data['status'] = $this->request->post['status'];
    122 		} elseif (!empty($module_info)) {
    123 			$data['status'] = $module_info['status'];
    124 		} else {
    125 			$data['status'] = '';
    126 		}
    127 
    128 		$this->load->model('design/banner');
    129 
    130 		$data['banners'] = $this->model_design_banner->getBanners();
    131 
    132 		$data['header'] = $this->load->controller('common/header');
    133 		$data['column_left'] = $this->load->controller('common/column_left');
    134 		$data['footer'] = $this->load->controller('common/footer');
    135 
    136 		$this->response->setOutput($this->load->view('extension/module/carousel', $data));
    137 	}
    138 
    139 	protected function validate() {
    140 		if (!$this->user->hasPermission('modify', 'extension/module/carousel')) {
    141 			$this->error['warning'] = $this->language->get('error_permission');
    142 		}
    143 
    144 		if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 64)) {
    145 			$this->error['name'] = $this->language->get('error_name');
    146 		}
    147 
    148 		if (!$this->request->post['width']) {
    149 			$this->error['width'] = $this->language->get('error_width');
    150 		}
    151 
    152 		if (!$this->request->post['height']) {
    153 			$this->error['height'] = $this->language->get('error_height');
    154 		}
    155 
    156 		return !$this->error;
    157 	}
    158 }