Skip to content

Commit

Permalink
Merge branch 'develop' into wip-laravel-11
Browse files Browse the repository at this point in the history
  • Loading branch information
mjauvin committed Nov 13, 2024
2 parents de72b46 + 65ab300 commit 059c4c5
Show file tree
Hide file tree
Showing 49 changed files with 1,578 additions and 365 deletions.
7 changes: 7 additions & 0 deletions modules/backend/console/scaffold/controller/controller.stub
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ class {{ studly_name }} extends Controller
\Backend\Behaviors\ListController::class,
];

/**
* @var array Permissions required to view this page.
*/
protected $requiredPermissions = [
'{{ lower_author }}.{{ lower_plugin }}.{{ lower_name }}.manage_all',
];

public function __construct()
{
parent::__construct();
Expand Down
2 changes: 1 addition & 1 deletion modules/backend/formwidgets/repeater/assets/js/repeater.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
return $textInput.val()
}
} else {
var $disabledTextInput = $('.text-field:first > .form-control', $target)
var $disabledTextInput = $('.form-control:first', $target)
if ($disabledTextInput.length) {
return $disabledTextInput.text()
}
Expand Down
5 changes: 5 additions & 0 deletions modules/backend/lang/ru/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'options_method_not_exists' => "Класс модели :model должен содержать метод :method(), возвращающий опции для поля формы ':field'.",
'options_static_method_invalid_value' => "Статический метод ':method()' в :class не вернул допустимый массив параметров.",
'colors_method_not_exists' => "Класс модели :model должен содержать метод :method(), возвращающий HTML цвет в HEX для поля формы ':field'.",
'colors_invalid_input' => 'Указанное значение цвета недействительно. Попробуйте ещё раз.',
],
'widget' => [
'not_registered' => "Класс виджета ':name' не зарегистрирован.",
Expand Down Expand Up @@ -370,12 +371,16 @@
'warnings' => [
'tips' => 'Подсказки по конфигурации системы',
'tips_description' => 'Есть проблемы на которые стоит обратить внимание, чтобы правильно настроить систему.',
'how_to_fix' => 'Как исправить',
'permissions' => 'Каталог :name или его подкаталоги недоступны для записи. Укажите соответствующие разрешения для веб-сервера.',
'extension' => 'Расширение PHP :name не установлено. Установите эту библиотеку и активируйте расширение.',
'plugin_missing' => 'Плагин :name имеет зависимость. Установите этот плагин.',
'debug' => 'Режим отладки включен. Это не рекомендуется для рабочих инсталяций.',
'decompileBackendAssets' => 'Ассеты в бэкенде в настоящее время декомпилированы. Это не рекомендуется для рабочих инсталяций.',
'default_backend_user' => 'Был обнаружен пользователь с данными для входа по умолчанию (admin / [email protected]). Измените ему имя пользователя и/или email-адрес, чтобы защитить систему.',
'auth_throttle_disabled' => 'Отключён контроль бэкенд авторизации. Это не рекомендуется для рабочих инсталяций, так как это может позволить злоумышленникам подбирать пароли пользователей методом подбора.',
'csrf' => 'Защита CSRF отключена. Это не рекомендуется для рабочих инсталяций, поскольку это ставит под угрозу безопасность установки и может допустить атаки с использованием межсайтового скриптинга.',
'restrict_base_dir' => 'Ограничение базового каталога отключено. Это не рекомендуется для рабочих инсталяций, так как это может позволить темам и файлам конфигурации получать доступ к файлам за пределами вашей установки Winter CMS.',
],
'editor' => [
'menu_label' => 'Настройки редактора',
Expand Down
2 changes: 1 addition & 1 deletion modules/backend/layouts/_head.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=0, minimal-ui">
<meta name="robots" content="noindex">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="app-timezone" content="<?= e(Config::get('app.timezone')) ?>">
<meta name="backend-base-path" content="<?= Backend::baseUrl() ?>">
<meta name="backend-timezone" content="<?= e(Backend\Models\Preference::get('timezone')) ?>">
Expand Down
2 changes: 1 addition & 1 deletion modules/backend/layouts/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=0">
<meta name="robots" content="noindex">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="backend-base-path" content="<?= Backend::baseUrl() ?>">
<meta name="csrf-token" content="<?= csrf_token() ?>">
<link rel="icon" type="image/png" href="<?= e(Backend\Models\BrandSetting::getFavicon()) ?>">
Expand Down
7 changes: 3 additions & 4 deletions modules/backend/widgets/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public function setFormValues($data = null)
public function onRefresh()
{
$result = [];
$saveData = $this->getSaveData(true);
$saveData = $this->getSaveData();

/**
* @event backend.form.beforeRefresh
Expand Down Expand Up @@ -1172,10 +1172,9 @@ protected function showFieldLabels($field)
/**
* Returns post data from a submitted form.
*/
public function getSaveData(bool $includeAllFields = false): array
public function getSaveData(): array
{
$this->defineFormFields();
$this->applyFiltersFromModel();

$result = [];

Expand All @@ -1194,7 +1193,7 @@ public function getSaveData(bool $includeAllFields = false): array
/*
* Disabled and hidden should be omitted from data set
*/
if (!$includeAllFields && ($field->disabled || $field->hidden)) {
if ($field->disabled || $field->hidden) {
continue;
}

Expand Down
8 changes: 1 addition & 7 deletions modules/backend/widgets/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,8 @@ public function init()
$this->dataSource = new $dataSourceClass($this->recordsKeyFrom);

if (Request::method() == 'POST' && $this->isClientDataSource()) {
if (strpos($this->fieldName, '[') === false) {
$requestDataField = $this->fieldName . 'TableData';
} else {
$requestDataField = $this->fieldName . '[TableData]';
}

// Use dot notation for request data field
$requestDataField = implode('.', HtmlHelper::nameToArray($requestDataField));
$requestDataField = implode('.', HtmlHelper::nameToArray($this->fieldName));

if (Request::exists($requestDataField)) {
// Load data into the client memory data source on POST
Expand Down
4 changes: 2 additions & 2 deletions modules/backend/widgets/table/assets/js/build-min.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ return}for(var i=0,len=this.options.columns.length;i<len;i++){var column=this.op
if(this.cellProcessors[column].onKeyDown(ev)===false){return}}if(this.navigation.onKeydown(ev)===false){return}if(this.search.onKeydown(ev)===false){return}}
Table.prototype.onFormSubmit=function(ev,data){if(data.handler==this.options.postbackHandlerName){this.unfocusTable()
if(!this.validate()){ev.preventDefault()
return}var fieldName=this.options.fieldName.indexOf('[')>-1?this.options.fieldName+'[TableData]':this.options.fieldName+'TableData'
data.options.data[fieldName]=this.dataSource.getAllData()}}
return}
data.options.data[this.options.fieldName]=this.dataSource.getAllData()}}
Table.prototype.onToolbarClick=function(ev){var target=this.getEventTarget(ev),cmd=target.getAttribute('data-cmd')
if(!cmd){return}switch(cmd){case'record-add':case'record-add-below':this.addRecord('below')
break
Expand Down
6 changes: 1 addition & 5 deletions modules/backend/widgets/table/assets/js/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -811,11 +811,7 @@
return
}

var fieldName = this.options.fieldName.indexOf('[') > -1
? this.options.fieldName + '[TableData]'
: this.options.fieldName + 'TableData'

data.options.data[fieldName] = this.dataSource.getAllData()
data.options.data[this.options.fieldName] = this.dataSource.getAllData()
}
}

Expand Down
46 changes: 39 additions & 7 deletions modules/cms/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@

use Backend;
use Backend\Classes\WidgetManager;
use Backend\Facades\BackendAuth;
use Backend\Facades\BackendMenu;
use Backend\Models\UserRole;
use BackendAuth;
use BackendMenu;
use Cms\Classes\CmsController;
use Cms\Classes\CmsObject;
use Cms\Classes\ComponentManager;
use Cms\Classes\Page as CmsPage;
use Cms\Classes\Router;
use Cms\Classes\Theme;
use Cms\Models\ThemeData;
use Cms\Models\ThemeLog;
use Cms\Twig\DebugExtension;
use Cms\Twig\Extension as CmsTwigExtension;
use Cms\Twig\Loader as CmsTwigLoader;
use Config;
use Event;
use File;
use Lang;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\View;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use System\Classes\CombineAssets;
use System\Classes\MarkupManager;
use System\Classes\SettingsManager;
use Twig\Cache\FilesystemCache as TwigCacheFilesystem;
use Url;
use Winter\Storm\Support\Facades\Event;
use Winter\Storm\Support\Facades\Url;
use Winter\Storm\Support\ModuleServiceProvider;

class ServiceProvider extends ModuleServiceProvider
Expand All @@ -37,6 +40,7 @@ public function register()
parent::register();

$this->registerConsole();
$this->registerErrorHandler();
$this->registerTwigParser();
$this->registerAssetBundles();
$this->registerComponents();
Expand Down Expand Up @@ -84,6 +88,34 @@ protected function registerConsole()
$this->registerConsoleCommand('theme.sync', \Cms\Console\ThemeSync::class);
}

