Compare commits

..

10 Commits

9 changed files with 69 additions and 30 deletions

View File

@ -1,3 +1,16 @@
2.2 - 2023.05.13
* require Dotclear 2.26
* release for Dotclear 2.26 stable
2.1 - 2023.04.24
* require Dotclear 2.26
* fix nullsafe warnings
* remove magic
2.0 - 2023.04.11
* require Dotclear 2.26
* use namespace
1.6 - 2022.12.16
* update to dotclear 2.24
* fix phpstan errors

View File

@ -3,7 +3,7 @@
[![Release](https://img.shields.io/github/v/release/JcDenis/bloganniv)](https://github.com/JcDenis/bloganniv/releases)
[![Date](https://img.shields.io/github/release-date/JcDenis/bloganniv)](https://github.com/JcDenis/bloganniv/releases)
[![Issues](https://img.shields.io/github/issues/JcDenis/bloganniv)](https://github.com/JcDenis/bloganniv/issues)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.24-blue.svg)](https://fr.dotclear.org/download)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/bloganniv)
[![License](https://img.shields.io/github/license/JcDenis/bloganniv)](https://github.com/JcDenis/bloganniv/blob/master/LICENSE)
@ -22,7 +22,7 @@ It adds widget showing:
_bloganniv_ requires:
* permissions to manage widgets
* Dotclear 2.24
* Dotclear 2.26
## USAGE

View File

@ -7,10 +7,10 @@
*
* @author Fran6t, Pierre Van Glabeke and Contributors
*
* @copyright Jean-Crhistian Denis
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
if (!defined('DC_RC_PATH') || is_null(dcCore::app()->auth)) {
return null;
}
@ -18,11 +18,11 @@ $this->registerModule(
'Blog Anniv',
'Counting the number of days before and after a particular date',
'Fran6t, Pierre Van Glabeke and Contributors',
'1.6',
'2.2',
[
'requires' => [['core', '2.24']],
'requires' => [['core', '2.26']],
'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_ADMIN,
dcCore::app()->auth::PERMISSION_ADMIN,
]),
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),

View File

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="bloganniv">
<name>Blog Anniv</name>
<version>1.6</version>
<version>2.2</version>
<author>Fran6t, Pierre Van Glabeke and Contributors</author>
<desc>Counting the number of days before and after a particular date</desc>
<file>https://github.com/JcDenis/bloganniv/releases/download/v1.6/plugin-bloganniv.zip</file>
<da:dcmin>2.24</da:dcmin>
<file>https://github.com/JcDenis/bloganniv/releases/download/v2.2/plugin-bloganniv.zip</file>
<da:dcmin>2.26</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/bloganniv</da:details>
<da:support>https://github.com/JcDenis/bloganniv</da:support>
</module>

View File

@ -0,0 +1,22 @@
<?php
/**
* @package Dotclear
*
* @copyright Olivier Meunier & Association Dotclear
* @copyright GPL-2.0-only
*/
#
# DOT NOT MODIFY THIS FILE !
#
use Dotclear\Helper\L10n;
L10n::$locales['Counting the number of days before and after a particular date'] = 'Décompte du nombre de jours avant et après une date donnée';
L10n::$locales['Born Date (dd/mm/yyyy) or blank:'] = 'Date de naissance (jj/mm/aaaa) ou vide :';
L10n::$locales['Display Born Date'] = 'Affichage date de naissance';
L10n::$locales['Display Year(s) Old'] = 'Affichage âge en année(s)';
L10n::$locales['Born:'] = 'Né le :';
L10n::$locales['Age:'] = 'Âge :';
L10n::$locales['year(s)'] = 'an(s)';
L10n::$locales['Birthday in'] = 'Anniversaire dans';
L10n::$locales['day(s)'] = 'jour(s)';

View File

@ -21,7 +21,7 @@ class Backend extends dcNsProcess
{
public static function init(): bool
{
static::$init = defined('DC_CONTEXT_ADMIN') && My::phpCompliant();
static::$init = defined('DC_CONTEXT_ADMIN');
return static::$init;
}

View File

@ -21,7 +21,7 @@ class Frontend extends dcNsProcess
{
public static function init(): bool
{
static::$init = My::phpCompliant();
static::$init = defined('DC_RC_PATH');
return static::$init;
}

View File

@ -17,15 +17,12 @@ namespace Dotclear\Plugin\bloganniv;
use dcCore;
/**
* Plugin definitions
* This module definitions.
*/
class My
{
/** @var string Required php version */
public const PHP_MIN = '7.4';
/**
* This module id
* This module id.
*/
public static function id(): string
{
@ -33,18 +30,20 @@ class My
}
/**
* This module name
* This module name.
*/
public static function name(): string
{
return __((string) dcCore::app()->plugins->moduleInfo(self::id(), 'name'));
$name = dcCore::app()->plugins->moduleInfo(self::id(), 'name');
return __(is_string($name) ? $name : self::id());
}
/**
* Check php version
* This module path.
*/
public static function phpCompliant(): bool
public static function path(): string
{
return version_compare(phpversion(), self::PHP_MIN, '>=');
return dirname(__DIR__);
}
}

View File

@ -30,7 +30,7 @@ class Widgets
null,
__('Counting the number of days before and after a particular date')
)
->addTitle('')
->addTitle(My::name())
->setting('ftdatecrea', __('Born Date (dd/mm/yyyy) or blank:'), '')
->setting('dispyearborn', __('Display Born Date'), 1, 'check')
->setting('dispyear', __('Display Year(s) Old'), 1, 'check')
@ -42,11 +42,16 @@ class Widgets
public static function parseWidget(WidgetsElement $w): string
{
if ($w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) {
if ($w->__get('offline') || !$w->checkHomeOnly(dcCore::app()->url->type)) {
return '';
}
$ftdatecrea = $w->ftdatecrea;
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog)) {
return '';
}
$ftdatecrea = $w->__get('ftdatecrea');
//Si la date est vide nous recherchons la date en base
if (strlen(rtrim($ftdatecrea)) == 0) {
$jour = date('d', dcCore::app()->blog->creadt);
@ -92,13 +97,13 @@ class Widgets
}
return $w->renderDiv(
(bool) $w->content_only,
My::id() . ' ' . $w->class,
(bool) $w->__get('content_only'),
My::id() . ' ' . $w->__get('class'),
'',
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
($w->__get('title') ? $w->renderTitle(Html::escapeHTML($w->__get('title'))) : '') .
'<ul>' .
($w->dispyearborn ? '<li>' . __('Born:') . ' <span class="annivne">' . $ftdatecrea . '</span></li>' : '') .
($w->dispyear ? '<li>' . __('Age:') . ' <span class="annivan">' . $nbreannee . '</span> ' . __('year(s)') . '</li>' : '') .
($w->__get('dispyearborn') ? '<li>' . __('Born:') . ' <span class="annivne">' . $ftdatecrea . '</span></li>' : '') .
($w->__get('dispyear') ? '<li>' . __('Age:') . ' <span class="annivan">' . $nbreannee . '</span> ' . __('year(s)') . '</li>' : '') .
'<li>' . __('Birthday in') . ' <span class="annivjrs">' . $nbrejours . '</span> ' . __('day(s)') . '</li>' .
'</ul>'
);