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
|
||||
* [ ] 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
|
||||
===========================================================
|
||||
* Require Dotclear 2.27
|
||||
|
|
30
README.md
30
README.md
|
@ -1,17 +1,16 @@
|
|||
# README
|
||||
|
||||
[![Release](https://img.shields.io/badge/release-1.4-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)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![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.10.22-c44d58.svg)
|
||||
[![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)
|
||||
[![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
|
||||
web publishing software called Dotclear.
|
||||
_improve_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
||||
|
||||
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
|
||||
* Easy and fast to use
|
||||
|
@ -19,11 +18,9 @@ It helps dev to clean up plugin or theme before publishing code.
|
|||
|
||||
## REQUIREMENTS
|
||||
|
||||
_improve_ requires:
|
||||
|
||||
* admin permission
|
||||
* Dotclear 2.27
|
||||
* Dotclear 2.28
|
||||
* PHP 8.1+
|
||||
* Dotclear Super admin permissions
|
||||
|
||||
## USAGE
|
||||
|
||||
|
@ -38,13 +35,14 @@ and help devs to maintain their plugins and themes.
|
|||
|
||||
## LINKS
|
||||
|
||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/improve) [GitHub Page](https://github.com/JcDenis/improve)
|
||||
* Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/improve/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/improve)
|
||||
* [License](https://git.dotclear.watch/JcDenis/improve/src/branch/master/LICENSE)
|
||||
* [Packages & details](https://git.dotclear.watch/JcDenis/improve/releases) (or on [Dotaddict](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
|
||||
|
||||
* Jean-Christian Denis
|
||||
* Jean-Christian Denis (author)
|
||||
* Gvx
|
||||
|
||||
You are welcome to contribute to this code.
|
||||
|
|
26
_define.php
26
_define.php
|
@ -1,30 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief improve, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin improve definition
|
||||
* @ingroup improve
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
* @defgroup improve Plugin improve.
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
* Tiny tools to fix things for module devs.
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
declare(strict_types=1);
|
||||
|
||||
$this->registerModule(
|
||||
'improve',
|
||||
'Tiny tools to fix things for module devs',
|
||||
'Jean-Christian Denis and contributors',
|
||||
'1.4',
|
||||
'1.5',
|
||||
[
|
||||
'requires' => [
|
||||
['php', '8.1'],
|
||||
['core', '2.27'],
|
||||
],
|
||||
'permissions' => null,
|
||||
'requires' => [['core', '2.28']],
|
||||
'permissions' => 'My',
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="improve">
|
||||
<name>improve</name>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
<author>Jean-Christian Denis and contributors</author>
|
||||
<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>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<file>https://git.dotclear.watch/JcDenis/improve/releases/download/v1.5/plugin-improve.zip</file>
|
||||
<da:dcmin>2.28</da:dcmin>
|
||||
<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>
|
||||
</module>
|
||||
|
|
|
@ -1,27 +1,19 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Favorites;
|
||||
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
|
||||
{
|
||||
|
@ -36,13 +28,13 @@ class Backend extends Process
|
|||
return false;
|
||||
}
|
||||
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
My::addBackendMenuItem();
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
App::behavior()->addBehaviors([
|
||||
'adminDashboardFavoritesV2' => function (Favorites $favs): void {
|
||||
$favs->register(
|
||||
My::id(),
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Notices;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
|
@ -30,9 +20,11 @@ use Dotclear\Helper\Html\Form\{
|
|||
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
|
||||
{
|
||||
|
@ -51,7 +43,7 @@ class Config extends Process
|
|||
return true;
|
||||
}
|
||||
|
||||
if (is_null(dcCore::app()->blog) || !My::settings()) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -67,12 +59,12 @@ class Config extends Process
|
|||
|
||||
Notices::addSuccessNotice(__('Configuration successfully updated'));
|
||||
|
||||
dcCore::app()->admin->url->redirect(
|
||||
App::backend()->url()->redirect(
|
||||
'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) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -84,10 +76,6 @@ class Config extends Process
|
|||
return;
|
||||
}
|
||||
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$items = [];
|
||||
|
||||
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(__('Options')))->fields([
|
||||
(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 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 Para())->items([
|
||||
(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();
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve;
|
||||
|
||||
use dcModuleDefine;
|
||||
use Dotclear\Module\ModuleDefine;
|
||||
use Dotclear\Helper\File\{
|
||||
Files,
|
||||
Path
|
||||
|
@ -22,43 +12,69 @@ use Dotclear\Helper\File\{
|
|||
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
|
||||
{
|
||||
/** @var Tasks $tasks The tasks stack instance */
|
||||
/**
|
||||
* The tasks stack instance.
|
||||
*
|
||||
* @var Tasks $tasks
|
||||
*/
|
||||
public readonly Tasks $tasks;
|
||||
|
||||
/** @var Logs $logs The logs stack instance */
|
||||
/**
|
||||
* The logs stack instance.
|
||||
*
|
||||
* @var 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 = [
|
||||
'php', 'xml', 'js', 'css', 'csv', 'html', 'htm', 'txt', 'md', 'po',
|
||||
];
|
||||
|
||||
/** @var Improve $instance Improve instance */
|
||||
/**
|
||||
* Improve instance.
|
||||
*
|
||||
* @var Improve $instance
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor.
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
$this->logs = new Logs();
|
||||
$this->tasks = new Tasks();
|
||||
|
||||
// mark some tasks as disabled (by settings)
|
||||
$disable = explode(';', (string) My::settings()?->get('disabled'));
|
||||
// Mark some tasks as disabled (by settings)
|
||||
$disable = explode(';', (string) My::settings()->get('disabled'));
|
||||
foreach ($disable as $id) {
|
||||
$this->tasks->get($id)?->disable();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable clone.
|
||||
*/
|
||||
protected function __clone()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Diable wakeup.
|
||||
*/
|
||||
public function __wakeup()
|
||||
{
|
||||
throw new Exception('nope');
|
||||
|
@ -78,7 +94,15 @@ class Improve
|
|||
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);
|
||||
|
||||
|
@ -166,6 +190,15 @@ class Improve
|
|||
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
|
||||
{
|
||||
$path = Path::real($path);
|
||||
|
|
|
@ -1,33 +1,27 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve;
|
||||
|
||||
use dcCore;
|
||||
use dcNamespace;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Improve install class
|
||||
* @brief improve install class.
|
||||
* @ingroup improve
|
||||
*
|
||||
* Set default settings and version
|
||||
* and manage changes on updates.
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Install extends Process
|
||||
{
|
||||
/** @var array Improve default settings */
|
||||
/**
|
||||
* Improve default settings.
|
||||
*
|
||||
* @var array<int, array<int, string>> $default_settings
|
||||
*/
|
||||
private static $default_settings = [[
|
||||
'disabled',
|
||||
'List of hidden tasks modules',
|
||||
|
@ -53,7 +47,7 @@ class Install extends Process
|
|||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -62,7 +56,7 @@ class Install extends Process
|
|||
private static function putSettings(): void
|
||||
{
|
||||
foreach (self::$default_settings as $v) {
|
||||
My::settings()?->put(
|
||||
My::settings()->put(
|
||||
$v[0],
|
||||
$v[2],
|
||||
$v[3],
|
||||
|
@ -76,7 +70,7 @@ class Install extends Process
|
|||
/** Update improve < 0.8 : action modules settings name */
|
||||
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) {
|
||||
$newId = str_replace('ImproveAction', '', $id);
|
||||
if ($id != $newId) {
|
||||
|
@ -89,22 +83,22 @@ class Install extends Process
|
|||
/** Update improve < 1.1 : use json_(en|de)code rather than (un)serialize */
|
||||
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) {
|
||||
$record = dcCore::app()->con->select(
|
||||
'SELECT * FROM ' . dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME . ' ' .
|
||||
"WHERE setting_ns = '" . dcCore::app()->con->escapeStr(My::id()) . "' " .
|
||||
$record = App::con()->select(
|
||||
'SELECT * FROM ' . App::con()->prefix() . App::blogWorkspace()::NS_TABLE_NAME . ' ' .
|
||||
"WHERE setting_ns = '" . App::con()->escapeStr(My::id()) . "' " .
|
||||
"AND setting_id LIKE '" . $key . "%' "
|
||||
);
|
||||
|
||||
while ($record->fetch()) {
|
||||
try {
|
||||
$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->update(
|
||||
"WHERE setting_id = '" . $record->f('setting_id') . "' and setting_ns = '" . dcCore::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')) . "' "))
|
||||
"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 ' : ("= '" . App::con()->escapeStr($record->f('blog_id')) . "' "))
|
||||
);
|
||||
} catch(Exception) {
|
||||
}
|
||||
|
|
64
src/Logs.php
64
src/Logs.php
|
@ -1,31 +1,32 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve;
|
||||
|
||||
use dcCore;
|
||||
use dcLog;
|
||||
use Dotclear\App;
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
/** @ 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;
|
||||
|
||||
/** @var array<string,bool> $has Has log of given type */
|
||||
/**
|
||||
* Has log of given type.
|
||||
*
|
||||
* @var array<string, bool> $has
|
||||
*/
|
||||
private $has = [
|
||||
'success' => false,
|
||||
'warning' => false,
|
||||
|
@ -35,19 +36,19 @@ class Logs
|
|||
/**
|
||||
* Add a log.
|
||||
*
|
||||
* @param string $task The task ID
|
||||
* @param string $path The path
|
||||
* @param array $msgs The messages
|
||||
* @param string $task The task ID
|
||||
* @param string $path The path
|
||||
* @param array<int, string> $msgs The messages
|
||||
*/
|
||||
public function add(string $task, string $path, array $msgs): void
|
||||
{
|
||||
// get existing messages
|
||||
// Get existing messages
|
||||
$logs = $this->stack[$task][$path] ?? [];
|
||||
|
||||
// merge with new messages
|
||||
// Merge with new messages
|
||||
$this->stack[$task][$path] = array_merge($logs, $msgs);
|
||||
|
||||
// check message type
|
||||
// Check message type
|
||||
if (in_array($path, ['success', 'warning', 'error'])) {
|
||||
$this->has[$path] = true;
|
||||
}
|
||||
|
@ -75,11 +76,11 @@ class Logs
|
|||
if (empty($this->stack)) {
|
||||
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_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
|
||||
*
|
||||
* @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
|
||||
{
|
||||
|
@ -103,8 +104,11 @@ class Logs
|
|||
foreach (['success', 'warning', 'error'] as $type) {
|
||||
$l_tools = [];
|
||||
foreach ($tools as $tool) {
|
||||
if (!is_string($tool)) {
|
||||
continue;
|
||||
}
|
||||
$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) {
|
||||
$l_msg[] = $msg;
|
||||
}
|
||||
|
@ -128,7 +132,7 @@ class Logs
|
|||
/**
|
||||
* 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
|
||||
{
|
||||
|
@ -142,15 +146,15 @@ class Logs
|
|||
*
|
||||
* @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
|
||||
{
|
||||
$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()) {
|
||||
return [];
|
||||
}
|
||||
dcCore::app()->log->delLogs($rs->f('log_id'));
|
||||
App::log()->delLogs($rs->f('log_id'));
|
||||
|
||||
$res = json_decode($rs->f('log_msg'), true);
|
||||
|
||||
|
|
|
@ -1,21 +1,10 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve;
|
||||
|
||||
use dcCore;
|
||||
use dcThemes;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Notices;
|
||||
use Dotclear\Core\Backend\Page;
|
||||
use Dotclear\Core\Process;
|
||||
|
@ -35,20 +24,33 @@ use Dotclear\Helper\Text as TText;
|
|||
use Exception;
|
||||
|
||||
/**
|
||||
* Improve page class
|
||||
* @brief improve manage class.
|
||||
* @ingroup improve
|
||||
*
|
||||
* Display page and configure modules
|
||||
* and execute tasks.
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Manage extends Process
|
||||
{
|
||||
/** @var string $type Current module(s) type */
|
||||
/**
|
||||
* Current module(s) type.
|
||||
*
|
||||
* @var string $type
|
||||
*/
|
||||
private static string $type = 'plugin';
|
||||
|
||||
/** @var string $module Current module id */
|
||||
/**
|
||||
* Current module id.
|
||||
*
|
||||
* @var 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;
|
||||
|
||||
public static function init(): bool
|
||||
|
@ -77,11 +79,11 @@ class Manage extends Process
|
|||
} else {
|
||||
try {
|
||||
$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']
|
||||
);
|
||||
$log_id = Improve::instance()->logs->write();
|
||||
dcCore::app()->blog?->triggerBlog();
|
||||
App::blog()->triggerBlog();
|
||||
|
||||
if (Improve::instance()->logs->has('error')) {
|
||||
$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;
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
$done = false;
|
||||
}
|
||||
}
|
||||
|
@ -138,6 +140,9 @@ class Manage extends Process
|
|||
Page::closeModule();
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure a task.
|
||||
*/
|
||||
private static function displayConfigurator(): void
|
||||
{
|
||||
$back_url = $_REQUEST['redir'] ?? My::manageURL(['type' => self::$type]);
|
||||
|
@ -162,12 +167,15 @@ class Manage extends Process
|
|||
(new Hidden('type', self::$type)),
|
||||
(new Hidden('config', self::$task->properties->id)),
|
||||
(new Hidden('redir', $redir)),
|
||||
dcCore::app()->formNonce(false),
|
||||
App::nonce()->formNonce(),
|
||||
]),
|
||||
])->render();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show actions.
|
||||
*/
|
||||
private static function displayActions(): void
|
||||
{
|
||||
echo
|
||||
|
@ -190,7 +198,7 @@ class Manage extends Process
|
|||
'<th colspan="2" class="first">' . __('Task') . '</td>' .
|
||||
'<th scope="col">' . __('Description') . '</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>';
|
||||
foreach (Improve::instance()->tasks->dump() as $task) {
|
||||
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]) .
|
||||
'" title="' . sprintf(__("Configure task '%s'"), $task->properties->name) . '">' . __('Configure') . '</a>'
|
||||
) . '</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>';
|
||||
}
|
||||
|
||||
|
@ -228,13 +236,13 @@ class Manage extends Process
|
|||
(new Select('module'))->default(self::$module)->items($combo_modules),
|
||||
(new Submit('fix'))->value(__('Fix it')),
|
||||
(new Hidden(['type'], self::$type)),
|
||||
dcCore::app()->formNonce(false),
|
||||
App::nonce()->formNonce(),
|
||||
]),
|
||||
])->render() .
|
||||
'<br class="clear" />
|
||||
</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']);
|
||||
|
||||
if (!empty($logs)) {
|
||||
|
@ -248,7 +256,9 @@ class Manage extends Process
|
|||
if (null !== $a) {
|
||||
echo '<li>' . $a->properties->name . '<ul>';
|
||||
foreach ($msgs as $msg) {
|
||||
echo '<li>' . $msg . '</li>';
|
||||
if (is_string($msg)) {
|
||||
echo '<li>' . $msg . '</li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
echo '</ul></li>';
|
||||
|
@ -283,11 +293,16 @@ class Manage extends Process
|
|||
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
|
||||
{
|
||||
try {
|
||||
if (!empty(self::$type)) {
|
||||
$preferences = My::settings()?->get('preferences');
|
||||
$preferences = My::settings()->get('preferences');
|
||||
if (is_string($preferences)) {
|
||||
$preferences = json_decode($preferences, true);
|
||||
if (is_array($preferences)) {
|
||||
|
@ -303,7 +318,7 @@ class Manage extends Process
|
|||
|
||||
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::$type] = [];
|
||||
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'));
|
||||
|
||||
return true;
|
||||
|
@ -322,20 +337,24 @@ class Manage extends Process
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get modules combo list.
|
||||
*
|
||||
* @return array<string, string> The modules combo
|
||||
*/
|
||||
private static function comboModules(): array
|
||||
{
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!(dcCore::app()->themes instanceof dcThemes)) {
|
||||
dcCore::app()->themes = new dcThemes();
|
||||
dcCore::app()->themes->loadModules(dcCore::app()->blog->themes_path, null);
|
||||
if (!App::themes()->isEmpty()) {
|
||||
App::themes()->loadModules(App::blog()->themesPath(), null);
|
||||
}
|
||||
|
||||
$combo_modules = [];
|
||||
$modules = self::$type == 'plugin' ? dcCore::app()->plugins->getDefines() : dcCore::app()->themes->getDefines();
|
||||
if (My::settings()?->get('combosortby') === 'id') {
|
||||
$modules = self::$type == 'plugin' ? App::plugins()->getDefines() : App::themes()->getDefines();
|
||||
if (My::settings()->get('combosortby') === 'id') {
|
||||
uasort($modules, fn ($a, $b) => strtolower($a->getId()) <=> strtolower($b->getId()));
|
||||
} else {
|
||||
uasort($modules, fn ($a, $b) => strtolower(TText::removeDiacritics($a->get('name'))) <=> strtolower(TText::removeDiacritics($b->get('name'))));
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve;
|
||||
|
@ -17,22 +7,30 @@ namespace Dotclear\Plugin\improve;
|
|||
use Dotclear\Helper\File\Path;
|
||||
|
||||
/**
|
||||
* Improve module helper
|
||||
* @brief improve module helper class.
|
||||
* @ingroup improve
|
||||
*
|
||||
* Help to load module configuration file (_define.php)
|
||||
* and gather information about it.
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Module
|
||||
{
|
||||
/** @var array Current module properties */
|
||||
/**
|
||||
* Current module properties.
|
||||
*
|
||||
* @var array<string, mixed> $properties
|
||||
*/
|
||||
private $properties = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $type Module type, plugin or theme
|
||||
* @param string $id Module id
|
||||
* @param array $properties Module properties
|
||||
* @param string $type Module type, plugin or theme
|
||||
* @param string $id Module id
|
||||
* @param array<string, mixed> $properties Module 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
|
||||
{
|
||||
|
@ -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 $id Module id
|
||||
* @param array $properties Module properties
|
||||
* @param string $type Module type, plugin or theme
|
||||
* @param string $id Module id
|
||||
* @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
|
||||
{
|
||||
|
@ -67,12 +65,12 @@ class Module
|
|||
}
|
||||
|
||||
/**
|
||||
* Replicate dcModule::loadDefine
|
||||
* Replicate dcModule::loadDefine.
|
||||
*
|
||||
* @param string $id Module id
|
||||
* @param string $root Module path
|
||||
* @param string $id Module id
|
||||
* @param string $root Module path
|
||||
*
|
||||
* @return boolean Success
|
||||
* @return bool True on success
|
||||
*/
|
||||
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 $desc The module description
|
||||
|
@ -94,7 +92,7 @@ class Module
|
|||
* @param string $version The module version
|
||||
* @param string|array $properties The properties
|
||||
*
|
||||
* @return boolean Success
|
||||
* @return bool True on success
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
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 $id Module id
|
||||
* @param array $properties Module properties
|
||||
* @param string $type Module type
|
||||
* @param string $id Module id
|
||||
* @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
|
||||
{
|
||||
|
@ -184,11 +182,11 @@ class Module
|
|||
}
|
||||
|
||||
/**
|
||||
* Replicate ModulesList::sanitizeString
|
||||
* Replicate ModulesList::sanitizeString.
|
||||
*
|
||||
* @param string $str String to sanitize
|
||||
* @param string $str String to sanitize
|
||||
*
|
||||
* @return string Sanitized string
|
||||
* @return string Sanitized string
|
||||
*/
|
||||
public static function sanitizeString(string $str): string
|
||||
{
|
||||
|
|
27
src/My.php
27
src/My.php
|
@ -1,27 +1,26 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
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
|
||||
{
|
||||
protected static function checkCustomContext(int $context): ?bool
|
||||
{
|
||||
return $context === My::INSTALL ? null :
|
||||
defined('DC_CONTEXT_ADMIN') && dcCore::app()->auth->isSuperAdmin();
|
||||
return match ($context) {
|
||||
self::MODULE => App::auth()->isSuperAdmin(),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
118
src/Task.php
118
src/Task.php
|
@ -1,55 +1,91 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve;
|
||||
|
||||
use dcModuleDefine;
|
||||
use Dotclear\Module\ModuleDefine;
|
||||
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
|
||||
{
|
||||
/** @var TaskDescriptor Task descriptor instance */
|
||||
/**
|
||||
* Task descriptor instance.
|
||||
*
|
||||
* @var TaskDescriptor $properties
|
||||
*/
|
||||
public readonly TaskDescriptor $properties;
|
||||
|
||||
/** @var TaskMessages Task success messages instance */
|
||||
/**
|
||||
* Task success messages instance.
|
||||
*
|
||||
* @var TaskMessages $success
|
||||
*/
|
||||
public readonly TaskMessages $success;
|
||||
|
||||
/** @var TaskMessages Task warning messages instance */
|
||||
/**
|
||||
* Task warning messages instance.
|
||||
*
|
||||
* @var TaskMessages $warning
|
||||
*/
|
||||
public readonly TaskMessages $warning;
|
||||
|
||||
/** @var TaskMessages Task error messages instance */
|
||||
/**
|
||||
* Task error messages instance.
|
||||
*
|
||||
* @var TaskMessages $error
|
||||
*/
|
||||
public readonly TaskMessages $error;
|
||||
|
||||
/** @var TaskSettings Task settings instance */
|
||||
/**
|
||||
* Task settings instance.
|
||||
*
|
||||
* @var 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;
|
||||
|
||||
/** @var string Current full path */
|
||||
/**
|
||||
* Current full path.
|
||||
*
|
||||
* @var string $path_full
|
||||
*/
|
||||
protected string $path_full = '';
|
||||
|
||||
/** @var string Current file extension */
|
||||
/**
|
||||
* Current file extension.
|
||||
*
|
||||
* @var 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;
|
||||
|
||||
/**
|
||||
|
@ -62,7 +98,7 @@ abstract class Task
|
|||
$this->error = new TaskMessages();
|
||||
$this->properties = $this->getProperties();
|
||||
$this->settings = new TaskSettings($this->properties->id);
|
||||
$this->module = new dcModuleDefine('undefined');
|
||||
$this->module = new ModuleDefine('undefined');
|
||||
|
||||
$this->init();
|
||||
}
|
||||
|
@ -70,7 +106,7 @@ abstract class Task
|
|||
/**
|
||||
* Get task description.
|
||||
*
|
||||
* @return TaskDescriptor The task description
|
||||
* @return TaskDescriptor The task description
|
||||
*/
|
||||
abstract protected function getProperties(): TaskDescriptor;
|
||||
|
||||
|
@ -79,7 +115,7 @@ abstract class Task
|
|||
*
|
||||
* Called when Task insatnce is created.
|
||||
*
|
||||
* @return bool True if initialisation is ok.
|
||||
* @return bool True if initialisation is ok.
|
||||
*/
|
||||
abstract protected function init(): bool;
|
||||
|
||||
|
@ -106,7 +142,7 @@ abstract class Task
|
|||
/**
|
||||
* Check if task is disabled.
|
||||
*
|
||||
* @return bool True on disabled
|
||||
* @return bool True on disabled
|
||||
*/
|
||||
final public function isDisabled(): bool
|
||||
{
|
||||
|
@ -129,14 +165,14 @@ abstract class Task
|
|||
/**
|
||||
* Check if task is well configured
|
||||
*
|
||||
* @return boolean True on well configured
|
||||
* @return bool True on well configured
|
||||
*/
|
||||
abstract public function isConfigured(): bool;
|
||||
|
||||
/**
|
||||
* Get task configuration page header
|
||||
* Get task configuration page header.
|
||||
*
|
||||
* @return string Headers
|
||||
* @return string Headers
|
||||
*/
|
||||
public function header(): ?string
|
||||
{
|
||||
|
@ -144,7 +180,7 @@ abstract class Task
|
|||
}
|
||||
|
||||
/**
|
||||
* Get configuraton gui
|
||||
* Get configuraton gui.
|
||||
*
|
||||
* If task class uses internal configuration,
|
||||
* it must share here html form content of its settings.
|
||||
|
@ -152,9 +188,9 @@ abstract class Task
|
|||
* This function must redirect form
|
||||
* after validation with $this->redirect($url);
|
||||
*
|
||||
* @param string $url post form redirect url
|
||||
* @param string $url post form redirect url
|
||||
*
|
||||
* @return string The configuration form
|
||||
* @return string The configuration form
|
||||
*/
|
||||
public function configure(string $url): string
|
||||
{
|
||||
|
@ -164,11 +200,11 @@ abstract class Task
|
|||
/**
|
||||
* Set in class var current module definitions.
|
||||
*
|
||||
* @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;
|
||||
|
||||
|
@ -178,9 +214,9 @@ abstract class Task
|
|||
/**
|
||||
* Set in class var current path definitons.
|
||||
*
|
||||
* @param string $path_full Full path
|
||||
* @param string $path_extension Path extension (if it is a file)
|
||||
* @param boolean $path_is_dir True if path is a directory
|
||||
* @param string $path_full Full path
|
||||
* @param string $path_extension Path extension (if it is a file)
|
||||
* @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
|
||||
{
|
||||
|
@ -229,7 +265,7 @@ abstract class Task
|
|||
* If you want to erase a content you must erase
|
||||
* the file on action openDirectory.
|
||||
*
|
||||
* @param string $content File content
|
||||
* @param string $content File content
|
||||
*/
|
||||
public function readFile(string &$content): ?bool
|
||||
{
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve\Task;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
Div,
|
||||
|
@ -34,11 +24,19 @@ use Dotclear\Plugin\improve\{
|
|||
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
|
||||
{
|
||||
/** @var string Exemple of header */
|
||||
/**
|
||||
* Exemple of header.
|
||||
*
|
||||
* @var string $exemple
|
||||
*/
|
||||
private static $exemple = <<<EOF
|
||||
@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
|
||||
EOF;
|
||||
|
||||
/** @var array<string> Allowed bloc replacement */
|
||||
/**
|
||||
* Allowed bloc replacement.
|
||||
*
|
||||
* @var array<int, string> $bloc_wildcards
|
||||
*/
|
||||
private $bloc_wildcards = [
|
||||
'%year%',
|
||||
'%module_id%',
|
||||
|
@ -64,16 +66,32 @@ class CssHeader extends Task
|
|||
'%user_url%',
|
||||
];
|
||||
|
||||
/** @var array Allowed action for header */
|
||||
/**
|
||||
* Allowed action for header.
|
||||
*
|
||||
* @var array<string, string> $action_bloc
|
||||
*/
|
||||
private $action_bloc = [];
|
||||
|
||||
/** @var string Parsed bloc */
|
||||
/**
|
||||
* Parsed bloc.
|
||||
*
|
||||
* @var string $bloc
|
||||
*/
|
||||
private $bloc = '';
|
||||
|
||||
/** @var boolean Stop parsing files */
|
||||
/**
|
||||
* Stop parsing files.
|
||||
*
|
||||
* @var bool $stop_scan
|
||||
*/
|
||||
private $stop_scan = false;
|
||||
|
||||
/** @var string Settings bloc content */
|
||||
/**
|
||||
* Settings bloc content.
|
||||
*
|
||||
* @var string $bloc_content
|
||||
*/
|
||||
private $bloc_content = '';
|
||||
|
||||
protected function getProperties(): TaskDescriptor
|
||||
|
@ -91,7 +109,7 @@ class CssHeader extends Task
|
|||
protected function init(): bool
|
||||
{
|
||||
$this->action_bloc = [
|
||||
__('Do nothing') => 0,
|
||||
__('Do nothing') => '',
|
||||
__('Add bloc if it does not exist') => 'create',
|
||||
__('Add and overwrite bloc') => 'overwrite',
|
||||
__('Overwrite bloc only if it exists') => 'replace',
|
||||
|
@ -162,12 +180,6 @@ class CssHeader extends Task
|
|||
|
||||
public function openModule(): ?bool
|
||||
{
|
||||
if (!isset(dcCore::app()->auth)) {
|
||||
$this->warning->add(__('Auth is not set'));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$bloc = trim($this->bloc_content);
|
||||
|
||||
if (empty($bloc)) {
|
||||
|
@ -188,13 +200,13 @@ class CssHeader extends Task
|
|||
[
|
||||
date('Y'),
|
||||
$this->module->getId(),
|
||||
$this->module->get('name'),
|
||||
$this->module->get('author'),
|
||||
$this->module->get('type'),
|
||||
dcCore::app()->auth->getInfo('user_cn'),
|
||||
dcCore::app()->auth->getinfo('user_name'),
|
||||
dcCore::app()->auth->getInfo('user_email'),
|
||||
dcCore::app()->auth->getInfo('user_url'),
|
||||
(string) $this->module->get('name'),
|
||||
(string) $this->module->get('author'),
|
||||
(string) $this->module->get('type'),
|
||||
(string) App::auth()->getInfo('user_cn'),
|
||||
(string) App::auth()->getinfo('user_name'),
|
||||
(string) App::auth()->getInfo('user_email'),
|
||||
(string) App::auth()->getInfo('user_url'),
|
||||
],
|
||||
(string) $bloc
|
||||
)
|
||||
|
@ -252,10 +264,10 @@ class CssHeader extends Task
|
|||
}
|
||||
|
||||
/**
|
||||
* Write bloc content in file content
|
||||
* Write bloc content in file content.
|
||||
*
|
||||
* @param string $content Old content
|
||||
* @return string New content
|
||||
* @param string $content Old content
|
||||
* @return string New content
|
||||
*/
|
||||
private function writeDocBloc(string $content): string
|
||||
{
|
||||
|
@ -275,10 +287,10 @@ class CssHeader extends Task
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete bloc content in file content
|
||||
* Delete bloc content in file content.
|
||||
*
|
||||
* @param string $content Old content
|
||||
* @return string New content
|
||||
* @param string $content Old content
|
||||
* @return string New content
|
||||
*/
|
||||
private function deleteDocBloc(string $content): string
|
||||
{
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
<?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);
|
||||
|
||||
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
|
||||
{
|
||||
/** @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' => []];
|
||||
|
||||
/** @var boolean Stop parsing files */
|
||||
/**
|
||||
* Stop parsing files
|
||||
*
|
||||
* @var bool $stop_scan
|
||||
*/
|
||||
private $stop_scan = false;
|
||||
|
||||
protected function getProperties(): TaskDescriptor
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve\Task;
|
||||
|
@ -34,11 +24,19 @@ use Dotclear\Plugin\improve\{
|
|||
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
|
||||
{
|
||||
/** @var string Settings dcstore zip url pattern */
|
||||
/**
|
||||
* Settings dcstore zip url pattern.
|
||||
*
|
||||
* @var string $pattern
|
||||
*/
|
||||
private $pattern = '';
|
||||
|
||||
protected function getProperties(): TaskDescriptor
|
||||
|
@ -109,6 +107,11 @@ class DcStore extends Task
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate dcstore XML content.
|
||||
*
|
||||
* @return string The XML content
|
||||
*/
|
||||
public function generateXML(): string
|
||||
{
|
||||
$xml = ['<modules xmlns:da="http://dotaddict.org/da/">'];
|
||||
|
@ -203,6 +206,11 @@ class DcStore extends Task
|
|||
return self::prettyXML($res->toXML());
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up XML content.
|
||||
*
|
||||
* @return string The pretty XML content
|
||||
*/
|
||||
private static function prettyXML(string $str): string
|
||||
{
|
||||
if (class_exists('DOMDocument')) {
|
||||
|
@ -217,6 +225,11 @@ class DcStore extends Task
|
|||
return str_replace('><', ">\n<", $str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse module info.
|
||||
*
|
||||
* @return string The parsed content
|
||||
*/
|
||||
private function parseFilePattern(): string
|
||||
{
|
||||
return Text::tidyURL(str_replace(
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
<?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);
|
||||
|
||||
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
|
||||
{
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve\Task;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
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
|
||||
{
|
||||
/** @var string Username of git repo */
|
||||
/**
|
||||
* Username of git repo.
|
||||
* @var string $username
|
||||
*/
|
||||
private $username = '';
|
||||
|
||||
/** @var string Domain of git repo */
|
||||
/**
|
||||
* Domain of git repo.
|
||||
*
|
||||
* @var string $domain
|
||||
*/
|
||||
private $domain = 'github.com';
|
||||
|
||||
/** @var boolean add Dotaddict shield */
|
||||
/**
|
||||
* Add Dotaddict shield.
|
||||
*
|
||||
* @var bool $dotaddict
|
||||
*/
|
||||
private $dotaddict = false;
|
||||
|
||||
/** @var boolean Stop scaning files */
|
||||
/**
|
||||
* Stop scaning files.
|
||||
*
|
||||
* @var bool $stop_scan
|
||||
*/
|
||||
private $stop_scan = false;
|
||||
|
||||
/** @var array Parsed bloc */
|
||||
/**
|
||||
* Parsed bloc.
|
||||
*
|
||||
* @var array<string, string> $blocs
|
||||
*/
|
||||
private $blocs = [];
|
||||
|
||||
/** @var array Search patterns */
|
||||
/**
|
||||
* Search patterns.
|
||||
*
|
||||
* @var array<string, string> $bloc_pattern
|
||||
*/
|
||||
protected $bloc_pattern = [
|
||||
'remove' => '/\[!\[Release(.*)LICENSE\)/ms',
|
||||
'target' => '/^([^\n]+)[\r\n|\n]{1,}/ms',
|
||||
];
|
||||
|
||||
/** @var array Shields patterns */
|
||||
/**
|
||||
* Shields patterns.
|
||||
*
|
||||
* @var array<string, string> $bloc_content
|
||||
*/
|
||||
protected $bloc_content = [
|
||||
'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)',
|
||||
'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%)',
|
||||
|
@ -150,6 +171,9 @@ class GitShields extends Task
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse module and user info.
|
||||
*/
|
||||
private function replaceInfo(): void
|
||||
{
|
||||
$blocs = [];
|
||||
|
@ -185,6 +209,9 @@ class GitShields extends Task
|
|||
$this->success->add(__('Prepare custom shield info'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dotclear version.
|
||||
*/
|
||||
private function getDotclearVersion(): string
|
||||
{
|
||||
$version = null;
|
||||
|
@ -203,9 +230,16 @@ class GitShields extends Task
|
|||
$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
|
||||
{
|
||||
$res = preg_replace(
|
||||
|
@ -222,6 +256,13 @@ class GitShields extends Task
|
|||
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
|
||||
{
|
||||
$res = preg_replace(
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve\Task;
|
||||
|
@ -31,21 +21,37 @@ use Dotclear\Plugin\improve\{
|
|||
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
|
||||
{
|
||||
/** @var array Possible license filenames */
|
||||
/**
|
||||
* Possible license filenames.
|
||||
*
|
||||
* @var array<int, string> $license_filenames
|
||||
*/
|
||||
protected static $license_filenames = [
|
||||
'license',
|
||||
'license.md',
|
||||
'license.txt',
|
||||
];
|
||||
|
||||
/** @var array Possible license names */
|
||||
/**
|
||||
* License names combo.
|
||||
*
|
||||
* @var array<string, string> $action_version
|
||||
*/
|
||||
private $action_version = [];
|
||||
|
||||
/** @var array Action */
|
||||
/**
|
||||
* Actions combo.
|
||||
*
|
||||
* @var array<string, string> $action_full
|
||||
*/
|
||||
private $action_full = [];
|
||||
|
||||
protected function getProperties(): TaskDescriptor
|
||||
|
@ -71,7 +77,7 @@ class LicenseFile extends Task
|
|||
__('Do What The Fuck You Want To Public License') => 'wtfpl',
|
||||
];
|
||||
$this->action_full = [
|
||||
__('Do nothing') => 0,
|
||||
__('Do nothing') => '',
|
||||
__('Add file if it does not exist') => 'create',
|
||||
__('Add file even if it exists') => 'overwrite',
|
||||
__('Add file and remove others') => 'full',
|
||||
|
@ -128,6 +134,11 @@ class LicenseFile extends Task
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write full license file.
|
||||
*
|
||||
* @return ?bool True on success
|
||||
*/
|
||||
private function writeFullLicense(): ?bool
|
||||
{
|
||||
try {
|
||||
|
@ -148,6 +159,11 @@ class LicenseFile extends Task
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete full license file.
|
||||
*
|
||||
* @return bool True on success
|
||||
*/
|
||||
private function deleteFullLicense(bool $only_one = false): bool
|
||||
{
|
||||
foreach (self::fileExists($this->module->get('root')) as $file) {
|
||||
|
@ -166,6 +182,13 @@ class LicenseFile extends Task
|
|||
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
|
||||
{
|
||||
$existing = [];
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
<?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);
|
||||
|
||||
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
|
||||
{
|
||||
|
@ -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
|
||||
* @return array Cleaned extension(s)
|
||||
* @param string|array<int, string> $in Extension(s) to clean
|
||||
*
|
||||
* @return array<int,string> Cleaned extension(s)
|
||||
*/
|
||||
private static function cleanExtensions($in): array
|
||||
{
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve\Task;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Page;
|
||||
use Dotclear\Helper\File\Path;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
|
@ -36,11 +26,19 @@ use Dotclear\Plugin\improve\{
|
|||
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
|
||||
{
|
||||
/** @var array<int,string> Type of runtime errors */
|
||||
/**
|
||||
* Type of runtime errors.
|
||||
*
|
||||
* @var array<int, string> $errors
|
||||
*/
|
||||
protected static $errors = [
|
||||
0 => 'OK.',
|
||||
1 => 'General error (or PHP minimal requirement not matched).',
|
||||
|
@ -51,13 +49,25 @@ class PhpCsFixer extends Task
|
|||
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;
|
||||
|
||||
/** @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';
|
||||
|
||||
/** @var string Settings PHP executable path */
|
||||
/**
|
||||
* Settings PHP executable path.
|
||||
*
|
||||
* @var string $phpexe_path
|
||||
*/
|
||||
private $phpexe_path = '';
|
||||
|
||||
protected function getProperties(): TaskDescriptor
|
||||
|
@ -76,11 +86,9 @@ class PhpCsFixer extends Task
|
|||
{
|
||||
$this->getPhpPath();
|
||||
|
||||
if (null !== dcCore::app()->auth->user_prefs) {
|
||||
dcCore::app()->auth->user_prefs->addWorkspace('interface');
|
||||
self::$user_ui_colorsyntax = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax');
|
||||
self::$user_ui_colorsyntax_theme = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme');
|
||||
}
|
||||
//App::auth()->prefs()->addWorkspace('interface');
|
||||
self::$user_ui_colorsyntax = App::auth()->prefs()->get('interface')->get('colorsyntax');
|
||||
self::$user_ui_colorsyntax_theme = App::auth()->prefs()->get('interface')->get('colorsyntax_theme');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -164,7 +172,7 @@ class PhpCsFixer extends Task
|
|||
}
|
||||
|
||||
/**
|
||||
* Get php executable path
|
||||
* Get php executable path.
|
||||
*/
|
||||
private function getPhpPath(): void
|
||||
{
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve\Task;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
Div,
|
||||
|
@ -34,11 +24,19 @@ use Dotclear\Plugin\improve\{
|
|||
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
|
||||
{
|
||||
/** @var string Exemple of header */
|
||||
/**
|
||||
* Exemple of header.
|
||||
*
|
||||
* @var string $exemple
|
||||
*/
|
||||
private static $exemple = <<<EOF
|
||||
@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
|
||||
EOF;
|
||||
|
||||
/** @var array<string> Allowed bloc replacement */
|
||||
/**
|
||||
* Allowed bloc replacement.
|
||||
*
|
||||
* @var array<int, string> bloc_wildcards
|
||||
*/
|
||||
private $bloc_wildcards = [
|
||||
'%year%',
|
||||
'%module_id%',
|
||||
|
@ -64,16 +66,32 @@ class PhpHeader extends Task
|
|||
'%user_url%',
|
||||
];
|
||||
|
||||
/** @var array Allowed action for header */
|
||||
/**
|
||||
* Allowed action for header.
|
||||
*
|
||||
* @var array<string, string> $action_bloc
|
||||
*/
|
||||
private $action_bloc = [];
|
||||
|
||||
/** @var string Parsed bloc */
|
||||
/**
|
||||
* Parsed bloc.
|
||||
*
|
||||
* @var string $bloc
|
||||
*/
|
||||
private $bloc = '';
|
||||
|
||||
/** @var boolean Stop parsing files */
|
||||
/**
|
||||
* Stop parsing files.
|
||||
*
|
||||
* @var bool $stop_scan
|
||||
*/
|
||||
private $stop_scan = false;
|
||||
|
||||
/** @var string Settings bloc content */
|
||||
/**
|
||||
* Settings bloc content.
|
||||
*
|
||||
* @var string $bloc_content
|
||||
*/
|
||||
private $bloc_content = '';
|
||||
|
||||
protected function getProperties(): TaskDescriptor
|
||||
|
@ -91,7 +109,7 @@ class PhpHeader extends Task
|
|||
protected function init(): bool
|
||||
{
|
||||
$this->action_bloc = [
|
||||
__('Do nothing') => 0,
|
||||
__('Do nothing') => '',
|
||||
__('Add bloc if it does not exist') => 'create',
|
||||
__('Add and overwrite bloc') => 'overwrite',
|
||||
__('Overwrite bloc only if it exists') => 'replace',
|
||||
|
@ -161,12 +179,6 @@ class PhpHeader extends Task
|
|||
|
||||
public function openModule(): ?bool
|
||||
{
|
||||
if (!isset(dcCore::app()->auth)) {
|
||||
$this->warning->add(__('Auth is not set'));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$bloc = trim($this->bloc_content);
|
||||
|
||||
if (empty($bloc)) {
|
||||
|
@ -187,13 +199,13 @@ class PhpHeader extends Task
|
|||
[
|
||||
date('Y'),
|
||||
$this->module->getId(),
|
||||
$this->module->get('name'),
|
||||
$this->module->get('author'),
|
||||
$this->module->get('type'),
|
||||
dcCore::app()->auth->getInfo('user_cn'),
|
||||
dcCore::app()->auth->getinfo('user_name'),
|
||||
dcCore::app()->auth->getInfo('user_email'),
|
||||
dcCore::app()->auth->getInfo('user_url'),
|
||||
(string) $this->module->get('name'),
|
||||
(string) $this->module->get('author'),
|
||||
(string) $this->module->get('type'),
|
||||
(string) App::auth()->getInfo('user_cn'),
|
||||
(string) App::auth()->getinfo('user_name'),
|
||||
(string) App::auth()->getInfo('user_email'),
|
||||
(string) App::auth()->getInfo('user_url'),
|
||||
],
|
||||
(string) $bloc
|
||||
)
|
||||
|
@ -253,10 +265,11 @@ class PhpHeader extends Task
|
|||
}
|
||||
|
||||
/**
|
||||
* Write bloc content in file content
|
||||
* Write bloc content in file content.
|
||||
*
|
||||
* @param string $content Old content
|
||||
* @return string New content
|
||||
* @param string $content Old content
|
||||
*
|
||||
* @return string New content
|
||||
*/
|
||||
private function writeDocBloc(string $content): string
|
||||
{
|
||||
|
@ -276,10 +289,11 @@ class PhpHeader extends Task
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete bloc content in file content
|
||||
* Delete bloc content in file content.
|
||||
*
|
||||
* @param string $content Old content
|
||||
* @return string New content
|
||||
* @param string $content Old content
|
||||
*
|
||||
* @return string New content
|
||||
*/
|
||||
private function deleteDocBloc(string $content): string
|
||||
{
|
||||
|
@ -298,10 +312,11 @@ 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
|
||||
* @return string New content
|
||||
* @param string $content Old content
|
||||
*
|
||||
* @return string New content
|
||||
*/
|
||||
private function deleteOldBloc(string $content): string
|
||||
{
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve\Task;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Page;
|
||||
use Dotclear\Helper\File\Path;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
|
@ -38,23 +28,47 @@ use Dotclear\Plugin\improve\{
|
|||
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
|
||||
{
|
||||
/** @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;
|
||||
|
||||
/** @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';
|
||||
|
||||
/** @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 = '';
|
||||
|
||||
/** @var string Settings PHP executable path */
|
||||
/**
|
||||
* Settings PHP executable path.
|
||||
*
|
||||
* @var string $phpexe_path
|
||||
*/
|
||||
private $phpexe_path = '';
|
||||
|
||||
protected function getProperties(): TaskDescriptor
|
||||
|
@ -79,18 +93,16 @@ class PhpStan extends Task
|
|||
$ignored_vars = $this->settings->get('ignored_vars');
|
||||
$this->ignored_vars = is_string($ignored_vars) ? $ignored_vars : '';
|
||||
|
||||
if (null !== dcCore::app()->auth->user_prefs) {
|
||||
dcCore::app()->auth->user_prefs->addWorkspace('interface');
|
||||
self::$user_ui_colorsyntax = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax');
|
||||
self::$user_ui_colorsyntax_theme = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme');
|
||||
}
|
||||
//App::auth()->prefs()->addWorkspace('interface');
|
||||
self::$user_ui_colorsyntax = App::auth()->prefs()->get('interface')->get('colorsyntax');
|
||||
self::$user_ui_colorsyntax_theme = App::auth()->prefs()->get('interface')->get('colorsyntax_theme');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isConfigured(): bool
|
||||
{
|
||||
return !My::settings()?->get('nodetails');
|
||||
return !My::settings()->get('nodetails');
|
||||
}
|
||||
|
||||
public function header(): ?string
|
||||
|
@ -220,23 +232,24 @@ class PhpStan extends Task
|
|||
}
|
||||
|
||||
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,
|
||||
__DIR__
|
||||
__DIR__,
|
||||
App::config()->varRoot() . '/phpstan.neon'
|
||||
), true);
|
||||
}
|
||||
|
||||
private function execFixer(string $path = null): bool
|
||||
{
|
||||
if (!empty($path)) {
|
||||
$path .= ' ';
|
||||
if (empty($path)) {
|
||||
$path = Path::real($this->module->get('root'));
|
||||
}
|
||||
|
||||
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,
|
||||
__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
|
||||
{
|
||||
|
@ -289,13 +302,15 @@ class PhpStan extends Task
|
|||
'%LEVEL%',
|
||||
'%MODULE_ROOT%',
|
||||
'%DC_ROOT%',
|
||||
'%CACHE_ROOT%',
|
||||
'%BOOTSTRAP_ROOT%',
|
||||
'%SCAN_DIRECTORIES%',
|
||||
],
|
||||
[
|
||||
$this->run_level,
|
||||
(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),
|
||||
$this->getScanDirectories(),
|
||||
],
|
||||
|
@ -314,17 +329,17 @@ class PhpStan extends Task
|
|||
' 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
|
||||
{
|
||||
$ret = '';
|
||||
if ($this->module->get('type') == 'plugin') {
|
||||
$paths = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
|
||||
$paths = explode(PATH_SEPARATOR, App::config()->pluginsRoot());
|
||||
foreach ($paths as $path) {
|
||||
$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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
<?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);
|
||||
|
||||
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
|
||||
{
|
||||
/** @var string License bloc */
|
||||
/**
|
||||
* License bloc.
|
||||
*
|
||||
* @var string $license
|
||||
*/
|
||||
private $license = <<<EOF
|
||||
/**
|
||||
* @package Dotclear
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
<?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);
|
||||
|
||||
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
|
||||
{
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve\Task;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Helper\File\{
|
||||
Files,
|
||||
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
|
||||
{
|
||||
/** @var array List of excluded file pattern */
|
||||
/**
|
||||
* List of excluded file pattern.
|
||||
*
|
||||
* @var array<int, string> $exclude
|
||||
*/
|
||||
public static $exclude = [
|
||||
'.',
|
||||
'..',
|
||||
|
@ -53,7 +51,11 @@ class Zip extends Task
|
|||
'_disabled',
|
||||
];
|
||||
|
||||
/** @var array Replacement wildcards */
|
||||
/**
|
||||
* Replacement wildcards.
|
||||
*
|
||||
* @var array<int, string> $filename_wildcards
|
||||
*/
|
||||
public static $filename_wildcards = [
|
||||
'%type%',
|
||||
'%id%',
|
||||
|
@ -62,13 +64,25 @@ class Zip extends Task
|
|||
'%time%',
|
||||
];
|
||||
|
||||
/** @var string Settings Excluded files */
|
||||
/**
|
||||
* Settings Excluded files.
|
||||
*
|
||||
* @var string $pack_excludefiles
|
||||
*/
|
||||
private $pack_excludefiles = '';
|
||||
|
||||
/** @var string Settings Main packacge filename */
|
||||
/**
|
||||
* Settings Main packacge filename.
|
||||
*
|
||||
* @var string $pack_filename
|
||||
*/
|
||||
private $pack_filename = '';
|
||||
|
||||
/** @var string Settings Second package filename */
|
||||
/**
|
||||
* Settings Second package filename.
|
||||
*
|
||||
* @var string $secondpack_filename
|
||||
*/
|
||||
private $secondpack_filename = '';
|
||||
|
||||
protected function getProperties(): TaskDescriptor
|
||||
|
@ -127,8 +141,8 @@ class Zip extends Task
|
|||
]),
|
||||
(new Note())->text(sprintf(
|
||||
__('Preconization: %s'),
|
||||
dcCore::app()->blog?->public_path ?
|
||||
Path::real(dcCore::app()->blog->public_path) : __("Blog's public directory")
|
||||
App::blog()->publicPath() ?
|
||||
Path::real(App::blog()->publicPath()) : __("Blog's public directory")
|
||||
))->class('form-note'),
|
||||
]),
|
||||
(new Fieldset())->class('fieldset')->legend((new Legend(__('Files'))))->fields([
|
||||
|
@ -187,6 +201,12 @@ class Zip extends Task
|
|||
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
|
||||
{
|
||||
$file = str_replace(
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,61 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief improve, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin improve task phpstan bootstrap
|
||||
* @ingroup improve
|
||||
*
|
||||
* @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
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
// 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_BACKUP_PATH', '');
|
||||
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);
|
||||
define('DC_FAIRTRACKBACKS_FORCE', true);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
parameters:
|
||||
level: %LEVEL%
|
||||
|
||||
tmpDir: %CACHE_ROOT%
|
||||
|
||||
paths:
|
||||
- %MODULE_ROOT%
|
||||
|
||||
|
@ -22,57 +24,10 @@ parameters:
|
|||
- in
|
||||
|
||||
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_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_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
|
||||
reportUnmatchedIgnoredErrors: false
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
parameters:
|
||||
level: %LEVEL%
|
||||
|
||||
tmpDir: %CACHE_ROOT%
|
||||
|
||||
paths:
|
||||
- %MODULE_ROOT%
|
||||
|
||||
|
@ -22,55 +24,8 @@ parameters:
|
|||
- in
|
||||
|
||||
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_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_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
|
||||
checkGenericClassInNonGenericObjectType: false
|
||||
|
@ -82,96 +37,140 @@ parameters:
|
|||
- message: '#Variable \$this might not be defined#'
|
||||
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
|
||||
- message: '#Call to an undefined method form[a-zA-Z0-9\\_]+::#'
|
||||
|
||||
# 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\\_]+.#'
|
||||
path: %currentWorkingDirectory%
|
||||
|
||||
# arrayObject/type
|
||||
- message: '#ArrayObject\<\*NEVER\*, \*NEVER\*\> does not accept#'
|
||||
|
||||
# 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\\_]+\)::#'
|
||||
path: %currentWorkingDirectory%
|
||||
|
||||
# 2.25+
|
||||
|
||||
# WidgetsStack object and auto properties
|
||||
- message: '#Access to an undefined property Dotclear\\Plugin\\widgets\\WidgetsStack::#'
|
||||
path: %currentWorkingDirectory%
|
||||
|
||||
# WidgetsElement object and auto properties
|
||||
- message: '#Access to an undefined property Dotclear\\Plugin\\widgets\\WidgetsElement::#'
|
||||
path: %currentWorkingDirectory%
|
||||
|
||||
# dcModuleDefine auto properties
|
||||
- message: '#Access to an undefined property dcModuleDefine::#'
|
||||
path: %currentWorkingDirectory%
|
||||
|
||||
# 2.26+
|
||||
|
||||
# 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\\_]+::#'
|
||||
path: %currentWorkingDirectory%
|
||||
|
||||
# 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\\_]+::#'
|
||||
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,22 +14,33 @@ declare(strict_types=1);
|
|||
|
||||
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
|
||||
{
|
||||
/** @var boolean Should remove comments from files */
|
||||
/**
|
||||
* Should remove comments from files.
|
||||
*
|
||||
* @var bool $remove_comment
|
||||
*/
|
||||
public static $remove_comment = false;
|
||||
|
||||
/**
|
||||
* Replace helper Zip::writeFile
|
||||
*
|
||||
* @param string $name The name
|
||||
* @param string $file The file
|
||||
* @param string $size The size
|
||||
* @param int|null $mtime The mtime
|
||||
*
|
||||
* @return void
|
||||
* @param string $name The name
|
||||
* @param string $file The file
|
||||
* @param int|float $size The size
|
||||
* @param int|float $mtime The mtime
|
||||
*/
|
||||
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])) {
|
||||
return;
|
||||
|
@ -51,8 +62,8 @@ class Zip extends \Dotclear\Helper\File\Zip\Zip
|
|||
|
||||
unset($content);
|
||||
|
||||
$mdate = $this->makeDate($mtime);
|
||||
$mtime = $this->makeTime($mtime);
|
||||
$mdate = $this->makeDate((int) $mtime);
|
||||
$mtime = $this->makeTime((int) $mtime);
|
||||
|
||||
# Data descriptor
|
||||
$data_desc = "\x50\x4b\x03\x04" .
|
||||
|
@ -101,6 +112,13 @@ class Zip extends \Dotclear\Helper\File\Zip\Zip
|
|||
$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
|
||||
{
|
||||
$comment = [T_COMMENT];
|
||||
|
|
|
@ -1,41 +1,43 @@
|
|||
<?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);
|
||||
|
||||
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
|
||||
{
|
||||
/** @var string The priority overload settings prefix */
|
||||
/**
|
||||
* The priority overload settings prefix.
|
||||
*
|
||||
* @var string PREFIX
|
||||
*/
|
||||
public const PREFIX = 'priority_';
|
||||
|
||||
/** @var int $priority The task priority */
|
||||
/**
|
||||
* The task priority.
|
||||
*
|
||||
* @var int $priority
|
||||
*/
|
||||
public readonly int $priority;
|
||||
|
||||
/**
|
||||
* Constructor sets all properties
|
||||
*
|
||||
* @param string $id The task ID
|
||||
* @param string $name The task translated name
|
||||
* @param string $description The task short descripton
|
||||
* @param bool $configurator The task has configuration form
|
||||
* @param array $types The task supported modules types
|
||||
* @param int $priority The task default priority
|
||||
* @param string $id The task ID
|
||||
* @param string $name The task translated name
|
||||
* @param string $description The task short descripton
|
||||
* @param bool $configurator The task has configuration form
|
||||
* @param array<int, string> $types The task supported modules types
|
||||
* @param int $priority The task default priority
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly string $id,
|
||||
|
@ -46,6 +48,6 @@ class TaskDescriptor
|
|||
int $priority = 500
|
||||
) {
|
||||
// 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,20 +15,32 @@ declare(strict_types=1);
|
|||
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
|
||||
{
|
||||
/** @ 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;
|
||||
|
||||
/** @ var string $path The current path */
|
||||
/**
|
||||
* The current path.
|
||||
*
|
||||
* @var string $path
|
||||
*/
|
||||
private string $path = 'root';
|
||||
|
||||
/**
|
||||
* Set current working path.
|
||||
*
|
||||
* @param string $path The path
|
||||
* @param string $path The path
|
||||
*/
|
||||
public function path(string $path = 'root'): void
|
||||
{
|
||||
|
@ -38,7 +50,7 @@ class TaskMessages
|
|||
/**
|
||||
* Check if there are messages.
|
||||
*
|
||||
* return bool True if not empty
|
||||
* @return bool True if not empty
|
||||
*/
|
||||
public function empty(): bool
|
||||
{
|
||||
|
@ -60,7 +72,7 @@ class TaskMessages
|
|||
*
|
||||
* @param string $path The path
|
||||
*
|
||||
* @return array The messages
|
||||
* @return array<int, string> The messages
|
||||
*/
|
||||
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
|
||||
{
|
||||
|
|
|
@ -1,31 +1,33 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
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
|
||||
{
|
||||
/** @var string The setting prefix */
|
||||
/**
|
||||
* The setting prefix.
|
||||
*
|
||||
* @var string PREFIX
|
||||
*/
|
||||
public const PREFIX = 'settings_';
|
||||
|
||||
/** @ var array<string,mixed> $stack The settings stack */
|
||||
/**
|
||||
* The settings stack.
|
||||
*
|
||||
* @var array<string, mixed> $stack
|
||||
*/
|
||||
private array $stack = [];
|
||||
|
||||
/**
|
||||
|
@ -36,11 +38,11 @@ class TaskSettings
|
|||
public function __construct(
|
||||
private string $suffix
|
||||
) {
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
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);
|
||||
$this->stack = is_array($settings) ? $settings : [];
|
||||
}
|
||||
|
@ -76,8 +78,8 @@ class TaskSettings
|
|||
*/
|
||||
public function save(): void
|
||||
{
|
||||
if (!is_null(dcCore::app()->blog)) {
|
||||
dcCore::app()->blog->settings->get(My::id())->put(
|
||||
if (App::blog()->isDefined()) {
|
||||
App::blog()->settings()->get(My::id())->put(
|
||||
self::PREFIX . $this->suffix,
|
||||
json_encode($this->stack),
|
||||
'string',
|
||||
|
@ -85,7 +87,7 @@ class TaskSettings
|
|||
true,
|
||||
true
|
||||
);
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
App::blog()->triggerBlog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +1,25 @@
|
|||
<?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);
|
||||
|
||||
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
|
||||
{
|
||||
/** @var array<string,Task> $stack The tasks stack */
|
||||
/**
|
||||
* The tasks stack.
|
||||
*
|
||||
* @var array<string, Task> $stack
|
||||
*/
|
||||
private array $stack = [];
|
||||
|
||||
/**
|
||||
|
@ -30,7 +28,7 @@ class Tasks
|
|||
public function __construct()
|
||||
{
|
||||
# --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->priority <=> $b->properties->priority);
|
||||
|
@ -55,7 +53,7 @@ class Tasks
|
|||
/**
|
||||
* Get all tasks.
|
||||
*
|
||||
* @return array<string,Task> The tasks stack
|
||||
* @return array<string, Task> The tasks stack
|
||||
*/
|
||||
public function dump(): array
|
||||
{
|
||||
|
|
|
@ -1,23 +1,19 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\improve;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
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
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -27,7 +23,7 @@ class Uninstall extends Process
|
|||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue