From 332930aab947c34059bf9b62b38ca3690959bdce Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 7 Oct 2023 15:33:13 +0200 Subject: [PATCH] update to Dotclear 2.28-dev --- CHANGELOG.md | 6 ++++++ README.md | 10 +++++----- _define.php | 6 +++--- dcstore.xml | 6 +++--- src/Backend.php | 8 ++++---- src/Config.php | 10 +++++----- src/My.php | 4 ++-- src/Utils.php | 45 +++++++++++++++++++++------------------------ 8 files changed, 49 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0db202..2cb2337 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +DotclearWatch 0.9 - 2023.10.07 +=========================================================== +* Require dotclear 2.28 +* Require php 8.1 +* Update to Dotclear 2.28-dev + DotclearWatch 0.8 - 2023.08.27 =========================================================== * Require dotclear 2.27 diff --git a/README.md b/README.md index a912ff5..bce15ac 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # README -[![Release](https://img.shields.io/badge/release-0.8-a2cbe9.svg)](https://git.dotclear.watch/dw/DotclearWatch/releases) -![Date](https://img.shields.io/badge/date-2023.08.27-c44d58.svg)] -[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download) +[![Release](https://img.shields.io/badge/release-0.9-a2cbe9.svg)](https://git.dotclear.watch/dw/DotclearWatch/releases) +![Date](https://img.shields.io/badge/date-2023.10.07-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/DotclearWatch) [![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/dw/DotclearWatch/src/branch/master/LICENSE) @@ -30,8 +30,8 @@ in aboutConfig global parameters called DotclearWatch->hidden_modules ## REQUIREMENTS * super admin permission to intall it -* Dotclear 2.27 -* PHP 7.4+ +* Dotclear 2.28 +* PHP 8.1+ ## USAGE diff --git a/_define.php b/_define.php index b9c8b15..ad6e9cf 100644 --- a/_define.php +++ b/_define.php @@ -14,11 +14,11 @@ $this->registerModule( 'Dotclear Watch', 'Send report about your Dotclear', 'Jean-Christian Denis and contributors', - '0.8', + '0.9', [ 'requires' => [ - ['php', '7.4'], - ['core', '2.27'], + ['php', '8.1'], + ['core', '2.28'], ], 'type' => 'plugin', 'support' => 'https://git.dotclear.watch/dw/' . basename(__DIR__) . '/issues', diff --git a/dcstore.xml b/dcstore.xml index daff1a6..b1d5e5d 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,11 +2,11 @@ Dotclear Watch - 0.8 + 0.9 Jean-Christian Denis and contributors Send report about your Dotclear - https://git.dotclear.watch/dw/DotclearWatch/releases/download/v0.8/plugin-DotclearWatch.zip - 2.27 + https://git.dotclear.watch/dw/DotclearWatch/releases/download/v0.9/plugin-DotclearWatch.zip + 2.28 https://git.dotclear.watch/dw/DotclearWatch/src/branch/master/README.md https://git.dotclear.watch/dw/DotclearWatch/issues diff --git a/src/Backend.php b/src/Backend.php index f661814..71f49a0 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -14,7 +14,7 @@ declare(strict_types=1); namespace Dotclear\Plugin\DotclearWatch; -use dcCore; +use Dotclear\App; use Dotclear\Core\Process; class Backend extends Process @@ -30,9 +30,9 @@ class Backend extends Process return false; } - dcCore::app()->addBehaviors([ + App::behavior()->addBehaviors([ 'adminDashboardHeaders' => function (): string { - return My::jsLoad('service', dcCore::app()->getVersion(My::id())); + return My::jsLoad('service', App::version()->getVersion(My::id())); }, 'adminPageFooterV2' => function (): void { if (My::settings()->getGlobal('distant_api_url')) { @@ -47,7 +47,7 @@ class Backend extends Process }, ]); - dcCore::app()->rest->addFunction( + App::rest()->addFunction( 'adminDotclearWatchSendReport', function (): array { Utils::sendReport(); diff --git a/src/Config.php b/src/Config.php index 2a16934..bf21dbc 100644 --- a/src/Config.php +++ b/src/Config.php @@ -12,7 +12,7 @@ declare(strict_types=1); namespace Dotclear\Plugin\DotclearWatch; -use dcCore; +use Dotclear\App; use Dotclear\Core\Backend\Notices; use Dotclear\Core\Backend\Page; use Dotclear\Core\Process; @@ -47,7 +47,7 @@ class Config extends Process } if (self::useColorSynthax()) { - dcCore::app()->addBehavior('pluginsToolsHeadersV2', fn (bool $plugin): string => Page::jsLoadCodeMirror(dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme'))); + App::behavior()->addBehavior('pluginsToolsHeadersV2', fn (bool $plugin): string => Page::jsLoadCodeMirror(App::auth()->prefs()->get('interface')->get('colorsyntax_theme'))); } self::$hidden_modules = (string) My::settings()->getGlobal('hidden_modules'); @@ -86,7 +86,7 @@ class Config extends Process } } - dcCore::app()->admin->url->redirect('admin.plugins', ['module' => My::id(), 'conf' => '1']); + App::backend()->url->redirect('admin.plugins', ['module' => My::id(), 'conf' => '1']); return true; } @@ -139,13 +139,13 @@ class Config extends Process ])->render() . ( self::useColorSynthax() ? - Page::jsRunCodeMirror(My::id() . 'editor', 'report_contents', 'json', dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme')) : '' + Page::jsRunCodeMirror(My::id() . 'editor', 'report_contents', 'json', App::auth()->prefs()->get('interface')->get('colorsyntax_theme')) : '' ); } } private static function useColorSynthax(): bool { - return dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax') && '' != dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme'); + return App::auth()->prefs()->get('interface')->get('colorsyntax') && '' != App::auth()->prefs()->get('interface')->get('colorsyntax_theme'); } } diff --git a/src/My.php b/src/My.php index 953bebe..6e0475f 100644 --- a/src/My.php +++ b/src/My.php @@ -14,7 +14,7 @@ declare(strict_types=1); namespace Dotclear\Plugin\DotclearWatch; -use dcCore; +use Dotclear\App; use Dotclear\Module\MyPlugin; class My extends MyPlugin @@ -22,6 +22,6 @@ class My extends MyPlugin protected static function checkCustomContext(int $context): ?bool { return $context === My::INSTALL ? null : - defined('DC_CONTEXT_ADMIN') && dcCore::app()->auth->isSuperAdmin(); + defined('DC_CONTEXT_ADMIN') && App::auth()->isSuperAdmin(); } } diff --git a/src/Utils.php b/src/Utils.php index 6506f73..e3127ee 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -14,12 +14,10 @@ declare(strict_types=1); namespace Dotclear\Plugin\DotclearWatch; -use dcCore; -use dcLog; -use dcModuleDefine; -use dcThemes; +use Dotclear\App; use Dotclear\Helper\Crypt; use Dotclear\Helper\Network\HttpClient; +use Dotclear\Module\ModuleDefine; use Exception; class Utils @@ -71,7 +69,7 @@ class Utils { $modules = []; $hiddens = self::getHiddens(); - $defines = dcCore::app()->plugins->getDefines($strict ? ['state' => dcModuleDefine::STATE_ENABLED] : []); + $defines = App::plugins()->getDefines($strict ? ['state' => ModuleDefine::STATE_ENABLED] : []); foreach ($defines as $define) { if ($strict && in_array($define->getId(), $hiddens)) { continue; @@ -91,14 +89,13 @@ class Utils */ public static function getThemes(bool $strict = true): array { - if (!(dcCore::app()->themes instanceof dcThemes)) { - dcCore::app()->themes = new dcThemes(); - dcCore::app()->themes->loadModules(dcCore::app()->blog->themes_path); + if (App::themes()->isEmpty()) { + App::themes()->loadModules(App::blog()->themesPath()); } $modules = []; $hiddens = self::getHiddens(); - $defines = dcCore::app()->themes->getDefines($strict ? ['state' => dcModuleDefine::STATE_ENABLED] : []); + $defines = App::themes()->getDefines($strict ? ['state' => ModuleDefine::STATE_ENABLED] : []); foreach ($defines as $define) { if ($strict && in_array($define->getId(), $hiddens)) { continue; @@ -157,7 +154,7 @@ class Utils */ public static function getError(): string { - $rs = dcCore::app()->log->getLogs([ + App::log()->getLogs([ 'log_table' => My::id() . '_error', ]); @@ -266,7 +263,7 @@ class Utils private static function buid(): string { - return md5(self::uid() . dcCore::app()->blog->uid); + return md5(self::uid() . App::blog()->uid()); } private static function url(): string @@ -278,7 +275,7 @@ class Utils private static function clear(): void { - $rs = dcCore::app()->log->getLogs([ + App::log()->getLogs([ 'log_table' => [ My::id() . '_report', My::id() . '_error', @@ -293,34 +290,34 @@ class Utils while ($rs->fetch()) { $logs[] = (int) $rs->f('log_id'); } - dcCore::app()->log->delLogs($logs); + App::log()->delLogs($logs); } private static function error(string $message): void { self::clear(); - $cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcLog::LOG_TABLE_NAME); + $cur = App::log()->openLogCursor(); $cur->setField('log_table', My::id() . '_error'); $cur->setField('log_msg', $message); - dcCore::app()->log->addLog($cur); + App::log()->addLog($cur); } private static function write(string $contents): void { self::clear(); - $cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcLog::LOG_TABLE_NAME); + $cur = App::log()->openLogCursor(); $cur->setField('log_table', My::id() . '_report'); $cur->setField('log_msg', $contents); - dcCore::app()->log->addLog($cur); + App::log()->addLog($cur); } private static function read(): string { - $rs = dcCore::app()->log->getLogs([ + App::log()->getLogs([ 'log_table' => My::id() . '_report', ]); @@ -329,7 +326,7 @@ class Utils private static function expired(): bool { - $rs = dcCore::app()->log->getLogs([ + App::log()->getLogs([ 'log_table' => My::id() . '_report', ]); @@ -345,11 +342,11 @@ class Utils 'plugins' => self::getPlugins(), // enabled plugins 'themes' => self::getThemes(), // enabled themes 'blog' => [ - 'lang' => (string) dcCore::app()->blog->settings->get('system')->get('lang'), - 'theme' => (string) dcCore::app()->blog->settings->get('system')->get('theme'), + 'lang' => (string) App::blog()->settings()->get('system')->get('lang'), + 'theme' => (string) App::blog()->settings()->get('system')->get('theme'), ], 'blogs' => [ - 'count' => (int) dcCore::app()->getBlogs([], true)->f(0), + 'count' => (int) App::blogs()->getBlogs([], true)->f(0), ], 'core' => [ 'version' => DC_VERSION, @@ -364,8 +361,8 @@ class Utils 'version' => php_uname('r'), ], 'database' => [ - 'driver' => dcCore::app()->con->driver(), - 'version' => dcCore::app()->con->version(), + 'driver' => App::con()->driver(), + 'version' => App::con()->version(), ], ], JSON_PRETTY_PRINT); }