fix nullsafe warnings
This commit is contained in:
parent
3001293077
commit
03d8f64238
14 changed files with 102 additions and 68 deletions
|
@ -82,7 +82,7 @@ abstract class Action
|
||||||
$this->class_name = str_replace(__NAMESPACE__ . '\\Module\\', '', get_called_class());
|
$this->class_name = str_replace(__NAMESPACE__ . '\\Module\\', '', get_called_class());
|
||||||
$this->module = new dcModuleDefine('undefined');
|
$this->module = new dcModuleDefine('undefined');
|
||||||
|
|
||||||
$settings = dcCore::app()->blog->settings->get(My::id())->get('settings_' . $this->class_name);
|
$settings = dcCore::app()->blog?->settings->get(My::id())->get('settings_' . $this->class_name);
|
||||||
if (null != $settings) {
|
if (null != $settings) {
|
||||||
$settings = json_decode($settings, true);
|
$settings = json_decode($settings, true);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ abstract class Action
|
||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
// can overload priority by settings
|
// can overload priority by settings
|
||||||
if (1 < ($p = (int) dcCore::app()->blog->settings->get(My::id())->get('priority_' . $this->class_name))) {
|
if (1 < ($p = (int) dcCore::app()->blog?->settings->get(My::id())->get('priority_' . $this->class_name))) {
|
||||||
$this->priority = $p;
|
$this->priority = $p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,16 +232,18 @@ abstract class Action
|
||||||
*/
|
*/
|
||||||
final protected function redirect(string $url): bool
|
final protected function redirect(string $url): bool
|
||||||
{
|
{
|
||||||
dcCore::app()->blog->settings->get(My::id())->put(
|
if (!is_null(dcCore::app()->blog)) {
|
||||||
'settings_' . $this->class_name,
|
dcCore::app()->blog->settings->get(My::id())->put(
|
||||||
json_encode($this->settings),
|
'settings_' . $this->class_name,
|
||||||
'string',
|
json_encode($this->settings),
|
||||||
null,
|
'string',
|
||||||
true,
|
null,
|
||||||
true
|
true,
|
||||||
);
|
true
|
||||||
dcCore::app()->blog->triggerBlog();
|
);
|
||||||
dcPage::addSuccessNotice(__('Configuration successfully updated'));
|
dcCore::app()->blog->triggerBlog();
|
||||||
|
dcPage::addSuccessNotice(__('Configuration successfully updated'));
|
||||||
|
}
|
||||||
Http::redirect($url);
|
Http::redirect($url);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -31,6 +31,7 @@ class Backend extends dcNsProcess
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||||
|
&& !is_null(dcCore::app()->auth)
|
||||||
&& dcCore::app()->auth->isSuperAdmin()
|
&& dcCore::app()->auth->isSuperAdmin()
|
||||||
&& My::phpCompliant();
|
&& My::phpCompliant();
|
||||||
|
|
||||||
|
@ -43,18 +44,9 @@ class Backend extends dcNsProcess
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void {
|
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||||
$favs->register(
|
return false;
|
||||||
My::id(),
|
}
|
||||||
[
|
|
||||||
'title' => My::name(),
|
|
||||||
'url' => dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
|
||||||
'small-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
|
||||||
'large-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
|
||||||
//'permissions' => null,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||||
My::name(),
|
My::name(),
|
||||||
|
@ -64,6 +56,19 @@ class Backend extends dcNsProcess
|
||||||
dcCore::app()->auth->isSuperAdmin()
|
dcCore::app()->auth->isSuperAdmin()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void {
|
||||||
|
$favs->register(
|
||||||
|
My::id(),
|
||||||
|
[
|
||||||
|
'title' => My::name(),
|
||||||
|
'url' => dcCore::app()->adminurl?->get('admin.plugin.' . My::id()),
|
||||||
|
'small-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
||||||
|
'large-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
||||||
|
//'permissions' => null,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
$dir = __DIR__ . DIRECTORY_SEPARATOR . 'module' . DIRECTORY_SEPARATOR;
|
$dir = __DIR__ . DIRECTORY_SEPARATOR . 'module' . DIRECTORY_SEPARATOR;
|
||||||
$ns = __NAMESPACE__ . '\\Module\\';
|
$ns = __NAMESPACE__ . '\\Module\\';
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ class Config extends dcNsProcess
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||||
|
&& !is_null(dcCore::app()->auth)
|
||||||
&& dcCore::app()->auth->isSuperAdmin()
|
&& dcCore::app()->auth->isSuperAdmin()
|
||||||
&& My::phpCompliant();
|
&& My::phpCompliant();
|
||||||
|
|
||||||
|
@ -55,6 +56,10 @@ class Config extends dcNsProcess
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$pdisabled = '';
|
$pdisabled = '';
|
||||||
if (!empty($_POST['disabled']) && is_array($_POST['disabled'])) {
|
if (!empty($_POST['disabled']) && is_array($_POST['disabled'])) {
|
||||||
|
@ -84,8 +89,13 @@ class Config extends dcNsProcess
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$improve = new Core();
|
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||||
$modules = $items = [];
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$improve = new Core();
|
||||||
|
$modules = $items = [];
|
||||||
|
$settings = dcCore::app()->blog->settings->get(My::id());
|
||||||
|
|
||||||
foreach ($improve->modules() as $action) {
|
foreach ($improve->modules() as $action) {
|
||||||
$modules[$action->name()] = $action->id();
|
$modules[$action->name()] = $action->id();
|
||||||
|
@ -103,16 +113,16 @@ class Config extends dcNsProcess
|
||||||
(new Fieldset())->class('fieldset')->legend(new Legend(__('List of disabled actions')))->fields($items),
|
(new Fieldset())->class('fieldset')->legend(new Legend(__('List of disabled actions')))->fields($items),
|
||||||
(new Fieldset())->class('fieldset')->legend(new Legend(__('Options')))->fields([
|
(new Fieldset())->class('fieldset')->legend(new Legend(__('Options')))->fields([
|
||||||
(new Para())->items([
|
(new Para())->items([
|
||||||
(new Checkbox('nodetails', (bool) dcCore::app()->blog->settings->get(My::id())->get('nodetails')))->value('1'),
|
(new Checkbox('nodetails', (bool) $settings->get('nodetails')))->value('1'),
|
||||||
(new Label(__('Hide details of rendered actions'), Label::OUTSIDE_LABEL_AFTER))->class('classic')->for('nodetails'),
|
(new Label(__('Hide details of rendered actions'), Label::OUTSIDE_LABEL_AFTER))->class('classic')->for('nodetails'),
|
||||||
]),
|
]),
|
||||||
(new Para())->items([
|
(new Para())->items([
|
||||||
(new Checkbox('allow_distrib', (bool) dcCore::app()->blog->settings->get(My::id())->get('allow_distrib')))->value('1'),
|
(new Checkbox('allow_distrib', (bool) $settings->get('allow_distrib')))->value('1'),
|
||||||
(new Label(__('Show dotclear distributed modules'), Label::OUTSIDE_LABEL_AFTER))->class('classic')->for('allow_distrib'),
|
(new Label(__('Show dotclear distributed modules'), Label::OUTSIDE_LABEL_AFTER))->class('classic')->for('allow_distrib'),
|
||||||
]),
|
]),
|
||||||
(new Para())->items([
|
(new Para())->items([
|
||||||
(new Label(__('Sort modules seletion by:'), Label::OUTSIDE_LABEL_BEFORE))->for('combosortby'),
|
(new Label(__('Sort modules seletion by:'), Label::OUTSIDE_LABEL_BEFORE))->for('combosortby'),
|
||||||
(new Select('combosortby'))->items([__('Name') => 'name', __('Id') => 'id'])->default(dcCore::app()->blog->settings->get(My::id())->get('combosortby')),
|
(new Select('combosortby'))->items([__('Name') => 'name', __('Id') => 'id'])->default($settings->get('combosortby')),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
])->render();
|
])->render();
|
||||||
|
|
|
@ -51,7 +51,7 @@ class Core
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$disabled = explode(';', (string) dcCore::app()->blog->settings->get(My::id())->get('disabled'));
|
$disabled = explode(';', (string) dcCore::app()->blog?->settings->get(My::id())->get('disabled'));
|
||||||
$list = new ArrayObject();
|
$list = new ArrayObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -307,11 +307,6 @@ class Core
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURL(array $params = []): string
|
|
||||||
{
|
|
||||||
return dcCore::app()->adminurl->get('admin.plugin.' . My::id(), $params, '&');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check and clean file extension
|
* Check and clean file extension
|
||||||
*
|
*
|
||||||
|
|
|
@ -66,7 +66,7 @@ class Install extends dcNsProcess
|
||||||
private static function putSettings(): void
|
private static function putSettings(): void
|
||||||
{
|
{
|
||||||
foreach (self::$default_settings as $v) {
|
foreach (self::$default_settings as $v) {
|
||||||
dcCore::app()->blog->settings->get(My::id())->put(
|
dcCore::app()->blog?->settings->get(My::id())->put(
|
||||||
$v[0],
|
$v[0],
|
||||||
$v[2],
|
$v[2],
|
||||||
$v[3],
|
$v[3],
|
||||||
|
@ -80,7 +80,7 @@ class Install extends dcNsProcess
|
||||||
/** Update improve < 0.8 : action modules settings name */
|
/** Update improve < 0.8 : action modules settings name */
|
||||||
private static function update_0_8_0(): void
|
private static function update_0_8_0(): void
|
||||||
{
|
{
|
||||||
if (version_compare(dcCore::app()->getVersion(My::id()) ?? '0', '0.8', '<')) {
|
if (!is_null(dcCore::app()->blog) && version_compare(dcCore::app()->getVersion(My::id()) ?? '0', '0.8', '<')) {
|
||||||
foreach (dcCore::app()->blog->settings->get(My::id())->dumpGlobalSettings() as $id => $values) {
|
foreach (dcCore::app()->blog->settings->get(My::id())->dumpGlobalSettings() as $id => $values) {
|
||||||
$newId = str_replace('ImproveAction', '', $id);
|
$newId = str_replace('ImproveAction', '', $id);
|
||||||
if ($id != $newId) {
|
if ($id != $newId) {
|
||||||
|
|
|
@ -51,11 +51,10 @@ class Manage extends dcNsProcess
|
||||||
/** @var Action|null $action Current action module */
|
/** @var Action|null $action Current action module */
|
||||||
private static $action = null;
|
private static $action = null;
|
||||||
|
|
||||||
protected static $init = false;
|
|
||||||
|
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||||
|
&& !is_null(dcCore::app()->auth)
|
||||||
&& dcCore::app()->auth->isSuperAdmin()
|
&& dcCore::app()->auth->isSuperAdmin()
|
||||||
&& My::phpCompliant();
|
&& My::phpCompliant();
|
||||||
|
|
||||||
|
@ -86,7 +85,7 @@ class Manage extends dcNsProcess
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (!empty(self::$type)) {
|
if (!empty(self::$type)) {
|
||||||
$preferences = dcCore::app()->blog->settings->get(My::id())->get('preferences');
|
$preferences = dcCore::app()->blog?->settings->get(My::id())->get('preferences');
|
||||||
if (is_string($preferences)) {
|
if (is_string($preferences)) {
|
||||||
$preferences = json_decode($preferences, true);
|
$preferences = json_decode($preferences, true);
|
||||||
if (is_array($preferences)) {
|
if (is_array($preferences)) {
|
||||||
|
@ -102,7 +101,7 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
private static function setPreferences(): bool
|
private static function setPreferences(): bool
|
||||||
{
|
{
|
||||||
if (!empty($_POST['save_preferences'])) {
|
if (!empty($_POST['save_preferences']) && !is_null(dcCore::app()->blog)) {
|
||||||
$preferences = self::getPreference(true);
|
$preferences = self::getPreference(true);
|
||||||
$preferences[self::$type] = [];
|
$preferences[self::$type] = [];
|
||||||
if (!empty($_POST['actions'])) {
|
if (!empty($_POST['actions'])) {
|
||||||
|
@ -123,6 +122,10 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
private static function comboModules(): array
|
private static function comboModules(): array
|
||||||
{
|
{
|
||||||
|
if (is_null(dcCore::app()->blog)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
if (!(dcCore::app()->themes instanceof dcThemes)) {
|
if (!(dcCore::app()->themes instanceof dcThemes)) {
|
||||||
dcCore::app()->themes = new dcThemes();
|
dcCore::app()->themes = new dcThemes();
|
||||||
dcCore::app()->themes->loadModules(dcCore::app()->blog->themes_path, null);
|
dcCore::app()->themes->loadModules(dcCore::app()->blog->themes_path, null);
|
||||||
|
@ -175,7 +178,7 @@ class Manage extends dcNsProcess
|
||||||
$_POST['actions']
|
$_POST['actions']
|
||||||
);
|
);
|
||||||
$log_id = self::$improve->writeLogs();
|
$log_id = self::$improve->writeLogs();
|
||||||
dcCore::app()->blog->triggerBlog();
|
dcCore::app()->blog?->triggerBlog();
|
||||||
|
|
||||||
if (self::$improve->hasLog('error')) {
|
if (self::$improve->hasLog('error')) {
|
||||||
$notice = ['type' => dcAdminNotices::NOTICE_ERROR, 'msg' => __('Fix of "%s" complete in %s secondes with errors')];
|
$notice = ['type' => dcAdminNotices::NOTICE_ERROR, 'msg' => __('Fix of "%s" complete in %s secondes with errors')];
|
||||||
|
@ -197,7 +200,7 @@ class Manage extends dcNsProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($done) {
|
if ($done) {
|
||||||
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), ['type' => self::$type, 'module' => self::$module, 'upd' => $log_id]);
|
dcCore::app()->adminurl?->redirect('admin.plugin.' . My::id(), ['type' => self::$type, 'module' => self::$module, 'upd' => $log_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -234,14 +237,14 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
private static function displayConfigurator(): void
|
private static function displayConfigurator(): void
|
||||||
{
|
{
|
||||||
$back_url = $_REQUEST['redir'] ?? dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['type' => self::$type]);
|
$back_url = $_REQUEST['redir'] ?? dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['type' => self::$type]);
|
||||||
|
|
||||||
if (null === self::$action) {
|
if (null === self::$action) {
|
||||||
echo '
|
echo '
|
||||||
<p class="warning">' . __('Unknow module') . '</p>
|
<p class="warning">' . __('Unknow module') . '</p>
|
||||||
<p><a class="back" href="' . $back_url . '">' . __('Back') . '</a></p>';
|
<p><a class="back" href="' . $back_url . '">' . __('Back') . '</a></p>';
|
||||||
} else {
|
} else {
|
||||||
$redir = $_REQUEST['redir'] ?? dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['type' => self::$type, 'config' => self::$action->id()]);
|
$redir = $_REQUEST['redir'] ?? dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['type' => self::$type, 'config' => self::$action->id()]);
|
||||||
$res = self::$action->configure($redir);
|
$res = self::$action->configure($redir);
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
@ -249,7 +252,7 @@ class Manage extends dcNsProcess
|
||||||
<p><a class="back" href="' . $back_url . '">' . __('Back') . '</a></p>
|
<p><a class="back" href="' . $back_url . '">' . __('Back') . '</a></p>
|
||||||
<h4>' . Html::escapeHTML(self::$action->description()) . '</h4>' .
|
<h4>' . Html::escapeHTML(self::$action->description()) . '</h4>' .
|
||||||
|
|
||||||
(new Form('form-actions'))->method('post')->action(dcCore::app()->adminurl->get('admin.plugin.' . My::id()))->fields([
|
(new Form('form-actions'))->method('post')->action(dcCore::app()->adminurl?->get('admin.plugin.' . My::id()))->fields([
|
||||||
empty($res) ? (new Text('p', __('Nothing to configure')))->class('message') : (new Text('', $res)),
|
empty($res) ? (new Text('p', __('Nothing to configure')))->class('message') : (new Text('', $res)),
|
||||||
(new Para())->class('clear')->items([
|
(new Para())->class('clear')->items([
|
||||||
(new Submit(['save']))->value(__('Save')),
|
(new Submit(['save']))->value(__('Save')),
|
||||||
|
@ -265,7 +268,7 @@ class Manage extends dcNsProcess
|
||||||
private static function displayActions(): void
|
private static function displayActions(): void
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
(new Form('improve_menu'))->method('get')->action(dcCore::app()->adminurl->get('admin.plugin.' . My::id()))->fields([
|
(new Form('improve_menu'))->method('get')->action(dcCore::app()->adminurl?->get('admin.plugin.' . My::id()))->fields([
|
||||||
(new Para())->class('anchor-nav')->items([
|
(new Para())->class('anchor-nav')->items([
|
||||||
(new Label(__('Goto:'), Label::OUTSIDE_LABEL_BEFORE))->for('type')->class('classic'),
|
(new Label(__('Goto:'), Label::OUTSIDE_LABEL_BEFORE))->for('type')->class('classic'),
|
||||||
(new Select('type'))->default(self::$type)->items([__('Plugins') => 'plugin', __('Themes') => 'theme']),
|
(new Select('type'))->default(self::$type)->items([__('Plugins') => 'plugin', __('Themes') => 'theme']),
|
||||||
|
@ -278,7 +281,7 @@ class Manage extends dcNsProcess
|
||||||
if (count($combo_modules) == 1) {
|
if (count($combo_modules) == 1) {
|
||||||
echo '<p class="message">' . __('No module to manage') . '</p>';
|
echo '<p class="message">' . __('No module to manage') . '</p>';
|
||||||
} else {
|
} else {
|
||||||
echo '<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id()) . '" method="post" id="form-actions">' .
|
echo '<form action="' . dcCore::app()->adminurl?->get('admin.plugin.' . My::id()) . '" method="post" id="form-actions">' .
|
||||||
'<table><caption class="hidden">' . __('Actions') . '</caption><thead><tr>' .
|
'<table><caption class="hidden">' . __('Actions') . '</caption><thead><tr>' .
|
||||||
'<th colspan="2" class="first">' . __('Action') . '</td>' .
|
'<th colspan="2" class="first">' . __('Action') . '</td>' .
|
||||||
'<th scope="col">' . __('Description') . '</td>' .
|
'<th scope="col">' . __('Description') . '</td>' .
|
||||||
|
@ -303,7 +306,7 @@ class Manage extends dcNsProcess
|
||||||
'<td class="maximal">' . $action->description() . '</td>' .
|
'<td class="maximal">' . $action->description() . '</td>' .
|
||||||
'<td class="minimal nowrap modules">' . (
|
'<td class="minimal nowrap modules">' . (
|
||||||
false === $action->configurator() ? '' :
|
false === $action->configurator() ? '' :
|
||||||
'<a class="module-config" href="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['type' => self::$type, 'config' => $action->id()]) .
|
'<a class="module-config" href="' . dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['type' => self::$type, 'config' => $action->id()]) .
|
||||||
'" title="' . sprintf(__("Configure action '%s'"), $action->name()) . '">' . __('Configure') . '</a>'
|
'" title="' . sprintf(__("Configure action '%s'"), $action->name()) . '">' . __('Configure') . '</a>'
|
||||||
) . '</td>' .
|
) . '</td>' .
|
||||||
(DC_DEBUG ? '<td class="minimal"><span class="debug">' . $action->priority() . '</span></td>' : '') . /* @phpstan-ignore-line */
|
(DC_DEBUG ? '<td class="minimal"><span class="debug">' . $action->priority() . '</span></td>' : '') . /* @phpstan-ignore-line */
|
||||||
|
@ -327,7 +330,7 @@ class Manage extends dcNsProcess
|
||||||
'<br class="clear" />
|
'<br class="clear" />
|
||||||
</form>';
|
</form>';
|
||||||
|
|
||||||
if (!empty($_REQUEST['upd']) && !dcCore::app()->blog->settings->get(My::id())->get('nodetails')) {
|
if (!empty($_REQUEST['upd']) && !dcCore::app()->blog?->settings->get(My::id())->get('nodetails')) {
|
||||||
$logs = self::$improve->parseLogs((int) $_REQUEST['upd']);
|
$logs = self::$improve->parseLogs((int) $_REQUEST['upd']);
|
||||||
|
|
||||||
if (!empty($logs)) {
|
if (!empty($logs)) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ use dcCore;
|
||||||
class My
|
class My
|
||||||
{
|
{
|
||||||
/** @var string Required php version */
|
/** @var string Required php version */
|
||||||
public const PHP_MIN = '8.0';
|
public const PHP_MIN = '8.1';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This module id
|
* This module id
|
||||||
|
|
|
@ -156,6 +156,12 @@ class cssheader extends Action
|
||||||
|
|
||||||
public function openModule(): ?bool
|
public function openModule(): ?bool
|
||||||
{
|
{
|
||||||
|
if (is_null(dcCore::app()->auth)) {
|
||||||
|
$this->setWarning(__('Auth is not set'));
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$bloc = trim($this->bloc_content);
|
$bloc = trim($this->bloc_content);
|
||||||
|
|
||||||
if (empty($bloc)) {
|
if (empty($bloc)) {
|
||||||
|
|
|
@ -109,31 +109,31 @@ class dcstore extends Action
|
||||||
$rsp = new XmlTag('module');
|
$rsp = new XmlTag('module');
|
||||||
|
|
||||||
# id
|
# id
|
||||||
$rsp->id = $this->module->getId();
|
$rsp->insertAttr('id', $this->module->getId());
|
||||||
|
|
||||||
# name
|
# name
|
||||||
if (empty($this->module->get('name'))) {
|
if (empty($this->module->get('name'))) {
|
||||||
$this->setError(__('unknow module name'));
|
$this->setError(__('unknow module name'));
|
||||||
}
|
}
|
||||||
$rsp->name($this->module->get('name'));
|
$rsp->insertNode(new XmlTag('name', $this->module->get('name')));
|
||||||
|
|
||||||
# version
|
# version
|
||||||
if (empty($this->module->get('version'))) {
|
if (empty($this->module->get('version'))) {
|
||||||
$this->setError(__('unknow module version'));
|
$this->setError(__('unknow module version'));
|
||||||
}
|
}
|
||||||
$rsp->version($this->module->get('version'));
|
$rsp->insertNode(new XmlTag('version', $this->module->get('version')));
|
||||||
|
|
||||||
# author
|
# author
|
||||||
if (empty($this->module->get('author'))) {
|
if (empty($this->module->get('author'))) {
|
||||||
$this->setError(__('unknow module author'));
|
$this->setError(__('unknow module author'));
|
||||||
}
|
}
|
||||||
$rsp->author($this->module->get('author'));
|
$rsp->insertNode(new XmlTag('author', $this->module->get('author')));
|
||||||
|
|
||||||
# desc
|
# desc
|
||||||
if (empty($this->module->get('desc'))) {
|
if (empty($this->module->get('desc'))) {
|
||||||
$this->setError(__('unknow module description'));
|
$this->setError(__('unknow module description'));
|
||||||
}
|
}
|
||||||
$rsp->desc($this->module->get('desc'));
|
$rsp->insertNode(new XmlTag('desc', $this->module->get('desc')));
|
||||||
|
|
||||||
# repository
|
# repository
|
||||||
if (empty($this->module->get('repository'))) {
|
if (empty($this->module->get('repository'))) {
|
||||||
|
@ -145,7 +145,7 @@ class dcstore extends Action
|
||||||
if (empty($file_pattern)) {
|
if (empty($file_pattern)) {
|
||||||
$this->setError(__('no zip file pattern set in configuration'));
|
$this->setError(__('no zip file pattern set in configuration'));
|
||||||
}
|
}
|
||||||
$rsp->file($file_pattern);
|
$rsp->insertNode(new XmlTag('file', $file_pattern));
|
||||||
|
|
||||||
# da dc_min or requires core
|
# da dc_min or requires core
|
||||||
if (!empty($this->module->get('requires')) && is_array($this->module->get('requires'))) {
|
if (!empty($this->module->get('requires')) && is_array($this->module->get('requires'))) {
|
||||||
|
|
|
@ -72,9 +72,11 @@ class phpcsfixer extends Action
|
||||||
|
|
||||||
$this->getPhpPath();
|
$this->getPhpPath();
|
||||||
|
|
||||||
dcCore::app()->auth->user_prefs->addWorkspace('interface');
|
if (null !== dcCore::app()->auth?->user_prefs) {
|
||||||
self::$user_ui_colorsyntax = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax');
|
dcCore::app()->auth->user_prefs->addWorkspace('interface');
|
||||||
self::$user_ui_colorsyntax_theme = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme');
|
self::$user_ui_colorsyntax = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax');
|
||||||
|
self::$user_ui_colorsyntax_theme = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme');
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,6 +155,12 @@ class phpheader extends Action
|
||||||
|
|
||||||
public function openModule(): ?bool
|
public function openModule(): ?bool
|
||||||
{
|
{
|
||||||
|
if (is_null(dcCore::app()->auth)) {
|
||||||
|
$this->setWarning(__('Auth is not set'));
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$bloc = trim($this->bloc_content);
|
$bloc = trim($this->bloc_content);
|
||||||
|
|
||||||
if (empty($bloc)) {
|
if (empty($bloc)) {
|
||||||
|
|
|
@ -75,16 +75,18 @@ class phpstan extends Action
|
||||||
$ignored_vars = $this->getSetting('ignored_vars');
|
$ignored_vars = $this->getSetting('ignored_vars');
|
||||||
$this->ignored_vars = is_string($ignored_vars) ? $ignored_vars : '';
|
$this->ignored_vars = is_string($ignored_vars) ? $ignored_vars : '';
|
||||||
|
|
||||||
dcCore::app()->auth->user_prefs->addWorkspace('interface');
|
if (null !== dcCore::app()->auth?->user_prefs) {
|
||||||
self::$user_ui_colorsyntax = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax');
|
dcCore::app()->auth->user_prefs->addWorkspace('interface');
|
||||||
self::$user_ui_colorsyntax_theme = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme');
|
self::$user_ui_colorsyntax = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax');
|
||||||
|
self::$user_ui_colorsyntax_theme = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme');
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isConfigured(): bool
|
public function isConfigured(): bool
|
||||||
{
|
{
|
||||||
return !dcCore::app()->blog->settings->get(My::id())->get('nodetails');
|
return !dcCore::app()->blog?->settings->get(My::id())->get('nodetails');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function header(): ?string
|
public function header(): ?string
|
||||||
|
@ -284,7 +286,7 @@ class phpstan extends Action
|
||||||
'%MODULE_ROOT%',
|
'%MODULE_ROOT%',
|
||||||
'%DC_ROOT%',
|
'%DC_ROOT%',
|
||||||
'%BOOTSTRAP_ROOT%',
|
'%BOOTSTRAP_ROOT%',
|
||||||
'%SCAN_DIRECTORIES%'
|
'%SCAN_DIRECTORIES%',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
$this->run_level,
|
$this->run_level,
|
||||||
|
@ -311,18 +313,19 @@ class phpstan extends Action
|
||||||
return (bool) file_put_contents(DC_VAR . '/phpstan.neon', $content);
|
return (bool) file_put_contents(DC_VAR . '/phpstan.neon', $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getScanDirectories()
|
private function getScanDirectories(): string
|
||||||
{
|
{
|
||||||
$ret = '';
|
$ret = '';
|
||||||
if ($this->module->get('type') == 'plugin') {
|
if ($this->module->get('type') == 'plugin') {
|
||||||
$paths = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
|
$paths = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
|
||||||
foreach($paths as $path) {
|
foreach ($paths as $path) {
|
||||||
$path = Path::real($path, false);
|
$path = Path::real($path, false);
|
||||||
if ($path !== false && $path != Path::real(DC_ROOT . DIRECTORY_SEPARATOR . 'plugins', false)) {
|
if ($path !== false && $path != Path::real(DC_ROOT . DIRECTORY_SEPARATOR . 'plugins', false)) {
|
||||||
$ret .= ' - ' . $path . "\n";
|
$ret .= ' - ' . $path . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ class zip extends Action
|
||||||
]),
|
]),
|
||||||
(new Note())->text(sprintf(
|
(new Note())->text(sprintf(
|
||||||
__('Preconization: %s'),
|
__('Preconization: %s'),
|
||||||
dcCore::app()->blog->public_path ?
|
dcCore::app()->blog?->public_path ?
|
||||||
Path::real(dcCore::app()->blog->public_path) : __("Blog's public directory")
|
Path::real(dcCore::app()->blog->public_path) : __("Blog's public directory")
|
||||||
))->class('form-note'),
|
))->class('form-note'),
|
||||||
]),
|
]),
|
||||||
|
|
|
@ -26,6 +26,8 @@ class Zip extends \Dotclear\Helper\File\Zip\Zip
|
||||||
* @param string $file The file
|
* @param string $file The file
|
||||||
* @param string $size The size
|
* @param string $size The size
|
||||||
* @param int|null $mtime The mtime
|
* @param int|null $mtime The mtime
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function writeFile($name, $file, $size, $mtime)
|
protected function writeFile($name, $file, $size, $mtime)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue