release 2.1
This commit is contained in:
parent
f1ca48f87e
commit
2bf8a23185
13
CHANGELOG.md
Normal file
13
CHANGELOG.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
2.1 - 2022.12.31
|
||||||
|
* update to dotclear 2.24
|
||||||
|
* update to jquery plugin 2.1.0 (2016)
|
||||||
|
* fix phpstan and php-cs-fixer errors
|
||||||
|
* fix js call
|
||||||
|
|
||||||
|
1.6 - 2022.12.28 - Pierre Van Glabeke
|
||||||
|
* màj partielle dc2.24
|
||||||
|
|
||||||
|
1.5 - 2016.07.29 - Pierre Van Glabeke
|
||||||
|
* mise à jour script jquery 1.6.3 -> 2.0.2
|
||||||
|
* mise à jour pour compatibilité avec dc2.9
|
||||||
|
* dc2.9 requis
|
53
README.md
53
README.md
@ -1,7 +1,52 @@
|
|||||||
# Countdown
|
# README
|
||||||
|
|
||||||
Le plugin propose un widget qui affiche un compte à rebours vers une date à venir ou un chronomètre vers une date passée.
|
[![Release](https://img.shields.io/github/v/release/JcDenis/countdown)](https://github.com/JcDenis/countdown/releases)
|
||||||
|
[![Date](https://img.shields.io/github/release-date/JcDenis/countdown)](https://github.com/JcDenis/countdown/releases)
|
||||||
|
[![Issues](https://img.shields.io/github/issues/JcDenis/countdown)](https://github.com/JcDenis/countdown/issues)
|
||||||
|
[![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/countdown)
|
||||||
|
[![License](https://img.shields.io/github/license/JcDenis/countdown)](https://github.com/JcDenis/countdown/blob/master/LICENSE)
|
||||||
|
|
||||||
Documentation
|
## WHAT IS COUNTDOWN ?
|
||||||
|
|
||||||
L'affichage dynamique utilise le plugin jQuery Countdown (http://keith-wood.name/countdown.html) qui propose une syntaxe riche pour le formatage (http://keith-wood.name/countdownRef.html#format) et l'affichage (http://keith-wood.name/countdownRef.html#layout).
|
_countdown_ is a plugin for the open-source
|
||||||
|
web publishing software called Dotclear.
|
||||||
|
|
||||||
|
It adds widget showing a countdown since/from a predefined date.
|
||||||
|
|
||||||
|
## REQUIREMENTS
|
||||||
|
|
||||||
|
_countdown_ requires:
|
||||||
|
|
||||||
|
* permissions to manage widgets
|
||||||
|
* Dotclear 2.24
|
||||||
|
* jQuery libs
|
||||||
|
|
||||||
|
## USAGE
|
||||||
|
|
||||||
|
First install _countdown_, manualy from a zip package or from
|
||||||
|
Dotaddict repository. (See Dotclear's documentation to know how do this)
|
||||||
|
|
||||||
|
Add and configure "Countdown" from widgets manager.
|
||||||
|
|
||||||
|
## LINKS
|
||||||
|
|
||||||
|
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||||
|
* Source & contribution : [GitHub Page](https://github.com/JcDenis/countdown)
|
||||||
|
* Packages & details : [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/countdown)
|
||||||
|
* Discuss & help : [Dotclear forum](https://forum.dotclear.org/viewforum.php?id=16)
|
||||||
|
|
||||||
|
## CONTRIBUTORS
|
||||||
|
|
||||||
|
* [Moe](http://gniark.net/) (author)
|
||||||
|
* Pierre Van Glabeke
|
||||||
|
* Jean-Christian Denis
|
||||||
|
|
||||||
|
You are welcome to contribute to this code.
|
||||||
|
|
||||||
|
## 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)
|
||||||
|
17
_admin.php
Normal file
17
_admin.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?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
|
||||||
|
*/
|
||||||
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
require __DIR__ . '/_widget.php';
|
48
_define.php
48
_define.php
@ -1,38 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
# ***** BEGIN LICENSE BLOCK *****
|
/**
|
||||||
#
|
* @brief countdown, a plugin for Dotclear 2
|
||||||
# This file is part of CountDown, a plugin for Dotclear 2
|
*
|
||||||
# Copyright 2007,2010 Moe (http://gniark.net/)
|
* @package Dotclear
|
||||||
#
|
* @subpackage Plugin
|
||||||
# CountDown is free software; you can redistribute it and/or
|
*
|
||||||
# modify it under the terms of the GNU General Public License v2.0
|
* @author Moe (http://gniark.net/) and contributors
|
||||||
# as published by the Free Software Foundation.
|
*
|
||||||
#
|
* @copyright Jean-Christian Denis
|
||||||
# CountDown is distributed in the hope that it will be useful,
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
*/
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
if (!defined('DC_RC_PATH')) {
|
||||||
# GNU General Public License for more details.
|
return;
|
||||||
#
|
}
|
||||||
# You should have received a copy of the GNU General Public
|
|
||||||
# License along with this program. If not, see
|
|
||||||
# <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# ***** END LICENSE BLOCK *****
|
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {return;}
|
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
'CountDown',
|
'CountDown',
|
||||||
'Countdown and stopwatch',
|
'Countdown and stopwatch',
|
||||||
'Moe (http://gniark.net/), Pierre Van Glabeke',
|
'Moe (http://gniark.net/) and contributors',
|
||||||
'2.0.0',
|
'2.1',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.24']],
|
'requires' => [['core', '2.24']],
|
||||||
'permissions' => dcCore::app()->auth->makePermissions([
|
'permissions' => dcCore::app()->auth->makePermissions([
|
||||||
dcAuth::PERMISSION_ADMIN,
|
dcAuth::PERMISSION_ADMIN,
|
||||||
]),
|
]),
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://forum.dotclear.org/viewforum.php?id=16',
|
'support' => 'https://forum.dotclear.org/viewforum.php?id=16',
|
||||||
'details' => 'http://plugins.dotaddict.org/dc2/details/countdown'
|
'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
|
||||||
|
'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
24
_prepend.php
24
_prepend.php
@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
# ***** BEGIN LICENSE BLOCK *****
|
|
||||||
#
|
|
||||||
# This file is part of CountDown, a plugin for Dotclear 2
|
|
||||||
# Copyright 2007,2010 Moe (http://gniark.net/)
|
|
||||||
#
|
|
||||||
# CountDown is free software; you can redistribute it and/or
|
|
||||||
# modify it under the terms of the GNU General Public License v2.0
|
|
||||||
# as published by the Free Software Foundation.
|
|
||||||
#
|
|
||||||
# CountDown is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public
|
|
||||||
# License along with this program. If not, see
|
|
||||||
# <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# ***** END LICENSE BLOCK *****
|
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {return;}
|
|
||||||
|
|
||||||
require_once(dirname(__FILE__).'/_widget.php');
|
|
17
_public.php
Normal file
17
_public.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?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
|
||||||
|
*/
|
||||||
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
require __DIR__ . '/_widget.php';
|
517
_widget.php
517
_widget.php
@ -1,286 +1,265 @@
|
|||||||
<?php
|
<?php
|
||||||
# ***** BEGIN LICENSE BLOCK *****
|
/**
|
||||||
#
|
* @brief countdown, a plugin for Dotclear 2
|
||||||
# This file is part of CountDown, a plugin for Dotclear 2
|
*
|
||||||
# Copyright 2007,2010 Moe (http://gniark.net/)
|
* @package Dotclear
|
||||||
#
|
* @subpackage Plugin
|
||||||
# CountDown is free software; you can redistribute it and/or
|
*
|
||||||
# modify it under the terms of the GNU General Public License v2.0
|
* @author Moe (http://gniark.net/) and contributors
|
||||||
# as published by the Free Software Foundation.
|
*
|
||||||
#
|
* @copyright Jean-Christian Denis
|
||||||
# CountDown is distributed in the hope that it will be useful,
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
*/
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
if (!defined('DC_RC_PATH')) {
|
||||||
# GNU General Public License for more details.
|
return null;
|
||||||
#
|
}
|
||||||
# You should have received a copy of the GNU General Public
|
|
||||||
# License along with this program. If not, see
|
|
||||||
# <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# ***** END LICENSE BLOCK *****
|
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {return;}
|
dcCore::app()->addBehavior(
|
||||||
|
'initWidgets',
|
||||||
|
['CountDownBehaviors','initWidgets']
|
||||||
|
);
|
||||||
|
|
||||||
dcCore::app()->addBehavior('initWidgets',
|
|
||||||
array('CountDownBehaviors','initWidgets'));
|
|
||||||
|
|
||||||
class CountDownBehaviors
|
class CountDownBehaviors
|
||||||
{
|
{
|
||||||
public static function initWidgets($w)
|
public static function initWidgets($w)
|
||||||
{
|
{
|
||||||
# set timezone
|
$tz = dcCore::app()->blog->settings->get('system')->get('blog_timezone');
|
||||||
dcCore::app();
|
|
||||||
$tz = dcCore::app()->blog->settings->system->blog_timezone;
|
|
||||||
|
|
||||||
$w->create('CountDown',__('Countdown'),
|
$array_year = $array_month = $array_day = $array_hour = [];
|
||||||
array('CountDownBehaviors','Show'),
|
$array_minute = $array_number_of_times = [];
|
||||||
null,
|
for ($i = 1902;$i <= 2037;$i++) {
|
||||||
__('A countdown to a future date or stopwatch to a past date'));
|
$array_year[$i] = $i;
|
||||||
|
}
|
||||||
|
for ($i = 1;$i <= 12;$i++) {
|
||||||
|
$i = str_repeat('0', (2 - strlen($i))) . $i;
|
||||||
|
$array_month[ucfirst(__(strftime('%B', mktime(0, 0, 0, (int) $i, 1, 1970)))) . ' (' . $i . ')'] = $i;
|
||||||
|
}
|
||||||
|
for ($i = 1;$i <= 31;$i++) {
|
||||||
|
$i = str_repeat('0', (2 - strlen($i))) . $i;
|
||||||
|
$array_day[$i] = $i;
|
||||||
|
}
|
||||||
|
for ($i = 0;$i <= 23;$i++) {
|
||||||
|
$i = str_repeat('0', (2 - strlen($i))) . $i;
|
||||||
|
$array_hour[$i] = $i;
|
||||||
|
}
|
||||||
|
for ($i = 0;$i <= 60;$i++) {
|
||||||
|
$i = str_repeat('0', (2 - strlen($i))) . $i;
|
||||||
|
$array_minute[$i] = $i;
|
||||||
|
}
|
||||||
|
for ($i = 1;$i <= 5;$i++) {
|
||||||
|
$array_number_of_times[$i] = $i;
|
||||||
|
}
|
||||||
|
$array_number_of_times['6 (' . __('all') . ')'] = 6;
|
||||||
|
|
||||||
$w->CountDown->setting('title',__('Title:'),__('CountDown'),'text');
|
$w->create(
|
||||||
|
'CountDown',
|
||||||
|
__('Countdown'),
|
||||||
|
['CountDownBehaviors', 'Show'],
|
||||||
|
null,
|
||||||
|
__('A countdown to a future date or stopwatch to a past date')
|
||||||
|
)
|
||||||
|
->addTitle(__('CountDown'))
|
||||||
|
->setting(
|
||||||
|
'text_before',
|
||||||
|
__('Text displayed if the date is in the future:'),
|
||||||
|
__('In'),
|
||||||
|
'text'
|
||||||
|
)
|
||||||
|
->setting(
|
||||||
|
'text_after',
|
||||||
|
__('Text displayed if the date is in the past:'),
|
||||||
|
__('For'),
|
||||||
|
'text'
|
||||||
|
)
|
||||||
|
|
||||||
$w->CountDown->setting('text_before',
|
->setting('year', ucfirst(__('year')) . ':', dt::str('%Y', null, $tz), 'combo', $array_year)
|
||||||
__('Text displayed if the date is in the future:'),__('In'),'text');
|
->setting('month', ucfirst(__('month')) . ':', dt::str('%m', null, $tz), 'combo', $array_month)
|
||||||
|
->setting('day', ucfirst(__('day')) . ':', dt::str('%d', null, $tz), 'combo', $array_day)
|
||||||
|
->setting('hour', ucfirst(__('hour')) . ':', dt::str('%H', null, $tz), 'combo', $array_hour)
|
||||||
|
->setting('minute', ucfirst(__('minute')) . ':', dt::str('%M', null, $tz), 'combo', $array_minute)
|
||||||
|
->setting('second', ucfirst(__('second')) . ':', dt::str('%S', null, $tz), 'combo', $array_minute)
|
||||||
|
|
||||||
$w->CountDown->setting('text_after',
|
->setting(
|
||||||
__('Text displayed if the date is in the past:'),__('For'),'text');
|
'number_of_times',
|
||||||
|
__('Number of values to be displayed:'),
|
||||||
|
'6',
|
||||||
|
'combo',
|
||||||
|
$array_number_of_times
|
||||||
|
)
|
||||||
|
->setting(
|
||||||
|
'zeros',
|
||||||
|
__('Show zeros before hours, minutes and seconds'),
|
||||||
|
false,
|
||||||
|
'check'
|
||||||
|
)
|
||||||
|
->setting(
|
||||||
|
'dynamic',
|
||||||
|
__('Enable dynamic display'),
|
||||||
|
false,
|
||||||
|
'check'
|
||||||
|
)
|
||||||
|
->setting(
|
||||||
|
'dynamic_format',
|
||||||
|
sprintf(
|
||||||
|
__('Dynamic display format (see <a href="%1$s" %2$s>jQuery Countdown Reference</a>):'),
|
||||||
|
'http://keith-wood.name/countdownRef.html#format',
|
||||||
|
'onclick="return window.confirm(\'' .
|
||||||
|
__('Are you sure you want to leave this page?') . '\')"'
|
||||||
|
),
|
||||||
|
__('yowdHMS'),
|
||||||
|
'text'
|
||||||
|
)
|
||||||
|
->setting(
|
||||||
|
'dynamic_layout_before',
|
||||||
|
sprintf(
|
||||||
|
__('Dynamic display layout if the date is in the future (see <a href="%1$s" %2$s>jQuery Countdown Reference</a>):'),
|
||||||
|
'http://keith-wood.name/countdownRef.html#layout',
|
||||||
|
'onclick="return window.confirm(\'' .
|
||||||
|
__('Are you sure you want to leave this page?') . '\')"'
|
||||||
|
),
|
||||||
|
__('In {y<}{yn} {yl}, {y>} {o<}{on} {ol}, {o>} {w<}{wn} {wl}, {w>} {d<}{dn} {dl}, {d>} {hn} {hl}, {mn} {ml} and {sn} {sl}'),
|
||||||
|
'textarea'
|
||||||
|
)
|
||||||
|
->setting(
|
||||||
|
'dynamic_layout_after',
|
||||||
|
sprintf(
|
||||||
|
__('Dynamic display layout if the date is in the past (see <a href="%1$s" %2$s>jQuery Countdown Reference</a>):'),
|
||||||
|
'http://keith-wood.name/countdownRef.html#layout',
|
||||||
|
'onclick="return window.confirm(\'' .
|
||||||
|
__('Are you sure you want to leave this page?') . '\')"'
|
||||||
|
),
|
||||||
|
__('For {y<}{yn} {yl}, {y>} {o<}{on} {ol}, {o>} {w<}{wn} {wl}, {w>} {d<}{dn} {dl}, {d>} {hn} {hl}, {mn} {ml} and {sn} {sl}'),
|
||||||
|
'textarea'
|
||||||
|
)
|
||||||
|
|
||||||
# create arrays for year, month, day, hour, minute and second
|
->addHomeOnly()
|
||||||
$array_year = $array_month = $array_day = $array_hour = array();
|
->addContentOnly()
|
||||||
$array_minute = $array_number_of_times = array();
|
->addClass()
|
||||||
for ($i = 1902;$i <= 2037;$i++)
|
->addOffline();
|
||||||
{
|
}
|
||||||
$array_year[$i] = $i;
|
|
||||||
}
|
|
||||||
for ($i = 1;$i <= 12;$i++)
|
|
||||||
{
|
|
||||||
$i = str_repeat('0',(2-strlen($i))).$i;
|
|
||||||
$array_month[ucfirst(__(strftime('%B', mktime(0, 0, 0, $i, 1, 1970)))).' ('.$i.')'] = $i;
|
|
||||||
}
|
|
||||||
for ($i = 1;$i <= 31;$i++)
|
|
||||||
{
|
|
||||||
$i = str_repeat('0',(2-strlen($i))).$i;
|
|
||||||
$array_day[$i] = $i;
|
|
||||||
}
|
|
||||||
for ($i = 0;$i <= 23;$i++)
|
|
||||||
{
|
|
||||||
$i = str_repeat('0',(2-strlen($i))).$i;
|
|
||||||
$array_hour[$i] = $i;
|
|
||||||
}
|
|
||||||
for ($i = 0;$i <= 60;$i++)
|
|
||||||
{
|
|
||||||
$i = str_repeat('0',(2-strlen($i))).$i;
|
|
||||||
$array_minute[$i] = $i;
|
|
||||||
}
|
|
||||||
for ($i = 1;$i <= 5;$i++)
|
|
||||||
{
|
|
||||||
$array_number_of_times[$i] = $i;
|
|
||||||
}
|
|
||||||
$array_number_of_times['6 ('.__('all').')'] = 6;
|
|
||||||
# /create arrays
|
|
||||||
|
|
||||||
$w->CountDown->setting('year',ucfirst(__('year')).':',
|
# escape quotes but not XHTML tags
|
||||||
dt::str('%Y',null,$tz),'combo',$array_year);
|
# inspired by html::escapeJS()
|
||||||
$w->CountDown->setting('month',ucfirst(__('month')).':',
|
public static function escapeQuotes($str)
|
||||||
dt::str('%m',null,$tz),'combo',$array_month);
|
{
|
||||||
$w->CountDown->setting('day',ucfirst(__('day')).':',
|
$str = str_replace("'", "\'", $str);
|
||||||
dt::str('%d',null,$tz),'combo',$array_day);
|
$str = str_replace('"', '\"', $str);
|
||||||
$w->CountDown->setting('hour',ucfirst(__('hour')).':',
|
|
||||||
dt::str('%H',null,$tz),'combo',$array_hour);
|
|
||||||
$w->CountDown->setting('minute',ucfirst(__('minute')).':',
|
|
||||||
dt::str('%M',null,$tz),'combo',$array_minute);
|
|
||||||
$w->CountDown->setting('second',ucfirst(__('second')).':',
|
|
||||||
dt::str('%S',null,$tz),'combo',$array_minute);
|
|
||||||
|
|
||||||
$w->CountDown->setting('number_of_times',
|
return $str;
|
||||||
__('Number of values to be displayed:'),'6','combo',
|
}
|
||||||
$array_number_of_times);
|
|
||||||
|
|
||||||
$w->CountDown->setting('zeros',
|
public static function Show($w)
|
||||||
__('Show zeros before hours, minutes and seconds'),false,'check');
|
{
|
||||||
|
if ($w->offline) {
|
||||||
$w->CountDown->setting('dynamic',
|
return null;
|
||||||
__('Enable dynamic display'),false,'check');
|
}
|
||||||
|
|
||||||
$w->CountDown->setting('dynamic_format',
|
|
||||||
sprintf(__('Dynamic display format (see <a href="%1$s" %2$s>jQuery Countdown Reference</a>):'),
|
|
||||||
'http://keith-wood.name/countdownRef.html#format',
|
|
||||||
'onclick="return window.confirm(\''.
|
|
||||||
__('Are you sure you want to leave this page?').'\')"'),
|
|
||||||
__('yowdHMS'),'text');
|
|
||||||
|
|
||||||
$w->CountDown->setting('dynamic_layout_before',
|
|
||||||
sprintf(__('Dynamic display layout if the date is in the future (see <a href="%1$s" %2$s>jQuery Countdown Reference</a>):'),
|
|
||||||
'http://keith-wood.name/countdownRef.html#layout',
|
|
||||||
'onclick="return window.confirm(\''.
|
|
||||||
__('Are you sure you want to leave this page?').'\')"'),
|
|
||||||
__('In {y<}{yn} {yl}, {y>} {o<}{on} {ol}, {o>} {w<}{wn} {wl}, {w>} {d<}{dn} {dl}, {d>} {hn} {hl}, {mn} {ml} and {sn} {sl}'),
|
|
||||||
'textarea');
|
|
||||||
|
|
||||||
$w->CountDown->setting('dynamic_layout_after',
|
|
||||||
sprintf(__('Dynamic display layout if the date is in the past (see <a href="%1$s" %2$s>jQuery Countdown Reference</a>):'),
|
|
||||||
'http://keith-wood.name/countdownRef.html#layout',
|
|
||||||
'onclick="return window.confirm(\''.
|
|
||||||
__('Are you sure you want to leave this page?').'\')"'),
|
|
||||||
__('For {y<}{yn} {yl}, {y>} {o<}{on} {ol}, {o>} {w<}{wn} {wl}, {w>} {d<}{dn} {dl}, {d>} {hn} {hl}, {mn} {ml} and {sn} {sl}'),
|
|
||||||
'textarea');
|
|
||||||
|
|
||||||
$w->CountDown->setting('homeonly',__('Display on:'),0,'combo',
|
|
||||||
array(
|
|
||||||
__('All pages') => 0,
|
|
||||||
__('Home page only') => 1,
|
|
||||||
__('Except on home page') => 2
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$w->CountDown->setting('content_only',__('Content only'),0,'check');
|
|
||||||
$w->CountDown->setting('class',__('CSS class:'),'');
|
|
||||||
$w->CountDown->setting('offline',__('Offline'),0,'check');
|
|
||||||
}
|
|
||||||
|
|
||||||
# escape quotes but not XHTML tags
|
|
||||||
# inspired by html::escapeJS()
|
|
||||||
public static function escapeQuotes($str)
|
|
||||||
{
|
|
||||||
$str = str_replace("'","\'",$str);
|
|
||||||
$str = str_replace('"','\"',$str);
|
|
||||||
return $str;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function Show($w)
|
|
||||||
{
|
|
||||||
# set timezone
|
|
||||||
dcCore::app();
|
|
||||||
|
|
||||||
if ($w->offline)
|
if (!$w->checkHomeOnly(dcCore::app()->url->type)) {
|
||||||
return;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (($w->homeonly == 1 && dcCore::app()->url->type != 'default') ||
|
# get local time
|
||||||
($w->homeonly == 2 && dcCore::app()->url->type == 'default')) {
|
$local_time = dt::addTimeZone(dcCore::app()->blog->settings->get('system')->get('blog_timezone'));
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
# get local time
|
$ts = mktime($w->hour, $w->minute, $w->second, $w->month, $w->day, $w->year);
|
||||||
$local_time = dt::addTimeZone(dcCore::app()->blog->settings->system->blog_timezone);
|
# get difference
|
||||||
|
(int) $diff = ($local_time - $ts);
|
||||||
|
$after = ($diff > 0) ? true : false;
|
||||||
|
$diff = abs($diff);
|
||||||
|
|
||||||
$ts = mktime($w->hour,$w->minute,$w->second,$w->month,$w->day,
|
$times = [];
|
||||||
$w->year);
|
|
||||||
# get difference
|
|
||||||
(int)$diff = ($local_time - $ts);
|
|
||||||
$after = ($diff > 0) ? true : false;
|
|
||||||
$diff = abs($diff);
|
|
||||||
|
|
||||||
$times = array();
|
|
||||||
|
|
||||||
$intervals = array
|
|
||||||
(
|
|
||||||
(3600*24*365.24) => array('one'=>__('year'),'more'=>__('years'),
|
|
||||||
'zeros'=>false),
|
|
||||||
(3600*24*30.4) => array('one'=>__('month'),'more'=>__('months'),
|
|
||||||
'zeros'=>false),
|
|
||||||
(3600*24) => array('one'=>__('day'),'more'=>__('days'),
|
|
||||||
'zeros'=>false),
|
|
||||||
(3600) => array('one'=>__('hour'),'more'=>__('hours'),
|
|
||||||
'zeros'=>true),
|
|
||||||
(60) => array('one'=>__('minute'),'more'=>__('minutes'),
|
|
||||||
'zeros'=>true),
|
|
||||||
(1) => array('one'=>__('second'),'more'=>__('seconds'),
|
|
||||||
'zeros'=>true),
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($intervals as $k => $v)
|
|
||||||
{
|
|
||||||
if ($diff >= $k)
|
|
||||||
{
|
|
||||||
$time = floor($diff/$k);
|
|
||||||
$times[] = (($w->zeros AND $v['zeros'])
|
|
||||||
? sprintf('%02d',$time) : $time).' '.(($time <= 1) ? $v['one']
|
|
||||||
: $v['more']);
|
|
||||||
$diff = $diff%$k;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# output
|
|
||||||
$text = ($after) ? $w->text_after : $w->text_before;
|
|
||||||
if (strlen($text) > 0) {$text .= ' ';}
|
|
||||||
|
|
||||||
# get times and make a string
|
|
||||||
$times = array_slice($times,0,$w->number_of_times);
|
|
||||||
if (count($times) > 1)
|
|
||||||
{
|
|
||||||
$last = array_pop($times);
|
|
||||||
$str = implode(', ',$times).' '.__('and').' '.$last;
|
|
||||||
}
|
|
||||||
else {$str = implode('',$times);}
|
|
||||||
|
|
||||||
if (!$w->dynamic)
|
|
||||||
{
|
|
||||||
|
|
||||||
$res = ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
|
$intervals = [
|
||||||
'<p>'.$text.'<span>'.$str.'</span></p>';
|
(3600 * 24 * 365.24) => ['one' => __('year'), 'more' => __('years'), 'zeros' => false],
|
||||||
return $w->renderDiv($w->content_only,'countdown '.$w->class,'',$res);
|
(3600 * 24 * 30.4) => ['one' => __('month'), 'more' => __('months'), 'zeros' => false],
|
||||||
}
|
(3600 * 24) => ['one' => __('day'), 'more' => __('days'), 'zeros' => false],
|
||||||
|
(3600) => ['one' => __('hour'), 'more' => __('hours'), 'zeros' => true],
|
||||||
else
|
(60) => ['one' => __('minute'), 'more' => __('minutes'), 'zeros' => true],
|
||||||
{
|
(1) => ['one' => __('second'), 'more' => __('seconds'), 'zeros' => true],
|
||||||
# dynamic display with Countdown for jQuery
|
];
|
||||||
if (!is_numeric(dcCore::app()->ctx->countdown))
|
|
||||||
{
|
foreach ($intervals as $k => $v) {
|
||||||
dcCore::app()->ctx->countdown = 0;
|
if ($diff >= $k) {
|
||||||
}
|
$time = floor($diff / $k);
|
||||||
$id = dcCore::app()->ctx->countdown;
|
$times[] = (($w->zeros and $v['zeros'])
|
||||||
dcCore::app()->ctx->countdown += 1;
|
? sprintf('%02d', $time) : $time) . ' ' . (($time <= 1) ? $v['one']
|
||||||
|
: $v['more']);
|
||||||
$script = '';
|
$diff = $diff % $k;
|
||||||
|
}
|
||||||
if (!defined('COUNTDOWN_SCRIPT'))
|
}
|
||||||
{
|
|
||||||
$script =
|
# output
|
||||||
'<script type="text/javascript" src="'.
|
$text = ($after) ? $w->text_after : $w->text_before;
|
||||||
dcCore::app()->blog->getQmarkURL().
|
if (strlen($text) > 0) {
|
||||||
'pf=countdown/js/jquery.countdown.min.js"></script>'."\n";
|
$text .= ' ';
|
||||||
|
}
|
||||||
$l10n_file =
|
|
||||||
'jquery.countdown-'.dcCore::app()->blog->settings->system->lang.'.js';
|
# get times and make a string
|
||||||
if (file_exists(dirname(__FILE__).'/js/'.$l10n_file))
|
$times = array_slice($times, 0, $w->number_of_times);
|
||||||
{
|
if (count($times) > 1) {
|
||||||
$script .=
|
$last = array_pop($times);
|
||||||
'<script type="text/javascript" src="'.dcCore::app()->blog->getQmarkURL().
|
$str = implode(', ', $times) . ' ' . __('and') . ' ' . $last;
|
||||||
'pf=countdown/js/'.$l10n_file.'"></script>'."\n";
|
} else {
|
||||||
}
|
$str = implode('', $times);
|
||||||
|
}
|
||||||
define('COUNTDOWN_SCRIPT',(bool)true);
|
|
||||||
}
|
if (!$w->dynamic) {
|
||||||
|
$res = ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
|
||||||
if ($after)
|
'<p>' . $text . '<span>' . $str . '</span></p>';
|
||||||
{
|
|
||||||
$to = 'since';
|
return $w->renderDiv($w->content_only, 'countdown ' . $w->class, '', $res);
|
||||||
$layout = $w->dynamic_layout_after;
|
}
|
||||||
}
|
|
||||||
else
|
# dynamic display with Countdown for jQuery
|
||||||
{
|
if (!is_numeric(dcCore::app()->ctx->__get('countdown'))) {
|
||||||
$to = 'until';
|
dcCore::app()->ctx->__set('countdown', 0);
|
||||||
$layout = $w->dynamic_layout_before;
|
}
|
||||||
}
|
$id = (int) dcCore::app()->ctx->__get('countdown');
|
||||||
|
dcCore::app()->ctx->__set('countdown', $id + 1);
|
||||||
$res = ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
|
|
||||||
'<p id="countdown-'.$id.'">'.$text.$str.'</p>'.
|
$script = '';
|
||||||
'<script type="text/javascript">'."\n".
|
|
||||||
'//<![CDATA['."\n".
|
if (!defined('COUNTDOWN_SCRIPT')) {
|
||||||
'$().ready(function() {'.
|
$script .= dcUtils::cssLoad(dcCore::app()->blog->getPF(basename(__DIR__) . '/css/jquery.countdown.css')) .
|
||||||
"$('#countdown-".$id."').countdown({".
|
dcUtils::jsLoad(dcCore::app()->blog->getPF(basename(__DIR__) . '/js/jquery.plugin.min.js')) .
|
||||||
# In Javascript, 0 = January, 11 = December
|
dcUtils::jsLoad(dcCore::app()->blog->getPF(basename(__DIR__) . '/js/jquery.countdown.min.js'));
|
||||||
$to.": new Date(".(int)$w->year.",".(int)$w->month."-1,".
|
|
||||||
(int)$w->day.",".(int)$w->hour.",".(int)$w->minute.",".
|
$l10n_file = 'jquery.countdown-' . dcCore::app()->blog->settings->get('system')->get('lang') . '.js';
|
||||||
(int)$w->second."),
|
if (file_exists(__DIR__ . '/js/' . $l10n_file)) {
|
||||||
description: '".html::escapeJS($text)."',
|
$script .= dcUtils::jsLoad(dcCore::app()->blog->getPF(basename(__DIR__) . '/js/' . $l10n_file));
|
||||||
format: '".$w->dynamic_format."',
|
}
|
||||||
layout: '".$layout."',
|
|
||||||
expiryText: '".html::escapeJS($w->text_after)."'
|
define('COUNTDOWN_SCRIPT', (bool) true);
|
||||||
});".
|
}
|
||||||
'});'."\n".
|
|
||||||
'//]]>'.
|
if ($after) {
|
||||||
'</script>'."\n";
|
$to = 'since';
|
||||||
return $w->renderDiv($w->content_only,'countdown '.$w->class,'',$res);
|
$layout = $w->dynamic_layout_after;
|
||||||
}
|
} else {
|
||||||
}
|
$to = 'until';
|
||||||
}
|
$layout = $w->dynamic_layout_before;
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
|
||||||
|
'<p id="countdown-' . $id . '">' . $text . $str . '</p>' .
|
||||||
|
$script .
|
||||||
|
'<script type="text/javascript">' . "\n" .
|
||||||
|
'//<![CDATA[' . "\n" .
|
||||||
|
'$().ready(function() {' .
|
||||||
|
"$('#countdown-" . $id . "').countdown({" .
|
||||||
|
# In Javascript, 0 = January, 11 = December
|
||||||
|
$to . ': new Date(' . (int) $w->year . ',' . (int) $w->month . '-1,' .
|
||||||
|
(int) $w->day . ',' . (int) $w->hour . ',' . (int) $w->minute . ',' .
|
||||||
|
(int) $w->second . "),
|
||||||
|
description: '" . html::escapeJS($text) . "',
|
||||||
|
format: '" . $w->dynamic_format . "',
|
||||||
|
layout: '" . $layout . "',
|
||||||
|
expiryText: '" . html::escapeJS($w->text_after) . "'
|
||||||
|
});" .
|
||||||
|
'});' . "\n" .
|
||||||
|
'//]]>' .
|
||||||
|
'</script>' . "\n";
|
||||||
|
|
||||||
|
return $w->renderDiv($w->content_only, 'countdown ' . $w->class, '', $res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
v1.6 - 28-12-2022 - Pierre Van Glabeke
|
|
||||||
* màj partielle dc2.24
|
|
||||||
|
|
||||||
v1.5 - 29-07-2016 - Pierre Van Glabeke
|
|
||||||
* mise à jour script jquery 1.6.3 -> 2.0.2
|
|
||||||
* mise à jour pour compatibilité avec dc2.9
|
|
||||||
* dc2.9 requis
|
|
13
dcstore.xml
Normal file
13
dcstore.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
|
<module id="countdown">
|
||||||
|
<name>CountDown</name>
|
||||||
|
<version>2.1</version>
|
||||||
|
<author>Moe (http://gniark.net/) and contributors</author>
|
||||||
|
<desc>Countdown and stopwatch</desc>
|
||||||
|
<file>https://github.com/JcDenis/countdown/releases/download/v2.1/plugin-countdown.zip</file>
|
||||||
|
<da:dcmin>2.24</da:dcmin>
|
||||||
|
<da:details>https://plugins.dotaddict.org/dc2/details/countdown</da:details>
|
||||||
|
<da:support>https://forum.dotclear.org/viewforum.php?id=16</da:support>
|
||||||
|
</module>
|
||||||
|
</modules>
|
40
locales/fr/main.lang.php
Normal file
40
locales/fr/main.lang.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Dotclear
|
||||||
|
*
|
||||||
|
* @copyright Olivier Meunier & Association Dotclear
|
||||||
|
* @copyright GPL-2.0-only
|
||||||
|
*/
|
||||||
|
#
|
||||||
|
# DOT NOT MODIFY THIS FILE !
|
||||||
|
#
|
||||||
|
|
||||||
|
l10n::$locales['Countdown and stopwatch'] = 'Compte à rebours ou chronomètre';
|
||||||
|
l10n::$locales['A countdown to a future date or stopwatch to a past date'] = 'Un compte à rebours vers une date à venir ou un chronomètre vers une date passée';
|
||||||
|
l10n::$locales['Countdown'] = 'Chronomètre';
|
||||||
|
l10n::$locales['Text displayed if the date is in the future:'] = 'Texte affiché si la date est dans le futur :';
|
||||||
|
l10n::$locales['In'] = 'Dans';
|
||||||
|
l10n::$locales['Text displayed if the date is in the past:'] = 'Texte affiché si la date est passée :';
|
||||||
|
l10n::$locales['For'] = 'Depuis';
|
||||||
|
l10n::$locales['all'] = 'tous';
|
||||||
|
l10n::$locales['year'] = 'an';
|
||||||
|
l10n::$locales['month'] = 'mois';
|
||||||
|
l10n::$locales['day'] = 'jour';
|
||||||
|
l10n::$locales['hour'] = 'heure';
|
||||||
|
l10n::$locales['minute'] = 'minute';
|
||||||
|
l10n::$locales['second'] = 'seconde';
|
||||||
|
l10n::$locales['Number of values to be displayed:'] = 'Nombre de valeurs à afficher :';
|
||||||
|
l10n::$locales['Show zeros before hours, minutes and seconds'] = 'Afficher des zéros devant les heures, les minutes et les secondes';
|
||||||
|
l10n::$locales['Enable dynamic display'] = 'Activer l\'affichage dynamique';
|
||||||
|
l10n::$locales['Dynamic display format (see <a href="%1$s" %2$s>jQuery Countdown Reference</a>):'] = 'Format de l\'affichage dynamique (voir <a href="%1$s" %2$s>jQuery Countdown Reference</a>) :';
|
||||||
|
l10n::$locales['Dynamic display layout if the date is in the future (see <a href="%1$s" %2$s>jQuery Countdown Reference</a>):'] = 'Mise en page de l\'affichage dynamique si la date est dans le futur (voir <a href="%1$s" %2$s>jQuery Countdown Reference</a>) :';
|
||||||
|
l10n::$locales['In {y<}{yn} {yl}, {y>} {o<}{on} {ol}, {o>} {w<}{wn} {wl}, {w>} {d<}{dn} {dl}, {d>} {hn} {hl}, {mn} {ml} and {sn} {sl}'] = 'Dans {y<}{yn} {yl}, {y>}{o<}{on} {ol}, {o>}{d<}{dn} {dl}, {d>}{hn} {hl}, {mn} {ml} et {sn} {sl}';
|
||||||
|
l10n::$locales['Dynamic display layout if the date is in the past (see <a href="%1$s" %2$s>jQuery Countdown Reference</a>):'] = 'Mise en page de l\'affichage dynamique si la date est passée (voir <a href="%1$s" %2$s>jQuery Countdown Reference</a>) :';
|
||||||
|
l10n::$locales['For {y<}{yn} {yl}, {y>} {o<}{on} {ol}, {o>} {w<}{wn} {wl}, {w>} {d<}{dn} {dl}, {d>} {hn} {hl}, {mn} {ml} and {sn} {sl}'] = 'Depuis {y<}{yn} {yl}, {y>} {o<}{on} {ol}, {o>} {w<}{wn} {wl}, {w>} {d<}{dn} {dl}, {d>} {hn} {hl}, {mn} {ml} et {sn} {sl}';
|
||||||
|
l10n::$locales['years'] = 'ans';
|
||||||
|
l10n::$locales['months'] = 'mois';
|
||||||
|
l10n::$locales['days'] = 'jours';
|
||||||
|
l10n::$locales['hours'] = 'heures';
|
||||||
|
l10n::$locales['minutes'] = 'minutes';
|
||||||
|
l10n::$locales['seconds'] = 'secondes';
|
||||||
|
l10n::$locales['and'] = 'et';
|
Loading…
Reference in New Issue
Block a user