Compare commits
No commits in common. "6e7d12a8eb1de4eb778fb5155dc8659b092d8202" and "62f92cd10e386484f841b9a3787bcf1fe1475a34" have entirely different histories.
6e7d12a8eb
...
62f92cd10e
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -1,15 +1,3 @@
|
|||
1.7.2 - 2023.06.17
|
||||
- require dotclear 2.26
|
||||
- fix require php 8.1
|
||||
|
||||
1.7.1 - 2023.05.13
|
||||
- require dotclear 2.26
|
||||
- cosmetic cleanup for dc2.26 stable
|
||||
|
||||
1.7 - 2023.04.25
|
||||
- require dotclear 2.26
|
||||
- use namespace
|
||||
|
||||
1.6 - 2022.12.15
|
||||
- update to dotclear 2.24
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
[![Release](https://img.shields.io/github/v/release/JcDenis/lunarPhase)](https://github.com/JcDenis/lunarPhase/releases)
|
||||
[![Date](https://img.shields.io/github/release-date/JcDenis/lunarPhase)](https://github.com/JcDenis/lunarPhase/releases)
|
||||
[![Issues](https://img.shields.io/github/issues/JcDenis/lunarPhase)](https://github.com/JcDenis/lunarPhase/issues)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.24-blue.svg)](https://fr.dotclear.org/download)
|
||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/lunarPhase)
|
||||
[![License](https://img.shields.io/github/license/JcDenis/lunarPhase)](https://github.com/JcDenis/lunarPhase/blob/master/LICENSE)
|
||||
|
||||
|
@ -19,8 +19,7 @@ It shows lunar phases on a widget.
|
|||
_lunarPhase_ requires:
|
||||
|
||||
* content admin permissions to manage widgets
|
||||
* Dotclear 2.26
|
||||
* require PHP 8.1+
|
||||
* Dotclear 2.24
|
||||
|
||||
## USAGE
|
||||
|
||||
|
@ -31,7 +30,7 @@ You should add widget to show lunar phases on your blog.
|
|||
|
||||
## LINKS
|
||||
|
||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
|
||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||
* Source & contribution : [GitHub Page](https://github.com/JcDenis/lunarPhase)
|
||||
* Packages & details : [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/lunarPhase)
|
||||
* Discuss and help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?pid=332971#p332971)
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief lunarPhase, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Tomtom, Pierre Van Glabeke and Contributors
|
||||
*
|
||||
* @copyright Jean-Crhistian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
require __DIR__ . '/_widgets.php';
|
17
_define.php
17
_define.php
|
@ -7,26 +7,23 @@
|
|||
*
|
||||
* @author Tomtom, Pierre Van Glabeke and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright Jean-Crhistian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH') || is_null(dcCore::app()->auth)) {
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->registerModule(
|
||||
'Moon phases',
|
||||
'lunarPhase',
|
||||
'Display the moon phases on a widget',
|
||||
'Tomtom, Pierre Van Glabeke and Contributors',
|
||||
'1.7.2',
|
||||
'1.6',
|
||||
[
|
||||
'requires' => [
|
||||
['php', '8.1'],
|
||||
['core', '2.26'],
|
||||
],
|
||||
'requires' => [['core', '2.24']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_USAGE,
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
dcAuth::PERMISSION_USAGE,
|
||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
]),
|
||||
'type' => 'plugin',
|
||||
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=332971#p332971',
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief lunarPhase, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Tomtom, Pierre Van Glabeke and Contributors
|
||||
*
|
||||
* @copyright Jean-Crhistian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Clearbricks::lib()->autoload(['lunarPhase' => __DIR__ . '/inc/class.lunarphase.php']);
|
||||
|
||||
// Register lunarphase CSS URL
|
||||
dcCore::app()->url->register(
|
||||
'lunarphase',
|
||||
'lunarphase.css',
|
||||
'^lunarphase\.css',
|
||||
function ($args) {
|
||||
$phases = [
|
||||
'new_moon' => 'nm',
|
||||
'waxing_crescent_moon' => 'wcm1',
|
||||
'first_quarter_moon' => 'fqm',
|
||||
'waxing_gibbous_moon' => 'wgm1',
|
||||
'full_moon' => 'fm',
|
||||
'waning_gibbous_moon' => 'wgm2',
|
||||
'last_quarter_moon' => 'tqm',
|
||||
'waning_crescent_moon' => 'wcm2',
|
||||
];
|
||||
|
||||
header('Content-Type: text/css; charset=UTF-8');
|
||||
echo "/* lunarphase widget style */\n";
|
||||
|
||||
foreach ($phases as $phase => $image) {
|
||||
echo
|
||||
sprintf(
|
||||
'#sidebar .lunarphase ul li.%s{background:transparent url(%s) no-repeat left 0.2em;padding-left:2em;}',
|
||||
$phase,
|
||||
dcCore::app()->blog->getPF(basename(__dir__) . '/img/' . $image . '.png')
|
||||
) . "\n";
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
);
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief lunarPhase, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Tomtom, Pierre Van Glabeke and Contributors
|
||||
*
|
||||
* @copyright Jean-Crhistian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
require __DIR__ . '/_widgets.php';
|
||||
|
||||
// Add public header for lunarphase css
|
||||
dcCore::app()->addBehavior('publicHeadContent', function () {
|
||||
echo dcUtils::cssLoad(dcCore::app()->blog->url . dcCore::app()->url->getURLFor('lunarphase'));
|
||||
});
|
|
@ -7,27 +7,23 @@
|
|||
*
|
||||
* @author Tomtom, Pierre Van Glabeke and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright Jean-Crhistian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
namespace Dotclear\Plugin\lunarPhase;
|
||||
dcCore::app()->addBehavior('initWidgets', ['lunarPhaseWidgets','initWidgets']);
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Helper\Date;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Plugin\widgets\WidgetsStack;
|
||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
||||
|
||||
class Widgets
|
||||
class lunarPhaseWidgets
|
||||
{
|
||||
public static function initWidgets(WidgetsStack $w): void
|
||||
public static function initWidgets($w)
|
||||
{
|
||||
$w->create(
|
||||
'lunarphase',
|
||||
__('Moon phases'),
|
||||
[self::class, 'parseWidget'],
|
||||
__('LunarPhase: moon phases'),
|
||||
['lunarPhaseWidgets','widget'],
|
||||
null,
|
||||
__('Display the moon phases')
|
||||
)
|
||||
|
@ -47,33 +43,36 @@ class Widgets
|
|||
->addOffline();
|
||||
}
|
||||
|
||||
public static function parseWidget(WidgetsElement $w): string
|
||||
public static function widget($w)
|
||||
{
|
||||
if ($w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) {
|
||||
return '';
|
||||
if ($w->offline) {
|
||||
return;
|
||||
}
|
||||
|
||||
$lp = new LunarPhase();
|
||||
if (!$w->checkHomeOnly(dcCore::app()->url->type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$lp = new lunarPhase();
|
||||
|
||||
return $w->renderDiv(
|
||||
(bool) $w->content_only,
|
||||
$w->content_only,
|
||||
'lunarphase ' . $w->class,
|
||||
'',
|
||||
($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') .
|
||||
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
|
||||
self::getLive($w, $lp) .
|
||||
self::getPrevisions($w, $lp)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns "live" part of lunarphase widget.
|
||||
*
|
||||
* @param WidgetsElement $w Widget instance
|
||||
* @param LunarPhase $lp LunarPhase instance
|
||||
* Returns "live" part of lunarphase widget
|
||||
*
|
||||
* @param dcWidget $w dcWidget object
|
||||
* @param lunarPhase $lp lunarPhase object
|
||||
* @return string Live HTML part
|
||||
*/
|
||||
public static function getLive(WidgetsElement $w, LunarPhase $lp): string
|
||||
public static function getLive($w, $lp)
|
||||
{
|
||||
$li = '<li class="%2$s">%1$s</li>';
|
||||
$live = $lp->getLive();
|
||||
|
@ -167,14 +166,13 @@ class Widgets
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns "previsions" part of lunarphase widget.
|
||||
*
|
||||
* @param WidgetsElement $w Widget instance
|
||||
* @param LunarPhase $lp LunarPhase instance
|
||||
* Returns "previsions" part of lunarphase widget
|
||||
*
|
||||
* @param dcWidget $w dcWidget object
|
||||
* @param lunarPhase $lp lunarPhase object
|
||||
* @return string Previsions HTML part
|
||||
*/
|
||||
public static function getPrevisions(WidgetsElement $w, LunarPhase $lp): string
|
||||
public static function getPrevisions($w, $lp)
|
||||
{
|
||||
$li = '<li class="%s" title="%s">%s</li>';
|
||||
$res = '';
|
||||
|
@ -191,29 +189,24 @@ class Widgets
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns value passed in argument with a correct format.
|
||||
* Returns value passed in argument with a correct format
|
||||
*
|
||||
* @param string $type Type of convertion
|
||||
* @param mixed $value Value to convert
|
||||
*
|
||||
* @return mixed Converted value
|
||||
*/
|
||||
public static function formatValue(string $type, mixed $value): mixed
|
||||
public static function formatValue($type, $value)
|
||||
{
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$res = '';
|
||||
$format = dcCore::app()->blog->settings->get('system')->get('date_format') . ' - ';
|
||||
$format .= dcCore::app()->blog->settings->get('system')->get('time_format');
|
||||
$tz = dcCore::app()->blog->settings->get('system')->get('blog_timezone');
|
||||
$format = dcCore::app()->blog->settings->system->date_format . ' - ';
|
||||
$format .= dcCore::app()->blog->settings->system->time_format;
|
||||
$tz = dcCore::app()->blog->settings->system->blog_timezone;
|
||||
|
||||
return match ($type) {
|
||||
'int' => number_format($value, 0),
|
||||
'float' => number_format($value, 2),
|
||||
'percent' => number_format($value * 100, 0),
|
||||
'date' => Date::str($format, (int) $value, $tz),
|
||||
'date' => dt::str($format, $value, $tz),
|
||||
'deg' => number_format(($value * (180.0 / M_PI)), 2),
|
||||
default => $value,
|
||||
};
|
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0"?>
|
||||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="lunarPhase">
|
||||
<name>Moon phases</name>
|
||||
<version>1.7.2</version>
|
||||
<name>lunarPhase</name>
|
||||
<version>1.6</version>
|
||||
<author>Tomtom, Pierre Van Glabeke and Contributors</author>
|
||||
<desc>Display the moon phases on a widget</desc>
|
||||
<file>https://github.com/JcDenis/lunarPhase/releases/download/v1.7.2/plugin-lunarPhase.zip</file>
|
||||
<da:dcmin>2.26</da:dcmin>
|
||||
<file>https://github.com/JcDenis/lunarPhase/releases/download/v1.6/plugin-lunarPhase.zip</file>
|
||||
<da:dcmin>2.24</da:dcmin>
|
||||
<da:details>https://plugins.dotaddict.org/dc2/details/lunarPhase</da:details>
|
||||
<da:support>http://forum.dotclear.org/viewtopic.php?pid=332971#p332971</da:support>
|
||||
</module>
|
||||
|
|
|
@ -7,16 +7,14 @@
|
|||
*
|
||||
* @author Tomtom, Pierre Van Glabeke and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright Jean-Crhistian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
namespace Dotclear\Plugin\lunarPhase;
|
||||
|
||||
use ArrayObject;
|
||||
|
||||
class LunarPhase
|
||||
class lunarPhase
|
||||
{
|
||||
# Astronomical constants.
|
||||
public const epoch = 2444238.5; # 1980 January 0.0
|
||||
|
@ -39,8 +37,8 @@ class LunarPhase
|
|||
public const mParallax = 0.9507; # parallax at distance a from Earth
|
||||
public const synodic = 29.53058868; # synodic month (new Moon to new Moon)
|
||||
|
||||
protected ArrayObject $live;
|
||||
protected ArrayObject $previsions;
|
||||
protected $live;
|
||||
protected $previsions;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -51,17 +49,17 @@ class LunarPhase
|
|||
$this->setPrevisions();
|
||||
}
|
||||
|
||||
public function getLive(): ArrayObject
|
||||
public function getLive()
|
||||
{
|
||||
return $this->live;
|
||||
}
|
||||
|
||||
public function getPrevisions(): ArrayObject
|
||||
public function getPrevisions()
|
||||
{
|
||||
return $this->previsions;
|
||||
}
|
||||
|
||||
private function setLive(): void
|
||||
private function setLive()
|
||||
{
|
||||
$day = $this->jTime(time()) - self::epoch;
|
||||
|
||||
|
@ -106,7 +104,7 @@ class LunarPhase
|
|||
$this->setPhase();
|
||||
}
|
||||
|
||||
private function setPhase(): void
|
||||
private function setPhase()
|
||||
{
|
||||
if ($this->live['age'] >= self::synodic || $this->live['age'] <= self::synodic / 8) {
|
||||
$this->live['id'] = 'new_moon';
|
||||
|
@ -135,7 +133,7 @@ class LunarPhase
|
|||
}
|
||||
}
|
||||
|
||||
private function setPrevisions(): void
|
||||
private function setPrevisions()
|
||||
{
|
||||
$ts_day = 24 * 60 * 60;
|
||||
$ts_synodic = self::synodic * $ts_day;
|
||||
|
@ -175,27 +173,27 @@ class LunarPhase
|
|||
];
|
||||
}
|
||||
|
||||
private function fixAngle(float $x): float
|
||||
private function fixAngle($x)
|
||||
{
|
||||
return ($x - 360.0 * (floor($x / 360.0)));
|
||||
}
|
||||
|
||||
private function toRad(float $x): float
|
||||
private function toRad($x)
|
||||
{
|
||||
return ($x * (M_PI / 180.0));
|
||||
}
|
||||
|
||||
private function toDeg(float $x): float
|
||||
private function toDeg($x)
|
||||
{
|
||||
return ($x * (180.0 / M_PI));
|
||||
}
|
||||
|
||||
private function jTime(float $t): float
|
||||
private function jTime($t)
|
||||
{
|
||||
return ($t / 86400) + 2440587.5;
|
||||
}
|
||||
|
||||
private function kepler(float $m, float $ecc): float
|
||||
private function kepler($m, $ecc)
|
||||
{
|
||||
$delta = null;
|
||||
$EPSILON = 1e-6;
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Dotclear
|
||||
*
|
||||
* @copyright Olivier Meunier & Association Dotclear
|
||||
* @copyright GPL-2.0-only
|
||||
*/
|
||||
#
|
||||
# DOT NOT MODIFY THIS FILE !
|
||||
#
|
||||
|
||||
use Dotclear\Helper\L10n;
|
||||
|
||||
L10n::$locales['Moon phases'] = 'Phases de la Lune';
|
||||
L10n::$locales['Display the moon phases'] = 'Afficher les phases de la Lune et autres données';
|
||||
L10n::$locales['Display actual phase of moon'] = 'Afficher la phase actuelle de la Lune';
|
||||
L10n::$locales['Display actual illumination of moon'] = 'Afficher le taux d\'illumination actuel de la Lune';
|
||||
L10n::$locales['Display actual age of moon'] = 'Afficher l\'âge actuel de la Lune';
|
||||
L10n::$locales['Display actual distance between moon and earth'] = 'Afficher la distance actuelle entre la Terre et la Lune';
|
||||
L10n::$locales['Display actual distance between moon and sun'] = 'Afficher la distance actuelle entre le Soleil et la Lune';
|
||||
L10n::$locales['Display actual angle of moon'] = 'Afficher l\'angle actuel de la Lune';
|
||||
L10n::$locales['Display actual angle of sun'] = 'Afficher l\'angle actuel du Soleil';
|
||||
L10n::$locales['Display actual parallax of moon'] = 'Afficher la parallaxe actuelle de la Lune';
|
||||
L10n::$locales['Display all previsions for the next moon phases'] = 'Afficher toutes les prévisions des prochaines lunaisons';
|
||||
L10n::$locales['Illumination: %s%%'] = 'Illumination : %s%%';
|
||||
L10n::$locales['Age of moon: %s days'] = 'Age de la Lune : %s jours';
|
||||
L10n::$locales['Distance to earth: %s km'] = 'Distance à la Terre : %s km';
|
||||
L10n::$locales['Distance to sun: %s km'] = 'Distance au Soleil : %s km';
|
||||
L10n::$locales['Angle of moon: %s deg'] = 'Angle de la Lune : %s deg';
|
||||
L10n::$locales['Angle of sun: %s deg'] = 'Angle du Soleil : %s deg';
|
||||
L10n::$locales['Parallax: %s deg'] = 'Parallaxe : %s deg';
|
||||
L10n::$locales['In live'] = 'En direct';
|
||||
L10n::$locales['Previsions'] = 'Prévisions';
|
||||
L10n::$locales['New moon'] = 'Nouvelle lune';
|
||||
L10n::$locales['Waxing crescent moon'] = 'Lune croissante';
|
||||
L10n::$locales['First quarter moon'] = 'Premier quartier';
|
||||
L10n::$locales['Waxing gibbous moon'] = 'Lune gibbeuse croissante';
|
||||
L10n::$locales['Full moon'] = 'Pleine lune';
|
||||
L10n::$locales['Waning gibbous moon'] = 'Lune gibbeuse décroissante';
|
||||
L10n::$locales['Last quarter moon'] = 'Dernier quartier';
|
||||
L10n::$locales['Waning crescent moon'] = 'Lune décroissante';
|
|
@ -10,12 +10,15 @@ msgstr ""
|
|||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
msgid "Moon phases"
|
||||
msgstr "Phases de la Lune"
|
||||
msgid "LunarPhase: moon phases"
|
||||
msgstr "LunarPhase : phases de la Lune"
|
||||
|
||||
msgid "Display the moon phases"
|
||||
msgstr "Afficher les phases de la Lune et autres données"
|
||||
|
||||
msgid "Moon phases"
|
||||
msgstr "Phases de la Lune"
|
||||
|
||||
msgid "Display actual phase of moon"
|
||||
msgstr "Afficher la phase actuelle de la Lune"
|
||||
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\lunarPhase;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
Input,
|
||||
Label,
|
||||
Para
|
||||
};
|
||||
|
||||
class Backend extends dcNsProcess
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN');
|
||||
|
||||
return static::$init;
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initWidgets']);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\lunarPhase;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use dcUtils;
|
||||
|
||||
class Frontend extends dcNsProcess
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_RC_PATH');
|
||||
|
||||
return static::$init;
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
// Add public header for lunarphase css
|
||||
'publicHeadContent' => function (): void {
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo dcUtils::cssLoad(dcCore::app()->blog->url . dcCore::app()->url->getURLFor('lunarphase'));
|
||||
},
|
||||
// Widgets
|
||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
61
src/My.php
61
src/My.php
|
@ -1,61 +0,0 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\lunarPhase;
|
||||
|
||||
use dcCore;
|
||||
|
||||
/**
|
||||
* This module definitions.
|
||||
*/
|
||||
class My
|
||||
{
|
||||
/** @var array<string,string> List of lunar phase => image */
|
||||
public const LUNAR_PHASES = [
|
||||
'new_moon' => 'nm.png',
|
||||
'waxing_crescent_moon' => 'wcm1.png',
|
||||
'first_quarter_moon' => 'fqm.png',
|
||||
'waxing_gibbous_moon' => 'wgm1.png',
|
||||
'full_moon' => 'fm.png',
|
||||
'waning_gibbous_moon' => 'wgm2.png',
|
||||
'last_quarter_moon' => 'tqm.png',
|
||||
'waning_crescent_moon' => 'wcm2.png',
|
||||
];
|
||||
|
||||
/**
|
||||
* This module id.
|
||||
*/
|
||||
public static function id(): string
|
||||
{
|
||||
return basename(dirname(__DIR__));
|
||||
}
|
||||
|
||||
/**
|
||||
* This module name.
|
||||
*/
|
||||
public static function name(): string
|
||||
{
|
||||
$name = dcCore::app()->plugins->moduleInfo(self::id(), 'name');
|
||||
|
||||
return __(is_string($name) ? $name : self::id());
|
||||
}
|
||||
|
||||
/**
|
||||
* This module path.
|
||||
*/
|
||||
public static function path(): string
|
||||
{
|
||||
return dirname(__DIR__);
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\lunarPhase;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
|
||||
class Prepend extends dcNsProcess
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_RC_PATH');
|
||||
|
||||
return static::$init;
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Register lunarphase CSS URL
|
||||
dcCore::app()->url->register(
|
||||
'lunarphase',
|
||||
'lunarphase.css',
|
||||
'^lunarphase\.css',
|
||||
function (?string $args): void {
|
||||
// avoid null warning
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
header('Content-Type: text/css; charset=UTF-8');
|
||||
echo "/* lunarphase widget style */\n";
|
||||
|
||||
foreach (My::LUNAR_PHASES as $phase => $image) {
|
||||
echo sprintf(
|
||||
"#sidebar .lunarphase ul li.%s{background:transparent url(%s) no-repeat left 0.2em;padding-left:2em;}\n",
|
||||
$phase,
|
||||
dcCore::app()->blog->getPF(My::id() . '/img/' . $image)
|
||||
);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
#sidebar .lunarphase ul li.new_moon{background:transparent url(index.php?pf=lunarPhase/img/nm.png) no-repeat left 0.2em;padding-left:2em;}
|
||||
#sidebar .lunarphase ul li.waxing_crescent_moon{background:transparent url(index.php?pf=lunarPhase/img/wcm1.png) no-repeat left 0.2em;padding-left:2em;}
|
||||
#sidebar .lunarphase ul li.first_quarter_moon{background:transparent url(index.php?pf=lunarPhase/img/fqm.png) no-repeat left 0.2em;padding-left:2em;}
|
||||
#sidebar .lunarphase ul li.waxing_gibbous_moon{background:transparent url(index.php?pf=lunarPhase/img/wgm1.png) no-repeat left 0.2em;padding-left:2em;}
|
||||
#sidebar .lunarphase ul li.full_moon{background:transparent url(index.php?pf=lunarPhase/img/fm.png) no-repeat left 0.2em;padding-left:2em;}
|
||||
#sidebar .lunarphase ul li.waning_gibbous_moon{background:transparent url(index.php?pf=lunarPhase/img/wgm2.png) no-repeat left 0.2em;padding-left:2em;}
|
||||
#sidebar .lunarphase ul li.last_quarter_moon{background:transparent url(index.php?pf=lunarPhase/img/tqm.png) no-repeat left 0.2em;padding-left:2em;}
|
||||
#sidebar .lunarphase ul li.waning_crescent_moon{background:transparent url(index.php?pf=lunarPhase/img/wcm2.png) no-repeat left 0.2em;padding-left:2em;}
|
Loading…
Reference in New Issue