upgrade to Dotclear 2.28

main v2.4
Jean-Christian Paul Denis 2023-10-15 22:15:37 +02:00
parent b6ac8bdba8
commit 9d8aa28988
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
8 changed files with 100 additions and 107 deletions

View File

@ -1,3 +1,9 @@
countdown 2.4 - 2023.10.15
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Upgrade to Dotclear 2.28
countdown 2.3 - 2023.08.06
===========================================================
* Require Dotclear 2.27

View File

@ -1,24 +1,22 @@
# README
[![Release](https://img.shields.io/badge/release-2.3-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/countdown/releases)
[![Date](https://img.shields.io/badge/date-2023.08.06-c44d58.svg)](https://git.dotclear.watch/JcDenis/countdown/releases)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
[![Release](https://img.shields.io/badge/release-2.4-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/countdown/releases)
![Date](https://img.shields.io/badge/date-2023.10.15-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/countdown)
[![License](https://img.shields.io/github/license/JcDenis/countdown)](https://git.dotclear.watch/JcDenis/countdown/blob/master/LICENSE)
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/countdown/src/branch/master/LICENSE)
## WHAT IS COUNTDOWN ?
## ABOUT
_countdown_ is a plugin for the open-source
web publishing software called Dotclear.
_countdown_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
It adds widget showing a countdown since/from a predefined date.
> Add widget showing a countdown since/from a predefined date.
## REQUIREMENTS
_countdown_ requires:
* permissions to manage widgets
* Dotclear 2.27
* Dotclear 2.28
* PHP 8.1
* Dotclear permissions to manage widgets
## USAGE
@ -30,22 +28,23 @@ It uses jquery for dynamic countdown.
## LINKS
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/countdown) or [GitHub Page](https://github.com/JcDenis/countdown)
* Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/countdown/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/countdown)
* Discuss & help : [Dotclear forum](https://forum.dotclear.org/viewforum.php?id=16)
* [License](https://git.dotclear.watch/JcDenis/countdown/src/branch/master/LICENSE)
* [Packages & details](https://git.dotclear.watch/JcDenis/countdown/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/countdown))
* [Sources & contributions](https://git.dotclear.watch/JcDenis/countdown) (or on [GitHub](https://github.com/JcDenis/countdown))
* [Issues & security](https://git.dotclear.watch/JcDenis/countdown/issues) (or on [GitHub](https://github.com/JcDenis/countdown/issues))
* [Discuss & help](https://forum.dotclear.org/viewforum.php?id=16)
## CONTRIBUTORS
* [Moe](http://gniark.net/) (author)
* Pierre Van Glabeke
* Jean-Christian Denis
* [Moe](http://gniark.net/) (author)
* Pierre Van Glabeke
* Jean-Christian Denis (latest)
You are welcome to contribute to this code.
You are welcome to contribute to this code.
## JQUERY PLUGIN
## JQUERY PLUGIN
Dynamic display uses plugin jQuery Countdown; See:
* [Plugin](http://keith-wood.name/countdown.html)
* [Formats](http://keith-wood.name/countdownRef.html#format)
* [Display](http://keith-wood.name/countdownRef.html#layout)
* [Plugin](http://keith-wood.name/countdown.html)
* [Formats](http://keith-wood.name/countdownRef.html#format)
* [Display](http://keith-wood.name/countdownRef.html#layout)

View File

@ -1,32 +1,30 @@
<?php
/**
* @brief countdown, a plugin for Dotclear 2
* @file
* @brief The plugin countdown definition
* @ingroup countdown
*
* @package Dotclear
* @subpackage Plugin
* @defgroup countdown Plugin countdown.
*
* @author Moe (http://gniark.net/) and contributors
* Countdown and stopwatch.
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* @author Moe (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return;
}
declare(strict_types=1);
$this->registerModule(
'CountDown',
'Countdown and stopwatch',
'Moe (http://gniark.net/) and contributors',
'2.3',
'2.4',
[
'requires' => [['core', '2.27']],
'permissions' => dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_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',
'requires' => [['core', '2.28']],
'permissions' => 'My',
'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/">
<module id="countdown">
<name>CountDown</name>
<version>2.3</version>
<version>2.4</version>
<author>Moe (http://gniark.net/) and contributors</author>
<desc>Countdown and stopwatch</desc>
<file>https://git.dotclear.watch/JcDenis/countdown/releases/download/v2.3/plugin-countdown.zip</file>
<da:dcmin>2.27</da:dcmin>
<file>https://git.dotclear.watch/JcDenis/countdown/releases/download/v2.4/plugin-countdown.zip</file>
<da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/countdown/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/countdown/issues</da:support>
</module>

View File

@ -1,22 +1,20 @@
<?php
/**
* @brief countdown, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Moe (http://gniark.net/) 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\countdown;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Process;
/**
* @brief countdown backend class.
* @ingroup countdown
*
* @author Moe (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Backend extends Process
{
public static function init(): bool
@ -30,7 +28,7 @@ class Backend extends Process
return false;
}
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initWidgets']);
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
return true;
}

View File

@ -1,22 +1,20 @@
<?php
/**
* @brief countdown, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Moe (http://gniark.net/) 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\countdown;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Process;
/**
* @brief countdown frontend class.
* @ingroup countdown
*
* @author Moe (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Frontend extends Process
{
public static function init(): bool
@ -30,7 +28,7 @@ class Frontend extends Process
return false;
}
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initWidgets']);
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
return true;
}

View File

@ -1,15 +1,5 @@
<?php
/**
* @brief countdown, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Moe (http://gniark.net/) 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\countdown;
@ -17,8 +7,14 @@ namespace Dotclear\Plugin\countdown;
use Dotclear\Module\MyPlugin;
/**
* This module definitions.
* @brief countdown My helper.
* @ingroup countdown
*
* @author Moe (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class My extends MyPlugin
{
// Use default permissions
}

View File

@ -1,34 +1,32 @@
<?php
/**
* @brief countdown, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Moe (http://gniark.net/) 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\countdown;
use dcCore;
use Dotclear\App;
use Dotclear\Helper\Date;
use Dotclear\Helper\Html\Html;
use Dotclear\Plugin\widgets\WidgetsStack;
use Dotclear\Plugin\widgets\WidgetsElement;
/**
* @brief countdown widgets class.
* @ingroup countdown
*
* @author Moe (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Widgets
{
public static function initWidgets(WidgetsStack $w): void
{
if (is_null(dcCore::app()->blog)) {
if (!App::blog()->isDefined()) {
return;
}
$tz = dcCore::app()->blog->settings->get('system')->get('blog_timezone');
$tz = App::blog()->settings()->get('system')->get('blog_timezone');
$array_year = $array_month = $array_day = $array_hour = [];
$array_minute = $array_number_of_times = [];
@ -59,7 +57,7 @@ class Widgets
$w->create(
'CountDown',
__('Countdown'),
[self::class, 'parseWidget'],
self::parseWidget(...),
null,
__('A countdown to a future date or stopwatch to a past date')
)
@ -145,15 +143,15 @@ class Widgets
public static function parseWidget(WidgetsElement $w): string
{
if (is_null(dcCore::app()->blog)
if (!App::blog()->isDefined()
|| $w->__get('offline')
|| !$w->checkHomeOnly(dcCore::app()->url->type)
|| !$w->checkHomeOnly(App::url()->type)
) {
return '';
}
# get local time
$local_time = Date::addTimeZone(dcCore::app()->blog->settings->get('system')->get('blog_timezone'));
$local_time = Date::addTimeZone(App::blog()->settings()->get('system')->get('blog_timezone'));
$ts = mktime((int) $w->hour, (int) $w->minute, (int) $w->second, (int) $w->month, (int) $w->day, (int) $w->year);
# get difference
@ -197,7 +195,7 @@ class Widgets
$str = implode('', $times);
}
if (!$w->dynamic || is_null(dcCore::app()->ctx)) {
if (!$w->dynamic) {
$res = ($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') .
'<p>' . $text . '<span>' . $str . '</span></p>';
@ -205,11 +203,11 @@ class Widgets
}
# dynamic display with Countdown for jQuery
if (!is_numeric(dcCore::app()->ctx->__get('countdown'))) {
dcCore::app()->ctx->__set('countdown', 0);
if (!is_numeric(App::frontend()->context()->__get('countdown'))) {
App::frontend()->context()->__set('countdown', 0);
}
$id = (int) dcCore::app()->ctx->__get('countdown');
dcCore::app()->ctx->__set('countdown', $id + 1);
$id = (int) App::frontend()->context()->__get('countdown');
App::frontend()->context()->__set('countdown', $id + 1);
$script = '';
@ -218,7 +216,7 @@ class Widgets
My::jsLoad('jquery.plugin.min.js') .
My::jsLoad('jquery.countdown.min.js');
$l10n_file = 'jquery.countdown-' . dcCore::app()->blog->settings->get('system')->get('lang') . '.js';
$l10n_file = 'jquery.countdown-' . App::blog()->settings()->get('system')->get('lang') . '.js';
if (file_exists(__DIR__ . '/../js/' . $l10n_file)) {
$script .= My::jsLoad($l10n_file);
}