Skip to content

Commit

Permalink
Merge pull request #11 from opencorero/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
opencorero authored Feb 5, 2020
2 parents d5e0d61 + fc4a2a0 commit 73c86d3
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 32 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
"nwidart/laravel-modules": "^4.1",
"rachidlaasri/laravel-installer": "^4.0",
"symfony/yaml": "^3.0",
"laravelcollective/html": "~5.0"
"laravelcollective/html": "~5.0",
"arcanedev/log-viewer": "^4.7",
"studio/laravel-totem": "^5.3"
},
"require-dev": {
"arcanedev/log-viewer": "^4.7",
"barryvdh/laravel-debugbar": "^3.2",
"beyondcode/laravel-dump-server": "^1.0",
"facade/ignition": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^7.5",
"studio/laravel-totem": "^5.3"
"phpunit/phpunit": "^7.5"
},
"config": {
"platform": {
Expand Down
4 changes: 2 additions & 2 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
|
*/

'locale' => 'en',
'locale' => env('APP_LOCALE', 'en'),

/*
|--------------------------------------------------------------------------
Expand All @@ -93,7 +93,7 @@
|
*/

'fallback_locale' => 'en',
'fallback_locale' => env('APP_LOCALE_FALLBACK', 'en'),

/*
|--------------------------------------------------------------------------
Expand Down
Binary file modified opencart-module/2.x/opencore.ocmod.zip
Binary file not shown.
11 changes: 7 additions & 4 deletions opencart-module/2.x/upload/admin/controller/startup/opencore.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ public function before_view($route, &$data)
$data['permissions'][] = 'core/*';

//get modules
$modules = app('modules')->all();
foreach ($modules as $module) {
if ($module->enabled()) {
$data['permissions'][] = strtolower($module->getName()) . '/*';
if (is_dir(realpath(DIR_APPLICATION . '../core/modules'))) {
foreach (glob(realpath(DIR_APPLICATION . '../core/modules') . '/*/module.json') as $path) {
$moduleManifest = json_decode(file_get_contents($path));
if (!json_last_error() && !empty($moduleManifest->active)) {
$moduleName = strtolower(basename(str_replace('/module.json', '', $path)));
$data['permissions'][] = $moduleName . '/*';
}
}
}
break;
Expand Down
Binary file modified opencart-module/3.x/opencore.ocmod.zip
Binary file not shown.
11 changes: 7 additions & 4 deletions opencart-module/3.x/upload/admin/controller/startup/opencore.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ public function before_view($route, &$data)
$data['permissions'][] = 'core/*';

//get modules
$modules = app('modules')->all();
foreach ($modules as $module) {
if ($module->enabled()) {
$data['permissions'][] = strtolower($module->getName()) . '/*';
if (is_dir(realpath(DIR_APPLICATION . '../core/modules'))) {
foreach (glob(realpath(DIR_APPLICATION . '../core/modules') . '/*/module.json') as $path) {
$moduleManifest = json_decode(file_get_contents($path));
if (!json_last_error() && !empty($moduleManifest->active)) {
$moduleName = strtolower(basename(str_replace('/module.json', '', $path)));
$data['permissions'][] = $moduleName . '/*';
}
}
}
break;
Expand Down
13 changes: 12 additions & 1 deletion support/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,20 @@ function token_field()
}
}

if (! function_exists('module_version')) {
if (!function_exists('module_version')) {
function module_version(\Nwidart\Modules\Laravel\Module $module)
{
return $module->version;
}
}

if (!function_exists('module_asset')) {
function module_asset($asset)
{
$url = Module::asset($asset);

$url = substr_replace($url, 'https://', 0, 2);

return $url;
}
}
38 changes: 21 additions & 17 deletions support/Opencart/Startup.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@
}

if (!defined('OPENCORE_VERSION')) {
define('OPENCORE_VERSION', '1.2.3');
define('OPENCORE_VERSION', '1.2.2');
}

require_once __DIR__ . '/../../Framework.php';

use Exception;
use Opencore\Framework;
use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;

class Startup extends \Controller
{
Expand Down Expand Up @@ -130,13 +135,14 @@ public function checkOpenCoreRoute()
$allowed_routes = [];

if (!$allowed_routes = $this->cache->get('opencore_routes')) {
$query = $this->db->query("SELECT method, uri FROM `" . DB_PREFIX . "opencore_routes` WHERE `status` = '1' ORDER BY uri");
$query = $this->db->query("SELECT method, name, uri FROM `opencore_routes` WHERE `status` = '1' ORDER BY uri");

if (!$query->num_rows)
return false;

foreach ($query->rows as $route) {
$allowed_routes[$route['method']][] = $route['uri'];
$name = $route['name'] ?? $route['uri'];
$allowed_routes[$route['method']][$name] = $route['uri'];
}

/**
Expand All @@ -147,22 +153,20 @@ public function checkOpenCoreRoute()

$requestMethod = $_SERVER['REQUEST_METHOD'];
if (!empty($allowed_routes[$requestMethod])) {
if (in_array($this->route, $allowed_routes[$requestMethod])) {
return true;
$routes = new RouteCollection();
$context = new RequestContext('/');

foreach ($allowed_routes[$requestMethod] as $name => $routeUri) {
$routeInstance = new Route($routeUri);
$routes->add($name, $routeInstance);
}

foreach ($allowed_routes[$requestMethod] as $route) {
if (preg_match_all('/\{(.*?)\??\}/', $route, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
foreach ($matches[0] as $match) {
$remainingUri = substr($this->route, $match[1], strlen($this->route));
$getSamePartFromRoute = strtok($remainingUri, '/');
$route = substr_replace($route, $getSamePartFromRoute, $match[1], strlen($match[0]));
}

if ($route === $this->route) {
return true;
}
}
$matcher = new UrlMatcher($routes, $context);

try {
return $matcher->match('/'.$this->route);
} catch(Exception $e) {
return false;
}
}

Expand Down

0 comments on commit 73c86d3

Please sign in to comment.