upgrade to Dotclear 2.28

This commit is contained in:
Jean-Christian Paul Denis 2023-10-19 21:18:26 +02:00
parent a74b1f8b43
commit 24077d4370
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
10 changed files with 115 additions and 129 deletions

View File

@ -1,3 +1,9 @@
lunarPhase 1.9 - 2023.10.19
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Upgrade to Dotclear 2.28
lunarPhase 1.8 - 2023.08.14 lunarPhase 1.8 - 2023.08.14
=========================================================== ===========================================================
* Require Dotclear 2.27 * Require Dotclear 2.27

View File

@ -1,25 +1,22 @@
# README # README
[![Release](https://img.shields.io/badge/release-1.8-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/lunarPhase/releases) [![Release](https://img.shields.io/badge/release-1.9-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/lunarPhase/releases)
[![Date](https://img.shields.io/badge/date-2023.08.15-c44d58.svg)](https://git.dotclear.watch/JcDenis/lunarPhase/releases) ![Date](https://img.shields.io/badge/date-2023.10.19-c44d58.svg)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download) [![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/lunarPhase) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/lunarPhase)
[![License](https://img.shields.io/github/license/JcDenis/lunarPhase)](https://git.dotclear.watch/JcDenis/lunarPhase/blob/master/LICENSE) [![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/lunarPhase/src/branch/master/LICENSE)
## WHAT IS LUNARPHASE ? ## ABOUT
_lunarPhase_ is a plugin for the open-source _lunarPhase_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
web publishing software called Dotclear.
It shows lunar phases on a widget. > Show lunar phases on a widget.
## REQUIREMENTS ## REQUIREMENTS
_lunarPhase_ requires: * Dotclear 2.28
* content admin permissions to manage widgets
* Dotclear 2.27
* PHP 8.1+ * PHP 8.1+
* Dotclear content admin permissions to manage widgets
## USAGE ## USAGE
@ -30,15 +27,16 @@ You should add widget to show lunar phases on your blog.
## LINKS ## LINKS
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html) * [License](https://git.dotclear.watch/JcDenis/lunarPhase/src/branch/master/LICENSE)
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/lunarPhase) or [GitHub Page](https://github.com/JcDenis/lunarPhase) * [Packages & details](https://git.dotclear.watch/JcDenis/lunarPhase/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/lunarPhase))
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/lunarPhase/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/lunarPhase) * [Sources & contributions](https://git.dotclear.watch/JcDenis/lunarPhase) (or on [GitHub](https://github.com/JcDenis/lunarPhase))
* Discuss and help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?pid=332971#p332971) * [Issues & security](https://git.dotclear.watch/JcDenis/lunarPhase/issues) (or on [GitHub](https://github.com/JcDenis/lunarPhase/issues))
* [Discuss & help](http://forum.dotclear.org/viewtopic.php?pid=332971#p332971)
## CONTRIBUTORS ## CONTRIBUTORS
* Tomtom (author) * Tomtom (author)
* Pierre Van Glabeke * Pierre Van Glabeke
* Jean-Christian Denis * Jean-Christian Denis (latest)
You are welcome to contribute to this code. You are welcome to contribute to this code.

View File

@ -1,36 +1,30 @@
<?php <?php
/** /**
* @brief lunarPhase, a plugin for Dotclear 2 * @file
* @brief The plugin lunarPhase definition
* @ingroup lunarPhase
* *
* @package Dotclear * @defgroup lunarPhase Plugin lunarPhase.
* @subpackage Plugin
* *
* @author Tomtom, Pierre Van Glabeke and Contributors * Display the moon phases on a widget.
* *
* @copyright Jean-Christian Denis * @author Tomtom (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_RC_PATH')) { declare(strict_types=1);
return null;
}
$this->registerModule( $this->registerModule(
'Moon phases', 'Moon phases',
'Display the moon phases on a widget', 'Display the moon phases on a widget',
'Tomtom, Pierre Van Glabeke and Contributors', 'Tomtom, Pierre Van Glabeke and Contributors',
'1.8', '1.9',
[ [
'requires' => [ 'requires' => [['core', '2.28']],
['php', '8.1'], 'permissions' => 'My',
['core', '2.26'], 'type' => 'plugin',
], 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'permissions' => dcCore::app()->auth->makePermissions([ 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
dcCore::app()->auth::PERMISSION_USAGE, 'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
]),
'type' => 'plugin',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
] ]
); );

View File

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="lunarPhase"> <module id="lunarPhase">
<name>Moon phases</name> <name>Moon phases</name>
<version>1.8</version> <version>1.9</version>
<author>Tomtom, Pierre Van Glabeke and Contributors</author> <author>Tomtom, Pierre Van Glabeke and Contributors</author>
<desc>Display the moon phases on a widget</desc> <desc>Display the moon phases on a widget</desc>
<file>https://git.dotclear.watch/JcDenis/lunarPhase/releases/download/v1.8/plugin-lunarPhase.zip</file> <file>https://git.dotclear.watch/JcDenis/lunarPhase/releases/download/v1.9/plugin-lunarPhase.zip</file>
<da:dcmin>2.26</da:dcmin> <da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/lunarPhase/src/branch/master/README.md</da:details> <da:details>https://git.dotclear.watch/JcDenis/lunarPhase/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/lunarPhase/issues</da:support> <da:support>https://git.dotclear.watch/JcDenis/lunarPhase/issues</da:support>
</module> </module>

View File

@ -1,22 +1,20 @@
<?php <?php
/**
* @brief lunarPhase, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Tomtom, Pierre Van Glabeke and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1); declare(strict_types=1);
namespace Dotclear\Plugin\lunarPhase; namespace Dotclear\Plugin\lunarPhase;
use dcCore; use Dotclear\App;
use Dotclear\Core\Process; use Dotclear\Core\Process;
/**
* @brief lunarPhase backend class.
* @ingroup lunarPhase
*
* @author Tomtom (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Backend extends Process class Backend extends Process
{ {
public static function init(): bool public static function init(): bool
@ -30,7 +28,7 @@ class Backend extends Process
return false; return false;
} }
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initWidgets']); App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
return true; return true;
} }

View File

@ -1,23 +1,20 @@
<?php <?php
/**
* @brief lunarPhase, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Tomtom, Pierre Van Glabeke and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1); declare(strict_types=1);
namespace Dotclear\Plugin\lunarPhase; namespace Dotclear\Plugin\lunarPhase;
use dcCore; use Dotclear\App;
use dcUtils;
use Dotclear\Core\Process; use Dotclear\Core\Process;
/**
* @brief lunarPhase frontend class.
* @ingroup lunarPhase
*
* @author Tomtom (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Frontend extends Process class Frontend extends Process
{ {
public static function init(): bool public static function init(): bool
@ -31,17 +28,15 @@ class Frontend extends Process
return false; return false;
} }
dcCore::app()->addBehaviors([ App::behavior()->addBehaviors([
// Add public header for lunarphase css // Add public header for lunarphase css
'publicHeadContent' => function (): void { 'publicHeadContent' => function (): void {
if (is_null(dcCore::app()->blog)) { if (App::blog()->isDefined()) {
return; echo App::plugins()->cssLoad(App::blog()->url() . App::url()->getURLFor('lunarphase'));
} }
echo dcUtils::cssLoad(dcCore::app()->blog->url . dcCore::app()->url->getURLFor('lunarphase'));
}, },
// Widgets // Widgets
'initWidgets' => [Widgets::class, 'initWidgets'], 'initWidgets' => Widgets::initWidgets(...),
]); ]);
return true; return true;

View File

@ -1,21 +1,19 @@
<?php <?php
/**
* @brief lunarPhase, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Tomtom, Pierre Van Glabeke and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1); declare(strict_types=1);
namespace Dotclear\Plugin\lunarPhase; namespace Dotclear\Plugin\lunarPhase;
use ArrayObject; use ArrayObject;
/**
* @brief lunarPhase main class.
* @ingroup lunarPhase
*
* @author Tomtom (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class LunarPhase class LunarPhase
{ {
# Astronomical constants. # Astronomical constants.

View File

@ -1,15 +1,5 @@
<?php <?php
/**
* @brief lunarPhase, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Tomtom, Pierre Van Glabeke and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1); declare(strict_types=1);
namespace Dotclear\Plugin\lunarPhase; namespace Dotclear\Plugin\lunarPhase;
@ -17,11 +7,20 @@ namespace Dotclear\Plugin\lunarPhase;
use Dotclear\Module\MyPlugin; use Dotclear\Module\MyPlugin;
/** /**
* This module definitions. * @brief lunarPhase My helper.
* @ingroup lunarPhase
*
* @author Tomtom (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
class My extends MyPlugin class My extends MyPlugin
{ {
/** @var array<string,string> List of lunar phase => image */ /**
* List of lunar phase => image.
*
* @var array<string, string> LUNAR_PHASES
*/
public const LUNAR_PHASES = [ public const LUNAR_PHASES = [
'new_moon' => 'nm.png', 'new_moon' => 'nm.png',
'waxing_crescent_moon' => 'wcm1.png', 'waxing_crescent_moon' => 'wcm1.png',
@ -32,4 +31,6 @@ class My extends MyPlugin
'last_quarter_moon' => 'tqm.png', 'last_quarter_moon' => 'tqm.png',
'waning_crescent_moon' => 'wcm2.png', 'waning_crescent_moon' => 'wcm2.png',
]; ];
// Use default permissions
} }

View File

@ -1,22 +1,20 @@
<?php <?php
/**
* @brief lunarPhase, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Tomtom, Pierre Van Glabeke and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1); declare(strict_types=1);
namespace Dotclear\Plugin\lunarPhase; namespace Dotclear\Plugin\lunarPhase;
use dcCore; use Dotclear\App;
use Dotclear\Core\Process; use Dotclear\Core\Process;
/**
* @brief lunarPhase backend class.
* @ingroup lunarPhase
*
* @author Tomtom (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Prepend extends Process class Prepend extends Process
{ {
public static function init(): bool public static function init(): bool
@ -31,7 +29,7 @@ class Prepend extends Process
} }
// Register lunarphase CSS URL // Register lunarphase CSS URL
dcCore::app()->url->register( App::url()->register(
'lunarphase', 'lunarphase',
'lunarphase.css', 'lunarphase.css',
'^lunarphase\.css', '^lunarphase\.css',

View File

@ -1,25 +1,23 @@
<?php <?php
/**
* @brief lunarPhase, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Tomtom, Pierre Van Glabeke and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1); declare(strict_types=1);
namespace Dotclear\Plugin\lunarPhase; namespace Dotclear\Plugin\lunarPhase;
use dcCore; use Dotclear\App;
use Dotclear\Helper\Date; use Dotclear\Helper\Date;
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
use Dotclear\Plugin\widgets\WidgetsStack; use Dotclear\Plugin\widgets\WidgetsStack;
use Dotclear\Plugin\widgets\WidgetsElement; use Dotclear\Plugin\widgets\WidgetsElement;
/**
* @brief lunarPhase widgets class.
* @ingroup lunarPhase
*
* @author Tomtom (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Widgets class Widgets
{ {
public static function initWidgets(WidgetsStack $w): void public static function initWidgets(WidgetsStack $w): void
@ -27,7 +25,7 @@ class Widgets
$w->create( $w->create(
'lunarphase', 'lunarphase',
__('Moon phases'), __('Moon phases'),
[self::class, 'parseWidget'], self::parseWidget(...),
null, null,
__('Display the moon phases') __('Display the moon phases')
) )
@ -49,7 +47,7 @@ class Widgets
public static function parseWidget(WidgetsElement $w): string public static function parseWidget(WidgetsElement $w): string
{ {
if ($w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) { if ($w->offline || !$w->checkHomeOnly(App::url()->type)) {
return ''; return '';
} }
@ -200,14 +198,14 @@ class Widgets
*/ */
public static function formatValue(string $type, mixed $value): mixed public static function formatValue(string $type, mixed $value): mixed
{ {
if (is_null(dcCore::app()->blog)) { if (!App::blog()->isDefined()) {
return null; return null;
} }
$res = ''; $res = '';
$format = dcCore::app()->blog->settings->get('system')->get('date_format') . ' - '; $format = App::blog()->settings()->get('system')->get('date_format') . ' - ';
$format .= dcCore::app()->blog->settings->get('system')->get('time_format'); $format .= App::blog()->settings()->get('system')->get('time_format');
$tz = dcCore::app()->blog->settings->get('system')->get('blog_timezone'); $tz = App::blog()->settings()->get('system')->get('blog_timezone');
return match ($type) { return match ($type) {
'int' => number_format($value, 0), 'int' => number_format($value, 0),