admine theme
This commit is contained in:
parent
e152e0f193
commit
aa913293ef
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Kernel",
|
"name": "Kernel",
|
||||||
"version": "0.2",
|
"version": "0.1",
|
||||||
"author": "ITGuild",
|
"author": "ITGuild",
|
||||||
"slug": "kernel",
|
"slug": "kernel",
|
||||||
"type": "kernel",
|
"type": "kernel",
|
||||||
|
@ -13,6 +13,7 @@ use kernel\helpers\RESTClient;
|
|||||||
use kernel\helpers\SMTP;
|
use kernel\helpers\SMTP;
|
||||||
use kernel\Mailing;
|
use kernel\Mailing;
|
||||||
use kernel\Request;
|
use kernel\Request;
|
||||||
|
use kernel\services\AdminThemeService;
|
||||||
use kernel\services\KernelService;
|
use kernel\services\KernelService;
|
||||||
use kernel\services\ModuleService;
|
use kernel\services\ModuleService;
|
||||||
use kernel\services\ModuleShopService;
|
use kernel\services\ModuleShopService;
|
||||||
@ -58,6 +59,7 @@ class ModuleShopClientController extends AdminController
|
|||||||
'module_count' => $module_count,
|
'module_count' => $module_count,
|
||||||
'per_page' => $per_page,
|
'per_page' => $per_page,
|
||||||
'kernelService' => new KernelService(),
|
'kernelService' => new KernelService(),
|
||||||
|
'adminThemeService' => new AdminThemeService(),
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$this->cgView->render("module_shop_error_connection.php");
|
$this->cgView->render("module_shop_error_connection.php");
|
||||||
|
@ -21,6 +21,10 @@ App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){
|
|||||||
App::$collector->get('/update_form', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionRenderKernelUpdateForm']);
|
App::$collector->get('/update_form', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionRenderKernelUpdateForm']);
|
||||||
App::$collector->post('/update', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionKernelUpdate']);
|
App::$collector->post('/update', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionKernelUpdate']);
|
||||||
});
|
});
|
||||||
|
App::$collector->group(["prefix" => "admin_theme"], function (RouteCollector $router) {
|
||||||
|
App::$collector->get('/install', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionAdminThemeInstall']);
|
||||||
|
App::$collector->post('/update', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionAdminThemeUpdate']);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -6,6 +6,7 @@
|
|||||||
* @var int $per_page
|
* @var int $per_page
|
||||||
* @var \kernel\services\ModuleService $moduleService
|
* @var \kernel\services\ModuleService $moduleService
|
||||||
* @var \kernel\services\KernelService $kernelService
|
* @var \kernel\services\KernelService $kernelService
|
||||||
|
* @var \kernel\services\AdminThemeService $adminThemeService
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Itguild\Tables\ListJsonTable;
|
use Itguild\Tables\ListJsonTable;
|
||||||
@ -52,7 +53,7 @@ $table->addAction(function ($row, $url) use ($moduleService){
|
|||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
$table->addAction(function ($row, $url) use ($moduleService, $kernelService){
|
$table->addAction(function ($row, $url) use ($moduleService) {
|
||||||
$slug = $row['slug'];
|
$slug = $row['slug'];
|
||||||
if ($moduleService->isInstall($slug)) {
|
if ($moduleService->isInstall($slug)) {
|
||||||
if (!$moduleService->isLastVersion($slug)) {
|
if (!$moduleService->isLastVersion($slug)) {
|
||||||
@ -62,6 +63,11 @@ $table->addAction(function ($row, $url) use ($moduleService, $kernelService){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$table->addAction(function ($row, $url) use ($kernelService) {
|
||||||
|
$slug = $row['slug'];
|
||||||
if ($slug === 'kernel') {
|
if ($slug === 'kernel') {
|
||||||
if (!$kernelService->isLastVersion()) {
|
if (!$kernelService->isLastVersion()) {
|
||||||
$url = "$url/kernel/update_form/";
|
$url = "$url/kernel/update_form/";
|
||||||
@ -73,6 +79,22 @@ $table->addAction(function ($row, $url) use ($moduleService, $kernelService){
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$table->addAction(function ($row, $url) use ($adminThemeService) {
|
||||||
|
$type = $row['type'];
|
||||||
|
$slug = $row['slug'];
|
||||||
|
if ($type === 'admin_theme') {
|
||||||
|
if ($adminThemeService->isInstall($slug)) {
|
||||||
|
if (!$adminThemeService->isLastVersion($slug)) {
|
||||||
|
$url = "$url/admin_theme/update/";
|
||||||
|
|
||||||
|
return \kernel\widgets\IconBtn\IconBtnUpdateWidget::create(['url' => $url])->run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
\kernel\widgets\ModuleTabsWidget::create()->run();
|
\kernel\widgets\ModuleTabsWidget::create()->run();
|
||||||
|
|
||||||
$table->create();
|
$table->create();
|
||||||
|
@ -2,20 +2,24 @@
|
|||||||
|
|
||||||
namespace kernel\services;
|
namespace kernel\services;
|
||||||
|
|
||||||
|
use DirectoryIterator;
|
||||||
use kernel\helpers\Debug;
|
use kernel\helpers\Debug;
|
||||||
use kernel\helpers\Manifest;
|
use kernel\helpers\Manifest;
|
||||||
|
use kernel\helpers\RESTClient;
|
||||||
use kernel\models\Option;
|
use kernel\models\Option;
|
||||||
|
|
||||||
class AdminThemeService
|
class AdminThemeService
|
||||||
{
|
{
|
||||||
protected Option $option;
|
protected Option $option;
|
||||||
protected string $active_theme;
|
protected string $active_theme;
|
||||||
|
protected ModuleService $moduleService;
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->option = new Option();
|
$this->option = new Option();
|
||||||
$this->findActiveAdminTheme();
|
$this->findActiveAdminTheme();
|
||||||
|
$this->moduleService = new ModuleService();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findActiveAdminTheme(): void
|
public function findActiveAdminTheme(): void
|
||||||
@ -56,4 +60,43 @@ class AdminThemeService
|
|||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isInstall(string $slug): bool
|
||||||
|
{
|
||||||
|
$adminThemePaths = Option::where("key", "admin_theme_paths")->first();
|
||||||
|
$dirs = [];
|
||||||
|
if ($adminThemePaths) {
|
||||||
|
$path = json_decode($adminThemePaths->value);
|
||||||
|
foreach ($path->paths as $p) {
|
||||||
|
$dirs[] = getConst($p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($dirs as $dir) {
|
||||||
|
foreach (new DirectoryIterator($dir) as $fileInfo) {
|
||||||
|
if ($fileInfo->isDot()) continue;
|
||||||
|
if ($this->getAdminThemeInfo($fileInfo->getPathname())['slug'] === $slug) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isLastVersion(string $slug): bool
|
||||||
|
{
|
||||||
|
if ($this->moduleService->isServerAvailable()) {
|
||||||
|
$modules_info = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug');
|
||||||
|
|
||||||
|
$modules_info = json_decode($modules_info->getBody()->getContents(), true);
|
||||||
|
|
||||||
|
$themeInfo = $this->getAdminThemeInfo($slug);
|
||||||
|
foreach ($modules_info as $mod) {
|
||||||
|
if ($mod['slug'] === $themeInfo['slug'] && $mod['version'] === $themeInfo['version']) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user