Parse error: syntax error, unexpected ')', expecting ']' in D:\xampp\xampp\htdocs\catalog\controller\common\header.php on line 15
This is the code.
I hope somebody can help my out with this. This is like Chinese for me
Code: Select all
<?php
class ControllerCommonHeader extends Controller {
protected function index() {
$this->data['products'] = array();
foreach ($this->cart->getProducts() as $result) {
$option_data = array();
foreach ($result['option'] as $option) {
$option_data[] = array(
'name' => $option['name'],
'value' => $option['value'
);
}
$this->data['products'][] = array(
'key' => $result['key'],
'name' => $result['name'],
'option' => $option_data,
'quantity' => $result['quantity'],
'stock' => $result['stock'],
'price' => $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))),
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&product_id=' . $result['product_id']),
);
}
$total_data = array();
$total = 0;
$taxes = $this->cart->getTaxes();
$this->load->model('checkout/extension');
$sort_order = array();
$results = $this->model_checkout_extension->getExtensions('total');
foreach ($results as $key => $value) {
$sort_order[$key] = $this->config->get($value['key'] . '_sort_order');
}
array_multisort($sort_order, SORT_ASC, $results);
foreach ($results as $result) {
$this->load->model('total/' . $result['key']);
$this->{'model_total_' . $result['key']}->getTotal($total_data, $total, $taxes);
}
$sort_order = array();
foreach ($total_data as $key => $value) {
$sort_order[$key] = $value['sort_order'];
}
array_multisort($sort_order, SORT_ASC, $total_data);
$this->data['totals'] = $total_data;
if (isset($this->session->data['coupon'])) {
$this->load->model('checkout/coupon');
$coupon = $this->model_checkout_coupon->getCoupon($this->session->data['coupon']);
if ($coupon) {
$data['coupon_id'] = $coupon['coupon_id'];
} else {
$data['coupon_id'] = 0;
}
} else {
$data['coupon_id'] = 0;
}
$this->data['ajax'] = $this->config->get('cart_ajax');
$this->id = 'cart';
if (($this->request->server['REQUEST_METHOD'] == 'POST') && isset($this->request->post['language_code'])) {
$this->session->data['language'] = $this->request->post['language_code'];
if (isset($this->request->post['redirect'])) {
$this->redirect($this->request->post['redirect']);
} else {
$this->redirect(HTTP_SERVER . 'index.php?route=common/home');
}
}
if (($this->request->server['REQUEST_METHOD'] == 'POST') && isset($this->request->post['currency_code'])) {
$this->currency->set($this->request->post['currency_code']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['shipping_method']);
if (isset($this->request->post['redirect'])) {
$this->redirect($this->request->post['redirect']);
} else {
$this->redirect(HTTP_SERVER . 'index.php?route=common/home');
}
}
$this->language->load('common/header');
if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
$server = HTTPS_IMAGE;
} else {
$server = HTTP_IMAGE;
}
foreach(get_object_vars($this->document) as $key => $value) {
$this->data[$key] = $value;
}
if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
$this->data['base'] = HTTPS_SERVER;
} else {
$this->data['base'] = HTTP_SERVER;
}
if ($this->config->get('config_icon') && file_exists(DIR_IMAGE . $this->config->get('config_icon'))) {
$this->data['icon'] = $server . $this->config->get('config_icon');
} else {
$this->data['icon'] = '';
}
if ($this->config->get('config_logo') && file_exists(DIR_IMAGE . $this->config->get('config_logo'))) {
$this->data['logo'] = $server . $this->config->get('config_logo');
} else {
$this->data['logo'] = '';
}
$this->data['charset'] = $this->language->get('charset');
$this->data['lang'] = $this->language->get('code');
$this->data['direction'] = $this->language->get('direction');
$this->data['template'] = $this->config->get('config_template');
$this->data['store'] = $this->config->get('config_name');
$this->data['text_home'] = $this->language->get('text_home');
$this->data['text_special'] = $this->language->get('text_special');
$this->data['text_contact'] = $this->language->get('text_contact');
$this->data['text_sitemap'] = $this->language->get('text_sitemap');
$this->data['text_bookmark'] = $this->language->get('text_bookmark');
$this->data['text_account'] = $this->language->get('text_account');
$this->data['text_login'] = $this->language->get('text_login');
$this->data['text_logout'] = $this->language->get('text_logout');
$this->data['text_cart'] = $this->language->get('text_cart');
$this->data['text_checkout'] = $this->language->get('text_checkout');
$this->data['text_keyword'] = $this->language->get('text_keyword');
$this->data['text_category'] = $this->language->get('text_category');
$this->data['text_advanced'] = $this->language->get('text_advanced');
$this->data['text_shoppingbag'] = $this->language->get('text_shoppingbag');
$this->data['text_create'] = $this->language->get('text_create');
$this->data['text_forgotpassword'] = $this->language->get('text_forgotpassword');
$this->data['text_myaccount'] = $this->language->get('text_myaccount');
$this->data['text_history'] = $this->language->get('text_history');
$this->data['text_address'] = $this->language->get('text_address');
$this->data['create'] = HTTPS_SERVER . 'index.php?route=account/create';
$this->data['forgotpassword'] = HTTPS_SERVER . 'index.php?route=account/forgotten';
$this->data['myaccount'] = HTTPS_SERVER . 'index.php?route=account/account';
$this->data['history'] = HTTPS_SERVER . 'index.php?route=account/history';
$this->data['address'] = HTTP_SERVER . 'index.php?route=account/address';
if (!$this->customer->isLogged()) {
$this->data['text_greeting'] = $this->language->get('text_greeting');
} else {
$this->data['text_greeting'] = sprintf($this->language->get('text_logged'), $this->customer->getFirstName());
}
$this->data['entry_search'] = $this->language->get('entry_search');
$this->data['button_go'] = $this->language->get('button_go');
$this->data['home'] = HTTP_SERVER . 'index.php?route=common/home';
$this->data['special'] = HTTP_SERVER . 'index.php?route=product/special';
$this->data['contact'] = HTTP_SERVER . 'index.php?route=information/contact';
$this->data['sitemap'] = HTTP_SERVER . 'index.php?route=information/sitemap';
$this->data['account'] = HTTPS_SERVER . 'index.php?route=account/account';
$this->data['logged'] = $this->customer->isLogged();
$this->data['login'] = HTTPS_SERVER . 'index.php?route=account/login';
$this->data['logout'] = HTTP_SERVER . 'index.php?route=account/logout';
$this->data['cart'] = HTTP_SERVER . 'index.php?route=checkout/cart';
$this->data['checkout'] = HTTPS_SERVER . 'index.php?route=checkout/shipping';
if (isset($this->request->get['keyword'])) {
$this->data['keyword'] = $this->request->get['keyword'];
} else {
$this->data['keyword'] = '';
}
if (isset($this->request->get['category_id'])) {
$this->data['category_id'] = $this->request->get['category_id'];
} elseif (isset($this->request->get['path'])) {
$path = explode('_', $this->request->get['path']);
$this->data['category_id'] = end($path);
} else {
$this->data['category_id'] = '';
}
$this->data['advanced'] = HTTP_SERVER . 'index.php?route=product/search';
$this->load->model('catalog/category');
$this->data['categories'] = $this->getCategories(0);
$this->data['action'] = HTTP_SERVER . 'index.php?route=common/home';
if (!isset($this->request->get['route'])) {
$this->data['redirect'] = HTTP_SERVER . 'index.php?route=common/home';
} else {
$this->load->model('tool/seo_url');
$data = $this->request->get;
unset($data['_route_']);
$route = $data['route'];
unset($data['route']);
$url = '';
if ($data) {
$url = '&' . urldecode(http_build_query($data));
}
$this->data['redirect'] = $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=' . $route . $url);
}
$this->data['language_code'] = $this->session->data['language'];
$this->load->model('localisation/language');
$this->data['languages'] = array();
$results = $this->model_localisation_language->getLanguages();
foreach ($results as $result) {
if ($result['status']) {
$this->data['languages'][] = array(
'name' => $result['name'],
'code' => $result['code'],
'image' => $result['image']
);
}
}
$this->data['currency_code'] = $this->currency->getCode();
$this->load->model('localisation/currency');
$this->data['currencies'] = array();
$results = $this->model_localisation_currency->getCurrencies();
foreach ($results as $result) {
if ($result['status']) {
$this->data['currencies'][] = array(
'title' => $result['title'],
'code' => $result['code']
);
}
}
$this->id = 'header';
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
$this->template = $this->config->get('config_template') . '/template/common/header.tpl';
} else {
$this->template = 'default/template/common/header.tpl';
}
$this->render();
}
private function getCategories($parent_id, $level = 0) {
$level++;
$data = array();
$results = $this->model_catalog_category->getCategories($parent_id);
foreach ($results as $result) {
$data[] = array(
'category_id' => $result['category_id'],
'name' => str_repeat(' ', $level) . $result['name']
);
$children = $this->getCategories($result['category_id'], $level);
if ($children) {
$data = array_merge($data, $children);
}
}
return $data;
}
}
?>