Skip to content

Commit

Permalink
more module changes done
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel kerr committed Sep 24, 2014
1 parent f735ca3 commit a55b527
Show file tree
Hide file tree
Showing 35 changed files with 340 additions and 351 deletions.
2 changes: 1 addition & 1 deletion tests/phpunit/selenium/catalog/AmazonPaymentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function setUpPage() {
$this->byCssSelector('.fa-plus-circle')->click();

for ($i = 1; ; $i++) {
$element = $this->byCssSelector('select[name="amazon_checkout_layout_module[0][layout_id]"] option:nth-child(' . $i . ')');
$element = $this->byCssSelector('select[name="amazon_button_module[0][layout_id]"] option:nth-child(' . $i . ')');

if ($element->text() == 'Cart') {
$element->click();
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/selenium/catalog/PayPalExpressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function setUpPage() {
$this->byCssSelector('.fa-plus-circle')->click();

for ($i = 1; ; $i++) {
$element = $this->byCssSelector("select[name=\"pp_layout_module[0][layout_id]\"] option:nth-child($i)");
$element = $this->byCssSelector("select[name=\"pp_button_module[0][layout_id]\"] option:nth-child($i)");

if ($element->text() == 'Cart') {
$element->click();
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/selenium/catalog/SagePayDirectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function setUpPage() {
$this->byCssSelector('.fa-plus-circle')->click();

for ($i = 1; ; $i++) {
$element = $this->byCssSelector("select[name=\"pp_layout_module[0][layout_id]\"] option:nth-child($i)");
$element = $this->byCssSelector("select[name=\"pp_button_module[0][layout_id]\"] option:nth-child($i)");

if ($element->text() == 'Cart') {
$element->click();
Expand Down
51 changes: 21 additions & 30 deletions upload/admin/controller/design/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,50 +360,41 @@ protected function getForm() {


$this->load->model('extension/extension');
$this->load->model('extension/module');

$data['modules'] = array();

// Get a list of installed modules
$extensions = $this->model_extension_extension->getInstalled('module');

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' => ''
);
}
}

// 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);
$this->load->language('module/' . $code);

$i = 1;

$i = 1;

$module_data = array();

$modules = $this->model_extension_module->getModules($code);
$module_data = array();

if ($this->config->has($code . '_module')) {
$modules = $this->config->get($code . '_module');

foreach ($modules as $module) {
foreach (array_keys($modules) as $key) {
$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
'code' => $code . '.' . $key
);
}
} else {
$module_data[] = array(
'name' => $this->language->get('heading_title'),
'code' => $code
);
}

if ($module_data) {
$data['modules'][] = array(
'name' => $this->language->get('heading_title'),
'module' => $module_data
);
}
}

Expand Down
4 changes: 4 additions & 0 deletions upload/admin/controller/extension/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public function uninstall() {

$this->model_setting_setting->deleteSetting($this->request->get['extension']);

$this->load->model('extension/module');

$this->model_extension_module->deleteModule($this->request->get['extension']);

// Call uninstall method if it exsits
$this->load->controller('module/' . $this->request->get['extension'] . '/uninstall');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php
class ControllerModuleAmazonCheckoutLayout extends Controller {
class ControllerModuleAmazonButton extends Controller {
public function index() {
$this->language->load('module/amazon_checkout_layout');
$this->language->load('module/amazon_button');

$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);
$this->model_setting_setting->editSetting('amazon_button', $this->request->post);

$this->session->data['success'] = $this->language->get('text_success');

Expand Down Expand Up @@ -48,25 +48,25 @@ public function index() {

$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('module/amazon_checkout_layout', 'token=' . $this->session->data['token'], 'SSL'),
'href' => $this->url->link('module/amazon_button', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => ' :: '
);

$data['action'] = $this->url->link('module/amazon_checkout_layout', 'token=' . $this->session->data['token'], 'SSL');
$data['action'] = $this->url->link('module/amazon_button', 'token=' . $this->session->data['token'], 'SSL');

$data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');

if (isset($this->request->post['amazon_checkout_layout_status'])) {
$data['amazon_checkout_layout_status'] = $this->request->post['amazon_checkout_layout_status'];
if (isset($this->request->post['amazon_button_status'])) {
$data['amazon_button_status'] = $this->request->post['amazon_button_status'];
} else {
$data['amazon_checkout_layout_status'] = $this->config->get('amazon_checkout_layout_status');
$data['amazon_button_status'] = $this->config->get('amazon_button_status');
}

$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');

$this->response->setOutput($this->load->view('module/amazon_checkout_layout.tpl', $data));
$this->response->setOutput($this->load->view('module/amazon_button.tpl', $data));
}

protected function validate() {
Expand Down
28 changes: 18 additions & 10 deletions upload/admin/controller/module/banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ 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('banner', $this->request->post);

// 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');

$this->response->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
Expand Down Expand Up @@ -78,10 +73,23 @@ public function index() {
$data['banner_status'] = $this->config->get('banner_status');
}

if (isset($this->request->post['module'])) {
$data['modules'] = $this->request->post['module'];
if (isset($this->request->post['banner_module'])) {
$modules = $this->request->post['banner_module'];
} elseif ($this->config->has('banner_module')) {
$modules = $this->config->get('banner_module');
} else {
$data['modules'] = $this->extension_module->getModules('banner');
$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']
);
}

$this->load->model('design/banner');
Expand All @@ -100,8 +108,8 @@ protected function validate() {
$this->error['warning'] = $this->language->get('error_permission');
}

if (isset($this->request->post['banner_module'])) {
foreach ($this->request->post['banner_module'] as $key => $value) {
if (isset($this->request->post['module'])) {
foreach ($this->request->post['module'] as $key => $value) {
if (!$value['width'] || !$value['height']) {
$this->error['dimension'][$key] = $this->language->get('error_dimension');
}
Expand Down
26 changes: 17 additions & 9 deletions upload/admin/controller/module/bestseller.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ 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('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');
Expand Down Expand Up @@ -80,12 +75,25 @@ public function index() {
$data['bestseller_status'] = $this->config->get('bestseller_status');
}

if (isset($this->request->post['module'])) {
$data['modules'] = $this->request->post['module'];
if (isset($this->request->post['bestseller_module'])) {
$modules = $this->request->post['bestseller_module'];
} elseif ($this->config->has('bestseller_module')) {
$modules = $this->config->get('bestseller_module');
} else {
$data['modules'] = $this->extension_module->getModules('bestseller');
$modules = array();
}


$data['bestseller_modules'] = array();

foreach ($modules as $key => $module) {
$data['bestseller_modules'][] = array(
'key' => $key,
'limit' => $module['limit'],
'width' => $module['width'],
'height' => $module['height']
);
}

$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
Expand Down
26 changes: 18 additions & 8 deletions upload/admin/controller/module/carousel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ 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('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');

Expand Down Expand Up @@ -80,10 +75,25 @@ public function index() {
$data['carousel_status'] = $this->config->get('carousel_status');
}

if (isset($this->request->post['module'])) {
$data['modules'] = $this->request->post['module'];
if (isset($this->request->post['carousel_module'])) {
$modules = $this->request->post['carousel_module'];
} elseif ($this->config->has('carousel_module')) {
$modules = $this->config->get('carousel_module');
} else {
$data['modules'] = $this->extension_module->getModules('carousel');
$modules = array();
}

$data['carousel_modules'] = array();

foreach ($modules as $key => $module) {
$data['carousel_modules'][] = array(
'key' => $key,
'banner_id' => $module['banner_id'],
'limit' => $module['limit'],
'scroll' => $module['scroll'],
'width' => $module['width'],
'height' => $module['height']
);
}

$this->load->model('design/banner');
Expand Down
26 changes: 17 additions & 9 deletions upload/admin/controller/module/featured.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ 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('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');

Expand Down Expand Up @@ -109,13 +104,26 @@ public function index() {
} else {
$data['featured_status'] = $this->config->get('featured_status');
}

if (isset($this->request->post['module'])) {
$data['modules'] = $this->request->post['module'];

if (isset($this->request->post['featured_module'])) {
$modules = $this->request->post['featured_module'];
} elseif ($this->config->has('featured_module')) {
$modules = $this->config->get('featured_module');
} else {
$data['modules'] = $this->extension_module->getModules('featured');
$modules = array();
}

$data['featured_modules'] = array();

foreach ($modules as $key => $module) {
$data['featured_modules'][] = array(
'key' => $key,
'limit' => $module['limit'],
'width' => $module['width'],
'height' => $module['height']
);
}

$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
Expand Down
22 changes: 15 additions & 7 deletions upload/admin/controller/module/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ 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('html', $this->request->post);

$this->model_extension_module->addModule('html', $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'));
Expand Down Expand Up @@ -71,10 +67,22 @@ public function index() {
$data['html_status'] = $this->config->get('html_status');
}

if (isset($this->request->post['module'])) {
$data['modules'] = $this->request->post['module'];
if (isset($this->request->post['html_module'])) {
$modules = $this->request->post['html_module'];
} elseif ($this->config->has('html_module')) {
$modules = $this->config->get('html_module');
} else {
$data['modules'] = $this->extension_module->getModules('html');
$modules = array();
}

$data['html_modules'] = array();

foreach ($modules as $key => $module) {
$data['html_modules'][] = array(
'key' => $key,
'heading' => $module['heading'],
'description' => $module['description']
);
}

$this->load->model('localisation/language');
Expand Down
Loading

0 comments on commit a55b527

Please sign in to comment.