This commit is contained in:
Kavalar 2025-01-21 17:10:03 +03:00
commit 67b3f62728
545 changed files with 22943 additions and 66 deletions

View File

@ -3,6 +3,7 @@
namespace kernel\services;
use DirectoryIterator;
use GuzzleHttp\Exception\GuzzleException;
use kernel\EntityRelation;
use kernel\Flash;
use kernel\helpers\Debug;
@ -19,6 +20,12 @@ class ModuleService
protected null|bool $serverAvailable = null;
public ModuleShopService $moduleShopService;
public function __construct()
{
$this->moduleShopService = new ModuleShopService();
}
/**
* @param string $module
* @return false|array|string
@ -458,12 +465,13 @@ class ModuleService
return false;
}
/**
* @throws GuzzleException
*/
public function isLastVersion(string $slug): bool
{
if ($this->isServerAvailable()) {
$modules_info = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug');
$modules_info = json_decode($modules_info->getBody()->getContents(), true);
$modules_info = $this->moduleShopService->getGroupedBySlugModules();
$mod_info = $this->getModuleInfoBySlug($slug);
@ -491,16 +499,18 @@ class ModuleService
return false;
}
/**
* @throws GuzzleException
*/
public function isShopModule(string $slug): bool
{
if ($this->isServerAvailable()) {
$modules_info = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug');
$modules_info = $this->moduleShopService->getGroupedBySlugModules();
if (!$this->issetModuleShopToken()) {
return false;
}
$modules_info = json_decode($modules_info->getBody()->getContents(), true);
if (isset($modules_info)) {
$mod_info = $this->getModuleInfoBySlug($slug);
foreach ($modules_info as $mod) {

View File

@ -3,7 +3,11 @@
namespace kernel\services;
use GuzzleHttp\Exception\GuzzleException;
use kernel\Flash;
use kernel\helpers\Debug;
use kernel\helpers\Files;
use kernel\helpers\RESTClient;
use kernel\Request;
class ModuleShopService
{
@ -17,20 +21,71 @@ class ModuleShopService
}
/**
* @param string $email
* @return mixed
* @throws GuzzleException
*/
public function email_auth(string $email)
public function email_auth(string $email): mixed
{
$request = RESTClient::post($this->url . "/api/secure/email_auth", ['email' => $email], false);
return json_decode($request->getBody()->getContents(), true);
}
public function code_check(string $code)
/**
* @param string $code
* @return mixed
* @throws GuzzleException
*/
public function code_check(string $code): mixed
{
$request = RESTClient::post($this->url . "/api/secure/code_check", ['code' => $code], false);
return json_decode($request->getBody()->getContents(), true);
}
/**
* @return mixed
* @throws GuzzleException
*/
public function getGroupedBySlugModules(): mixed
{
$modulesInfo = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug');
return json_decode($modulesInfo->getBody()->getContents(), true);
}
/**
* @param string $slug
* @return void
* @throws GuzzleException
*/
public function installModule(string $slug): void
{
$moduleInfo = $this->getModuleInfoBySlug($slug);
$moduleInfo = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/install/' . $moduleInfo['id']);
$moduleInfo = json_decode($moduleInfo->getBody()->getContents(), true);
Files::uploadByUrl($_ENV['MODULE_SHOP_URL'] . $moduleInfo['path_to_archive'], RESOURCES_DIR . "/tmp/modules");
(new ModuleService())->installModule('/resources/tmp/modules/' . basename($moduleInfo['path_to_archive']));
}
/**
* @param string $slug
* @return false|mixed
* @throws GuzzleException
*/
public function getModuleInfoBySlug(string $slug): mixed
{
$modulesInfo = $this->getGroupedBySlugModules();
foreach ($modulesInfo as $module) {
if ($module['slug'] === $slug) {
return $module;
}
}
return false;
}
}

View File

@ -3,6 +3,7 @@
namespace kernel\services;
use DirectoryIterator;
use kernel\Flash;
use kernel\helpers\Debug;
use kernel\helpers\Files;
use kernel\helpers\Manifest;
@ -19,12 +20,14 @@ class ThemeService
protected ModuleService $moduleService;
protected ModuleShopService $moduleShopService;
public function __construct()
{
$this->option = new Option();
$this->findActiveTheme();
$this->moduleService = new ModuleService();
$this->moduleShopService = new ModuleShopService();
}
/**
@ -55,7 +58,13 @@ class ThemeService
return $this->active_theme;
}
public function setActiveTheme(string $theme): void
/**
* @param string $theme
* @return bool
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function setActiveTheme(string $theme): bool
{
$activeTheme = $this->option::where("key", "active_theme")->first();
@ -63,21 +72,25 @@ class ThemeService
if (isset($themeInfo['dependence'])) {
$dependence_array = explode(',', $themeInfo['dependence']);
foreach ($dependence_array as $depend) {
$this->moduleService->runInitScript($depend);
}
}
$currentThemeInfo = $this->getActiveThemeInfo();
if (isset($currentThemeInfo['dependence'])) {
$dependence_array = explode(',', $currentThemeInfo['dependence']);
foreach ($dependence_array as $depend) {
$this->moduleService->runDeactivateScript($depend);
if (!$this->moduleService->isInstall($depend)) {
if ($this->moduleService->isShopModule($depend)) {
$this->moduleShopService->installModule($depend);
} else {
Flash::setMessage("error", "Модуль не найден в IT Guild Framework Shop.");
return false;
}
} else {
if (!$this->moduleService->isActive($depend)) {
$this->moduleService->setActiveModule($depend);
}
}
}
}
$activeTheme->value = getConst($theme);
$activeTheme->save();
return true;
}
public function getActiveThemeInfo(): false|array|string

View File

@ -9,5 +9,5 @@
"resource": "/resources/themes/default",
"resource_path": "{RESOURCES}/themes/default",
"routs": "routs/default.php",
"dependence": "user,option,menu,secure"
"dependence": ""
}

View File

@ -79,7 +79,5 @@ if ($moduleService->isActive('module_shop_client')) {
ModuleTabsWidget::create()->run();
}
$table->create();
$table->render();

View File

@ -1,9 +1,9 @@
// Responsive images (ensure images don't scale beyond their parents)
// Responsive default_user_photo (ensure default_user_photo don't scale beyond their parents)
//
// This is purposefully opt-in via an explicit class rather than being the default for all `<img>`s.
// We previously tried the "images are responsive by default" approach in Bootstrap v2,
// We previously tried the "default_user_photo are responsive by default" approach in Bootstrap v2,
// and abandoned it in Bootstrap v3 because it breaks lots of third-party widgets (including Google Maps)
// which weren't expecting the images within themselves to be involuntarily resized.
// which weren't expecting the default_user_photo within themselves to be involuntarily resized.
// See also https://github.com/twbs/bootstrap/issues/18178
.img-fluid {
@include img-fluid;

View File

@ -249,7 +249,7 @@ figure {
img {
vertical-align: middle;
border-style: none; // Remove the border on images inside links in IE 10-.
border-style: none; // Remove the border on default_user_photo inside links in IE 10-.
}
svg {

View File

@ -5,12 +5,12 @@
// Responsive image
//
// Keep images from scaling beyond the width of their parents.
// Keep default_user_photo from scaling beyond the width of their parents.
@mixin img-fluid {
// Part 1: Set a maximum relative to the parent
max-width: 100%;
// Part 2: Override the height to auto, otherwise images will be stretched
// Part 2: Override the height to auto, otherwise default_user_photo will be stretched
// when setting a width and height attribute on the img element.
height: auto;
}

View File

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 120 KiB

View File

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

File diff suppressed because one or more lines are too long

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Some files were not shown because too many files have changed in this diff Show More