shop.balmet.com

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

default.php (17766B)


      1 <?php
      2 class ControllerExtensionThemeDefault extends Controller {
      3 	private $error = array();
      4 
      5 	public function index() {
      6 		$this->load->language('extension/theme/default');
      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('theme_default', $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=theme', 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['product_limit'])) {
     27 			$data['error_product_limit'] = $this->error['product_limit'];
     28 		} else {
     29 			$data['error_product_limit'] = '';
     30 		}
     31 
     32 		if (isset($this->error['product_description_length'])) {
     33 			$data['error_product_description_length'] = $this->error['product_description_length'];
     34 		} else {
     35 			$data['error_product_description_length'] = '';
     36 		}
     37 
     38 		if (isset($this->error['image_category'])) {
     39 			$data['error_image_category'] = $this->error['image_category'];
     40 		} else {
     41 			$data['error_image_category'] = '';
     42 		}
     43 
     44 		if (isset($this->error['image_thumb'])) {
     45 			$data['error_image_thumb'] = $this->error['image_thumb'];
     46 		} else {
     47 			$data['error_image_thumb'] = '';
     48 		}
     49 
     50 		if (isset($this->error['image_popup'])) {
     51 			$data['error_image_popup'] = $this->error['image_popup'];
     52 		} else {
     53 			$data['error_image_popup'] = '';
     54 		}
     55 
     56 		if (isset($this->error['image_product'])) {
     57 			$data['error_image_product'] = $this->error['image_product'];
     58 		} else {
     59 			$data['error_image_product'] = '';
     60 		}
     61 
     62 		if (isset($this->error['image_additional'])) {
     63 			$data['error_image_additional'] = $this->error['image_additional'];
     64 		} else {
     65 			$data['error_image_additional'] = '';
     66 		}
     67 
     68 		if (isset($this->error['image_related'])) {
     69 			$data['error_image_related'] = $this->error['image_related'];
     70 		} else {
     71 			$data['error_image_related'] = '';
     72 		}
     73 
     74 		if (isset($this->error['image_compare'])) {
     75 			$data['error_image_compare'] = $this->error['image_compare'];
     76 		} else {
     77 			$data['error_image_compare'] = '';
     78 		}
     79 
     80 		if (isset($this->error['image_wishlist'])) {
     81 			$data['error_image_wishlist'] = $this->error['image_wishlist'];
     82 		} else {
     83 			$data['error_image_wishlist'] = '';
     84 		}
     85 
     86 		if (isset($this->error['image_cart'])) {
     87 			$data['error_image_cart'] = $this->error['image_cart'];
     88 		} else {
     89 			$data['error_image_cart'] = '';
     90 		}
     91 
     92 		if (isset($this->error['image_location'])) {
     93 			$data['error_image_location'] = $this->error['image_location'];
     94 		} else {
     95 			$data['error_image_location'] = '';
     96 		}
     97 		
     98 		$data['breadcrumbs'] = array();
     99 
    100 		$data['breadcrumbs'][] = array(
    101 			'text' => $this->language->get('text_home'),
    102 			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
    103 		);
    104 
    105 		$data['breadcrumbs'][] = array(
    106 			'text' => $this->language->get('text_extension'),
    107 			'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=theme', true)
    108 		);
    109 
    110 		$data['breadcrumbs'][] = array(
    111 			'text' => $this->language->get('heading_title'),
    112 			'href' => $this->url->link('extension/theme/default', 'user_token=' . $this->session->data['user_token'] . '&store_id=' . $this->request->get['store_id'], true)
    113 		);
    114 
    115 		$data['action'] = $this->url->link('extension/theme/default', 'user_token=' . $this->session->data['user_token'] . '&store_id=' . $this->request->get['store_id'], true);
    116 
    117 		$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=theme', true);
    118 
    119 		if (isset($this->request->get['store_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
    120 			$setting_info = $this->model_setting_setting->getSetting('theme_default', $this->request->get['store_id']);
    121 		}
    122 		
    123 		if (isset($this->request->post['theme_default_directory'])) {
    124 			$data['theme_default_directory'] = $this->request->post['theme_default_directory'];
    125 		} elseif (isset($setting_info['theme_default_directory'])) {
    126 			$data['theme_default_directory'] = $setting_info['theme_default_directory'];
    127 		} else {
    128 			$data['theme_default_directory'] = 'default';
    129 		}		
    130 
    131 		$data['directories'] = array();
    132 
    133 		$directories = glob(DIR_CATALOG . 'view/theme/*', GLOB_ONLYDIR);
    134 
    135 		foreach ($directories as $directory) {
    136 			$data['directories'][] = basename($directory);
    137 		}
    138 
    139 		if (isset($this->request->post['theme_default_product_limit'])) {
    140 			$data['theme_default_product_limit'] = $this->request->post['theme_default_product_limit'];
    141 		} elseif (isset($setting_info['theme_default_product_limit'])) {
    142 			$data['theme_default_product_limit'] = $setting_info['theme_default_product_limit'];
    143 		} else {
    144 			$data['theme_default_product_limit'] = 15;
    145 		}		
    146 		
    147 		if (isset($this->request->post['theme_default_status'])) {
    148 			$data['theme_default_status'] = $this->request->post['theme_default_status'];
    149 		} elseif (isset($setting_info['theme_default_status'])) {
    150 			$data['theme_default_status'] = $setting_info['theme_default_status'];
    151 		} else {
    152 			$data['theme_default_status'] = '';
    153 		}
    154 		
    155 		if (isset($this->request->post['theme_default_product_description_length'])) {
    156 			$data['theme_default_product_description_length'] = $this->request->post['theme_default_product_description_length'];
    157 		} elseif (isset($setting_info['theme_default_product_description_length'])) {
    158 			$data['theme_default_product_description_length'] = $setting_info['theme_default_product_description_length'];
    159 		} else {
    160 			$data['theme_default_product_description_length'] = 100;
    161 		}
    162 		
    163 		if (isset($this->request->post['theme_default_image_category_width'])) {
    164 			$data['theme_default_image_category_width'] = $this->request->post['theme_default_image_category_width'];
    165 		} elseif (isset($setting_info['theme_default_image_category_width'])) {
    166 			$data['theme_default_image_category_width'] = $setting_info['theme_default_image_category_width'];
    167 		} else {
    168 			$data['theme_default_image_category_width'] = 80;		
    169 		}
    170 		
    171 		if (isset($this->request->post['theme_default_image_category_height'])) {
    172 			$data['theme_default_image_category_height'] = $this->request->post['theme_default_image_category_height'];
    173 		} elseif (isset($setting_info['theme_default_image_category_height'])) {
    174 			$data['theme_default_image_category_height'] = $setting_info['theme_default_image_category_height'];
    175 		} else {
    176 			$data['theme_default_image_category_height'] = 80;
    177 		}
    178 		
    179 		if (isset($this->request->post['theme_default_image_thumb_width'])) {
    180 			$data['theme_default_image_thumb_width'] = $this->request->post['theme_default_image_thumb_width'];
    181 		} elseif (isset($setting_info['theme_default_image_thumb_width'])) {
    182 			$data['theme_default_image_thumb_width'] = $setting_info['theme_default_image_thumb_width'];
    183 		} else {
    184 			$data['theme_default_image_thumb_width'] = 228;
    185 		}
    186 		
    187 		if (isset($this->request->post['theme_default_image_thumb_height'])) {
    188 			$data['theme_default_image_thumb_height'] = $this->request->post['theme_default_image_thumb_height'];
    189 		} elseif (isset($setting_info['theme_default_image_thumb_height'])) {
    190 			$data['theme_default_image_thumb_height'] = $setting_info['theme_default_image_thumb_height'];
    191 		} else {
    192 			$data['theme_default_image_thumb_height'] = 228;		
    193 		}
    194 		
    195 		if (isset($this->request->post['theme_default_image_popup_width'])) {
    196 			$data['theme_default_image_popup_width'] = $this->request->post['theme_default_image_popup_width'];
    197 		} elseif (isset($setting_info['theme_default_image_popup_width'])) {
    198 			$data['theme_default_image_popup_width'] = $setting_info['theme_default_image_popup_width'];
    199 		} else {
    200 			$data['theme_default_image_popup_width'] = 500;
    201 		}
    202 		
    203 		if (isset($this->request->post['theme_default_image_popup_height'])) {
    204 			$data['theme_default_image_popup_height'] = $this->request->post['theme_default_image_popup_height'];
    205 		} elseif (isset($setting_info['theme_default_image_popup_height'])) {
    206 			$data['theme_default_image_popup_height'] = $setting_info['theme_default_image_popup_height'];
    207 		} else {
    208 			$data['theme_default_image_popup_height'] = 500;
    209 		}
    210 		
    211 		if (isset($this->request->post['theme_default_image_product_width'])) {
    212 			$data['theme_default_image_product_width'] = $this->request->post['theme_default_image_product_width'];
    213 		} elseif (isset($setting_info['theme_default_image_product_width'])) {
    214 			$data['theme_default_image_product_width'] = $setting_info['theme_default_image_product_width'];
    215 		} else {
    216 			$data['theme_default_image_product_width'] = 228;
    217 		}
    218 		
    219 		if (isset($this->request->post['theme_default_image_product_height'])) {
    220 			$data['theme_default_image_product_height'] = $this->request->post['theme_default_image_product_height'];
    221 		} elseif (isset($setting_info['theme_default_image_product_height'])) {
    222 			$data['theme_default_image_product_height'] = $setting_info['theme_default_image_product_height'];
    223 		} else {
    224 			$data['theme_default_image_product_height'] = 228;
    225 		}
    226 		
    227 		if (isset($this->request->post['theme_default_image_additional_width'])) {
    228 			$data['theme_default_image_additional_width'] = $this->request->post['theme_default_image_additional_width'];
    229 		} elseif (isset($setting_info['theme_default_image_additional_width'])) {
    230 			$data['theme_default_image_additional_width'] = $setting_info['theme_default_image_additional_width'];
    231 		} else {
    232 			$data['theme_default_image_additional_width'] = 74;
    233 		}
    234 		
    235 		if (isset($this->request->post['theme_default_image_additional_height'])) {
    236 			$data['theme_default_image_additional_height'] = $this->request->post['theme_default_image_additional_height'];
    237 		} elseif (isset($setting_info['theme_default_image_additional_height'])) {
    238 			$data['theme_default_image_additional_height'] = $setting_info['theme_default_image_additional_height'];
    239 		} else {
    240 			$data['theme_default_image_additional_height'] = 74;
    241 		}
    242 		
    243 		if (isset($this->request->post['theme_default_image_related_width'])) {
    244 			$data['theme_default_image_related_width'] = $this->request->post['theme_default_image_related_width'];
    245 		} elseif (isset($setting_info['theme_default_image_related_width'])) {
    246 			$data['theme_default_image_related_width'] = $setting_info['theme_default_image_related_width'];
    247 		} else {
    248 			$data['theme_default_image_related_width'] = 80;
    249 		}
    250 		
    251 		if (isset($this->request->post['theme_default_image_related_height'])) {
    252 			$data['theme_default_image_related_height'] = $this->request->post['theme_default_image_related_height'];
    253 		} elseif (isset($setting_info['theme_default_image_related_height'])) {
    254 			$data['theme_default_image_related_height'] = $setting_info['theme_default_image_related_height'];
    255 		} else {
    256 			$data['theme_default_image_related_height'] = 80;
    257 		}
    258 		
    259 		if (isset($this->request->post['theme_default_image_compare_width'])) {
    260 			$data['theme_default_image_compare_width'] = $this->request->post['theme_default_image_compare_width'];
    261 		} elseif (isset($setting_info['theme_default_image_compare_width'])) {
    262 			$data['theme_default_image_compare_width'] = $setting_info['theme_default_image_compare_width'];
    263 		} else {
    264 			$data['theme_default_image_compare_width'] = 90;
    265 		}
    266 		
    267 		if (isset($this->request->post['theme_default_image_compare_height'])) {
    268 			$data['theme_default_image_compare_height'] = $this->request->post['theme_default_image_compare_height'];
    269 		} elseif (isset($setting_info['theme_default_image_compare_height'])) {
    270 			$data['theme_default_image_compare_height'] = $setting_info['theme_default_image_compare_height'];
    271 		} else {
    272 			$data['theme_default_image_compare_height'] = 90;
    273 		}
    274 		
    275 		if (isset($this->request->post['theme_default_image_wishlist_width'])) {
    276 			$data['theme_default_image_wishlist_width'] = $this->request->post['theme_default_image_wishlist_width'];
    277 		} elseif (isset($setting_info['theme_default_image_wishlist_width'])) {
    278 			$data['theme_default_image_wishlist_width'] = $setting_info['theme_default_image_wishlist_width'];
    279 		} else {
    280 			$data['theme_default_image_wishlist_width'] = 47;
    281 		}
    282 		
    283 		if (isset($this->request->post['theme_default_image_wishlist_height'])) {
    284 			$data['theme_default_image_wishlist_height'] = $this->request->post['theme_default_image_wishlist_height'];
    285 		} elseif (isset($setting_info['theme_default_image_wishlist_height'])) {
    286 			$data['theme_default_image_wishlist_height'] = $setting_info['theme_default_image_wishlist_height'];
    287 		} else {
    288 			$data['theme_default_image_wishlist_height'] = 47;
    289 		}
    290 		
    291 		if (isset($this->request->post['theme_default_image_cart_width'])) {
    292 			$data['theme_default_image_cart_width'] = $this->request->post['theme_default_image_cart_width'];
    293 		} elseif (isset($setting_info['theme_default_image_cart_width'])) {
    294 			$data['theme_default_image_cart_width'] = $setting_info['theme_default_image_cart_width'];
    295 		} else {
    296 			$data['theme_default_image_cart_width'] = 47;
    297 		}
    298 		
    299 		if (isset($this->request->post['theme_default_image_cart_height'])) {
    300 			$data['theme_default_image_cart_height'] = $this->request->post['theme_default_image_cart_height'];
    301 		} elseif (isset($setting_info['theme_default_image_cart_height'])) {
    302 			$data['theme_default_image_cart_height'] = $setting_info['theme_default_image_cart_height'];
    303 		} else {
    304 			$data['theme_default_image_cart_height'] = 47;
    305 		}
    306 		
    307 		if (isset($this->request->post['theme_default_image_location_width'])) {
    308 			$data['theme_default_image_location_width'] = $this->request->post['theme_default_image_location_width'];
    309 		} elseif (isset($setting_info['theme_default_image_location_width'])) {
    310 			$data['theme_default_image_location_width'] = $setting_info['theme_default_image_location_width'];
    311 		} else {
    312 			$data['theme_default_image_location_width'] = 268;
    313 		}
    314 		
    315 		if (isset($this->request->post['theme_default_image_location_height'])) {
    316 			$data['theme_default_image_location_height'] = $this->request->post['theme_default_image_location_height'];
    317 		} elseif (isset($setting_info['theme_default_image_location_height'])) {
    318 			$data['theme_default_image_location_height'] = $setting_info['theme_default_image_location_height'];
    319 		} else {
    320 			$data['theme_default_image_location_height'] = 50;
    321 		}
    322 		
    323 		$data['header'] = $this->load->controller('common/header');
    324 		$data['column_left'] = $this->load->controller('common/column_left');
    325 		$data['footer'] = $this->load->controller('common/footer');
    326 
    327 		$this->response->setOutput($this->load->view('extension/theme/default', $data));
    328 	}
    329 
    330 	protected function validate() {
    331 		if (!$this->user->hasPermission('modify', 'extension/theme/default')) {
    332 			$this->error['warning'] = $this->language->get('error_permission');
    333 		}
    334 
    335 		if (!$this->request->post['theme_default_product_limit']) {
    336 			$this->error['product_limit'] = $this->language->get('error_limit');
    337 		}
    338 
    339 		if (!$this->request->post['theme_default_product_description_length']) {
    340 			$this->error['product_description_length'] = $this->language->get('error_limit');
    341 		}
    342 
    343 		if (!$this->request->post['theme_default_image_category_width'] || !$this->request->post['theme_default_image_category_height']) {
    344 			$this->error['image_category'] = $this->language->get('error_image_category');
    345 		}
    346 
    347 		if (!$this->request->post['theme_default_image_thumb_width'] || !$this->request->post['theme_default_image_thumb_height']) {
    348 			$this->error['image_thumb'] = $this->language->get('error_image_thumb');
    349 		}
    350 
    351 		if (!$this->request->post['theme_default_image_popup_width'] || !$this->request->post['theme_default_image_popup_height']) {
    352 			$this->error['image_popup'] = $this->language->get('error_image_popup');
    353 		}
    354 
    355 		if (!$this->request->post['theme_default_image_product_width'] || !$this->request->post['theme_default_image_product_height']) {
    356 			$this->error['image_product'] = $this->language->get('error_image_product');
    357 		}
    358 
    359 		if (!$this->request->post['theme_default_image_additional_width'] || !$this->request->post['theme_default_image_additional_height']) {
    360 			$this->error['image_additional'] = $this->language->get('error_image_additional');
    361 		}
    362 
    363 		if (!$this->request->post['theme_default_image_related_width'] || !$this->request->post['theme_default_image_related_height']) {
    364 			$this->error['image_related'] = $this->language->get('error_image_related');
    365 		}
    366 
    367 		if (!$this->request->post['theme_default_image_compare_width'] || !$this->request->post['theme_default_image_compare_height']) {
    368 			$this->error['image_compare'] = $this->language->get('error_image_compare');
    369 		}
    370 
    371 		if (!$this->request->post['theme_default_image_wishlist_width'] || !$this->request->post['theme_default_image_wishlist_height']) {
    372 			$this->error['image_wishlist'] = $this->language->get('error_image_wishlist');
    373 		}
    374 
    375 		if (!$this->request->post['theme_default_image_cart_width'] || !$this->request->post['theme_default_image_cart_height']) {
    376 			$this->error['image_cart'] = $this->language->get('error_image_cart');
    377 		}
    378 
    379 		if (!$this->request->post['theme_default_image_location_width'] || !$this->request->post['theme_default_image_location_height']) {
    380 			$this->error['image_location'] = $this->language->get('error_image_location');
    381 		}
    382 
    383 		return !$this->error;
    384 	}
    385 }