/**
* Error handling for abort() errors
*/
protected function registerErrorHandler()
{
$this->app->error(function (HttpExceptionInterface $exception, $code, $fromConsole) {
$theme = Theme::getActiveTheme();
$controller = new CmsController($theme);
if ($code === 404) {
return Response::make($controller->run('/404')->original, 404, []);
}

if (!Config::get('app.debug', false)) {
$router = new Router($theme);
// Use the default view if no "/error" URL is found.
if (!$router->findByUrl('/error')) {
$result = View::make('cms::error');
} else {
// Route to the CMS error page.
$controller = new CmsController($theme);
$result = $controller->run('/error')->original;
}

return Response::make($result, $code, []);
}
});
}

/*
* Register Twig Environments and other Twig modifications provided by the module
*/
Expand Down
2 changes: 1 addition & 1 deletion modules/cms/classes/CmsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct()
* Finds and serves the request using the primary controller.
* @param string $url Specifies the requested page URL.
* If the parameter is omitted, the current URL used.
* @return string Returns the processed page content.
* @return BaseResponse Returns the response to the provided URL
*/
public function run($url = '/')
{
Expand Down
4 changes: 2 additions & 2 deletions modules/cms/classes/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public static function getMenuTypeInfo(string $type)
*
* @param \Winter\Sitemap\Classes\DefinitionItem|\Winter\Pages\Classes\MenuItem $item Specifies the menu item.
*/
public static function resolveMenuItem(object $item, string $url, Theme $theme): ?array
public static function resolveMenuItem(object $item, string $url, Theme $theme, bool $routePersistence = false): ?array
{
$result = null;

Expand All @@ -202,7 +202,7 @@ public static function resolveMenuItem(object $item, string $url, Theme $theme):
}

$controller = Controller::getController() ?: new Controller;
$pageUrl = $controller->pageUrl($item->reference, [], false);
$pageUrl = $controller->pageUrl($item->reference, [], $routePersistence);

$result = [];
$result['url'] = $pageUrl;
Expand Down
2 changes: 1 addition & 1 deletion modules/cms/console/CreateTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected function getNameInput(): string
*/
protected function prepareVars(): array
{
$scaffold = $this->argument('scaffold') ?? 'less';
$scaffold = $this->argument('scaffold') ?? 'tailwind';
$validOptions = $this->suggestScaffoldValues();
if (!in_array($scaffold, $validOptions)) {
throw new InvalidArgumentException("$scaffold is not an available theme scaffold type (Available types: " . implode(', ', $validOptions) . ')');
Expand Down
4 changes: 3 additions & 1 deletion modules/system/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ assets/vendor
# Ignore test fixtures
tests/js
tests/fixtures/themes/test/assets/js
tests/fixtures/themes/vitetest/assets/javascript
tests/fixtures/themes/npmtest
tests/fixtures/themes/assettest
tests/fixtures/plugins/mix
23 changes: 12 additions & 11 deletions modules/system/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

use Backend;
use Backend\Classes\WidgetManager;
use Backend\Facades\BackendAuth;
use Backend\Facades\BackendMenu;
use Backend\Models\UserRole;
use BackendAuth;
use BackendMenu;
use Config;
use DateInterval;
use Event;
use Illuminate\Foundation\Vite as LaravelVite;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Schema;
use Markdown;
use Request;
use Illuminate\Support\Facades\View;
use System\Classes\CombineAssets;
use System\Classes\ErrorHandler;
use System\Classes\MailManager;
Expand All @@ -24,13 +23,14 @@
use System\Models\EventLog;
use System\Models\MailSetting;
use System\Twig\Engine as TwigEngine;
use SystemException;
use Twig\Environment;
use Twig\Extension\CoreExtension;
use Validator;
use View;
use Winter\Storm\Exception\SystemException;
use Winter\Storm\Router\Helper as RouterHelper;
use Winter\Storm\Support\ClassLoader;
use Winter\Storm\Support\Facades\Event;
use Winter\Storm\Support\Facades\Markdown;
use Winter\Storm\Support\Facades\Validator;
use Winter\Storm\Support\ModuleServiceProvider;

class ServiceProvider extends ModuleServiceProvider
Expand Down Expand Up @@ -333,8 +333,9 @@ protected function registerConsole()
$this->registerConsoleCommand('vite.list', Console\Asset\Vite\ViteList::class);
$this->registerConsoleCommand('vite.watch', Console\Asset\Vite\ViteWatch::class);

$this->registerConsoleCommand('npm.run', Console\Asset\NpmRun::class);
$this->registerConsoleCommand('npm.update', Console\Asset\NpmUpdate::class);
$this->registerConsoleCommand('npm.run', Console\Asset\Npm\NpmRun::class);
$this->registerConsoleCommand('npm.install', Console\Asset\Npm\NpmInstall::class);
$this->registerConsoleCommand('npm.update', Console\Asset\Npm\NpmUpdate::class);
}

/*
Expand Down
15 changes: 11 additions & 4 deletions modules/system/classes/asset/PackageJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,24 @@ class PackageJson
/**
* The contents of the package.json being modified
*/
protected array $data;
protected array $data = [];

/**
* Create a new instance with optional path, loads file if file already exists
* @throws \JsonException
*/
public function __construct(
protected ?string $path = null
) {
$this->data = File::exists($this->path)
? json_decode(File::get($this->path), JSON_OBJECT_AS_ARRAY)
: [];
if (File::exists($this->path)) {
// Test the json to insure it's valid
$json = json_decode(File::get($this->path), JSON_OBJECT_AS_ARRAY);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \JsonException('The contents of the file "' . $this->path . '" is not valid json.');
}

$this->data = $json;
}
}

/**
Expand Down
Loading

0 comments on commit 059c4c5

Please sign in to comment.