diff --git a/upload/admin/controller/design/layout.php b/upload/admin/controller/design/layout.php index c787b9dc652..3ed4ada4823 100644 --- a/upload/admin/controller/design/layout.php +++ b/upload/admin/controller/design/layout.php @@ -358,24 +358,55 @@ protected function getForm() { $data['layout_modules'] = array(); } + + $this->load->model('extension/extension'); $this->load->model('extension/module'); $data['modules'] = array(); - $modules = $this->model_extension_module->getModules(); + // Get a list of installed modules + $extensions = $this->model_extension_extension->getInstalled('module'); - $i = 1; + foreach ($extensions as $code) { + if (!$this->config->has($code . '_module')) { + $this->load->language('module/' . $code); + + $data['modules'][] = array( + 'name' => $this->language->get('heading_title'), + 'code' => $code, + 'module' => '' + ); + } + } - foreach ($modules as $module) { - $this->load->language('module/' . $module['code']); + // Add all the modules which have multiple settings for each module + foreach ($extensions as $code) { + if ($this->config->has($code . '_module')) { + $this->load->language('module/' . $code); - $data['modules'][] = array( - 'module_id' => $module['module_id'], - 'name' => $this->language->get('heading_title') . ' ' . $i++, - 'code' => $module['code'] - ); + $i = 1; + + $module_data = array(); + + $modules = $this->model_extension_module->getModules($code); + + foreach ($modules as $module) { + $module_data[] = array( + 'name' => $this->language->get('heading_title') . ' ' . $i++, + 'code' => $code . '.' . $module['module_id'] + ); + } + + if ($module_data) { + $data['modules'][] = array( + 'name' => $this->language->get('heading_title'), + 'code' => $code, + 'module' => $module_data + ); + } + } } - + $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); diff --git a/upload/admin/controller/module/account.php b/upload/admin/controller/module/account.php index 4fb6feef817..304706d68cd 100644 --- a/upload/admin/controller/module/account.php +++ b/upload/admin/controller/module/account.php @@ -8,14 +8,10 @@ public function index() { $this->document->setTitle($this->language->get('heading_title')); $this->load->model('setting/setting'); - - $this->load->model('extension/module'); if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $this->model_setting_setting->editSetting('account', $this->request->post); - $this->model_extension_module->editModule('account'); - $this->session->data['success'] = $this->language->get('text_success'); $this->response->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL')); @@ -79,7 +75,4 @@ protected function validate() { return !$this->error; } - - - } \ No newline at end of file diff --git a/upload/admin/controller/module/amazon_checkout_layout.php b/upload/admin/controller/module/amazon_checkout_layout.php index 412e0754728..7a3fa428b12 100644 --- a/upload/admin/controller/module/amazon_checkout_layout.php +++ b/upload/admin/controller/module/amazon_checkout_layout.php @@ -3,9 +3,9 @@ class ControllerModuleAmazonCheckoutLayout extends Controller { public function index() { $this->language->load('module/amazon_checkout_layout'); - $this->load->model('setting/setting'); - $this->document->setTitle($this->language->get('heading_title')); + + $this->load->model('setting/setting'); if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $this->model_setting_setting->editSetting('amazon_checkout_layout', $this->request->post); diff --git a/upload/admin/controller/module/banner.php b/upload/admin/controller/module/banner.php index 5d390793def..133b0539fd6 100644 --- a/upload/admin/controller/module/banner.php +++ b/upload/admin/controller/module/banner.php @@ -8,18 +8,14 @@ public function index() { $this->document->setTitle($this->language->get('heading_title')); $this->load->model('setting/setting'); - + $this->load->model('extension/module'); if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $this->model_setting_setting->editSetting('banner', $this->request->post); - // Add positions for all the modules so they can be used with the layouts - $this->model_extension_module->deleteModule('banner'); - - foreach (array_keys($this->request->post['banner_module']) as $key) { - $this->model_extension_module->addModule('banner', $key); - } + // We need to add modules to a separate table + $this->model_extension_module->addModule('banner', $this->request->post['module']); $this->session->data['success'] = $this->language->get('text_success'); @@ -36,8 +32,6 @@ public function index() { $data['entry_dimension'] = $this->language->get('entry_dimension'); $data['entry_width'] = $this->language->get('entry_width'); $data['entry_height'] = $this->language->get('entry_height'); - $data['entry_width'] = $this->language->get('entry_width'); - $data['entry_height'] = $this->language->get('entry_height'); $data['entry_status'] = $this->language->get('entry_status'); $data['button_save'] = $this->language->get('button_save'); @@ -84,23 +78,10 @@ public function index() { $data['banner_status'] = $this->config->get('banner_status'); } - if (isset($this->request->post['banner_module'])) { - $modules = $this->request->post['banner_module']; - } elseif ($this->config->get('banner_module')) { - $modules = $this->config->get('banner_module'); + if (isset($this->request->post['module'])) { + $data['modules'] = $this->request->post['module']; } else { - $modules = array(); - } - - $data['banner_modules'] = array(); - - foreach ($modules as $key => $module) { - $data['banner_modules'][] = array( - 'key' => $key, - 'banner_id' => $module['banner_id'], - 'width' => $module['width'], - 'height' => $module['height'] - ); + $data['modules'] = $this->extension_module->getModules('banner'); } $this->load->model('design/banner'); diff --git a/upload/admin/controller/module/bestseller.php b/upload/admin/controller/module/bestseller.php index ce29a4d2992..ec7ec4f5fca 100644 --- a/upload/admin/controller/module/bestseller.php +++ b/upload/admin/controller/module/bestseller.php @@ -14,6 +14,9 @@ public function index() { if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $this->model_setting_setting->editSetting('bestseller', $this->request->post['bestseller_status']); + // We need to add modules to a table + $this->model_extension_module->addModule('bestseller', $this->request->post['module']); + $this->cache->delete('product'); $this->session->data['success'] = $this->language->get('text_success'); @@ -71,17 +74,17 @@ public function index() { $data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'); - if (isset($this->request->post['module'])) { - $data['modules'] = $this->request->post['module']; - } else { - $data['modules'] = $this->model_extension_module->getModulesByCode('bestseller'); - } - if (isset($this->request->post['bestseller_status'])) { $data['bestseller_status'] = $this->request->post['bestseller_status']; } else { $data['bestseller_status'] = $this->config->get('bestseller_status'); } + + if (isset($this->request->post['module'])) { + $data['modules'] = $this->request->post['module']; + } else { + $data['modules'] = $this->extension_module->getModules('bestseller'); + } $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); diff --git a/upload/admin/controller/module/carousel.php b/upload/admin/controller/module/carousel.php index 482f82b58db..2063fda5ce5 100644 --- a/upload/admin/controller/module/carousel.php +++ b/upload/admin/controller/module/carousel.php @@ -13,6 +13,9 @@ public function index() { if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $this->model_setting_setting->editSetting('carousel', $this->request->post); + + // We need to add modules to a table + $this->model_extension_module->addModule('bestseller', $this->request->post['module']); $this->session->data['success'] = $this->language->get('text_success'); @@ -71,22 +74,22 @@ public function index() { $data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'); + if (isset($this->request->post['carousel_status'])) { + $data['carousel_status'] = $this->request->post['carousel_status']; + } else { + $data['carousel_status'] = $this->config->get('carousel_status'); + } + if (isset($this->request->post['module'])) { $data['modules'] = $this->request->post['module']; } else { - $data['modules'] = $this->model_extension_module->getModulesByCode('carousel'); + $data['modules'] = $this->extension_module->getModules('carousel'); } $this->load->model('design/banner'); $data['banners'] = $this->model_design_banner->getBanners(); - if (isset($this->request->post['carousel_status'])) { - $data['carousel_status'] = $this->request->post['carousel_status']; - } else { - $data['carousel_status'] = $this->config->get('carousel_status'); - } - $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); diff --git a/upload/admin/controller/module/category.php b/upload/admin/controller/module/category.php index b149c241398..aed37e304e1 100644 --- a/upload/admin/controller/module/category.php +++ b/upload/admin/controller/module/category.php @@ -9,8 +9,6 @@ public function index() { $this->load->model('setting/setting'); - $this->load->model('extension/module'); - if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $this->model_setting_setting->editSetting('category', $this->request->post); diff --git a/upload/admin/controller/module/featured.php b/upload/admin/controller/module/featured.php index 96d64b299d9..fbdf21c2f58 100644 --- a/upload/admin/controller/module/featured.php +++ b/upload/admin/controller/module/featured.php @@ -13,6 +13,9 @@ public function index() { if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $this->model_setting_setting->editSetting('featured', $this->request->post); + + // We need to add modules to a table + $this->model_extension_module->addModule('featured', $this->request->post['module']); $this->session->data['success'] = $this->language->get('text_success'); @@ -110,7 +113,7 @@ public function index() { if (isset($this->request->post['module'])) { $data['modules'] = $this->request->post['module']; } else { - $data['modules'] = $this->model_extension_module->getModulesByCode('featured'); + $data['modules'] = $this->extension_module->getModules('featured'); } $data['header'] = $this->load->controller('common/header'); diff --git a/upload/admin/controller/module/filter.php b/upload/admin/controller/module/filter.php index 498c496ee4d..b61c895e6c1 100644 --- a/upload/admin/controller/module/filter.php +++ b/upload/admin/controller/module/filter.php @@ -55,12 +55,12 @@ public function index() { $data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'); - if (isset($this->request->post['featured_status'])) { - $data['featured_status'] = $this->request->post['featured_status']; + if (isset($this->request->post['filter_status'])) { + $data['filter_status'] = $this->request->post['filter_status']; } else { - $data['featured_status'] = $this->config->get('featured_status'); + $data['filter_status'] = $this->config->get('filter_status'); } - + $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); diff --git a/upload/admin/controller/module/google_hangouts.php b/upload/admin/controller/module/google_hangouts.php index 31f3c65abaa..5f753417031 100644 --- a/upload/admin/controller/module/google_hangouts.php +++ b/upload/admin/controller/module/google_hangouts.php @@ -9,8 +9,6 @@ public function index() { $this->load->model('setting/setting'); - $this->load->model('extension/module'); - if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $this->model_setting_setting->editSetting('google_hangouts', $this->request->post); diff --git a/upload/admin/controller/module/html.php b/upload/admin/controller/module/html.php index e14508b6cce..81253bdca0a 100644 --- a/upload/admin/controller/module/html.php +++ b/upload/admin/controller/module/html.php @@ -14,9 +14,7 @@ public function index() { if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $this->model_setting_setting->editSetting('html', $this->request->post); - foreach ($this->request->post['html_module'] as $module) { - $this->model_setting_setting->addModule('html', $this->request->post); - } + $this->model_extension_module->addModule('html', $this->request->post['module']); $this->session->data['success'] = $this->language->get('text_success'); @@ -66,23 +64,23 @@ public function index() { $data['action'] = $this->url->link('module/html', 'token=' . $this->session->data['token'], 'SSL'); $data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'); - + + if (isset($this->request->post['html_status'])) { + $data['html_status'] = $this->request->post['html_status']; + } else { + $data['html_status'] = $this->config->get('html_status'); + } + if (isset($this->request->post['module'])) { $data['modules'] = $this->request->post['module']; } else { - $data['modules'] = $this->model_extension_module->getModulesByCode('html'); + $data['modules'] = $this->extension_module->getModules('html'); } $this->load->model('localisation/language'); $data['languages'] = $this->model_localisation_language->getLanguages(); - if (isset($this->request->post['html_status'])) { - $data['html_status'] = $this->request->post['html_status']; - } else { - $data['html_status'] = $this->config->get('html_status'); - } - $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); diff --git a/upload/admin/controller/module/information.php b/upload/admin/controller/module/information.php index 380cb9ea7ea..451ad1d74e7 100644 --- a/upload/admin/controller/module/information.php +++ b/upload/admin/controller/module/information.php @@ -9,8 +9,6 @@ public function index() { $this->load->model('setting/setting'); - $this->load->model('extension/module'); - if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $this->model_setting_setting->editSetting('information', $this->request->post); diff --git a/upload/admin/controller/module/latest.php b/upload/admin/controller/module/latest.php index a7bbbdc7128..d4681b4c382 100644 --- a/upload/admin/controller/module/latest.php +++ b/upload/admin/controller/module/latest.php @@ -14,6 +14,9 @@ public function index() { if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $this->model_setting_setting->editSetting('latest', $this->request->post); + // We need to add modules to a table + $this->model_extension_module->addModule('latest', $this->request->post['module']); + $this->cache->delete('product'); $this->session->data['success'] = $this->language->get('text_success'); @@ -70,12 +73,6 @@ public function index() { $data['action'] = $this->url->link('module/latest', 'token=' . $this->session->data['token'], 'SSL'); $data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'); - - if (isset($this->request->post['module'])) { - $data['modules'] = $this->request->post['module']; - } else { - $data['modules'] = $this->model_extension_module->getModulesByCode('latest'); - } if (isset($this->request->post['latest_status'])) { $data['latest_status'] = $this->request->post['latest_status']; @@ -83,6 +80,12 @@ public function index() { $data['latest_status'] = $this->config->get('latest_status'); } + if (isset($this->request->post['module'])) { + $data['modules'] = $this->request->post['module']; + } else { + $data['modules'] = $this->model_extension_module->getModules('latest'); + } + $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); diff --git a/upload/admin/controller/module/pp_layout.php b/upload/admin/controller/module/pp_layout.php index a058305edc3..1bbee7139fa 100644 --- a/upload/admin/controller/module/pp_layout.php +++ b/upload/admin/controller/module/pp_layout.php @@ -5,8 +5,6 @@ public function index() { $this->load->model('setting/setting'); - $this->load->model('extension/module'); - $this->document->setTitle($this->language->get('heading_title')); if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { @@ -52,14 +50,9 @@ public function index() { ); $data['action'] = $this->url->link('module/pp_layout', 'token=' . $this->session->data['token'], 'SSL'); + $data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'); - if (isset($this->request->post['module'])) { - $data['modules'] = $this->request->post['module']; - } else { - $data['modules'] = $this->config->get('pp_layout_module'); - } - if (isset($this->request->post['pp_layout_status'])) { $data['pp_layout_status'] = $this->request->post['pp_layout_status']; } else { diff --git a/upload/admin/controller/module/pp_login.php b/upload/admin/controller/module/pp_login.php index 326eea8f7bf..7d97d2d6783 100644 --- a/upload/admin/controller/module/pp_login.php +++ b/upload/admin/controller/module/pp_login.php @@ -7,8 +7,6 @@ public function index() { $this->load->model('setting/setting'); - $this->load->model('extension/module'); - $this->document->setTitle($this->language->get('heading_title')); if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { diff --git a/upload/admin/controller/module/slideshow.php b/upload/admin/controller/module/slideshow.php index 7b22a4d3b53..f7f52dfca82 100644 --- a/upload/admin/controller/module/slideshow.php +++ b/upload/admin/controller/module/slideshow.php @@ -14,6 +14,8 @@ public function index() { if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $this->model_setting_setting->editSetting('slideshow', $this->request->post); + $this->model_extension_module->addModule('slideshow', $this->request->post['module']); + $this->session->data['success'] = $this->language->get('text_success'); $this->response->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL')); @@ -68,23 +70,23 @@ public function index() { $data['action'] = $this->url->link('module/slideshow', 'token=' . $this->session->data['token'], 'SSL'); $data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'); - - if (isset($this->request->post['slideshow_module'])) { - $data['modules'] = $this->request->post['slideshow_module']; - } elseif ($this->config->get('slideshow_module')) { - $data['modules'] = $this->config->get('slideshow_module'); - } - - $this->load->model('design/banner'); - - $data['banners'] = $this->model_design_banner->getBanners(); if (isset($this->request->post['slideshow_status'])) { $data['slideshow_status'] = $this->request->post['slideshow_status']; } else { $data['slideshow_status'] = $this->config->get('slideshow_status'); } + + if (isset($this->request->post['module'])) { + $data['modules'] = $this->request->post['module']; + } else { + $data['modules'] = $this->model_extension_module->getModules('latest'); + } + + $this->load->model('design/banner'); + $data['banners'] = $this->model_design_banner->getBanners(); + $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); diff --git a/upload/admin/controller/module/special.php b/upload/admin/controller/module/special.php index 04ac30f2bc5..c5b12259f1f 100644 --- a/upload/admin/controller/module/special.php +++ b/upload/admin/controller/module/special.php @@ -13,6 +13,9 @@ public function index() { if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $this->model_setting_setting->editSetting('special', $this->request->post); + + // We need to add modules to a table + $this->model_extension_module->addModule('special', $this->request->post['module']); $this->cache->delete('product'); @@ -70,12 +73,6 @@ public function index() { $data['action'] = $this->url->link('module/special', 'token=' . $this->session->data['token'], 'SSL'); $data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'); - - if (isset($this->request->post['module'])) { - $data['modules'] = $this->request->post['module']; - } else { - $data['modules'] = $this->model_extension_module->getModulesByCode('special'); - } if (isset($this->request->post['special_status'])) { $data['special_status'] = $this->request->post['special_status']; @@ -83,6 +80,12 @@ public function index() { $data['special_status'] = $this->config->get('special_status'); } + if (isset($this->request->post['module'])) { + $data['modules'] = $this->request->post['module']; + } else { + $data['modules'] = $this->model_extension_module->getModules('special'); + } + $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); diff --git a/upload/admin/model/extension/module.php b/upload/admin/model/extension/module.php index 5430c35f112..3239136eccd 100644 --- a/upload/admin/model/extension/module.php +++ b/upload/admin/model/extension/module.php @@ -1,36 +1,22 @@ db->query("DELETE FROM " . DB_PREFIX . "module WHERE code = '" . $this->db->escape($code) . "'"); - - foreach ($data as $module) { - if ($module['module_id']) { - $this->db->query("INSERT INTO " . DB_PREFIX . "module SET `module_id` = '" . (int)$module['module_id'] . "', `code` = '" . $this->db->escape($code) . "', `index` = '" . $this->db->escape($module) . "'"); - } else { - $this->db->query("INSERT INTO " . DB_PREFIX . "module SET `code` = '" . $this->db->escape($code) . "', `setting` = '" . $this->db->escape(serialize($module)) . "'"); - } + + if ($data['module_id']) { + $this->db->query("INSERT INTO " . DB_PREFIX . "module SET module_id = '" . $data['module_id'] . "', `code` = '" . $this->db->escape($code) . "', `setting` = '" . $this->db->escape(serialize($setting)) . "'"); + } else { + $this->db->query("INSERT INTO " . DB_PREFIX . "module SET `code` = '" . $this->db->escape($code) . "', `setting` = '" . $this->db->escape(serialize($setting)) . "'"); } } - public function deleteModuleByCode($code) { + public function deleteModules($code) { $this->db->query("DELETE FROM " . DB_PREFIX . "module WHERE code = '" . $this->db->escape($code) . "'"); } - public function getModulesByCode($code) { - $module_data = array(); - + public function getModules($code) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "module WHERE code = '" . $this->db->escape($code) . "'"); - foreach ($query->rows as $result) { - $module_data[$result['module_id']] = $result['code']; - } - - return $module_data; - } - - public function getModules() { - $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "module"); - return $query->rows; } } \ No newline at end of file diff --git a/upload/admin/view/stylesheet/stylesheet.css b/upload/admin/view/stylesheet/stylesheet.css index 892518df628..b318b62d25d 100644 --- a/upload/admin/view/stylesheet/stylesheet.css +++ b/upload/admin/view/stylesheet/stylesheet.css @@ -404,6 +404,11 @@ label.control-label span:after { label.control-label { /*font-weight: normal;*/ } + +fieldset legend { + padding-bottom: 5px; +} + input[type="radio"], input[type="checkbox"] { margin: 2px 0 0; } diff --git a/upload/admin/view/template/catalog/product_form.tpl b/upload/admin/view/template/catalog/product_form.tpl index f71535b82a0..a4e433f2210 100644 --- a/upload/admin/view/template/catalog/product_form.tpl +++ b/upload/admin/view/template/catalog/product_form.tpl @@ -95,6 +95,13 @@