upgrade to Dotclear 2.28
This commit is contained in:
parent
95d78d2217
commit
9445a68a1b
37 changed files with 1002 additions and 868 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -6,6 +6,18 @@ improve todo - xxxx.xx.xx
|
||||||
* [ ] add module to minify .js
|
* [ ] add module to minify .js
|
||||||
* [ ] write documentation of php class
|
* [ ] write documentation of php class
|
||||||
|
|
||||||
|
improve 1.5 - 2023.10.22
|
||||||
|
===========================================================
|
||||||
|
* Require Dotclear 2.28
|
||||||
|
* Require PHP 8.1
|
||||||
|
* Upgrade to Dotclear 2.28
|
||||||
|
* Upgrade to php-cs-fixer 3.35.1
|
||||||
|
* Upgrade to phpstan 1.10.39
|
||||||
|
* Use Dotclear cache for phpstan (fix right on system tmp dir)
|
||||||
|
* Update phpstan default rules to follow Dotclear rules
|
||||||
|
* Code review (phpstan)
|
||||||
|
* Deprecated task is not yet up-to-date with Dotclear 2.28...
|
||||||
|
|
||||||
improve 1.4 - 2023.08.07
|
improve 1.4 - 2023.08.07
|
||||||
===========================================================
|
===========================================================
|
||||||
* Require Dotclear 2.27
|
* Require Dotclear 2.27
|
||||||
|
|
30
README.md
30
README.md
|
@ -1,17 +1,16 @@
|
||||||
# README
|
# README
|
||||||
|
|
||||||
[![Release](https://img.shields.io/badge/release-1.4-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/improve/releases)
|
[![Release](https://img.shields.io/badge/release-1.5-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/improve/releases)
|
||||||
[![Date](https://img.shields.io/badge/date-2023.08.06-c44d58.svg)](https://git.dotclear.watch/JcDenis/improve/releases)
|
![Date](https://img.shields.io/badge/date-2023.10.22-c44d58.svg)
|
||||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
|
||||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/improve)
|
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/improve)
|
||||||
[![License](https://img.shields.io/github/license/JcDenis/improve)](https://git.dotclear.watch/JcDenis/improve/blob/master/LICENSE)
|
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/improve/src/branch/master/LICENSE)
|
||||||
|
|
||||||
## WHAT IS IMPROVE ?
|
## ABOUT
|
||||||
|
|
||||||
_improve_ is a plugin for the open-source
|
_improve_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
||||||
web publishing software called Dotclear.
|
|
||||||
|
|
||||||
It helps dev to clean up plugin or theme before publishing code.
|
> Help dev to clean up plugin or theme before publishing code.
|
||||||
|
|
||||||
* Open to third party plugin
|
* Open to third party plugin
|
||||||
* Easy and fast to use
|
* Easy and fast to use
|
||||||
|
@ -19,11 +18,9 @@ It helps dev to clean up plugin or theme before publishing code.
|
||||||
|
|
||||||
## REQUIREMENTS
|
## REQUIREMENTS
|
||||||
|
|
||||||
_improve_ requires:
|
* Dotclear 2.28
|
||||||
|
|
||||||
* admin permission
|
|
||||||
* Dotclear 2.27
|
|
||||||
* PHP 8.1+
|
* PHP 8.1+
|
||||||
|
* Dotclear Super admin permissions
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
|
@ -38,13 +35,14 @@ and help devs to maintain their plugins and themes.
|
||||||
|
|
||||||
## LINKS
|
## LINKS
|
||||||
|
|
||||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
* [License](https://git.dotclear.watch/JcDenis/improve/src/branch/master/LICENSE)
|
||||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/improve) [GitHub Page](https://github.com/JcDenis/improve)
|
* [Packages & details](https://git.dotclear.watch/JcDenis/improve/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/improve))
|
||||||
* Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/improve/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/improve)
|
* [Sources & contributions](https://git.dotclear.watch/JcDenis/improve) (or on [GitHub](https://github.com/JcDenis/improve))
|
||||||
|
* [Issues & security](https://git.dotclear.watch/JcDenis/improve/issues) (or on [GitHub](https://github.com/JcDenis/improve/issues))
|
||||||
|
|
||||||
## CONTRIBUTORS
|
## CONTRIBUTORS
|
||||||
|
|
||||||
* Jean-Christian Denis
|
* Jean-Christian Denis (author)
|
||||||
* Gvx
|
* Gvx
|
||||||
|
|
||||||
You are welcome to contribute to this code.
|
You are welcome to contribute to this code.
|
||||||
|
|
24
_define.php
24
_define.php
|
@ -1,30 +1,26 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief improve, a plugin for Dotclear 2
|
* @file
|
||||||
|
* @brief The plugin improve definition
|
||||||
|
* @ingroup improve
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @defgroup improve Plugin improve.
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis and contributors
|
* Tiny tools to fix things for module devs.
|
||||||
*
|
*
|
||||||
* @copyright Jean-Christian Denis
|
* @author Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
if (!defined('DC_RC_PATH')) {
|
declare(strict_types=1);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
'improve',
|
'improve',
|
||||||
'Tiny tools to fix things for module devs',
|
'Tiny tools to fix things for module devs',
|
||||||
'Jean-Christian Denis and contributors',
|
'Jean-Christian Denis and contributors',
|
||||||
'1.4',
|
'1.5',
|
||||||
[
|
[
|
||||||
'requires' => [
|
'requires' => [['core', '2.28']],
|
||||||
['php', '8.1'],
|
'permissions' => 'My',
|
||||||
['core', '2.27'],
|
|
||||||
],
|
|
||||||
'permissions' => null,
|
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||||
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
<modules xmlns:da="http://dotaddict.org/da/">
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
<module id="improve">
|
<module id="improve">
|
||||||
<name>improve</name>
|
<name>improve</name>
|
||||||
<version>1.4</version>
|
<version>1.5</version>
|
||||||
<author>Jean-Christian Denis and contributors</author>
|
<author>Jean-Christian Denis and contributors</author>
|
||||||
<desc>Tiny tools to fix things for module devs</desc>
|
<desc>Tiny tools to fix things for module devs</desc>
|
||||||
<file>https://git.dotclear.watch/JcDenis/improve/releases/download/v1.4/plugin-improve.zip</file>
|
<file>https://git.dotclear.watch/JcDenis/improve/releases/download/v1.5/plugin-improve.zip</file>
|
||||||
<da:dcmin>2.27</da:dcmin>
|
<da:dcmin>2.28</da:dcmin>
|
||||||
<da:details>https://git.dotclear.watch/JcDenis/improve/src/branch/master/README.md</da:details>
|
<da:details>https://git.dotclear.watch/JcDenis/improve/src/branch/master/README.md</da:details>
|
||||||
<da:support>https://git.dotclear.watch/JcDenis/improve/issues</da:support>
|
<da:support>https://git.dotclear.watch/JcDenis/improve/issues</da:support>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -1,27 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve;
|
namespace Dotclear\Plugin\improve;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Core\Backend\Favorites;
|
use Dotclear\Core\Backend\Favorites;
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve admin class
|
* @brief improve backend class.
|
||||||
|
* @ingroup improve
|
||||||
*
|
*
|
||||||
* Add menu and dashboard icons, load Improve tasks.
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class Backend extends Process
|
class Backend extends Process
|
||||||
{
|
{
|
||||||
|
@ -36,13 +28,13 @@ class Backend extends Process
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null(dcCore::app()->blog)) {
|
if (!App::blog()->isDefined()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
My::addBackendMenuItem();
|
My::addBackendMenuItem();
|
||||||
|
|
||||||
dcCore::app()->addBehaviors([
|
App::behavior()->addBehaviors([
|
||||||
'adminDashboardFavoritesV2' => function (Favorites $favs): void {
|
'adminDashboardFavoritesV2' => function (Favorites $favs): void {
|
||||||
$favs->register(
|
$favs->register(
|
||||||
My::id(),
|
My::id(),
|
||||||
|
|
|
@ -1,20 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve;
|
namespace Dotclear\Plugin\improve;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Core\Backend\Notices;
|
use Dotclear\Core\Backend\Notices;
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Helper\Html\Form\{
|
use Dotclear\Helper\Html\Form\{
|
||||||
|
@ -30,9 +20,11 @@ use Dotclear\Helper\Html\Form\{
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Admin Improve configuration class
|
* @brief improve backend config class.
|
||||||
|
* @ingroup improve
|
||||||
*
|
*
|
||||||
* Set preference for this plugin.
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class Config extends Process
|
class Config extends Process
|
||||||
{
|
{
|
||||||
|
@ -51,7 +43,7 @@ class Config extends Process
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null(dcCore::app()->blog) || !My::settings()) {
|
if (!App::blog()->isDefined()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,12 +59,12 @@ class Config extends Process
|
||||||
|
|
||||||
Notices::addSuccessNotice(__('Configuration successfully updated'));
|
Notices::addSuccessNotice(__('Configuration successfully updated'));
|
||||||
|
|
||||||
dcCore::app()->admin->url->redirect(
|
App::backend()->url()->redirect(
|
||||||
'admin.plugins',
|
'admin.plugins',
|
||||||
['module' => My::id(), 'conf' => 1, 'chk' => 1, 'redir' => dcCore::app()->admin->__get('list')->getRedir()]
|
['module' => My::id(), 'conf' => 1, 'chk' => 1, 'redir' => App::backend()->__get('list')->getRedir()]
|
||||||
);
|
);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
App::error()->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -84,10 +76,6 @@ class Config extends Process
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null(dcCore::app()->blog)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$items = [];
|
$items = [];
|
||||||
|
|
||||||
foreach (Improve::instance()->tasks->dump() as $task) {
|
foreach (Improve::instance()->tasks->dump() as $task) {
|
||||||
|
@ -102,16 +90,16 @@ class Config extends Process
|
||||||
(new Fieldset())->class('fieldset')->legend(new Legend(__('List of disabled tasks')))->fields($items),
|
(new Fieldset())->class('fieldset')->legend(new Legend(__('List of disabled tasks')))->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) My::settings()?->get('nodetails')))->value('1'),
|
(new Checkbox('nodetails', (bool) My::settings()->get('nodetails')))->value('1'),
|
||||||
(new Label(__('Hide details of rendered tasks'), Label::OUTSIDE_LABEL_AFTER))->class('classic')->for('nodetails'),
|
(new Label(__('Hide details of rendered tasks'), Label::OUTSIDE_LABEL_AFTER))->class('classic')->for('nodetails'),
|
||||||
]),
|
]),
|
||||||
(new Para())->items([
|
(new Para())->items([
|
||||||
(new Checkbox('allow_distrib', (bool) My::settings()?->get('allow_distrib')))->value('1'),
|
(new Checkbox('allow_distrib', (bool) My::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(My::settings()?->get('combosortby')),
|
(new Select('combosortby'))->items([__('Name') => 'name', __('Id') => 'id'])->default(My::settings()->get('combosortby')),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
])->render();
|
])->render();
|
||||||
|
|
|
@ -1,20 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve;
|
namespace Dotclear\Plugin\improve;
|
||||||
|
|
||||||
use dcModuleDefine;
|
use Dotclear\Module\ModuleDefine;
|
||||||
use Dotclear\Helper\File\{
|
use Dotclear\Helper\File\{
|
||||||
Files,
|
Files,
|
||||||
Path
|
Path
|
||||||
|
@ -22,43 +12,69 @@ use Dotclear\Helper\File\{
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve main class
|
* @brief improve main class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class Improve
|
class Improve
|
||||||
{
|
{
|
||||||
/** @var Tasks $tasks The tasks stack instance */
|
/**
|
||||||
|
* The tasks stack instance.
|
||||||
|
*
|
||||||
|
* @var Tasks $tasks
|
||||||
|
*/
|
||||||
public readonly Tasks $tasks;
|
public readonly Tasks $tasks;
|
||||||
|
|
||||||
/** @var Logs $logs The logs stack instance */
|
/**
|
||||||
|
* The logs stack instance.
|
||||||
|
*
|
||||||
|
* @var Logs $logs
|
||||||
|
*/
|
||||||
public readonly Logs $logs;
|
public readonly Logs $logs;
|
||||||
|
|
||||||
/** @var array $readfile_extensions Allowed file extensions to open */
|
/**
|
||||||
|
* Allowed file extensions to open.
|
||||||
|
*
|
||||||
|
* @var array<int, string> $readfile_extensions
|
||||||
|
*/
|
||||||
private static $readfile_extensions = [
|
private static $readfile_extensions = [
|
||||||
'php', 'xml', 'js', 'css', 'csv', 'html', 'htm', 'txt', 'md', 'po',
|
'php', 'xml', 'js', 'css', 'csv', 'html', 'htm', 'txt', 'md', 'po',
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var Improve $instance Improve instance */
|
/**
|
||||||
|
* Improve instance.
|
||||||
|
*
|
||||||
|
* @var Improve $instance
|
||||||
|
*/
|
||||||
private static $instance;
|
private static $instance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
protected function __construct()
|
protected function __construct()
|
||||||
{
|
{
|
||||||
$this->logs = new Logs();
|
$this->logs = new Logs();
|
||||||
$this->tasks = new Tasks();
|
$this->tasks = new Tasks();
|
||||||
|
|
||||||
// mark some tasks as disabled (by settings)
|
// Mark some tasks as disabled (by settings)
|
||||||
$disable = explode(';', (string) My::settings()?->get('disabled'));
|
$disable = explode(';', (string) My::settings()->get('disabled'));
|
||||||
foreach ($disable as $id) {
|
foreach ($disable as $id) {
|
||||||
$this->tasks->get($id)?->disable();
|
$this->tasks->get($id)?->disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable clone.
|
||||||
|
*/
|
||||||
protected function __clone()
|
protected function __clone()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diable wakeup.
|
||||||
|
*/
|
||||||
public function __wakeup()
|
public function __wakeup()
|
||||||
{
|
{
|
||||||
throw new Exception('nope');
|
throw new Exception('nope');
|
||||||
|
@ -78,7 +94,15 @@ class Improve
|
||||||
return self::$instance;
|
return self::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fix(dcModuleDefine $module, array $tasks): float
|
/**
|
||||||
|
* Fix a module.
|
||||||
|
*
|
||||||
|
* @param ModuleDefine $module The module
|
||||||
|
* @param array<int, string> $tasks The tasks
|
||||||
|
*
|
||||||
|
* @return float The spent time
|
||||||
|
*/
|
||||||
|
public function fix(ModuleDefine $module, array $tasks): float
|
||||||
{
|
{
|
||||||
$time_start = microtime(true);
|
$time_start = microtime(true);
|
||||||
|
|
||||||
|
@ -166,6 +190,15 @@ class Improve
|
||||||
return round(microtime(true) - $time_start, 5);
|
return round(microtime(true) - $time_start, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get module files.
|
||||||
|
*
|
||||||
|
* @param string $path The module path
|
||||||
|
* @param string $dir (internal) The working directory
|
||||||
|
* @param array<int, array{0: string, 1: string, 2: bool}> $res (internal) The files stack
|
||||||
|
*
|
||||||
|
* @return array<int, array{0: string, 1: string, 2: bool}> The files stack
|
||||||
|
*/
|
||||||
private static function getModuleFiles(string $path, string $dir = '', array $res = []): array
|
private static function getModuleFiles(string $path, string $dir = '', array $res = []): array
|
||||||
{
|
{
|
||||||
$path = Path::real($path);
|
$path = Path::real($path);
|
||||||
|
|
|
@ -1,33 +1,27 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve;
|
namespace Dotclear\Plugin\improve;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use dcNamespace;
|
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve install class
|
* @brief improve install class.
|
||||||
|
* @ingroup improve
|
||||||
*
|
*
|
||||||
* Set default settings and version
|
* @author Jean-Christian Denis
|
||||||
* and manage changes on updates.
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class Install extends Process
|
class Install extends Process
|
||||||
{
|
{
|
||||||
/** @var array Improve default settings */
|
/**
|
||||||
|
* Improve default settings.
|
||||||
|
*
|
||||||
|
* @var array<int, array<int, string>> $default_settings
|
||||||
|
*/
|
||||||
private static $default_settings = [[
|
private static $default_settings = [[
|
||||||
'disabled',
|
'disabled',
|
||||||
'List of hidden tasks modules',
|
'List of hidden tasks modules',
|
||||||
|
@ -53,7 +47,7 @@ class Install extends Process
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
App::error()->add($e->getMessage());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +56,7 @@ class Install extends Process
|
||||||
private static function putSettings(): void
|
private static function putSettings(): void
|
||||||
{
|
{
|
||||||
foreach (self::$default_settings as $v) {
|
foreach (self::$default_settings as $v) {
|
||||||
My::settings()?->put(
|
My::settings()->put(
|
||||||
$v[0],
|
$v[0],
|
||||||
$v[2],
|
$v[2],
|
||||||
$v[3],
|
$v[3],
|
||||||
|
@ -76,7 +70,7 @@ class Install extends Process
|
||||||
/** 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 (!is_null(dcCore::app()->blog) && My::settings() && version_compare(dcCore::app()->getVersion(My::id()) ?? '0', '0.8', '<')) {
|
if (App::blog()->isDefined() && version_compare(App::version()->getVersion(My::id()), '0.8', '<')) {
|
||||||
foreach (My::settings()->dumpGlobalSettings() as $id => $values) {
|
foreach (My::settings()->dumpGlobalSettings() as $id => $values) {
|
||||||
$newId = str_replace('ImproveAction', '', $id);
|
$newId = str_replace('ImproveAction', '', $id);
|
||||||
if ($id != $newId) {
|
if ($id != $newId) {
|
||||||
|
@ -89,22 +83,22 @@ class Install extends Process
|
||||||
/** Update improve < 1.1 : use json_(en|de)code rather than (un)serialize */
|
/** Update improve < 1.1 : use json_(en|de)code rather than (un)serialize */
|
||||||
private static function update_1_1_0(): void
|
private static function update_1_1_0(): void
|
||||||
{
|
{
|
||||||
if (version_compare(dcCore::app()->getVersion(My::id()) ?? '0', '1.1', '<')) {
|
if (version_compare(App::version()->getVersion(My::id()), '1.1', '<')) {
|
||||||
foreach (['setting_', 'preferences'] as $key) {
|
foreach (['setting_', 'preferences'] as $key) {
|
||||||
$record = dcCore::app()->con->select(
|
$record = App::con()->select(
|
||||||
'SELECT * FROM ' . dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME . ' ' .
|
'SELECT * FROM ' . App::con()->prefix() . App::blogWorkspace()::NS_TABLE_NAME . ' ' .
|
||||||
"WHERE setting_ns = '" . dcCore::app()->con->escapeStr(My::id()) . "' " .
|
"WHERE setting_ns = '" . App::con()->escapeStr(My::id()) . "' " .
|
||||||
"AND setting_id LIKE '" . $key . "%' "
|
"AND setting_id LIKE '" . $key . "%' "
|
||||||
);
|
);
|
||||||
|
|
||||||
while ($record->fetch()) {
|
while ($record->fetch()) {
|
||||||
try {
|
try {
|
||||||
$value = @unserialize($record->f('setting_value'));
|
$value = @unserialize($record->f('setting_value'));
|
||||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME);
|
$cur = App::blogWorkspace()->openBlogWorkspaceCursor();
|
||||||
$cur->setField('setting_value', json_encode(is_array($value) ? $value : []));
|
$cur->setField('setting_value', json_encode(is_array($value) ? $value : []));
|
||||||
$cur->update(
|
$cur->update(
|
||||||
"WHERE setting_id = '" . $record->f('setting_id') . "' and setting_ns = '" . dcCore::app()->con->escapeStr($record->f('setting_ns')) . "' " .
|
"WHERE setting_id = '" . $record->f('setting_id') . "' and setting_ns = '" . App::con()->escapeStr($record->f('setting_ns')) . "' " .
|
||||||
'AND blog_id ' . (null === $record->f('blog_id') ? 'IS NULL ' : ("= '" . dcCore::app()->con->escapeStr($record->f('blog_id')) . "' "))
|
'AND blog_id ' . (null === $record->f('blog_id') ? 'IS NULL ' : ("= '" . App::con()->escapeStr($record->f('blog_id')) . "' "))
|
||||||
);
|
);
|
||||||
} catch(Exception) {
|
} catch(Exception) {
|
||||||
}
|
}
|
||||||
|
|
60
src/Logs.php
60
src/Logs.php
|
@ -1,31 +1,32 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve;
|
namespace Dotclear\Plugin\improve;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use dcLog;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs management.
|
* @brief improve logs helper class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class Logs
|
class Logs
|
||||||
{
|
{
|
||||||
/** @ var array<string,array> $stack The logs stack */
|
/**
|
||||||
|
* The logs stack.
|
||||||
|
*
|
||||||
|
* @var array<string, array<string, array<int, string>|array<string, array<int, string>>>> $stack
|
||||||
|
*/
|
||||||
private array $stack;
|
private array $stack;
|
||||||
|
|
||||||
/** @var array<string,bool> $has Has log of given type */
|
/**
|
||||||
|
* Has log of given type.
|
||||||
|
*
|
||||||
|
* @var array<string, bool> $has
|
||||||
|
*/
|
||||||
private $has = [
|
private $has = [
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'warning' => false,
|
'warning' => false,
|
||||||
|
@ -37,17 +38,17 @@ class Logs
|
||||||
*
|
*
|
||||||
* @param string $task The task ID
|
* @param string $task The task ID
|
||||||
* @param string $path The path
|
* @param string $path The path
|
||||||
* @param array $msgs The messages
|
* @param array<int, string> $msgs The messages
|
||||||
*/
|
*/
|
||||||
public function add(string $task, string $path, array $msgs): void
|
public function add(string $task, string $path, array $msgs): void
|
||||||
{
|
{
|
||||||
// get existing messages
|
// Get existing messages
|
||||||
$logs = $this->stack[$task][$path] ?? [];
|
$logs = $this->stack[$task][$path] ?? [];
|
||||||
|
|
||||||
// merge with new messages
|
// Merge with new messages
|
||||||
$this->stack[$task][$path] = array_merge($logs, $msgs);
|
$this->stack[$task][$path] = array_merge($logs, $msgs);
|
||||||
|
|
||||||
// check message type
|
// Check message type
|
||||||
if (in_array($path, ['success', 'warning', 'error'])) {
|
if (in_array($path, ['success', 'warning', 'error'])) {
|
||||||
$this->has[$path] = true;
|
$this->has[$path] = true;
|
||||||
}
|
}
|
||||||
|
@ -75,11 +76,11 @@ class Logs
|
||||||
if (empty($this->stack)) {
|
if (empty($this->stack)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcLog::LOG_TABLE_NAME);
|
$cur = App::log()->openLogCursor();
|
||||||
$cur->setField('log_msg', json_encode($this->stack));
|
$cur->setField('log_msg', json_encode($this->stack));
|
||||||
$cur->setField('log_table', My::id());
|
$cur->setField('log_table', My::id());
|
||||||
|
|
||||||
return dcCore::app()->log->addLog($cur);
|
return App::log()->addLog($cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,7 +90,7 @@ class Logs
|
||||||
*
|
*
|
||||||
* @param int $id The log ID
|
* @param int $id The log ID
|
||||||
*
|
*
|
||||||
* @return array The parse logs
|
* @return array<string, array<string, array<string, array<int|string, string|array<int, string>>>>> The parse logs
|
||||||
*/
|
*/
|
||||||
public function parse(int $id): array
|
public function parse(int $id): array
|
||||||
{
|
{
|
||||||
|
@ -103,8 +104,11 @@ class Logs
|
||||||
foreach (['success', 'warning', 'error'] as $type) {
|
foreach (['success', 'warning', 'error'] as $type) {
|
||||||
$l_tools = [];
|
$l_tools = [];
|
||||||
foreach ($tools as $tool) {
|
foreach ($tools as $tool) {
|
||||||
|
if (!is_string($tool)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$l_msg = [];
|
$l_msg = [];
|
||||||
if (!empty($logs[$tool][$type][$path])) {
|
if (!empty($logs[$tool][$type][$path]) && is_array($logs[$tool][$type][$path])) {
|
||||||
foreach ($logs[$tool][$type][$path] as $msg) {
|
foreach ($logs[$tool][$type][$path] as $msg) {
|
||||||
$l_msg[] = $msg;
|
$l_msg[] = $msg;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +132,7 @@ class Logs
|
||||||
/**
|
/**
|
||||||
* Get all messages
|
* Get all messages
|
||||||
*
|
*
|
||||||
* @return array<string,array> The messages stack
|
* @return array<string, array<string, array<int, string>|array<string, array<int, string>>>> The messages stack
|
||||||
*/
|
*/
|
||||||
public function dump(): array
|
public function dump(): array
|
||||||
{
|
{
|
||||||
|
@ -142,15 +146,15 @@ class Logs
|
||||||
*
|
*
|
||||||
* @param int $id The log ID
|
* @param int $id The log ID
|
||||||
*
|
*
|
||||||
* @return array The logs
|
* @return array<string, array<string, array<int, string>|array<string, array<int, string>>>> The logs
|
||||||
*/
|
*/
|
||||||
private function read(int $id): array
|
private function read(int $id): array
|
||||||
{
|
{
|
||||||
$rs = dcCore::app()->log->getLogs(['log_table' => My::id(), 'log_id' => $id, 'limit' => 1]);
|
$rs = App::log()->getLogs(['log_table' => My::id(), 'log_id' => $id, 'limit' => 1]);
|
||||||
if ($rs->isEmpty()) {
|
if ($rs->isEmpty()) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
dcCore::app()->log->delLogs($rs->f('log_id'));
|
App::log()->delLogs($rs->f('log_id'));
|
||||||
|
|
||||||
$res = json_decode($rs->f('log_msg'), true);
|
$res = json_decode($rs->f('log_msg'), true);
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve;
|
namespace Dotclear\Plugin\improve;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use dcThemes;
|
|
||||||
use Dotclear\Core\Backend\Notices;
|
use Dotclear\Core\Backend\Notices;
|
||||||
use Dotclear\Core\Backend\Page;
|
use Dotclear\Core\Backend\Page;
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
|
@ -35,20 +24,33 @@ use Dotclear\Helper\Text as TText;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve page class
|
* @brief improve manage class.
|
||||||
|
* @ingroup improve
|
||||||
*
|
*
|
||||||
* Display page and configure modules
|
* @author Jean-Christian Denis
|
||||||
* and execute tasks.
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class Manage extends Process
|
class Manage extends Process
|
||||||
{
|
{
|
||||||
/** @var string $type Current module(s) type */
|
/**
|
||||||
|
* Current module(s) type.
|
||||||
|
*
|
||||||
|
* @var string $type
|
||||||
|
*/
|
||||||
private static string $type = 'plugin';
|
private static string $type = 'plugin';
|
||||||
|
|
||||||
/** @var string $module Current module id */
|
/**
|
||||||
|
* Current module id.
|
||||||
|
*
|
||||||
|
* @var string $module
|
||||||
|
*/
|
||||||
private static string $module = '-';
|
private static string $module = '-';
|
||||||
|
|
||||||
/** @var null|Task $task Current tasks instance */
|
/**
|
||||||
|
* Current tasks instance.
|
||||||
|
*
|
||||||
|
* @var null|Task $task
|
||||||
|
*/
|
||||||
private static ?Task $task = null;
|
private static ?Task $task = null;
|
||||||
|
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
|
@ -77,11 +79,11 @@ class Manage extends Process
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
$time = Improve::instance()->fix(
|
$time = Improve::instance()->fix(
|
||||||
self::$type == 'plugin' ? dcCore::app()->plugins->getDefine(self::$module) : dcCore::app()->themes->getDefine(self::$module),
|
self::$type == 'plugin' ? App::plugins()->getDefine(self::$module) : App::themes()->getDefine(self::$module),
|
||||||
$_POST['actions']
|
$_POST['actions']
|
||||||
);
|
);
|
||||||
$log_id = Improve::instance()->logs->write();
|
$log_id = Improve::instance()->logs->write();
|
||||||
dcCore::app()->blog?->triggerBlog();
|
App::blog()->triggerBlog();
|
||||||
|
|
||||||
if (Improve::instance()->logs->has('error')) {
|
if (Improve::instance()->logs->has('error')) {
|
||||||
$notice = ['type' => Notices::NOTICE_ERROR, 'msg' => __('Fix of "%s" complete in %s secondes with errors')];
|
$notice = ['type' => Notices::NOTICE_ERROR, 'msg' => __('Fix of "%s" complete in %s secondes with errors')];
|
||||||
|
@ -96,7 +98,7 @@ class Manage extends Process
|
||||||
|
|
||||||
$done = true;
|
$done = true;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
App::error()->add($e->getMessage());
|
||||||
$done = false;
|
$done = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,6 +140,9 @@ class Manage extends Process
|
||||||
Page::closeModule();
|
Page::closeModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure a task.
|
||||||
|
*/
|
||||||
private static function displayConfigurator(): void
|
private static function displayConfigurator(): void
|
||||||
{
|
{
|
||||||
$back_url = $_REQUEST['redir'] ?? My::manageURL(['type' => self::$type]);
|
$back_url = $_REQUEST['redir'] ?? My::manageURL(['type' => self::$type]);
|
||||||
|
@ -162,12 +167,15 @@ class Manage extends Process
|
||||||
(new Hidden('type', self::$type)),
|
(new Hidden('type', self::$type)),
|
||||||
(new Hidden('config', self::$task->properties->id)),
|
(new Hidden('config', self::$task->properties->id)),
|
||||||
(new Hidden('redir', $redir)),
|
(new Hidden('redir', $redir)),
|
||||||
dcCore::app()->formNonce(false),
|
App::nonce()->formNonce(),
|
||||||
]),
|
]),
|
||||||
])->render();
|
])->render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show actions.
|
||||||
|
*/
|
||||||
private static function displayActions(): void
|
private static function displayActions(): void
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
|
@ -190,7 +198,7 @@ class Manage extends Process
|
||||||
'<th colspan="2" class="first">' . __('Task') . '</td>' .
|
'<th colspan="2" class="first">' . __('Task') . '</td>' .
|
||||||
'<th scope="col">' . __('Description') . '</td>' .
|
'<th scope="col">' . __('Description') . '</td>' .
|
||||||
'<th scope="col">' . __('Configuration') . '</td>' .
|
'<th scope="col">' . __('Configuration') . '</td>' .
|
||||||
(DC_DEBUG ? '<th scope="col">' . __('Priority') . '</td>' : '') . /* @phpstan-ignore-line */
|
(App::config()->debugMode() ? '<th scope="col">' . __('Priority') . '</td>' : '') . /* @phpstan-ignore-line */
|
||||||
'</tr></thead><tbody>';
|
'</tr></thead><tbody>';
|
||||||
foreach (Improve::instance()->tasks->dump() as $task) {
|
foreach (Improve::instance()->tasks->dump() as $task) {
|
||||||
if ($task->isDisabled() || !in_array(self::$type, $task->properties->types)) {
|
if ($task->isDisabled() || !in_array(self::$type, $task->properties->types)) {
|
||||||
|
@ -213,7 +221,7 @@ class Manage extends Process
|
||||||
'<a class="module-config" href="' . My::manageUrl(['type' => self::$type, 'config' => $task->properties->id]) .
|
'<a class="module-config" href="' . My::manageUrl(['type' => self::$type, 'config' => $task->properties->id]) .
|
||||||
'" title="' . sprintf(__("Configure task '%s'"), $task->properties->name) . '">' . __('Configure') . '</a>'
|
'" title="' . sprintf(__("Configure task '%s'"), $task->properties->name) . '">' . __('Configure') . '</a>'
|
||||||
) . '</td>' .
|
) . '</td>' .
|
||||||
(DC_DEBUG ? '<td class="minimal"><span class="debug">' . $task->properties->priority . '</span></td>' : '') . /* @phpstan-ignore-line */
|
(App::config()->debugMode() ? '<td class="minimal"><span class="debug">' . $task->properties->priority . '</span></td>' : '') . /* @phpstan-ignore-line */
|
||||||
'</tr>';
|
'</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,13 +236,13 @@ class Manage extends Process
|
||||||
(new Select('module'))->default(self::$module)->items($combo_modules),
|
(new Select('module'))->default(self::$module)->items($combo_modules),
|
||||||
(new Submit('fix'))->value(__('Fix it')),
|
(new Submit('fix'))->value(__('Fix it')),
|
||||||
(new Hidden(['type'], self::$type)),
|
(new Hidden(['type'], self::$type)),
|
||||||
dcCore::app()->formNonce(false),
|
App::nonce()->formNonce(),
|
||||||
]),
|
]),
|
||||||
])->render() .
|
])->render() .
|
||||||
'<br class="clear" />
|
'<br class="clear" />
|
||||||
</form>';
|
</form>';
|
||||||
|
|
||||||
if (!empty($_REQUEST['upd']) && !My::settings()?->get('nodetails')) {
|
if (!empty($_REQUEST['upd']) && !My::settings()->get('nodetails')) {
|
||||||
$logs = Improve::instance()->logs->parse((int) $_REQUEST['upd']);
|
$logs = Improve::instance()->logs->parse((int) $_REQUEST['upd']);
|
||||||
|
|
||||||
if (!empty($logs)) {
|
if (!empty($logs)) {
|
||||||
|
@ -248,9 +256,11 @@ class Manage extends Process
|
||||||
if (null !== $a) {
|
if (null !== $a) {
|
||||||
echo '<li>' . $a->properties->name . '<ul>';
|
echo '<li>' . $a->properties->name . '<ul>';
|
||||||
foreach ($msgs as $msg) {
|
foreach ($msgs as $msg) {
|
||||||
|
if (is_string($msg)) {
|
||||||
echo '<li>' . $msg . '</li>';
|
echo '<li>' . $msg . '</li>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
echo '</ul></li>';
|
echo '</ul></li>';
|
||||||
}
|
}
|
||||||
echo '</ul></div>';
|
echo '</ul></div>';
|
||||||
|
@ -283,11 +293,16 @@ class Manage extends Process
|
||||||
return empty($_REQUEST['config']) ? null : Improve::instance()->tasks->get($_REQUEST['config']);
|
return empty($_REQUEST['config']) ? null : Improve::instance()->tasks->get($_REQUEST['config']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get tasks preferences.
|
||||||
|
*
|
||||||
|
* @return array<string, array<string, mixed>|mixed>
|
||||||
|
*/
|
||||||
private static function getPreference(bool $all = false): array
|
private static function getPreference(bool $all = false): array
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (!empty(self::$type)) {
|
if (!empty(self::$type)) {
|
||||||
$preferences = My::settings()?->get('preferences');
|
$preferences = My::settings()->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)) {
|
||||||
|
@ -303,7 +318,7 @@ class Manage extends Process
|
||||||
|
|
||||||
private static function setPreferences(): bool
|
private static function setPreferences(): bool
|
||||||
{
|
{
|
||||||
if (!empty($_POST['save_preferences']) && !is_null(dcCore::app()->blog)) {
|
if (!empty($_POST['save_preferences']) && App::blog()->isDefined()) {
|
||||||
$preferences = self::getPreference(true);
|
$preferences = self::getPreference(true);
|
||||||
$preferences[self::$type] = [];
|
$preferences[self::$type] = [];
|
||||||
if (!empty($_POST['actions'])) {
|
if (!empty($_POST['actions'])) {
|
||||||
|
@ -313,7 +328,7 @@ class Manage extends Process
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
My::settings()?->put('preferences', json_encode($preferences), 'string', null, true, true);
|
My::settings()->put('preferences', json_encode($preferences), 'string', null, true, true);
|
||||||
Notices::addSuccessNotice(__('Configuration successfully updated'));
|
Notices::addSuccessNotice(__('Configuration successfully updated'));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -322,20 +337,24 @@ class Manage extends Process
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get modules combo list.
|
||||||
|
*
|
||||||
|
* @return array<string, string> The modules combo
|
||||||
|
*/
|
||||||
private static function comboModules(): array
|
private static function comboModules(): array
|
||||||
{
|
{
|
||||||
if (is_null(dcCore::app()->blog)) {
|
if (!App::blog()->isDefined()) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dcCore::app()->themes instanceof dcThemes)) {
|
if (!App::themes()->isEmpty()) {
|
||||||
dcCore::app()->themes = new dcThemes();
|
App::themes()->loadModules(App::blog()->themesPath(), null);
|
||||||
dcCore::app()->themes->loadModules(dcCore::app()->blog->themes_path, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$combo_modules = [];
|
$combo_modules = [];
|
||||||
$modules = self::$type == 'plugin' ? dcCore::app()->plugins->getDefines() : dcCore::app()->themes->getDefines();
|
$modules = self::$type == 'plugin' ? App::plugins()->getDefines() : App::themes()->getDefines();
|
||||||
if (My::settings()?->get('combosortby') === 'id') {
|
if (My::settings()->get('combosortby') === 'id') {
|
||||||
uasort($modules, fn ($a, $b) => strtolower($a->getId()) <=> strtolower($b->getId()));
|
uasort($modules, fn ($a, $b) => strtolower($a->getId()) <=> strtolower($b->getId()));
|
||||||
} else {
|
} else {
|
||||||
uasort($modules, fn ($a, $b) => strtolower(TText::removeDiacritics($a->get('name'))) <=> strtolower(TText::removeDiacritics($b->get('name'))));
|
uasort($modules, fn ($a, $b) => strtolower(TText::removeDiacritics($a->get('name'))) <=> strtolower(TText::removeDiacritics($b->get('name'))));
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve;
|
namespace Dotclear\Plugin\improve;
|
||||||
|
@ -17,22 +7,30 @@ namespace Dotclear\Plugin\improve;
|
||||||
use Dotclear\Helper\File\Path;
|
use Dotclear\Helper\File\Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve module helper
|
* @brief improve module helper class.
|
||||||
|
* @ingroup improve
|
||||||
*
|
*
|
||||||
* Help to load module configuration file (_define.php)
|
* Help to load module configuration file (_define.php)
|
||||||
* and gather information about it.
|
* and gather information about it.
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class Module
|
class Module
|
||||||
{
|
{
|
||||||
/** @var array Current module properties */
|
/**
|
||||||
|
* Current module properties.
|
||||||
|
*
|
||||||
|
* @var array<string, mixed> $properties
|
||||||
|
*/
|
||||||
private $properties = [];
|
private $properties = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param string $type Module type, plugin or theme
|
* @param string $type Module type, plugin or theme
|
||||||
* @param string $id Module id
|
* @param string $id Module id
|
||||||
* @param array $properties Module properties
|
* @param array<string, mixed> $properties Module properties
|
||||||
*/
|
*/
|
||||||
public function __construct(string $type, string $id, array $properties = [])
|
public function __construct(string $type, string $id, array $properties = [])
|
||||||
{
|
{
|
||||||
|
@ -41,9 +39,9 @@ class Module
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get module properties
|
* Get module properties.
|
||||||
*
|
*
|
||||||
* @return array The properties
|
* @return array<string, mixed> The properties
|
||||||
*/
|
*/
|
||||||
public function get(): array
|
public function get(): array
|
||||||
{
|
{
|
||||||
|
@ -51,13 +49,13 @@ class Module
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get clean properties of registered module
|
* Get clean properties of registered module.
|
||||||
*
|
*
|
||||||
* @param string $type Module type, plugin or theme
|
* @param string $type Module type, plugin or theme
|
||||||
* @param string $id Module id
|
* @param string $id Module id
|
||||||
* @param array $properties Module properties
|
* @param array<string, mixed> $properties Module properties
|
||||||
*
|
*
|
||||||
* @return array Module properties
|
* @return array<string, mixed> Module properties
|
||||||
*/
|
*/
|
||||||
public static function clean(string $type, string $id, array $properties): array
|
public static function clean(string $type, string $id, array $properties): array
|
||||||
{
|
{
|
||||||
|
@ -67,12 +65,12 @@ class Module
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replicate dcModule::loadDefine
|
* Replicate dcModule::loadDefine.
|
||||||
*
|
*
|
||||||
* @param string $id Module id
|
* @param string $id Module id
|
||||||
* @param string $root Module path
|
* @param string $root Module path
|
||||||
*
|
*
|
||||||
* @return boolean Success
|
* @return bool True on success
|
||||||
*/
|
*/
|
||||||
private function loadDefine(string $id, string $root): bool
|
private function loadDefine(string $id, string $root): bool
|
||||||
{
|
{
|
||||||
|
@ -86,7 +84,7 @@ class Module
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replicate dcModule::registerModule
|
* Replicate dcModule::registerModule.
|
||||||
*
|
*
|
||||||
* @param string $name The module name
|
* @param string $name The module name
|
||||||
* @param string $desc The module description
|
* @param string $desc The module description
|
||||||
|
@ -94,7 +92,7 @@ class Module
|
||||||
* @param string $version The module version
|
* @param string $version The module version
|
||||||
* @param string|array $properties The properties
|
* @param string|array $properties The properties
|
||||||
*
|
*
|
||||||
* @return boolean Success
|
* @return bool True on success
|
||||||
* @phpstan-ignore-next-line
|
* @phpstan-ignore-next-line
|
||||||
*/
|
*/
|
||||||
private function registerModule(string $name, string $desc, string $author, string $version, $properties = []): bool
|
private function registerModule(string $name, string $desc, string $author, string $version, $properties = []): bool
|
||||||
|
@ -128,13 +126,13 @@ class Module
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replicate ModulesList::sanitizeModule
|
* Replicate ModulesList::sanitizeModule.
|
||||||
*
|
*
|
||||||
* @param string $type Module type
|
* @param string $type Module type
|
||||||
* @param string $id Module id
|
* @param string $id Module id
|
||||||
* @param array $properties Module properties
|
* @param array<string, mixed> $properties Module properties
|
||||||
*
|
*
|
||||||
* @return array Sanitized module properties
|
* @return array<string, mixed> Sanitized module properties
|
||||||
*/
|
*/
|
||||||
public static function sanitizeModule(string $type, string $id, array $properties): array
|
public static function sanitizeModule(string $type, string $id, array $properties): array
|
||||||
{
|
{
|
||||||
|
@ -184,7 +182,7 @@ class Module
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replicate ModulesList::sanitizeString
|
* Replicate ModulesList::sanitizeString.
|
||||||
*
|
*
|
||||||
* @param string $str String to sanitize
|
* @param string $str String to sanitize
|
||||||
*
|
*
|
||||||
|
|
27
src/My.php
27
src/My.php
|
@ -1,27 +1,26 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve;
|
namespace Dotclear\Plugin\improve;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Module\MyPlugin;
|
use Dotclear\Module\MyPlugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief improve My helper.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
class My extends MyPlugin
|
class My extends MyPlugin
|
||||||
{
|
{
|
||||||
protected static function checkCustomContext(int $context): ?bool
|
protected static function checkCustomContext(int $context): ?bool
|
||||||
{
|
{
|
||||||
return $context === My::INSTALL ? null :
|
return match ($context) {
|
||||||
defined('DC_CONTEXT_ADMIN') && dcCore::app()->auth->isSuperAdmin();
|
self::MODULE => App::auth()->isSuperAdmin(),
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
98
src/Task.php
98
src/Task.php
|
@ -1,55 +1,91 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve;
|
namespace Dotclear\Plugin\improve;
|
||||||
|
|
||||||
use dcModuleDefine;
|
use Dotclear\Module\ModuleDefine;
|
||||||
use Dotclear\Helper\Network\Http;
|
use Dotclear\Helper\Network\Http;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task abstract class.
|
* @brief improve task helper.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* Task MUST extends this class.
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
abstract class Task
|
abstract class Task
|
||||||
{
|
{
|
||||||
/** @var TaskDescriptor Task descriptor instance */
|
/**
|
||||||
|
* Task descriptor instance.
|
||||||
|
*
|
||||||
|
* @var TaskDescriptor $properties
|
||||||
|
*/
|
||||||
public readonly TaskDescriptor $properties;
|
public readonly TaskDescriptor $properties;
|
||||||
|
|
||||||
/** @var TaskMessages Task success messages instance */
|
/**
|
||||||
|
* Task success messages instance.
|
||||||
|
*
|
||||||
|
* @var TaskMessages $success
|
||||||
|
*/
|
||||||
public readonly TaskMessages $success;
|
public readonly TaskMessages $success;
|
||||||
|
|
||||||
/** @var TaskMessages Task warning messages instance */
|
/**
|
||||||
|
* Task warning messages instance.
|
||||||
|
*
|
||||||
|
* @var TaskMessages $warning
|
||||||
|
*/
|
||||||
public readonly TaskMessages $warning;
|
public readonly TaskMessages $warning;
|
||||||
|
|
||||||
/** @var TaskMessages Task error messages instance */
|
/**
|
||||||
|
* Task error messages instance.
|
||||||
|
*
|
||||||
|
* @var TaskMessages $error
|
||||||
|
*/
|
||||||
public readonly TaskMessages $error;
|
public readonly TaskMessages $error;
|
||||||
|
|
||||||
/** @var TaskSettings Task settings instance */
|
/**
|
||||||
|
* Task settings instance.
|
||||||
|
*
|
||||||
|
* @var TaskSettings $settings
|
||||||
|
*/
|
||||||
protected readonly TaskSettings $settings;
|
protected readonly TaskSettings $settings;
|
||||||
|
|
||||||
/** @var dcModuleDefine Current module */
|
/**
|
||||||
protected dcModuleDefine $module;
|
* Current module.
|
||||||
|
*
|
||||||
|
* @var ModuleDefine $module
|
||||||
|
*/
|
||||||
|
protected ModuleDefine $module;
|
||||||
|
|
||||||
/** @var bool Is disabled task */
|
/**
|
||||||
|
* Is disabled task.
|
||||||
|
*
|
||||||
|
* @var bool $disabled
|
||||||
|
*/
|
||||||
private bool $disabled = false;
|
private bool $disabled = false;
|
||||||
|
|
||||||
/** @var string Current full path */
|
/**
|
||||||
|
* Current full path.
|
||||||
|
*
|
||||||
|
* @var string $path_full
|
||||||
|
*/
|
||||||
protected string $path_full = '';
|
protected string $path_full = '';
|
||||||
|
|
||||||
/** @var string Current file extension */
|
/**
|
||||||
|
* Current file extension.
|
||||||
|
*
|
||||||
|
* @var string $path_extension
|
||||||
|
*/
|
||||||
protected string $path_extension = '';
|
protected string $path_extension = '';
|
||||||
|
|
||||||
/** @var null|bool Current path is directory */
|
/**
|
||||||
|
* Current path is directory.
|
||||||
|
*
|
||||||
|
* @var null|bool $path_is_dir
|
||||||
|
*/
|
||||||
protected ?bool $path_is_dir = null;
|
protected ?bool $path_is_dir = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,7 +98,7 @@ abstract class Task
|
||||||
$this->error = new TaskMessages();
|
$this->error = new TaskMessages();
|
||||||
$this->properties = $this->getProperties();
|
$this->properties = $this->getProperties();
|
||||||
$this->settings = new TaskSettings($this->properties->id);
|
$this->settings = new TaskSettings($this->properties->id);
|
||||||
$this->module = new dcModuleDefine('undefined');
|
$this->module = new ModuleDefine('undefined');
|
||||||
|
|
||||||
$this->init();
|
$this->init();
|
||||||
}
|
}
|
||||||
|
@ -129,12 +165,12 @@ abstract class Task
|
||||||
/**
|
/**
|
||||||
* Check if task is well configured
|
* Check if task is well configured
|
||||||
*
|
*
|
||||||
* @return boolean True on well configured
|
* @return bool True on well configured
|
||||||
*/
|
*/
|
||||||
abstract public function isConfigured(): bool;
|
abstract public function isConfigured(): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get task configuration page header
|
* Get task configuration page header.
|
||||||
*
|
*
|
||||||
* @return string Headers
|
* @return string Headers
|
||||||
*/
|
*/
|
||||||
|
@ -144,7 +180,7 @@ abstract class Task
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get configuraton gui
|
* Get configuraton gui.
|
||||||
*
|
*
|
||||||
* If task class uses internal configuration,
|
* If task class uses internal configuration,
|
||||||
* it must share here html form content of its settings.
|
* it must share here html form content of its settings.
|
||||||
|
@ -166,9 +202,9 @@ abstract class Task
|
||||||
*
|
*
|
||||||
* @see Improve::sanitizeModule()
|
* @see Improve::sanitizeModule()
|
||||||
*
|
*
|
||||||
* @param dcModuleDefine $module Module definitons
|
* @param ModuleDefine $module Module definitons
|
||||||
*/
|
*/
|
||||||
final public function setModule(dcModuleDefine $module): bool
|
final public function setModule(ModuleDefine $module): bool
|
||||||
{
|
{
|
||||||
$this->module = $module;
|
$this->module = $module;
|
||||||
|
|
||||||
|
@ -180,7 +216,7 @@ abstract class Task
|
||||||
*
|
*
|
||||||
* @param string $path_full Full path
|
* @param string $path_full Full path
|
||||||
* @param string $path_extension Path extension (if it is a file)
|
* @param string $path_extension Path extension (if it is a file)
|
||||||
* @param boolean $path_is_dir True if path is a directory
|
* @param bool $path_is_dir True if path is a directory
|
||||||
*/
|
*/
|
||||||
final public function setPath(string $path_full, string $path_extension, bool $path_is_dir): bool
|
final public function setPath(string $path_full, string $path_extension, bool $path_is_dir): bool
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,20 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve\Task;
|
namespace Dotclear\Plugin\improve\Task;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Helper\Html\Form\{
|
use Dotclear\Helper\Html\Form\{
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Div,
|
Div,
|
||||||
|
@ -34,11 +24,19 @@ use Dotclear\Plugin\improve\{
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve action module php header
|
* @brief improve task: php header class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class CssHeader extends Task
|
class CssHeader extends Task
|
||||||
{
|
{
|
||||||
/** @var string Exemple of header */
|
/**
|
||||||
|
* Exemple of header.
|
||||||
|
*
|
||||||
|
* @var string $exemple
|
||||||
|
*/
|
||||||
private static $exemple = <<<EOF
|
private static $exemple = <<<EOF
|
||||||
@brief %module_id%, a %module_type% for Dotclear 2
|
@brief %module_id%, a %module_type% for Dotclear 2
|
||||||
|
|
||||||
|
@ -51,7 +49,11 @@ class CssHeader extends Task
|
||||||
@copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
@copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
/** @var array<string> Allowed bloc replacement */
|
/**
|
||||||
|
* Allowed bloc replacement.
|
||||||
|
*
|
||||||
|
* @var array<int, string> $bloc_wildcards
|
||||||
|
*/
|
||||||
private $bloc_wildcards = [
|
private $bloc_wildcards = [
|
||||||
'%year%',
|
'%year%',
|
||||||
'%module_id%',
|
'%module_id%',
|
||||||
|
@ -64,16 +66,32 @@ class CssHeader extends Task
|
||||||
'%user_url%',
|
'%user_url%',
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var array Allowed action for header */
|
/**
|
||||||
|
* Allowed action for header.
|
||||||
|
*
|
||||||
|
* @var array<string, string> $action_bloc
|
||||||
|
*/
|
||||||
private $action_bloc = [];
|
private $action_bloc = [];
|
||||||
|
|
||||||
/** @var string Parsed bloc */
|
/**
|
||||||
|
* Parsed bloc.
|
||||||
|
*
|
||||||
|
* @var string $bloc
|
||||||
|
*/
|
||||||
private $bloc = '';
|
private $bloc = '';
|
||||||
|
|
||||||
/** @var boolean Stop parsing files */
|
/**
|
||||||
|
* Stop parsing files.
|
||||||
|
*
|
||||||
|
* @var bool $stop_scan
|
||||||
|
*/
|
||||||
private $stop_scan = false;
|
private $stop_scan = false;
|
||||||
|
|
||||||
/** @var string Settings bloc content */
|
/**
|
||||||
|
* Settings bloc content.
|
||||||
|
*
|
||||||
|
* @var string $bloc_content
|
||||||
|
*/
|
||||||
private $bloc_content = '';
|
private $bloc_content = '';
|
||||||
|
|
||||||
protected function getProperties(): TaskDescriptor
|
protected function getProperties(): TaskDescriptor
|
||||||
|
@ -91,7 +109,7 @@ class CssHeader extends Task
|
||||||
protected function init(): bool
|
protected function init(): bool
|
||||||
{
|
{
|
||||||
$this->action_bloc = [
|
$this->action_bloc = [
|
||||||
__('Do nothing') => 0,
|
__('Do nothing') => '',
|
||||||
__('Add bloc if it does not exist') => 'create',
|
__('Add bloc if it does not exist') => 'create',
|
||||||
__('Add and overwrite bloc') => 'overwrite',
|
__('Add and overwrite bloc') => 'overwrite',
|
||||||
__('Overwrite bloc only if it exists') => 'replace',
|
__('Overwrite bloc only if it exists') => 'replace',
|
||||||
|
@ -162,12 +180,6 @@ class CssHeader extends Task
|
||||||
|
|
||||||
public function openModule(): ?bool
|
public function openModule(): ?bool
|
||||||
{
|
{
|
||||||
if (!isset(dcCore::app()->auth)) {
|
|
||||||
$this->warning->add(__('Auth is not set'));
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$bloc = trim($this->bloc_content);
|
$bloc = trim($this->bloc_content);
|
||||||
|
|
||||||
if (empty($bloc)) {
|
if (empty($bloc)) {
|
||||||
|
@ -188,13 +200,13 @@ class CssHeader extends Task
|
||||||
[
|
[
|
||||||
date('Y'),
|
date('Y'),
|
||||||
$this->module->getId(),
|
$this->module->getId(),
|
||||||
$this->module->get('name'),
|
(string) $this->module->get('name'),
|
||||||
$this->module->get('author'),
|
(string) $this->module->get('author'),
|
||||||
$this->module->get('type'),
|
(string) $this->module->get('type'),
|
||||||
dcCore::app()->auth->getInfo('user_cn'),
|
(string) App::auth()->getInfo('user_cn'),
|
||||||
dcCore::app()->auth->getinfo('user_name'),
|
(string) App::auth()->getinfo('user_name'),
|
||||||
dcCore::app()->auth->getInfo('user_email'),
|
(string) App::auth()->getInfo('user_email'),
|
||||||
dcCore::app()->auth->getInfo('user_url'),
|
(string) App::auth()->getInfo('user_url'),
|
||||||
],
|
],
|
||||||
(string) $bloc
|
(string) $bloc
|
||||||
)
|
)
|
||||||
|
@ -252,7 +264,7 @@ class CssHeader extends Task
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write bloc content in file content
|
* Write bloc content in file content.
|
||||||
*
|
*
|
||||||
* @param string $content Old content
|
* @param string $content Old content
|
||||||
* @return string New content
|
* @return string New content
|
||||||
|
@ -275,7 +287,7 @@ class CssHeader extends Task
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete bloc content in file content
|
* Delete bloc content in file content.
|
||||||
*
|
*
|
||||||
* @param string $content Old content
|
* @param string $content Old content
|
||||||
* @return string New content
|
* @return string New content
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve\Task;
|
namespace Dotclear\Plugin\improve\Task;
|
||||||
|
@ -24,14 +14,28 @@ use Dotclear\Plugin\improve\{
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve action module Dotclear depreciated
|
* @brief improve task: deprecated class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class DcDeprecated extends Task
|
class DcDeprecated extends Task
|
||||||
{
|
{
|
||||||
/** @var array Deprecated functions [filetype [pattern, deprecated, replacement, version, help link]] */
|
/**
|
||||||
|
* Deprecated functions.
|
||||||
|
*
|
||||||
|
* [filetype [pattern, deprecated, replacement, version, help link]]
|
||||||
|
*
|
||||||
|
* @var array<string, array<int, array<int<0, 4>, string>>> $deprecated
|
||||||
|
*/
|
||||||
private $deprecated = ['php' => [], 'js' => []];
|
private $deprecated = ['php' => [], 'js' => []];
|
||||||
|
|
||||||
/** @var boolean Stop parsing files */
|
/**
|
||||||
|
* Stop parsing files
|
||||||
|
*
|
||||||
|
* @var bool $stop_scan
|
||||||
|
*/
|
||||||
private $stop_scan = false;
|
private $stop_scan = false;
|
||||||
|
|
||||||
protected function getProperties(): TaskDescriptor
|
protected function getProperties(): TaskDescriptor
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve\Task;
|
namespace Dotclear\Plugin\improve\Task;
|
||||||
|
@ -34,11 +24,19 @@ use Dotclear\Plugin\improve\{
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve action module dcstore.xml
|
* @brief improve task: dcstore class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class DcStore extends Task
|
class DcStore extends Task
|
||||||
{
|
{
|
||||||
/** @var string Settings dcstore zip url pattern */
|
/**
|
||||||
|
* Settings dcstore zip url pattern.
|
||||||
|
*
|
||||||
|
* @var string $pattern
|
||||||
|
*/
|
||||||
private $pattern = '';
|
private $pattern = '';
|
||||||
|
|
||||||
protected function getProperties(): TaskDescriptor
|
protected function getProperties(): TaskDescriptor
|
||||||
|
@ -109,6 +107,11 @@ class DcStore extends Task
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate dcstore XML content.
|
||||||
|
*
|
||||||
|
* @return string The XML content
|
||||||
|
*/
|
||||||
public function generateXML(): string
|
public function generateXML(): string
|
||||||
{
|
{
|
||||||
$xml = ['<modules xmlns:da="http://dotaddict.org/da/">'];
|
$xml = ['<modules xmlns:da="http://dotaddict.org/da/">'];
|
||||||
|
@ -203,6 +206,11 @@ class DcStore extends Task
|
||||||
return self::prettyXML($res->toXML());
|
return self::prettyXML($res->toXML());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up XML content.
|
||||||
|
*
|
||||||
|
* @return string The pretty XML content
|
||||||
|
*/
|
||||||
private static function prettyXML(string $str): string
|
private static function prettyXML(string $str): string
|
||||||
{
|
{
|
||||||
if (class_exists('DOMDocument')) {
|
if (class_exists('DOMDocument')) {
|
||||||
|
@ -217,6 +225,11 @@ class DcStore extends Task
|
||||||
return str_replace('><', ">\n<", $str);
|
return str_replace('><', ">\n<", $str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse module info.
|
||||||
|
*
|
||||||
|
* @return string The parsed content
|
||||||
|
*/
|
||||||
private function parseFilePattern(): string
|
private function parseFilePattern(): string
|
||||||
{
|
{
|
||||||
return Text::tidyURL(str_replace(
|
return Text::tidyURL(str_replace(
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve\Task;
|
namespace Dotclear\Plugin\improve\Task;
|
||||||
|
@ -29,7 +19,11 @@ use Dotclear\Plugin\improve\{
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve action module end of file
|
* @brief improve task: EOF class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class EndOfFile extends Task
|
class EndOfFile extends Task
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,20 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve\Task;
|
namespace Dotclear\Plugin\improve\Task;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Helper\Html\Form\{
|
use Dotclear\Helper\Html\Form\{
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Div,
|
Div,
|
||||||
|
@ -31,35 +21,66 @@ use Dotclear\Plugin\improve\{
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve action module Github shields.io
|
* @brief improve task: EOF class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class GitShields extends Task
|
class GitShields extends Task
|
||||||
{
|
{
|
||||||
/** @var string Username of git repo */
|
/**
|
||||||
|
* Username of git repo.
|
||||||
|
* @var string $username
|
||||||
|
*/
|
||||||
private $username = '';
|
private $username = '';
|
||||||
|
|
||||||
/** @var string Domain of git repo */
|
/**
|
||||||
|
* Domain of git repo.
|
||||||
|
*
|
||||||
|
* @var string $domain
|
||||||
|
*/
|
||||||
private $domain = 'github.com';
|
private $domain = 'github.com';
|
||||||
|
|
||||||
/** @var boolean add Dotaddict shield */
|
/**
|
||||||
|
* Add Dotaddict shield.
|
||||||
|
*
|
||||||
|
* @var bool $dotaddict
|
||||||
|
*/
|
||||||
private $dotaddict = false;
|
private $dotaddict = false;
|
||||||
|
|
||||||
/** @var boolean Stop scaning files */
|
/**
|
||||||
|
* Stop scaning files.
|
||||||
|
*
|
||||||
|
* @var bool $stop_scan
|
||||||
|
*/
|
||||||
private $stop_scan = false;
|
private $stop_scan = false;
|
||||||
|
|
||||||
/** @var array Parsed bloc */
|
/**
|
||||||
|
* Parsed bloc.
|
||||||
|
*
|
||||||
|
* @var array<string, string> $blocs
|
||||||
|
*/
|
||||||
private $blocs = [];
|
private $blocs = [];
|
||||||
|
|
||||||
/** @var array Search patterns */
|
/**
|
||||||
|
* Search patterns.
|
||||||
|
*
|
||||||
|
* @var array<string, string> $bloc_pattern
|
||||||
|
*/
|
||||||
protected $bloc_pattern = [
|
protected $bloc_pattern = [
|
||||||
'remove' => '/\[!\[Release(.*)LICENSE\)/ms',
|
'remove' => '/\[!\[Release(.*)LICENSE\)/ms',
|
||||||
'target' => '/^([^\n]+)[\r\n|\n]{1,}/ms',
|
'target' => '/^([^\n]+)[\r\n|\n]{1,}/ms',
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var array Shields patterns */
|
/**
|
||||||
|
* Shields patterns.
|
||||||
|
*
|
||||||
|
* @var array<string, string> $bloc_content
|
||||||
|
*/
|
||||||
protected $bloc_content = [
|
protected $bloc_content = [
|
||||||
'release' => '[![Release](https://img.shields.io/badge/release-%version%-a2cbe9.svg)](https://%domain%/%username%/%module%/releases)',
|
'release' => '[![Release](https://img.shields.io/badge/release-%version%-a2cbe9.svg)](https://%domain%/%username%/%module%/releases)',
|
||||||
'date' => '[![Date](https://img.shields.io/badge/date-%date%-c44d58.svg)](https://%domain%/%username%/%module%/releases)',
|
'date' => '![Date](https://img.shields.io/badge/date-%date%-c44d58.svg)',
|
||||||
# 'issues' => '[![Issues](https://img.shields.io/github/issues/%username%/%module%)](https://%domain%/%username%/%module%/issues)',
|
# 'issues' => '[![Issues](https://img.shields.io/github/issues/%username%/%module%)](https://%domain%/%username%/%module%/issues)',
|
||||||
'dotclear' => '[![Dotclear](https://img.shields.io/badge/dotclear-v%dotclear%-137bbb.svg)](https://fr.dotclear.org/download)',
|
'dotclear' => '[![Dotclear](https://img.shields.io/badge/dotclear-v%dotclear%-137bbb.svg)](https://fr.dotclear.org/download)',
|
||||||
'dotaddict' => '[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://%type%s.dotaddict.org/dc2/details/%module%)',
|
'dotaddict' => '[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://%type%s.dotaddict.org/dc2/details/%module%)',
|
||||||
|
@ -150,6 +171,9 @@ class GitShields extends Task
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse module and user info.
|
||||||
|
*/
|
||||||
private function replaceInfo(): void
|
private function replaceInfo(): void
|
||||||
{
|
{
|
||||||
$blocs = [];
|
$blocs = [];
|
||||||
|
@ -185,6 +209,9 @@ class GitShields extends Task
|
||||||
$this->success->add(__('Prepare custom shield info'));
|
$this->success->add(__('Prepare custom shield info'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get dotclear version.
|
||||||
|
*/
|
||||||
private function getDotclearVersion(): string
|
private function getDotclearVersion(): string
|
||||||
{
|
{
|
||||||
$version = null;
|
$version = null;
|
||||||
|
@ -203,9 +230,16 @@ class GitShields extends Task
|
||||||
$version = $this->module->get('dc_min');
|
$version = $this->module->get('dc_min');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $version ?: dcCore::app()->getVersion('core');
|
return $version ?: App::version()->getVersion('core');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write shield bloc.
|
||||||
|
*
|
||||||
|
* @param string $content The file content
|
||||||
|
*
|
||||||
|
* @return string The README file content
|
||||||
|
*/
|
||||||
private function writeShieldsBloc(string $content): string
|
private function writeShieldsBloc(string $content): string
|
||||||
{
|
{
|
||||||
$res = preg_replace(
|
$res = preg_replace(
|
||||||
|
@ -222,6 +256,13 @@ class GitShields extends Task
|
||||||
return (string) $res;
|
return (string) $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete existing shield bloc.
|
||||||
|
*
|
||||||
|
* @param string $content The file content
|
||||||
|
*
|
||||||
|
* @return string The README file content
|
||||||
|
*/
|
||||||
private function deleteShieldsBloc(string $content): string
|
private function deleteShieldsBloc(string $content): string
|
||||||
{
|
{
|
||||||
$res = preg_replace(
|
$res = preg_replace(
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve\Task;
|
namespace Dotclear\Plugin\improve\Task;
|
||||||
|
@ -31,21 +21,37 @@ use Dotclear\Plugin\improve\{
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve action module license file
|
* @brief improve task: license class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class LicenseFile extends Task
|
class LicenseFile extends Task
|
||||||
{
|
{
|
||||||
/** @var array Possible license filenames */
|
/**
|
||||||
|
* Possible license filenames.
|
||||||
|
*
|
||||||
|
* @var array<int, string> $license_filenames
|
||||||
|
*/
|
||||||
protected static $license_filenames = [
|
protected static $license_filenames = [
|
||||||
'license',
|
'license',
|
||||||
'license.md',
|
'license.md',
|
||||||
'license.txt',
|
'license.txt',
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var array Possible license names */
|
/**
|
||||||
|
* License names combo.
|
||||||
|
*
|
||||||
|
* @var array<string, string> $action_version
|
||||||
|
*/
|
||||||
private $action_version = [];
|
private $action_version = [];
|
||||||
|
|
||||||
/** @var array Action */
|
/**
|
||||||
|
* Actions combo.
|
||||||
|
*
|
||||||
|
* @var array<string, string> $action_full
|
||||||
|
*/
|
||||||
private $action_full = [];
|
private $action_full = [];
|
||||||
|
|
||||||
protected function getProperties(): TaskDescriptor
|
protected function getProperties(): TaskDescriptor
|
||||||
|
@ -71,7 +77,7 @@ class LicenseFile extends Task
|
||||||
__('Do What The Fuck You Want To Public License') => 'wtfpl',
|
__('Do What The Fuck You Want To Public License') => 'wtfpl',
|
||||||
];
|
];
|
||||||
$this->action_full = [
|
$this->action_full = [
|
||||||
__('Do nothing') => 0,
|
__('Do nothing') => '',
|
||||||
__('Add file if it does not exist') => 'create',
|
__('Add file if it does not exist') => 'create',
|
||||||
__('Add file even if it exists') => 'overwrite',
|
__('Add file even if it exists') => 'overwrite',
|
||||||
__('Add file and remove others') => 'full',
|
__('Add file and remove others') => 'full',
|
||||||
|
@ -128,6 +134,11 @@ class LicenseFile extends Task
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write full license file.
|
||||||
|
*
|
||||||
|
* @return ?bool True on success
|
||||||
|
*/
|
||||||
private function writeFullLicense(): ?bool
|
private function writeFullLicense(): ?bool
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
@ -148,6 +159,11 @@ class LicenseFile extends Task
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete full license file.
|
||||||
|
*
|
||||||
|
* @return bool True on success
|
||||||
|
*/
|
||||||
private function deleteFullLicense(bool $only_one = false): bool
|
private function deleteFullLicense(bool $only_one = false): bool
|
||||||
{
|
{
|
||||||
foreach (self::fileExists($this->module->get('root')) as $file) {
|
foreach (self::fileExists($this->module->get('root')) as $file) {
|
||||||
|
@ -166,6 +182,13 @@ class LicenseFile extends Task
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if files exist.
|
||||||
|
*
|
||||||
|
* @param string $root The path to scan
|
||||||
|
*
|
||||||
|
* @return array<int, string> The existing license files
|
||||||
|
*/
|
||||||
private static function fileExists(string $root): array
|
private static function fileExists(string $root): array
|
||||||
{
|
{
|
||||||
$existing = [];
|
$existing = [];
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve\Task;
|
namespace Dotclear\Plugin\improve\Task;
|
||||||
|
@ -31,7 +21,11 @@ use Dotclear\Plugin\improve\{
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve action module new line
|
* @brief improve task: nl class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class NewLine extends Task
|
class NewLine extends Task
|
||||||
{
|
{
|
||||||
|
@ -112,10 +106,11 @@ class NewLine extends Task
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check and clean file extension
|
* Check and clean file extension.
|
||||||
*
|
*
|
||||||
* @param string|array $in Extension(s) to clean
|
* @param string|array<int, string> $in Extension(s) to clean
|
||||||
* @return array Cleaned extension(s)
|
*
|
||||||
|
* @return array<int,string> Cleaned extension(s)
|
||||||
*/
|
*/
|
||||||
private static function cleanExtensions($in): array
|
private static function cleanExtensions($in): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,20 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve\Task;
|
namespace Dotclear\Plugin\improve\Task;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Core\Backend\Page;
|
use Dotclear\Core\Backend\Page;
|
||||||
use Dotclear\Helper\File\Path;
|
use Dotclear\Helper\File\Path;
|
||||||
use Dotclear\Helper\Html\Form\{
|
use Dotclear\Helper\Html\Form\{
|
||||||
|
@ -36,11 +26,19 @@ use Dotclear\Plugin\improve\{
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve action module PHP CS Fixer
|
* @brief improve task: PHP CS Fixer class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class PhpCsFixer extends Task
|
class PhpCsFixer extends Task
|
||||||
{
|
{
|
||||||
/** @var array<int,string> Type of runtime errors */
|
/**
|
||||||
|
* Type of runtime errors.
|
||||||
|
*
|
||||||
|
* @var array<int, string> $errors
|
||||||
|
*/
|
||||||
protected static $errors = [
|
protected static $errors = [
|
||||||
0 => 'OK.',
|
0 => 'OK.',
|
||||||
1 => 'General error (or PHP minimal requirement not matched).',
|
1 => 'General error (or PHP minimal requirement not matched).',
|
||||||
|
@ -51,13 +49,25 @@ class PhpCsFixer extends Task
|
||||||
64 => 'Exception raised within the application',
|
64 => 'Exception raised within the application',
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var boolean User pref to use colored synthax */
|
/**
|
||||||
|
* User pref to use colored synthax.
|
||||||
|
*
|
||||||
|
* @var bool $user_ui_colorsyntax
|
||||||
|
*/
|
||||||
protected static $user_ui_colorsyntax = false;
|
protected static $user_ui_colorsyntax = false;
|
||||||
|
|
||||||
/** @var string User pref for colored synthax theme */
|
/**
|
||||||
|
* User pref for colored synthax theme.
|
||||||
|
*
|
||||||
|
* @var string $user_ui_colorsyntax_theme
|
||||||
|
*/
|
||||||
protected static $user_ui_colorsyntax_theme = 'default';
|
protected static $user_ui_colorsyntax_theme = 'default';
|
||||||
|
|
||||||
/** @var string Settings PHP executable path */
|
/**
|
||||||
|
* Settings PHP executable path.
|
||||||
|
*
|
||||||
|
* @var string $phpexe_path
|
||||||
|
*/
|
||||||
private $phpexe_path = '';
|
private $phpexe_path = '';
|
||||||
|
|
||||||
protected function getProperties(): TaskDescriptor
|
protected function getProperties(): TaskDescriptor
|
||||||
|
@ -76,11 +86,9 @@ class PhpCsFixer extends Task
|
||||||
{
|
{
|
||||||
$this->getPhpPath();
|
$this->getPhpPath();
|
||||||
|
|
||||||
if (null !== dcCore::app()->auth->user_prefs) {
|
//App::auth()->prefs()->addWorkspace('interface');
|
||||||
dcCore::app()->auth->user_prefs->addWorkspace('interface');
|
self::$user_ui_colorsyntax = App::auth()->prefs()->get('interface')->get('colorsyntax');
|
||||||
self::$user_ui_colorsyntax = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax');
|
self::$user_ui_colorsyntax_theme = App::auth()->prefs()->get('interface')->get('colorsyntax_theme');
|
||||||
self::$user_ui_colorsyntax_theme = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme');
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +172,7 @@ class PhpCsFixer extends Task
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get php executable path
|
* Get php executable path.
|
||||||
*/
|
*/
|
||||||
private function getPhpPath(): void
|
private function getPhpPath(): void
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,20 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve\Task;
|
namespace Dotclear\Plugin\improve\Task;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Helper\Html\Form\{
|
use Dotclear\Helper\Html\Form\{
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Div,
|
Div,
|
||||||
|
@ -34,11 +24,19 @@ use Dotclear\Plugin\improve\{
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve action module php header
|
* @brief improve task: header class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class PhpHeader extends Task
|
class PhpHeader extends Task
|
||||||
{
|
{
|
||||||
/** @var string Exemple of header */
|
/**
|
||||||
|
* Exemple of header.
|
||||||
|
*
|
||||||
|
* @var string $exemple
|
||||||
|
*/
|
||||||
private static $exemple = <<<EOF
|
private static $exemple = <<<EOF
|
||||||
@brief %module_id%, a %module_type% for Dotclear 2
|
@brief %module_id%, a %module_type% for Dotclear 2
|
||||||
|
|
||||||
|
@ -51,7 +49,11 @@ class PhpHeader extends Task
|
||||||
@copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
@copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
/** @var array<string> Allowed bloc replacement */
|
/**
|
||||||
|
* Allowed bloc replacement.
|
||||||
|
*
|
||||||
|
* @var array<int, string> bloc_wildcards
|
||||||
|
*/
|
||||||
private $bloc_wildcards = [
|
private $bloc_wildcards = [
|
||||||
'%year%',
|
'%year%',
|
||||||
'%module_id%',
|
'%module_id%',
|
||||||
|
@ -64,16 +66,32 @@ class PhpHeader extends Task
|
||||||
'%user_url%',
|
'%user_url%',
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var array Allowed action for header */
|
/**
|
||||||
|
* Allowed action for header.
|
||||||
|
*
|
||||||
|
* @var array<string, string> $action_bloc
|
||||||
|
*/
|
||||||
private $action_bloc = [];
|
private $action_bloc = [];
|
||||||
|
|
||||||
/** @var string Parsed bloc */
|
/**
|
||||||
|
* Parsed bloc.
|
||||||
|
*
|
||||||
|
* @var string $bloc
|
||||||
|
*/
|
||||||
private $bloc = '';
|
private $bloc = '';
|
||||||
|
|
||||||
/** @var boolean Stop parsing files */
|
/**
|
||||||
|
* Stop parsing files.
|
||||||
|
*
|
||||||
|
* @var bool $stop_scan
|
||||||
|
*/
|
||||||
private $stop_scan = false;
|
private $stop_scan = false;
|
||||||
|
|
||||||
/** @var string Settings bloc content */
|
/**
|
||||||
|
* Settings bloc content.
|
||||||
|
*
|
||||||
|
* @var string $bloc_content
|
||||||
|
*/
|
||||||
private $bloc_content = '';
|
private $bloc_content = '';
|
||||||
|
|
||||||
protected function getProperties(): TaskDescriptor
|
protected function getProperties(): TaskDescriptor
|
||||||
|
@ -91,7 +109,7 @@ class PhpHeader extends Task
|
||||||
protected function init(): bool
|
protected function init(): bool
|
||||||
{
|
{
|
||||||
$this->action_bloc = [
|
$this->action_bloc = [
|
||||||
__('Do nothing') => 0,
|
__('Do nothing') => '',
|
||||||
__('Add bloc if it does not exist') => 'create',
|
__('Add bloc if it does not exist') => 'create',
|
||||||
__('Add and overwrite bloc') => 'overwrite',
|
__('Add and overwrite bloc') => 'overwrite',
|
||||||
__('Overwrite bloc only if it exists') => 'replace',
|
__('Overwrite bloc only if it exists') => 'replace',
|
||||||
|
@ -161,12 +179,6 @@ class PhpHeader extends Task
|
||||||
|
|
||||||
public function openModule(): ?bool
|
public function openModule(): ?bool
|
||||||
{
|
{
|
||||||
if (!isset(dcCore::app()->auth)) {
|
|
||||||
$this->warning->add(__('Auth is not set'));
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$bloc = trim($this->bloc_content);
|
$bloc = trim($this->bloc_content);
|
||||||
|
|
||||||
if (empty($bloc)) {
|
if (empty($bloc)) {
|
||||||
|
@ -187,13 +199,13 @@ class PhpHeader extends Task
|
||||||
[
|
[
|
||||||
date('Y'),
|
date('Y'),
|
||||||
$this->module->getId(),
|
$this->module->getId(),
|
||||||
$this->module->get('name'),
|
(string) $this->module->get('name'),
|
||||||
$this->module->get('author'),
|
(string) $this->module->get('author'),
|
||||||
$this->module->get('type'),
|
(string) $this->module->get('type'),
|
||||||
dcCore::app()->auth->getInfo('user_cn'),
|
(string) App::auth()->getInfo('user_cn'),
|
||||||
dcCore::app()->auth->getinfo('user_name'),
|
(string) App::auth()->getinfo('user_name'),
|
||||||
dcCore::app()->auth->getInfo('user_email'),
|
(string) App::auth()->getInfo('user_email'),
|
||||||
dcCore::app()->auth->getInfo('user_url'),
|
(string) App::auth()->getInfo('user_url'),
|
||||||
],
|
],
|
||||||
(string) $bloc
|
(string) $bloc
|
||||||
)
|
)
|
||||||
|
@ -253,9 +265,10 @@ class PhpHeader extends Task
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write bloc content in file content
|
* Write bloc content in file content.
|
||||||
*
|
*
|
||||||
* @param string $content Old content
|
* @param string $content Old content
|
||||||
|
*
|
||||||
* @return string New content
|
* @return string New content
|
||||||
*/
|
*/
|
||||||
private function writeDocBloc(string $content): string
|
private function writeDocBloc(string $content): string
|
||||||
|
@ -276,9 +289,10 @@ class PhpHeader extends Task
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete bloc content in file content
|
* Delete bloc content in file content.
|
||||||
*
|
*
|
||||||
* @param string $content Old content
|
* @param string $content Old content
|
||||||
|
*
|
||||||
* @return string New content
|
* @return string New content
|
||||||
*/
|
*/
|
||||||
private function deleteDocBloc(string $content): string
|
private function deleteDocBloc(string $content): string
|
||||||
|
@ -298,9 +312,10 @@ class PhpHeader extends Task
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete old style bloc content in file content
|
* Delete old style bloc content in file content.
|
||||||
*
|
*
|
||||||
* @param string $content Old content
|
* @param string $content Old content
|
||||||
|
*
|
||||||
* @return string New content
|
* @return string New content
|
||||||
*/
|
*/
|
||||||
private function deleteOldBloc(string $content): string
|
private function deleteOldBloc(string $content): string
|
||||||
|
|
|
@ -1,20 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve\Task;
|
namespace Dotclear\Plugin\improve\Task;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Core\Backend\Page;
|
use Dotclear\Core\Backend\Page;
|
||||||
use Dotclear\Helper\File\Path;
|
use Dotclear\Helper\File\Path;
|
||||||
use Dotclear\Helper\Html\Form\{
|
use Dotclear\Helper\Html\Form\{
|
||||||
|
@ -38,23 +28,47 @@ use Dotclear\Plugin\improve\{
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve action module PHPStan
|
* @brief improve task: PHPstan class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class PhpStan extends Task
|
class PhpStan extends Task
|
||||||
{
|
{
|
||||||
/** @var boolean User pref to use colored synthax */
|
/**
|
||||||
|
* User pref to use colored synthax.
|
||||||
|
*
|
||||||
|
* @var bool $user_ui_colorsyntax
|
||||||
|
*/
|
||||||
protected static $user_ui_colorsyntax = false;
|
protected static $user_ui_colorsyntax = false;
|
||||||
|
|
||||||
/** @var string User pref for colored synthax theme */
|
/**
|
||||||
|
* User pref for colored synthax theme.
|
||||||
|
*
|
||||||
|
* @var string $user_ui_colorsyntax_theme
|
||||||
|
*/
|
||||||
protected static $user_ui_colorsyntax_theme = 'default';
|
protected static $user_ui_colorsyntax_theme = 'default';
|
||||||
|
|
||||||
/** @var integer Settings phpstan run level */
|
/**
|
||||||
private $run_level = 5;
|
* Settings phpstan run level.
|
||||||
|
*
|
||||||
|
* @var int $run_level
|
||||||
|
*/
|
||||||
|
private $run_level = 8;
|
||||||
|
|
||||||
/** @var string Settings phpstan ignored vars */
|
/**
|
||||||
|
* Settings phpstan ignored vars.
|
||||||
|
*
|
||||||
|
* @var string $ignored_vars
|
||||||
|
*/
|
||||||
private $ignored_vars = '';
|
private $ignored_vars = '';
|
||||||
|
|
||||||
/** @var string Settings PHP executable path */
|
/**
|
||||||
|
* Settings PHP executable path.
|
||||||
|
*
|
||||||
|
* @var string $phpexe_path
|
||||||
|
*/
|
||||||
private $phpexe_path = '';
|
private $phpexe_path = '';
|
||||||
|
|
||||||
protected function getProperties(): TaskDescriptor
|
protected function getProperties(): TaskDescriptor
|
||||||
|
@ -79,18 +93,16 @@ class PhpStan extends Task
|
||||||
$ignored_vars = $this->settings->get('ignored_vars');
|
$ignored_vars = $this->settings->get('ignored_vars');
|
||||||
$this->ignored_vars = is_string($ignored_vars) ? $ignored_vars : '';
|
$this->ignored_vars = is_string($ignored_vars) ? $ignored_vars : '';
|
||||||
|
|
||||||
if (null !== dcCore::app()->auth->user_prefs) {
|
//App::auth()->prefs()->addWorkspace('interface');
|
||||||
dcCore::app()->auth->user_prefs->addWorkspace('interface');
|
self::$user_ui_colorsyntax = App::auth()->prefs()->get('interface')->get('colorsyntax');
|
||||||
self::$user_ui_colorsyntax = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax');
|
self::$user_ui_colorsyntax_theme = App::auth()->prefs()->get('interface')->get('colorsyntax_theme');
|
||||||
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 !My::settings()?->get('nodetails');
|
return !My::settings()->get('nodetails');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function header(): ?string
|
public function header(): ?string
|
||||||
|
@ -220,23 +232,24 @@ class PhpStan extends Task
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->execCmd(sprintf(
|
return $this->execCmd(sprintf(
|
||||||
'%sphp %s/phpstan/libs/phpstan.phar clear-result-cache',
|
'%sphp %s/phpstan/libs/phpstan.phar clear-result-cache --configuration=%s',
|
||||||
$this->phpexe_path,
|
$this->phpexe_path,
|
||||||
__DIR__
|
__DIR__,
|
||||||
|
App::config()->varRoot() . '/phpstan.neon'
|
||||||
), true);
|
), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function execFixer(string $path = null): bool
|
private function execFixer(string $path = null): bool
|
||||||
{
|
{
|
||||||
if (!empty($path)) {
|
if (empty($path)) {
|
||||||
$path .= ' ';
|
$path = Path::real($this->module->get('root'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->execCmd(sprintf(
|
return $this->execCmd(sprintf(
|
||||||
'%sphp %s/phpstan/libs/phpstan.phar analyse ' . $path . '--configuration=%s',
|
'%sphp %s/phpstan/libs/phpstan.phar analyse ' . $path . ' --configuration=%s',
|
||||||
$this->phpexe_path,
|
$this->phpexe_path,
|
||||||
__DIR__,
|
__DIR__,
|
||||||
DC_VAR . '/phpstan.neon'
|
App::config()->varRoot() . '/phpstan.neon'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +276,7 @@ class PhpStan extends Task
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get php executable path
|
* Get php executable path.
|
||||||
*/
|
*/
|
||||||
private function getPhpPath(): void
|
private function getPhpPath(): void
|
||||||
{
|
{
|
||||||
|
@ -289,13 +302,15 @@ class PhpStan extends Task
|
||||||
'%LEVEL%',
|
'%LEVEL%',
|
||||||
'%MODULE_ROOT%',
|
'%MODULE_ROOT%',
|
||||||
'%DC_ROOT%',
|
'%DC_ROOT%',
|
||||||
|
'%CACHE_ROOT%',
|
||||||
'%BOOTSTRAP_ROOT%',
|
'%BOOTSTRAP_ROOT%',
|
||||||
'%SCAN_DIRECTORIES%',
|
'%SCAN_DIRECTORIES%',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
$this->run_level,
|
$this->run_level,
|
||||||
(string) Path::real($this->module->get('root'), false),
|
(string) Path::real($this->module->get('root'), false),
|
||||||
(string) Path::real(DC_ROOT, false),
|
(string) Path::real(App::config()->dotclearRoot(), false),
|
||||||
|
(string) Path::real(App::config()->cacheRoot(), false),
|
||||||
(string) Path::real(__DIR__ . '/phpstan', false),
|
(string) Path::real(__DIR__ . '/phpstan', false),
|
||||||
$this->getScanDirectories(),
|
$this->getScanDirectories(),
|
||||||
],
|
],
|
||||||
|
@ -314,17 +329,17 @@ class PhpStan extends Task
|
||||||
' path: *' . "\n\n";
|
' path: *' . "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return (bool) file_put_contents(DC_VAR . '/phpstan.neon', $content);
|
return (bool) file_put_contents(App::config()->varRoot() . '/phpstan.neon', $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getScanDirectories(): string
|
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, App::config()->pluginsRoot());
|
||||||
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(App::config()->dotclearRoot() . DIRECTORY_SEPARATOR . 'plugins', false)) {
|
||||||
$ret .= ' - ' . $path . "\n";
|
$ret .= ' - ' . $path . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve\Task;
|
namespace Dotclear\Plugin\improve\Task;
|
||||||
|
@ -21,11 +11,19 @@ use Dotclear\Plugin\improve\{
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve action module dcstore.xml
|
* @brief improve task: po class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class Po2Php extends Task
|
class Po2Php extends Task
|
||||||
{
|
{
|
||||||
/** @var string License bloc */
|
/**
|
||||||
|
* License bloc.
|
||||||
|
*
|
||||||
|
* @var string $license
|
||||||
|
*/
|
||||||
private $license = <<<EOF
|
private $license = <<<EOF
|
||||||
/**
|
/**
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve\Task;
|
namespace Dotclear\Plugin\improve\Task;
|
||||||
|
@ -20,7 +10,11 @@ use Dotclear\Plugin\improve\{
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve action module tab
|
* @brief improve task: tab class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class Tab extends Task
|
class Tab extends Task
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,20 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve\Task;
|
namespace Dotclear\Plugin\improve\Task;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Helper\File\{
|
use Dotclear\Helper\File\{
|
||||||
Files,
|
Files,
|
||||||
Path
|
Path
|
||||||
|
@ -35,11 +25,19 @@ use Dotclear\Plugin\improve\{
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve action module zip
|
* @brief improve task: zip class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class Zip extends Task
|
class Zip extends Task
|
||||||
{
|
{
|
||||||
/** @var array List of excluded file pattern */
|
/**
|
||||||
|
* List of excluded file pattern.
|
||||||
|
*
|
||||||
|
* @var array<int, string> $exclude
|
||||||
|
*/
|
||||||
public static $exclude = [
|
public static $exclude = [
|
||||||
'.',
|
'.',
|
||||||
'..',
|
'..',
|
||||||
|
@ -53,7 +51,11 @@ class Zip extends Task
|
||||||
'_disabled',
|
'_disabled',
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var array Replacement wildcards */
|
/**
|
||||||
|
* Replacement wildcards.
|
||||||
|
*
|
||||||
|
* @var array<int, string> $filename_wildcards
|
||||||
|
*/
|
||||||
public static $filename_wildcards = [
|
public static $filename_wildcards = [
|
||||||
'%type%',
|
'%type%',
|
||||||
'%id%',
|
'%id%',
|
||||||
|
@ -62,13 +64,25 @@ class Zip extends Task
|
||||||
'%time%',
|
'%time%',
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var string Settings Excluded files */
|
/**
|
||||||
|
* Settings Excluded files.
|
||||||
|
*
|
||||||
|
* @var string $pack_excludefiles
|
||||||
|
*/
|
||||||
private $pack_excludefiles = '';
|
private $pack_excludefiles = '';
|
||||||
|
|
||||||
/** @var string Settings Main packacge filename */
|
/**
|
||||||
|
* Settings Main packacge filename.
|
||||||
|
*
|
||||||
|
* @var string $pack_filename
|
||||||
|
*/
|
||||||
private $pack_filename = '';
|
private $pack_filename = '';
|
||||||
|
|
||||||
/** @var string Settings Second package filename */
|
/**
|
||||||
|
* Settings Second package filename.
|
||||||
|
*
|
||||||
|
* @var string $secondpack_filename
|
||||||
|
*/
|
||||||
private $secondpack_filename = '';
|
private $secondpack_filename = '';
|
||||||
|
|
||||||
protected function getProperties(): TaskDescriptor
|
protected function getProperties(): TaskDescriptor
|
||||||
|
@ -127,8 +141,8 @@ class Zip extends Task
|
||||||
]),
|
]),
|
||||||
(new Note())->text(sprintf(
|
(new Note())->text(sprintf(
|
||||||
__('Preconization: %s'),
|
__('Preconization: %s'),
|
||||||
dcCore::app()->blog?->public_path ?
|
App::blog()->publicPath() ?
|
||||||
Path::real(dcCore::app()->blog->public_path) : __("Blog's public directory")
|
Path::real(App::blog()->publicPath()) : __("Blog's public directory")
|
||||||
))->class('form-note'),
|
))->class('form-note'),
|
||||||
]),
|
]),
|
||||||
(new Fieldset())->class('fieldset')->legend((new Legend(__('Files'))))->fields([
|
(new Fieldset())->class('fieldset')->legend((new Legend(__('Files'))))->fields([
|
||||||
|
@ -187,6 +201,12 @@ class Zip extends Task
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zip module.
|
||||||
|
*
|
||||||
|
* @param string $file Path to zip
|
||||||
|
* @param array<int, string> $exclude files to exlude
|
||||||
|
*/
|
||||||
private function zipModule(string $file, array $exclude): void
|
private function zipModule(string $file, array $exclude): void
|
||||||
{
|
{
|
||||||
$file = str_replace(
|
$file = str_replace(
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,61 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief improve, a plugin for Dotclear 2
|
* @file
|
||||||
|
* @brief The plugin improve task phpstan bootstrap
|
||||||
|
* @ingroup improve
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @author Jean-Christian Denis
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
// Mock some global constants
|
// Mock some global constants
|
||||||
define('DC_ADMIN_SSL', true);
|
|
||||||
define('DC_ADMIN_URL', '');
|
|
||||||
define('DC_ALLOW_MULTI_MODULES', true);
|
|
||||||
define('DC_ALLOW_REPOSITORIES', true);
|
|
||||||
define('DC_CRYPT_ALGO', 'md5');
|
|
||||||
define('DC_DBDRIVER', '');
|
|
||||||
define('DC_DBHOST', '');
|
|
||||||
define('DC_DBNAME', '');
|
|
||||||
define('DC_DBPASSWORD', '');
|
|
||||||
define('DC_DBPREFIX', '');
|
|
||||||
define('DC_DBUSER', '');
|
|
||||||
define('DC_DEBUG', false);
|
|
||||||
define('DC_DEFAULT_JQUERY', '');
|
|
||||||
define('DC_DEFAULT_TPLSET', '');
|
|
||||||
define('DC_DIGESTS', '');
|
|
||||||
define('DC_DISTRIB_PLUGINS', '');
|
|
||||||
define('DC_DISTRIB_THEMES', '');
|
|
||||||
define('DC_FAIRTRACKBACKS_FORCE', true);
|
|
||||||
define('DC_L10N_ROOT', '');
|
|
||||||
define('DC_L10N_UPDATE_URL', '');
|
|
||||||
define('DC_MASTER_KEY', '');
|
|
||||||
define('DC_MAX_UPLOAD_SIZE', 42);
|
|
||||||
define('DC_NEXT_REQUIRED_PHP', '');
|
|
||||||
define('DC_NOT_UPDATE', false);
|
|
||||||
define('DC_PLUGINS_ROOT', '');
|
|
||||||
define('DC_QUERY_TIMEOUT', 4);
|
|
||||||
define('DC_RC_PATH', '');
|
|
||||||
define('DC_ROOT', '');
|
|
||||||
define('DC_SESSION_NAME', '');
|
|
||||||
define('DC_SESSION_TTL', null);
|
|
||||||
define('DC_STORE_NOT_UPDATE', false);
|
|
||||||
define('DC_TPL_CACHE', '');
|
|
||||||
define('DC_UPDATE_URL', '');
|
|
||||||
define('DC_UPDATE_VERSION', '');
|
|
||||||
define('DC_VAR', '');
|
|
||||||
define('DC_VENDOR_NAME', '');
|
|
||||||
define('DC_VERSION', '');
|
|
||||||
define('DC_XMLRPC_URL', '');
|
|
||||||
define('DC_ADBLOCKER_CHECK', true);
|
|
||||||
define('DC_AKISMET_SUPER', true);
|
|
||||||
define('DC_ANTISPAM_CONF_SUPER', true);
|
define('DC_ANTISPAM_CONF_SUPER', true);
|
||||||
define('DC_BACKUP_PATH', '');
|
define('DC_FAIRTRACKBACKS_FORCE', true);
|
||||||
define('DC_CSP_LOGFILE', '');
|
|
||||||
define('DC_DEV', true);
|
|
||||||
define('DC_DNSBL_SUPER', '');
|
|
||||||
define('DC_ERRORFILE', '');
|
|
||||||
define('DC_FORCE_SCHEME_443', false);
|
|
||||||
define('DC_REVERSE_PROXY', false);
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
parameters:
|
parameters:
|
||||||
level: %LEVEL%
|
level: %LEVEL%
|
||||||
|
|
||||||
|
tmpDir: %CACHE_ROOT%
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
- %MODULE_ROOT%
|
- %MODULE_ROOT%
|
||||||
|
|
||||||
|
@ -22,57 +24,10 @@ parameters:
|
||||||
- in
|
- in
|
||||||
|
|
||||||
dynamicConstantNames:
|
dynamicConstantNames:
|
||||||
- DC_ADBLOCKER_CHECK
|
|
||||||
- DC_ADMIN_SSL
|
|
||||||
- DC_ADMIN_URL
|
|
||||||
- DC_AKISMET_SUPER
|
|
||||||
- DC_ALLOW_MULTI_MODULES
|
|
||||||
- DC_ALLOW_REPOSITORIES
|
|
||||||
- DC_ANTISPAM_CONF_SUPER
|
- DC_ANTISPAM_CONF_SUPER
|
||||||
- DC_BACKUP_PATH
|
|
||||||
- DC_CRYPT_ALGO
|
|
||||||
- DC_CSP_LOGFILE
|
|
||||||
- DC_DBDRIVER
|
|
||||||
- DC_DBHOST
|
|
||||||
- DC_DBNAME
|
|
||||||
- DC_DBPASSWORD
|
|
||||||
- DC_DBPREFIX
|
|
||||||
- DC_DBUSER
|
|
||||||
- DC_DEBUG
|
|
||||||
- DC_DEFAULT_JQUERY
|
|
||||||
- DC_DEFAULT_THEME
|
|
||||||
- DC_DEFAULT_TPLSET
|
|
||||||
- DC_DEV
|
|
||||||
- DC_DIGESTS
|
|
||||||
- DC_DISTRIB_PLUGINS
|
|
||||||
- DC_DISTRIB_THEMES
|
|
||||||
- DC_DNSBL_SUPER
|
|
||||||
- DC_ERRORFILE
|
|
||||||
- DC_FAIRTRACKBACKS_FORCE
|
- DC_FAIRTRACKBACKS_FORCE
|
||||||
- DC_FORCE_SCHEME_443
|
|
||||||
- DC_L10N_ROOT
|
|
||||||
- DC_L10N_UPDATE_URL
|
|
||||||
- DC_MASTER_KEY
|
|
||||||
- DC_MAX_UPLOAD_SIZE
|
|
||||||
- DC_NEXT_REQUIRED_PHP
|
|
||||||
- DC_NOT_UPDATE
|
|
||||||
- DC_PLUGINS_ROOT
|
|
||||||
- DC_QUERY_TIMEOUT
|
|
||||||
- DC_RC_PATH
|
|
||||||
- DC_REVERSE_PROXY
|
|
||||||
- DC_ROOT
|
|
||||||
- DC_SESSION_NAME
|
|
||||||
- DC_SESSION_TTL
|
|
||||||
- DC_STORE_NOT_UPDATE
|
|
||||||
- DC_TPL_CACHE
|
|
||||||
- DC_UPDATE_URL
|
|
||||||
- DC_UPDATE_VERSION
|
|
||||||
- DC_VAR
|
|
||||||
- DC_VENDOR_NAME
|
|
||||||
- DC_VERSION
|
|
||||||
- DC_XMLRPC_URL
|
|
||||||
|
|
||||||
checkMissingIterableValueType: false
|
#checkMissingIterableValueType: false
|
||||||
checkGenericClassInNonGenericObjectType: false
|
checkGenericClassInNonGenericObjectType: false
|
||||||
reportUnmatchedIgnoredErrors: false
|
reportUnmatchedIgnoredErrors: false
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
parameters:
|
parameters:
|
||||||
level: %LEVEL%
|
level: %LEVEL%
|
||||||
|
|
||||||
|
tmpDir: %CACHE_ROOT%
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
- %MODULE_ROOT%
|
- %MODULE_ROOT%
|
||||||
|
|
||||||
|
@ -22,55 +24,8 @@ parameters:
|
||||||
- in
|
- in
|
||||||
|
|
||||||
dynamicConstantNames:
|
dynamicConstantNames:
|
||||||
- DC_ADBLOCKER_CHECK
|
|
||||||
- DC_ADMIN_SSL
|
|
||||||
- DC_ADMIN_URL
|
|
||||||
- DC_AKISMET_SUPER
|
|
||||||
- DC_ALLOW_MULTI_MODULES
|
|
||||||
- DC_ALLOW_REPOSITORIES
|
|
||||||
- DC_ANTISPAM_CONF_SUPER
|
- DC_ANTISPAM_CONF_SUPER
|
||||||
- DC_BACKUP_PATH
|
|
||||||
- DC_CRYPT_ALGO
|
|
||||||
- DC_CSP_LOGFILE
|
|
||||||
- DC_DBDRIVER
|
|
||||||
- DC_DBHOST
|
|
||||||
- DC_DBNAME
|
|
||||||
- DC_DBPASSWORD
|
|
||||||
- DC_DBPREFIX
|
|
||||||
- DC_DBUSER
|
|
||||||
- DC_DEBUG
|
|
||||||
- DC_DEFAULT_JQUERY
|
|
||||||
- DC_DEFAULT_THEME
|
|
||||||
- DC_DEFAULT_TPLSET
|
|
||||||
- DC_DEV
|
|
||||||
- DC_DIGESTS
|
|
||||||
- DC_DISTRIB_PLUGINS
|
|
||||||
- DC_DISTRIB_THEMES
|
|
||||||
- DC_DNSBL_SUPER
|
|
||||||
- DC_ERRORFILE
|
|
||||||
- DC_FAIRTRACKBACKS_FORCE
|
- DC_FAIRTRACKBACKS_FORCE
|
||||||
- DC_FORCE_SCHEME_443
|
|
||||||
- DC_L10N_ROOT
|
|
||||||
- DC_L10N_UPDATE_URL
|
|
||||||
- DC_MASTER_KEY
|
|
||||||
- DC_MAX_UPLOAD_SIZE
|
|
||||||
- DC_NEXT_REQUIRED_PHP
|
|
||||||
- DC_NOT_UPDATE
|
|
||||||
- DC_PLUGINS_ROOT
|
|
||||||
- DC_QUERY_TIMEOUT
|
|
||||||
- DC_RC_PATH
|
|
||||||
- DC_REVERSE_PROXY
|
|
||||||
- DC_ROOT
|
|
||||||
- DC_SESSION_NAME
|
|
||||||
- DC_SESSION_TTL
|
|
||||||
- DC_STORE_NOT_UPDATE
|
|
||||||
- DC_TPL_CACHE
|
|
||||||
- DC_UPDATE_URL
|
|
||||||
- DC_UPDATE_VERSION
|
|
||||||
- DC_VAR
|
|
||||||
- DC_VENDOR_NAME
|
|
||||||
- DC_VERSION
|
|
||||||
- DC_XMLRPC_URL
|
|
||||||
|
|
||||||
checkMissingIterableValueType: false
|
checkMissingIterableValueType: false
|
||||||
checkGenericClassInNonGenericObjectType: false
|
checkGenericClassInNonGenericObjectType: false
|
||||||
|
@ -82,96 +37,140 @@ parameters:
|
||||||
- message: '#Variable \$this might not be defined#'
|
- message: '#Variable \$this might not be defined#'
|
||||||
path: */*/_define.php
|
path: */*/_define.php
|
||||||
|
|
||||||
# dcAdmin object and auto properties
|
|
||||||
- message: '#Access to an undefined property dcAdmin::#'
|
|
||||||
|
|
||||||
# dcNamespace object and auto properties
|
|
||||||
- message: '#Access to an undefined property dcNamespace::#'
|
|
||||||
|
|
||||||
# context object and auto properties
|
|
||||||
- message: '#Access to an undefined property context::#'
|
|
||||||
|
|
||||||
# record object and auto properties
|
|
||||||
- message: '#Access to an undefined property record::#'
|
|
||||||
|
|
||||||
# dcWidgets object and auto properties
|
|
||||||
- message: '#Access to an undefined property dcWidgets::#'
|
|
||||||
|
|
||||||
# dcWidgets object methods
|
|
||||||
- message: '#Call to an undefined method dcWidgets::#'
|
|
||||||
|
|
||||||
# dcWidget object and auto properties
|
|
||||||
- message: '#Access to an undefined property dcWidget::#'
|
|
||||||
|
|
||||||
# dcWidget object methods
|
|
||||||
- message: '#Call to an undefined method dcWidget::#'
|
|
||||||
|
|
||||||
# xmlTag object and auto properties
|
|
||||||
- message : '#Access to an undefined property xmlTag::#'
|
|
||||||
|
|
||||||
# xmlTag object methods
|
|
||||||
- message : '#Call to an undefined method xmlTag::#'
|
|
||||||
|
|
||||||
# dcSettings object and auto properties
|
|
||||||
- message : '#Access to an undefined property dcSettings::#'
|
|
||||||
|
|
||||||
# dcPrefs object and auto properties
|
|
||||||
- message : '#Access to an undefined property dcPrefs::#'
|
|
||||||
|
|
||||||
# dbStruct object and auto properties
|
|
||||||
- message : '#Access to an undefined property dbStruct::#'
|
|
||||||
|
|
||||||
# cursor object and auto properties
|
|
||||||
- message : '#Access to an undefined property cursor::#'
|
|
||||||
|
|
||||||
# dcRecord object and auto properties
|
|
||||||
- message: '#Access to an undefined property dcRecord::#'
|
|
||||||
|
|
||||||
# dcRecord object methods
|
|
||||||
- message: '#Call to an undefined method dcRecord::#'
|
|
||||||
|
|
||||||
# Intensive use of magic __set/__get/__call/__invoke causes theses wrong warnings
|
# Intensive use of magic __set/__get/__call/__invoke causes theses wrong warnings
|
||||||
- message: '#Call to an undefined method form[a-zA-Z0-9\\_]+::#'
|
- message: '#Call to an undefined method form[a-zA-Z0-9\\_]+::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
# Intensive use of magic __set/__get/__call/__invoke causes theses wrong warnings
|
|
||||||
- message: '#Access to an undefined property form[a-zA-Z0-9\\_]+::#'
|
|
||||||
|
|
||||||
# form<*>filters
|
|
||||||
- message: '#Access to an undefined property admin[a-zA-Z0-9\\_]+Filter::\$[a-zA-Z0-9\\_]+.#'
|
|
||||||
|
|
||||||
# dcAdminfilters
|
|
||||||
- message: '#Access to an undefined property dcAdminFilter::\$[a-zA-Z0-9\\_]+.#'
|
|
||||||
|
|
||||||
# adminMediaPage
|
|
||||||
- message: '#Access to an undefined property adminMediaPage::\$[a-zA-Z0-9\\_]+.#'
|
|
||||||
|
|
||||||
# arrayObject/type
|
# arrayObject/type
|
||||||
- message: '#ArrayObject\<\*NEVER\*, \*NEVER\*\> does not accept#'
|
- message: '#ArrayObject\<\*NEVER\*, \*NEVER\*\> does not accept#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
# dcAdmin::$widgets user-defined properties
|
|
||||||
- message: '#Access to an undefined property dcCore::\$widgets.#'
|
|
||||||
|
|
||||||
# dcAdmin::$default_widgets user-defined properties
|
|
||||||
- message: '#Access to an undefined property dcCore::\$default_widgets.#'
|
|
||||||
|
|
||||||
# formXXX
|
|
||||||
- message: '#Access to an undefined property \$this\(form[a-zA-Z0-9\\_]+\)::#'
|
|
||||||
|
|
||||||
# 2.25+
|
# 2.25+
|
||||||
|
|
||||||
# WidgetsStack object and auto properties
|
# WidgetsStack object and auto properties
|
||||||
- message: '#Access to an undefined property Dotclear\\Plugin\\widgets\\WidgetsStack::#'
|
- message: '#Access to an undefined property Dotclear\\Plugin\\widgets\\WidgetsStack::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
# WidgetsElement object and auto properties
|
# WidgetsElement object and auto properties
|
||||||
- message: '#Access to an undefined property Dotclear\\Plugin\\widgets\\WidgetsElement::#'
|
- message: '#Access to an undefined property Dotclear\\Plugin\\widgets\\WidgetsElement::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
# dcModuleDefine auto properties
|
# dcModuleDefine auto properties
|
||||||
- message: '#Access to an undefined property dcModuleDefine::#'
|
- message: '#Access to an undefined property dcModuleDefine::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
# 2.26+
|
# 2.26+
|
||||||
|
|
||||||
# Intensive use of magic __set/__get/__call/__invoke causes theses wrong warnings
|
# Intensive use of magic __set/__get/__call/__invoke causes theses wrong warnings
|
||||||
- message: '#Call to an undefined method Dotclear\\Helper\\Html\\Form\\[a-zA-Z0-9\\_]+::#'
|
- message: '#Call to an undefined method Dotclear\\Helper\\Html\\Form\\[a-zA-Z0-9\\_]+::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
# Intensive use of magic __set/__get/__call/__invoke causes theses wrong warnings
|
# Intensive use of magic __set/__get/__call/__invoke causes theses wrong warnings
|
||||||
- message: '#Access to an undefined property Dotclear\\Helper\\Html\\Form\\[a-zA-Z0-9\\_]+::#'
|
- message: '#Access to an undefined property Dotclear\\Helper\\Html\\Form\\[a-zA-Z0-9\\_]+::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# XmlTag object and magic properties
|
||||||
|
- message: '#Access to an undefined property Dotclear\\Helper\\Html\\XmlTag::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# XmlTag object and magic methods
|
||||||
|
- message : '#Call to an undefined method Dotclear\\Helper\\Html\\XmlTag::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Intensive use of magic __set/__get/__call/__invoke causes theses wrong warnings
|
||||||
|
- message : '#Access to an undefined property Dotclear\\Helper\\File\\File::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Record object and auto properties
|
||||||
|
- message: '#Access to an undefined property Dotclear\\Database\\Record::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Cursor object and auto properties
|
||||||
|
- message : '#Access to an undefined property Dotclear\\Database\\Cursor::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# MetaRecord object and auto properties
|
||||||
|
- message: '#Access to an undefined property Dotclear\\Database\\MetaRecord::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# MetaRecord object methods
|
||||||
|
- message: '#Call to an undefined method Dotclear\\Database\\MetaRecord::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Structure object and auto properties
|
||||||
|
- message: '#Access to an undefined property Dotclear\\Database\\Structure::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# getDefines() ambiguous return value
|
||||||
|
- message: '#Call to an undefined method object::addMissing\(\).#'
|
||||||
|
path: */*/inc/core/class.dc.modules.php
|
||||||
|
- message: '#Call to an undefined method object::getId\(\).#'
|
||||||
|
path: */*/inc/core/class.dc.modules.php
|
||||||
|
|
||||||
|
# 2.27+
|
||||||
|
|
||||||
|
# Dotclear\Core\Backend\Utility object and auto properties
|
||||||
|
- message: '#Access to an undefined property Dotclear\\Core\\Backend\\Utility::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Dotclear\Core\Backend\MediaPage object and auto properties
|
||||||
|
- message: '#Access to an undefined property Dotclear\\Core\\Backend\\MediaPage::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Dotclear\Core\Backend\Filter\Filter
|
||||||
|
- message: '#Access to an undefined property Dotclear\\Core\\Backend\\Filter\\Filter::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Dotclear\Core\Backend\Filter\FilterBlogs
|
||||||
|
- message: '#Access to an undefined property Dotclear\\Core\\Backend\\Filter\\FilterBlogs::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Dotclear\Core\Backend\Filter\FilterComments
|
||||||
|
- message: '#Access to an undefined property Dotclear\\Core\\Backend\\Filter\\FilterComments::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Dotclear\Core\Backend\Filter\FilterPosts
|
||||||
|
- message: '#Access to an undefined property Dotclear\\Core\\Backend\\Filter\\FilterPosts::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Dotclear\Core\Backend\Filter\FilterUsers
|
||||||
|
- message: '#Access to an undefined property Dotclear\\Core\\Backend\\Filter\\FilterUsers::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Dotclear\Core\Backend\Filter\FilterMedia
|
||||||
|
- message: '#Access to an undefined property Dotclear\\Core\\Backend\\Filter\\FilterMedia::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# 2.28+
|
||||||
|
|
||||||
|
# Dotclear\Core\Frontend\Ctx object and auto properties
|
||||||
|
- message: '#Access to an undefined property Dotclear\\Core\\Frontend\\Ctx::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Dotclear\Interface\Core\BlogWorkspaceInterface object and auto properties
|
||||||
|
- message: '#Access to an undefined property Dotclear\\Interface\\Core\\BlogWorkspaceInterface::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Dotclear\Interface\Core\BlogSettingsInterface object and auto properties
|
||||||
|
- message : '#Access to an undefined property Dotclear\\Interface\\Core\\BlogSettingsInterface::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Dotclear\Interface\Core\UserWorkspaceInterface object and auto properties
|
||||||
|
- message : '#Access to an undefined property Dotclear\\Interface\\Core\\UserWorkspaceInterface::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Dotclear\Interface\Core\UserPreferencesInterface object and auto properties
|
||||||
|
- message : '#Access to an undefined property Dotclear\\Interface\\Core\\UserPreferencesInterface::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Dotclear\Module\ModuleDefine object and auto properties
|
||||||
|
- message : '#Access to an undefined property Dotclear\\Module\\ModuleDefine::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Dotclear\Interface\Core\UrlInterface object and auto properties
|
||||||
|
- message : '#Access to an undefined property Dotclear\\Interface\\Core\\UrlInterface::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
||||||
|
# Dotclear\Helper\File\File object and auto properties
|
||||||
|
- message : '#Access to an undefined property Dotclear\\Helper\\File\\File|stdClass::#'
|
||||||
|
path: %currentWorkingDirectory%
|
||||||
|
|
|
@ -14,9 +14,22 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve\Task\zip;
|
namespace Dotclear\Plugin\improve\Task\zip;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief improve Zip hack class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* Extend Zip Helper to add some functions.
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
class Zip extends \Dotclear\Helper\File\Zip\Zip
|
class Zip extends \Dotclear\Helper\File\Zip\Zip
|
||||||
{
|
{
|
||||||
/** @var boolean Should remove comments from files */
|
/**
|
||||||
|
* Should remove comments from files.
|
||||||
|
*
|
||||||
|
* @var bool $remove_comment
|
||||||
|
*/
|
||||||
public static $remove_comment = false;
|
public static $remove_comment = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,12 +37,10 @@ class Zip extends \Dotclear\Helper\File\Zip\Zip
|
||||||
*
|
*
|
||||||
* @param string $name The name
|
* @param string $name The name
|
||||||
* @param string $file The file
|
* @param string $file The file
|
||||||
* @param string $size The size
|
* @param int|float $size The size
|
||||||
* @param int|null $mtime The mtime
|
* @param int|float $mtime The mtime
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
protected function writeFile($name, $file, $size, $mtime)
|
protected function writeFile(string $name, string $file, int|float $size, int|float $mtime): void
|
||||||
{
|
{
|
||||||
if (!isset($this->entries[$name])) {
|
if (!isset($this->entries[$name])) {
|
||||||
return;
|
return;
|
||||||
|
@ -51,8 +62,8 @@ class Zip extends \Dotclear\Helper\File\Zip\Zip
|
||||||
|
|
||||||
unset($content);
|
unset($content);
|
||||||
|
|
||||||
$mdate = $this->makeDate($mtime);
|
$mdate = $this->makeDate((int) $mtime);
|
||||||
$mtime = $this->makeTime($mtime);
|
$mtime = $this->makeTime((int) $mtime);
|
||||||
|
|
||||||
# Data descriptor
|
# Data descriptor
|
||||||
$data_desc = "\x50\x4b\x03\x04" .
|
$data_desc = "\x50\x4b\x03\x04" .
|
||||||
|
@ -101,6 +112,13 @@ class Zip extends \Dotclear\Helper\File\Zip\Zip
|
||||||
$this->ctrl_dir[] = $cdrec;
|
$this->ctrl_dir[] = $cdrec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove PHP comments.
|
||||||
|
*
|
||||||
|
* @param string $content The file content
|
||||||
|
*
|
||||||
|
* @return string The cleaned file content
|
||||||
|
*/
|
||||||
protected static function removePHPComment(string $content): string
|
protected static function removePHPComment(string $content): string
|
||||||
{
|
{
|
||||||
$comment = [T_COMMENT];
|
$comment = [T_COMMENT];
|
||||||
|
|
|
@ -1,30 +1,32 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve;
|
namespace Dotclear\Plugin\improve;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task description.
|
* @brief improve task descriptor class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class TaskDescriptor
|
class TaskDescriptor
|
||||||
{
|
{
|
||||||
/** @var string The priority overload settings prefix */
|
/**
|
||||||
|
* The priority overload settings prefix.
|
||||||
|
*
|
||||||
|
* @var string PREFIX
|
||||||
|
*/
|
||||||
public const PREFIX = 'priority_';
|
public const PREFIX = 'priority_';
|
||||||
|
|
||||||
/** @var int $priority The task priority */
|
/**
|
||||||
|
* The task priority.
|
||||||
|
*
|
||||||
|
* @var int $priority
|
||||||
|
*/
|
||||||
public readonly int $priority;
|
public readonly int $priority;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +36,7 @@ class TaskDescriptor
|
||||||
* @param string $name The task translated name
|
* @param string $name The task translated name
|
||||||
* @param string $description The task short descripton
|
* @param string $description The task short descripton
|
||||||
* @param bool $configurator The task has configuration form
|
* @param bool $configurator The task has configuration form
|
||||||
* @param array $types The task supported modules types
|
* @param array<int, string> $types The task supported modules types
|
||||||
* @param int $priority The task default priority
|
* @param int $priority The task default priority
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
@ -46,6 +48,6 @@ class TaskDescriptor
|
||||||
int $priority = 500
|
int $priority = 500
|
||||||
) {
|
) {
|
||||||
// Overload task priority from settings
|
// Overload task priority from settings
|
||||||
$this->priority = !is_null(dcCore::app()->blog) && 1 < ($p = (int) dcCore::app()->blog->settings->get(My::id())->get(self::PREFIX . $this->id)) ? $p : abs($priority);
|
$this->priority = App::blog()->isDefined() && 1 < ($p = (int) App::blog()->settings()->get(My::id())->get(self::PREFIX . $this->id)) ? $p : abs($priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,14 +15,26 @@ declare(strict_types=1);
|
||||||
namespace Dotclear\Plugin\improve;
|
namespace Dotclear\Plugin\improve;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task messages group.
|
* @brief improve messages group class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class TaskMessages
|
class TaskMessages
|
||||||
{
|
{
|
||||||
/** @ var array<string,array> $stack The messages by path stack */
|
/**
|
||||||
|
* The messages by path stack.
|
||||||
|
*
|
||||||
|
* @var array<string, array<int, string>> $stack
|
||||||
|
*/
|
||||||
private array $stack;
|
private array $stack;
|
||||||
|
|
||||||
/** @ var string $path The current path */
|
/**
|
||||||
|
* The current path.
|
||||||
|
*
|
||||||
|
* @var string $path
|
||||||
|
*/
|
||||||
private string $path = 'root';
|
private string $path = 'root';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +50,7 @@ class TaskMessages
|
||||||
/**
|
/**
|
||||||
* Check if there are messages.
|
* Check if there are messages.
|
||||||
*
|
*
|
||||||
* return bool True if not empty
|
* @return bool True if not empty
|
||||||
*/
|
*/
|
||||||
public function empty(): bool
|
public function empty(): bool
|
||||||
{
|
{
|
||||||
|
@ -60,7 +72,7 @@ class TaskMessages
|
||||||
*
|
*
|
||||||
* @param string $path The path
|
* @param string $path The path
|
||||||
*
|
*
|
||||||
* @return array The messages
|
* @return array<int, string> The messages
|
||||||
*/
|
*/
|
||||||
public function get(string $path): array
|
public function get(string $path): array
|
||||||
{
|
{
|
||||||
|
@ -68,9 +80,9 @@ class TaskMessages
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all messages
|
* Get all messages.
|
||||||
*
|
*
|
||||||
* @return array<string,array> The messages stack
|
* @return array<string, array<int, string>> The messages stack
|
||||||
*/
|
*/
|
||||||
public function dump(): array
|
public function dump(): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,31 +1,33 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve;
|
namespace Dotclear\Plugin\improve;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task settings management.
|
* @brief improve task settings helper class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class TaskSettings
|
class TaskSettings
|
||||||
{
|
{
|
||||||
/** @var string The setting prefix */
|
/**
|
||||||
|
* The setting prefix.
|
||||||
|
*
|
||||||
|
* @var string PREFIX
|
||||||
|
*/
|
||||||
public const PREFIX = 'settings_';
|
public const PREFIX = 'settings_';
|
||||||
|
|
||||||
/** @ var array<string,mixed> $stack The settings stack */
|
/**
|
||||||
|
* The settings stack.
|
||||||
|
*
|
||||||
|
* @var array<string, mixed> $stack
|
||||||
|
*/
|
||||||
private array $stack = [];
|
private array $stack = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,11 +38,11 @@ class TaskSettings
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private string $suffix
|
private string $suffix
|
||||||
) {
|
) {
|
||||||
if (is_null(dcCore::app()->blog)) {
|
if (!App::blog()->isDefined()) {
|
||||||
throw new Exception(__('Blog is not set'));
|
throw new Exception(__('Blog is not set'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== ($settings = dcCore::app()->blog->settings->get(My::id())->get(self::PREFIX . $this->suffix))) {
|
if (null !== ($settings = App::blog()->settings()->get(My::id())->get(self::PREFIX . $this->suffix))) {
|
||||||
$settings = json_decode($settings, true);
|
$settings = json_decode($settings, true);
|
||||||
$this->stack = is_array($settings) ? $settings : [];
|
$this->stack = is_array($settings) ? $settings : [];
|
||||||
}
|
}
|
||||||
|
@ -76,8 +78,8 @@ class TaskSettings
|
||||||
*/
|
*/
|
||||||
public function save(): void
|
public function save(): void
|
||||||
{
|
{
|
||||||
if (!is_null(dcCore::app()->blog)) {
|
if (App::blog()->isDefined()) {
|
||||||
dcCore::app()->blog->settings->get(My::id())->put(
|
App::blog()->settings()->get(My::id())->put(
|
||||||
self::PREFIX . $this->suffix,
|
self::PREFIX . $this->suffix,
|
||||||
json_encode($this->stack),
|
json_encode($this->stack),
|
||||||
'string',
|
'string',
|
||||||
|
@ -85,7 +87,7 @@ class TaskSettings
|
||||||
true,
|
true,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
dcCore::app()->blog->triggerBlog();
|
App::blog()->triggerBlog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,25 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve;
|
namespace Dotclear\Plugin\improve;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Tasks stack.
|
* @brief improve tasks stack class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class Tasks
|
class Tasks
|
||||||
{
|
{
|
||||||
/** @var array<string,Task> $stack The tasks stack */
|
/**
|
||||||
|
* The tasks stack.
|
||||||
|
*
|
||||||
|
* @var array<string, Task> $stack
|
||||||
|
*/
|
||||||
private array $stack = [];
|
private array $stack = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,7 +28,7 @@ class Tasks
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
# --BEHAVIOR-- improveTaskAdd: Tasks
|
# --BEHAVIOR-- improveTaskAdd: Tasks
|
||||||
dcCore::app()->callBehavior('improveTaskAdd', $this);
|
App::behavior()->callBehavior('improveTaskAdd', $this);
|
||||||
|
|
||||||
uasort($this->stack, fn ($a, $b) => $a->properties->name <=> $b->properties->name);
|
uasort($this->stack, fn ($a, $b) => $a->properties->name <=> $b->properties->name);
|
||||||
uasort($this->stack, fn ($a, $b) => $a->properties->priority <=> $b->properties->priority);
|
uasort($this->stack, fn ($a, $b) => $a->properties->priority <=> $b->properties->priority);
|
||||||
|
@ -55,7 +53,7 @@ class Tasks
|
||||||
/**
|
/**
|
||||||
* Get all tasks.
|
* Get all tasks.
|
||||||
*
|
*
|
||||||
* @return array<string,Task> The tasks stack
|
* @return array<string, Task> The tasks stack
|
||||||
*/
|
*/
|
||||||
public function dump(): array
|
public function dump(): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,23 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve;
|
namespace Dotclear\Plugin\improve;
|
||||||
|
|
||||||
use dcCore;
|
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief improve uninstall class.
|
||||||
|
* @ingroup improve
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
class Uninstall extends Process
|
class Uninstall extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
|
@ -27,7 +23,7 @@ class Uninstall extends Process
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue