Compare commits

..

No commits in common. "master" and "v1.8" have entirely different histories.
master ... v1.8

10 changed files with 129 additions and 115 deletions

View File

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

View File

@ -1,30 +1,36 @@
<?php <?php
/** /**
* @file * @brief lunarPhase, a plugin for Dotclear 2
* @brief The plugin lunarPhase definition
* @ingroup lunarPhase
* *
* @defgroup lunarPhase Plugin lunarPhase. * @package Dotclear
* @subpackage Plugin
* *
* Display the moon phases on a widget. * @author Tomtom, Pierre Van Glabeke and Contributors
* *
* @author Tomtom (author) * @copyright Jean-Christian Denis
* @author Jean-Christian Denis (latest) * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
declare(strict_types=1); if (!defined('DC_RC_PATH')) {
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.9', '1.8',
[ [
'requires' => [['core', '2.28']], 'requires' => [
'permissions' => 'My', ['php', '8.1'],
'type' => 'plugin', ['core', '2.26'],
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', ],
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md', 'permissions' => dcCore::app()->auth->makePermissions([
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml', dcCore::app()->auth::PERMISSION_USAGE,
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.9</version> <version>1.8</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.9/plugin-lunarPhase.zip</file> <file>https://git.dotclear.watch/JcDenis/lunarPhase/releases/download/v1.8/plugin-lunarPhase.zip</file>
<da:dcmin>2.28</da:dcmin> <da:dcmin>2.26</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,20 +1,22 @@
<?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 Dotclear\App; use dcCore;
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
@ -28,7 +30,7 @@ class Backend extends Process
return false; return false;
} }
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...)); dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initWidgets']);
return true; return true;
} }

View File

@ -1,20 +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 Dotclear\App; use dcCore;
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
@ -28,15 +31,17 @@ class Frontend extends Process
return false; return false;
} }
App::behavior()->addBehaviors([ dcCore::app()->addBehaviors([
// Add public header for lunarphase css // Add public header for lunarphase css
'publicHeadContent' => function (): void { 'publicHeadContent' => function (): void {
if (App::blog()->isDefined()) { if (is_null(dcCore::app()->blog)) {
echo App::plugins()->cssLoad(App::blog()->url() . App::url()->getURLFor('lunarphase')); return;
} }
echo dcUtils::cssLoad(dcCore::app()->blog->url . dcCore::app()->url->getURLFor('lunarphase'));
}, },
// Widgets // Widgets
'initWidgets' => Widgets::initWidgets(...), 'initWidgets' => [Widgets::class, 'initWidgets'],
]); ]);
return true; return true;

View File

@ -1,19 +1,21 @@
<?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,5 +1,15 @@
<?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;
@ -7,20 +17,11 @@ namespace Dotclear\Plugin\lunarPhase;
use Dotclear\Module\MyPlugin; use Dotclear\Module\MyPlugin;
/** /**
* @brief lunarPhase My helper. * This module definitions.
* @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',
@ -31,6 +32,4 @@ 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,20 +1,22 @@
<?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 Dotclear\App; use dcCore;
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
@ -29,7 +31,7 @@ class Prepend extends Process
} }
// Register lunarphase CSS URL // Register lunarphase CSS URL
App::url()->register( dcCore::app()->url->register(
'lunarphase', 'lunarphase',
'lunarphase.css', 'lunarphase.css',
'^lunarphase\.css', '^lunarphase\.css',

View File

@ -1,23 +1,25 @@
<?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 Dotclear\App; use dcCore;
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
@ -25,7 +27,7 @@ class Widgets
$w->create( $w->create(
'lunarphase', 'lunarphase',
__('Moon phases'), __('Moon phases'),
self::parseWidget(...), [self::class, 'parseWidget'],
null, null,
__('Display the moon phases') __('Display the moon phases')
) )
@ -47,7 +49,7 @@ class Widgets
public static function parseWidget(WidgetsElement $w): string public static function parseWidget(WidgetsElement $w): string
{ {
if ($w->offline || !$w->checkHomeOnly(App::url()->type)) { if ($w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) {
return ''; return '';
} }
@ -198,14 +200,14 @@ class Widgets
*/ */
public static function formatValue(string $type, mixed $value): mixed public static function formatValue(string $type, mixed $value): mixed
{ {
if (!App::blog()->isDefined()) { if (is_null(dcCore::app()->blog)) {
return null; return null;
} }
$res = ''; $res = '';
$format = App::blog()->settings()->get('system')->get('date_format') . ' - '; $format = dcCore::app()->blog->settings->get('system')->get('date_format') . ' - ';
$format .= App::blog()->settings()->get('system')->get('time_format'); $format .= dcCore::app()->blog->settings->get('system')->get('time_format');
$tz = App::blog()->settings()->get('system')->get('blog_timezone'); $tz = dcCore::app()->blog->settings->get('system')->get('blog_timezone');
return match ($type) { return match ($type) {
'int' => number_format($value, 0), 'int' => number_format($value, 0),