Skip to content

Commit

Permalink
Merge pull request #5 from opencorero/dev
Browse files Browse the repository at this point in the history
Version update
  • Loading branch information
opencorero authored Jan 20, 2020
2 parents 1f8af43 + 8ef6280 commit efb1054
Show file tree
Hide file tree
Showing 21 changed files with 632 additions and 8 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align="center"><img src="https://opencore.me/images/logo/opencore-logo-large-transparent.png" width="180" alt="OpenCore"></h1>
<h1 align="center"><img src="https://opencore.me/images/logo/opencore-logo-large-transparent.png" width="250" alt="OpenCore"></h1>

**An application build on Laravel which can run as a subsystem for OpenCart system.**

Expand Down Expand Up @@ -51,7 +51,7 @@ admin / setting / server / Use SEO URLs: Yes
6. php artisan key:generate
7. php artisan migrate:install
8. php artisan migrate
9. copy OpenCart extension files from core/opencart-module/2.3/upload to you OpenCart root folder
9. copy OpenCart extension files from core/opencart-module/(2.x|3.x)/upload to you OpenCart root folder
10. go to OpenCart admin panel / extensions / extensions / modules, find OpenCore module and install it
11. click on the OpenCore icon from admin / left column / section "System Requirements" and make sure there's nothing marked with red
12. Optional: in order to enable Developer & Example modules you need to access admin / user / user groups section and add permission for them
Expand Down Expand Up @@ -117,5 +117,12 @@ MIT license. Please see the [license file](LICENSE) for more information.

## Screenshots

<img src="https://opencore.me/images/screenshots/screenshot-opencore-home.png">
<img src="https://opencore.me/images/screenshots/screenshot-opencore-home-2.png">
<img alt="OpenCore home OpenCart 2x" src="https://opencore.me/images/screenshots/home-2x.png">
<img alt="OpenCore home OpenCart 3x" src="https://opencore.me/images/screenshots/home-3x.png">
<img alt="System Requirements" src="https://opencore.me/images/screenshots/system-requirements.png">
<img alt="OpenCore Modules management" src="https://opencore.me/images/screenshots/modules-management.png">
<img alt="Developer Module" src="https://opencore.me/images/screenshots/developer-module.png">
<img alt="Logs Dashboard" src="https://opencore.me/images/screenshots/logs-dashboard.png">
<img alt="Tasks" src="https://opencore.me/images/screenshots/tasks-module.png">
<img alt="Add Task" src="https://opencore.me/images/screenshots/tasks-module-add.png">
<img alt="Example Module" src="https://opencore.me/images/screenshots/example-module.png">
4 changes: 3 additions & 1 deletion app/Http/Middleware/AdminMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ public function handle(Request $request, Closure $next)

$session = Startup::getRegistry('session');

$tokenKey = getTokenKey();

/** check if OpenCart admin token is present and if is valid */
if(empty($session->data['token']) || empty($request->get('token')) || $session->data['token'] != $request->get('token')) {
if(empty($session->data[$tokenKey]) || empty($request->get($tokenKey)) || $session->data[$tokenKey] != $request->get($tokenKey)) {
return redirect(basename(DIR_APPLICATION) . '/login');
}

Expand Down
File renamed without changes.
Binary file added opencart-module/3.x/opencore.ocmod.zip
Binary file not shown.
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 opencart-module/3.x/upload/admin/controller/startup/opencore.php
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;
}
}
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';
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';
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">&times;</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">&times;</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">&times;</button>
</div>
{% endfor %}
{% endif %}
</div>
</div>
{{ footer }}
56 changes: 56 additions & 0 deletions opencart-module/3.x/upload/catalog/controller/startup/opencore.php
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;
} */
}
Loading

0 comments on commit efb1054

Please sign in to comment.