-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from opencorero/dev
Version update
- Loading branch information
Showing
21 changed files
with
632 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
132 changes: 132 additions & 0 deletions
132
opencart-module/3.x/upload/admin/controller/extension/module/opencore.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<?php | ||
|
||
require_once realpath(__DIR__ . '/../../../../') . '/core/support/Opencart/Startup.php'; | ||
|
||
use OpenCore\Support\OpenCart\Installer; | ||
use OpenCore\Support\OpenCart\OcCore; | ||
|
||
class ControllerExtensionModuleOpencore extends Controller | ||
{ | ||
use OcCore, Installer; | ||
|
||
static $booted = false; | ||
|
||
private $errors = []; | ||
|
||
public function index() | ||
{ | ||
$this->load->language('extension/module/opencore'); | ||
|
||
$this->document->setTitle($this->language->get('heading_title')); | ||
|
||
$data['heading_title'] = $this->language->get('heading_title'); | ||
|
||
$data['breadcrumbs'] = array(); | ||
|
||
$data['breadcrumbs'][] = array( | ||
'text' => $this->language->get('text_home'), | ||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) | ||
); | ||
|
||
$data['breadcrumbs'][] = array( | ||
'text' => $this->language->get('text_extension'), | ||
'href' => $this->url->link('extension/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true) | ||
); | ||
|
||
$data['breadcrumbs'][] = array( | ||
'text' => $this->language->get('heading_title'), | ||
'href' => $this->url->link('extension/module/opencore', 'user_token=' . $this->session->data['user_token'], true) | ||
); | ||
|
||
$this->checkInstalation(); | ||
if (empty($this->errors)) { | ||
$data['success_message'] = $this->language->get('text_success'); | ||
} else { | ||
$data['error_instalation_failure'] = $this->language->get('error_instalation_failure'); | ||
$data['errors'] = $this->errors; | ||
} | ||
|
||
$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('extension/module/opencore', $data)); | ||
} | ||
|
||
public function install() | ||
{ | ||
$this->installHtaccess(); | ||
|
||
$this->installOcmod('opencore'); | ||
$this->refreshOcmod(); | ||
|
||
$this->installEvent('opencore_admin_menu', 'startup/opencore/before_view', 'admin/view/*/before'); | ||
$this->installEvent('opencore_admin_before_c', 'startup/opencore/before_controller', 'admin/controller/*/before'); | ||
$this->installEvent('opencore_catalog_before_c', 'startup/opencore/before_controller', 'catalog/controller/*/before'); | ||
|
||
$this->addPermissions('extension/module/opencore', ['access', 'modify']); | ||
$this->addPermissions('core/*', ['access', 'modify']); | ||
|
||
$this->session->data['success'] = $this->language->get('text_success'); | ||
} | ||
|
||
public function uninstall() | ||
{ | ||
$this->removeHtaccess(); | ||
|
||
$this->removeOcmod('opencore'); | ||
$this->refreshOcmod(); | ||
|
||
$this->removeEvent('opencore_admin_menu'); | ||
$this->removeEvent('opencore_admin_before_c'); | ||
$this->removeEvent('opencore_catalog_before_c'); | ||
|
||
$this->removePermissions('extension/module/opencore', ['access', 'modify']); | ||
$this->removePermissions('core/*', ['access', 'modify']); | ||
|
||
$this->session->data['success'] = $this->language->get('text_success'); | ||
|
||
if (isOc3()) { | ||
$route = 'marketplace/extension'; | ||
} else { | ||
$route = 'extension/extension'; | ||
} | ||
|
||
$location = "index.php?route={$route}&" . $this->getTokenStr() . '&type=module'; | ||
die("<script>window.location.href = '{$location}';</script>"); | ||
} | ||
|
||
private function checkInstalation() | ||
{ | ||
/* | ||
* Server Requirements | ||
* PHP >= 5.6.4 | ||
* OpenSSL PHP Extension | ||
* PDO PHP Extension | ||
* Mbstring PHP Extension | ||
*/ | ||
|
||
//will fail if the before_controller will not be triggered | ||
if (!class_exists('ControllerStartupOpencore')) { | ||
$this->errors[] = $this->language->get('error_router'); | ||
} | ||
|
||
//TODO: need to check event entry/status for opencore_catalog_before_controll & opencore_admin_menu | ||
|
||
$this->load->model('setting/modification'); | ||
$modification = $this->model_setting_modification->getModificationByCode('opencore'); | ||
|
||
if (empty($modification)) { | ||
$this->errors[] = $this->language->get('error_modification_entry'); | ||
} elseif (empty($modification['status'])) { | ||
$this->errors[] = $this->language->get('error_modification_status'); | ||
} elseif (empty($modification['xml'])) { | ||
$this->errors[] = $this->language->get('error_modification_empty_xml'); | ||
} | ||
|
||
//TODO: check if opencore menu event is installed! | ||
if (!file_exists(DIR_APPLICATION . '.htaccess')) { | ||
$this->errors[] = $this->language->get('error_htaccess_not_found'); | ||
} | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
opencart-module/3.x/upload/admin/controller/startup/opencore.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
/* | ||
* Created on Fri Dec 13 2019 by DaRock | ||
* | ||
* Aweb Design | ||
* https://www.awebdesign.ro | ||
* | ||
*/ | ||
|
||
require_once realpath(__DIR__ . '/../../../') . '/core/support/Opencart/Startup.php'; | ||
|
||
use OpenCore\Support\Opencart\Startup; | ||
use OpenCore\Support\OpenCart\OcCore; | ||
|
||
class ControllerStartupOpencore extends Startup | ||
{ | ||
use OcCore; | ||
|
||
private $booted = []; | ||
|
||
/** | ||
* This method is executed everytime before loading any controller | ||
* | ||
* @param string $route | ||
* @param array $data | ||
* @return string | ||
*/ | ||
function before_controller($route, &$data, &$output = false) | ||
{ | ||
/** | ||
* Check if a laravel route exists and if so execute it | ||
* else return NULL | ||
*/ | ||
return $this->executeIfRouteExists($route, $data, $output); | ||
|
||
/** | ||
* in case the view\/*\/before event is not activated by default we can call | ||
* $this->event->register('view/\*\/before', new Action('startup/opencore/before_view')); | ||
*/ | ||
} | ||
|
||
/** | ||
* Adds admin menu entries | ||
* | ||
* @param string $route | ||
* @param array $data | ||
*/ | ||
public function before_view($route, &$data) | ||
{ | ||
if (isset($this->booted[$route])) { | ||
return; | ||
} | ||
|
||
switch ($route) { | ||
case 'common/column_left': | ||
//adding entries into admin menu for OpenCore panel | ||
$data['menus'][] = [ | ||
'id' => 'opencore-menu', | ||
'icon' => 'fa-cube', | ||
'name' => 'OpenCore', | ||
'href' => $this->url->link('core/home', $this->getTokenStr()), | ||
'children' => [] | ||
]; | ||
break; | ||
case 'user/user_group_form': | ||
//adding permissions into admin user/permissions page for OpenCore panel | ||
$data['permissions'][] = 'core/*'; | ||
|
||
//get modules | ||
$modules = app('modules')->all(); | ||
foreach ($modules as $module) { | ||
if ($module->enabled()) { | ||
$data['permissions'][] = strtolower($module->getName()) . '/*'; | ||
} | ||
} | ||
break; | ||
} | ||
|
||
$this->booted($route); | ||
} | ||
|
||
private function booted($route) | ||
{ | ||
$this->booted[$route] = true; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
opencart-module/3.x/upload/admin/language/en-gb/extension/module/opencore.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
// Heading | ||
$_['heading_title'] = 'OpenCore'; | ||
|
||
// Text | ||
$_['text_extension'] = 'Extensions'; | ||
$_['text_success'] = 'Success: Your module has been successfully installed into your system!'; | ||
|
||
// Errors | ||
$_['error_instalation_failure'] = 'Warning: OpenCore module is not installed properly! Please uninstall & reinstall this module to avoid system failure!'; | ||
$_['error_router'] = 'OpenCore Router could not be initialize!'; | ||
$_['error_modification_entry'] = 'Missing modifications table entry!'; | ||
$_['error_modification_status'] = 'OpenCore modification entry is disabled!'; | ||
$_['error_modification_empty_xml'] = 'OpenCore modification XML is empty!'; | ||
$_['error_htaccess_not_found'] = 'Missing .htaccess file from admin folder'; |
15 changes: 15 additions & 0 deletions
15
opencart-module/3.x/upload/admin/language/ro-ro/extension/module/opencore.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
// Heading | ||
$_['heading_title'] = 'OpenCore'; | ||
|
||
// Text | ||
$_['text_extension'] = 'Extensii'; | ||
$_['text_success'] = 'Succes: Modulul a fost instalat cu succes!'; | ||
|
||
// Errors | ||
$_['error_instalation_failure'] = 'Atentie: modulul OpenCore nu este instalat corect! Va rugam sa dezinstalati & sa reinstalati acest modul pentru a evita o eroare de system!'; | ||
$_['error_router'] = 'Ruterul OpenCore nu functioneaza!'; | ||
$_['error_modification_entry'] = 'Lipsa intrare tabela modificari!'; | ||
$_['error_modification_status'] = 'Modificarea pentru OpenCore este dezactivata!'; | ||
$_['error_modification_empty_xml'] = 'Lipsa cod XML pentru modificarea OpenCore!'; | ||
$_['error_htaccess_not_found'] = 'Lipseste fisierul .htaccess din folderul admin'; |
33 changes: 33 additions & 0 deletions
33
opencart-module/3.x/upload/admin/view/template/extension/module/opencore.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{{ header }}{{ column_left }} | ||
<div id="content"> | ||
<div class="page-header"> | ||
<div class="container-fluid"> | ||
<h1>{{ heading_title }}</h1> | ||
<ul class="breadcrumb"> | ||
{% for breadcrumb in breadcrumbs %} | ||
<li><a href="{{ breadcrumb['href'] }}">{{ breadcrumb['text'] }}</a></li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
</div> | ||
<div class="container-fluid"> | ||
{% if success_message %} | ||
<div class="alert alert-success"><i class="fa fa-exclamation-circle"></i> {{ success_message }} | ||
<button type="button" class="close" data-dismiss="alert">×</button> | ||
</div> | ||
{% endif %} | ||
{% if error is defined %} | ||
<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> {{ error_instalation_failure }} | ||
<button type="button" class="close" data-dismiss="alert">×</button> | ||
</div> | ||
{% endif %} | ||
{% if error is defined %} | ||
{% for error in errors %} | ||
<div class="alert alert-warning"><i class="fa fa-exclamation-circle"></i> {{ error }} | ||
<button type="button" class="close" data-dismiss="alert">×</button> | ||
</div> | ||
{% endfor %} | ||
{% endif %} | ||
</div> | ||
</div> | ||
{{ footer }} |
56 changes: 56 additions & 0 deletions
56
opencart-module/3.x/upload/catalog/controller/startup/opencore.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/* | ||
* Created on Fri Dec 13 2019 by DaRock | ||
* | ||
* Aweb Design | ||
* https://www.awebdesign.ro | ||
* | ||
*/ | ||
|
||
require_once realpath(__DIR__ . '/../../../') . '/core/support/Opencart/Startup.php'; | ||
|
||
use OpenCore\Support\Opencart\Startup; | ||
use OpenCore\Support\OpenCart\OcCore; | ||
|
||
class ControllerStartupOpencore extends Startup | ||
{ | ||
use OcCore; | ||
|
||
/* static $booted = false; */ | ||
|
||
/** | ||
* This method is executed everytime before loading any controller | ||
* | ||
* @param string $route | ||
* @param array $data | ||
* @return string | ||
*/ | ||
function before_controller($route, &$data, &$output = false) | ||
{ | ||
/* if (self::$booted) { | ||
return false; | ||
} */ | ||
|
||
/** | ||
* Check if a laravel route exists and if so execute it | ||
* else return NULL | ||
*/ | ||
return $this->executeIfRouteExists($route, $data, $output); | ||
|
||
/** | ||
* in case the view\/*\/before event is not activated by default we can call | ||
* $this->event->register('view/\*\/before', new Action('startup/opencore/before_view')); | ||
*/ | ||
} | ||
|
||
/** | ||
* Before loading views event | ||
* | ||
* @param string $route | ||
* @param array $data | ||
*/ | ||
/* public function before_view($route, &$data) | ||
{ | ||
return null; | ||
} */ | ||
} |
Oops, something went wrong.