Skip to content
This repository was archived by the owner on Oct 20, 2021. It is now read-only.

Commit bb5d6c1

Browse files
committed
added opencart3 compatibility
1 parent 492d0d0 commit bb5d6c1

File tree

5 files changed

+425
-14
lines changed

5 files changed

+425
-14
lines changed

pack.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/bin/bash
2-
out=foc_carousel.ocmod.zip
2+
out=foc_carousel_oc3.ocmod.zip
3+
out2=foc_carousel_oc2.ocmod.zip
34
if [[ -f "$out" ]]; then
45
rm $out
56
fi
6-
zip -r9 --exclude=*.git* --exclude=*.DS_Store* $out ./upload ./install.xml
7+
if [[ -f "$out2" ]]; then
8+
rm $out2
9+
fi
10+
11+
zip -r9 --exclude=*.git* --exclude=*.DS_Store* --exclude=*.tpl $out ./upload ./install.xml
12+
zip -r9 --exclude=*.git* --exclude=*.DS_Store* --exclude=*.twig $out2 ./upload ./install.xml

upload/admin/controller/extension/module/foc_carousel.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,16 @@ private function createUrl ($url) {
3232
public function index () {
3333
$this->load->language('extension/module/foc_carousel');
3434
$this->load->model('localisation/language');
35-
$this->load->model('extension/module');
35+
36+
if ($this->isOpencart3()) {
37+
$this->load->model('setting/module');
38+
$moduleModel = $this->model_setting_module;
39+
}
40+
else {
41+
$this->load->model('extension/module');
42+
$moduleModel = $this->model_extension_module;
43+
}
44+
3645
$this->load->model('tool/image');
3746

3847
$this->document->addStyle('view/javascript/jquery/jquery-ui/jquery-ui.min.css');
@@ -51,24 +60,29 @@ public function index () {
5160
$post['foc_carousel'] = $carousel;
5261

5362
if (!isset($this->request->get['module_id'])) {
54-
$this->model_extension_module->addModule('foc_carousel', $post);
63+
$moduleModel->addModule('foc_carousel', $post);
5564
} else {
56-
$this->model_extension_module->editModule($this->request->get['module_id'], $post);
65+
$moduleModel->editModule($this->request->get['module_id'], $post);
5766
}
5867

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

61-
$this->response->redirect($this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=module', true));
70+
if ($this->isOpencart3()) {
71+
$this->response->redirect($this->url->link('marketplace/extension', $this->getTokenParam() . '&type=module', true));
72+
}
73+
else {
74+
$this->response->redirect($this->url->link('extension/extension', $this->getTokenParam() . '&type=module', true));
75+
}
6276
}
6377

6478
if (!isset($this->request->get['module_id'])) {
65-
$data['action'] = $this->url->link('extension/module/carousel', 'token=' . $this->session->data['token'], true);
79+
$data['action'] = $this->url->link('extension/module/foc_carousel', $this->getTokenParam(), true);
6680
} else {
67-
$data['action'] = $this->url->link('extension/module/carousel', 'token=' . $this->session->data['token'] . '&module_id=' . $this->request->get['module_id'], true);
81+
$data['action'] = $this->url->link('extension/module/foc_carousel', $this->getTokenParam() . '&module_id=' . $this->request->get['module_id'], true);
6882
}
6983

7084
if (isset($this->request->get['module_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
71-
$module_info = $this->model_extension_module->getModule($this->request->get['module_id']);
85+
$module_info = $moduleModel->getModule($this->request->get['module_id']);
7286
}
7387

7488
if (isset($this->request->post['name'])) {
@@ -147,8 +161,6 @@ public function index () {
147161
}
148162
}
149163

150-
151-
152164
$data['heading_title'] = $this->language->get('heading_title');
153165
$data['breadcrumbs'] = $this->breadcrumbs();
154166
$data['header'] = $this->load->controller('common/header');
@@ -198,7 +210,7 @@ private function breadcrumbs () {
198210
);
199211
$breadcrumbs[] = array(
200212
'text' => $this->language->get('text_extension'),
201-
'href' => $this->createUrl('extension/extension'),
213+
'href' => $this->isOpencart3() ? $this->createUrl('marketplace/extension') : $this->createUrl('extension/extension'),
202214
'separator' => ' :: '
203215
);
204216
$breadcrumbs[] = array(

0 commit comments

Comments
 (0)