release 1.6 for dotclear 2.24
This commit is contained in:
parent
09555d4f5e
commit
c4022ad996
10 changed files with 249 additions and 284 deletions
24
CHANGELOG.md
24
CHANGELOG.md
|
@ -1,33 +1,37 @@
|
||||||
v 1.5.1 - 22-04-2015 - Pierre Van Glabeke
|
1.6 - 2022.12.16
|
||||||
|
* update to dotclear 2.24
|
||||||
|
* fix phpstan errors
|
||||||
|
|
||||||
|
1.5.1 - 2015.04.22 - Pierre Van Glabeke
|
||||||
* nommage widget
|
* nommage widget
|
||||||
* modifs localisation
|
* modifs localisation
|
||||||
|
|
||||||
v 1.5 - Pierre Van Glabeke
|
1.5 - Pierre Van Glabeke
|
||||||
* compatibilité dc2.7
|
* compatibilité dc2.7
|
||||||
|
|
||||||
v 1.4.1 - Pierre Van Glabeke
|
1.4.1 - Pierre Van Glabeke
|
||||||
* Ajustements settings
|
* Ajustements settings
|
||||||
* Fin de ligne unix
|
* Fin de ligne unix
|
||||||
* complément _define.php
|
* complément define.php
|
||||||
|
|
||||||
v 1.4 - Pierre Van Glabeke
|
1.4 - Pierre Van Glabeke
|
||||||
* Modifs affichage pour le widget (remplacement paragraphe par une liste)
|
* Modifs affichage pour le widget (remplacement paragraphe par une liste)
|
||||||
|
|
||||||
v 1.3.1
|
1.3.1
|
||||||
* Ajout choix affichage page pour le widget (content only + css)
|
* Ajout choix affichage page pour le widget (content only + css)
|
||||||
|
|
||||||
v 1.3
|
1.3
|
||||||
* Ajout choix affichage page pour le widget
|
* Ajout choix affichage page pour le widget
|
||||||
* Correction de traduction
|
* Correction de traduction
|
||||||
|
|
||||||
v 1.2
|
1.2
|
||||||
* Ajout du piochage automatique de la date du blog si non saisie dans le widget
|
* Ajout du piochage automatique de la date du blog si non saisie dans le widget
|
||||||
* Ajout @ devant la fonction checkdate pour eviter un warning
|
* Ajout @ devant la fonction checkdate pour eviter un warning
|
||||||
|
|
||||||
v 1.1
|
1.1
|
||||||
* Compatibilité dc2.2
|
* Compatibilité dc2.2
|
||||||
* Localisation
|
* Localisation
|
||||||
* Intégration corrections proposées sur http://www.myouaibe.com/index.php/post/2007/08/23/Plugin-BlogAnniv-pour-DOTCLEAR-2
|
* Intégration corrections proposées sur http://www.myouaibe.com/index.php/post/2007/08/23/Plugin-BlogAnniv-pour-DOTCLEAR-2
|
||||||
|
|
||||||
v 1.0
|
1.0
|
||||||
* Création
|
* Création
|
23
LICENSE
23
LICENSE
|
@ -1,12 +1,12 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 2, June 1991
|
Version 2, June 1991
|
||||||
|
|
||||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
Preamble
|
Preamble
|
||||||
|
|
||||||
The licenses for most software are designed to take away your
|
The licenses for most software are designed to take away your
|
||||||
freedom to share and change it. By contrast, the GNU General Public
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
@ -56,7 +56,7 @@ patent must be licensed for everyone's free use or not licensed at all.
|
||||||
The precise terms and conditions for copying, distribution and
|
The precise terms and conditions for copying, distribution and
|
||||||
modification follow.
|
modification follow.
|
||||||
|
|
||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
0. This License applies to any program or other work which contains
|
0. This License applies to any program or other work which contains
|
||||||
|
@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
|
||||||
of preserving the free status of all derivatives of our free software and
|
of preserving the free status of all derivatives of our free software and
|
||||||
of promoting the sharing and reuse of software generally.
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
NO WARRANTY
|
NO WARRANTY
|
||||||
|
|
||||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
POSSIBILITY OF SUCH DAMAGES.
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
If you develop a new program, and you want it to be of the greatest
|
||||||
possible use to the public, the best way to achieve this is to make it
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
@ -290,8 +290,8 @@ to attach them to the start of each source file to most effectively
|
||||||
convey the exclusion of warranty; and each file should have at least
|
convey the exclusion of warranty; and each file should have at least
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
{description}
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
Copyright (C) {year} {fullname}
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -329,7 +329,7 @@ necessary. Here is a sample; alter the names:
|
||||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
{signature of Ty Coon}, 1 April 1989
|
<signature of Ty Coon>, 1 April 1989
|
||||||
Ty Coon, President of Vice
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
This General Public License does not permit incorporating your program into
|
This General Public License does not permit incorporating your program into
|
||||||
|
@ -337,4 +337,3 @@ proprietary programs. If your program is a subroutine library, you may
|
||||||
consider it more useful to permit linking proprietary applications with the
|
consider it more useful to permit linking proprietary applications with the
|
||||||
library. If this is what you want to do, use the GNU Lesser General
|
library. If this is what you want to do, use the GNU Lesser General
|
||||||
Public License instead of this License.
|
Public License instead of this License.
|
||||||
|
|
||||||
|
|
49
README.md
49
README.md
|
@ -1,9 +1,46 @@
|
||||||
# bloganniv
|
# README
|
||||||
Décompte du nombre de jours avant et après une date donnée
|
|
||||||
|
|
||||||
Ce plugin permet l'affichage dans la sidebar par le biais du widget de :
|
[![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)
|
||||||
|
[![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)
|
||||||
|
|
||||||
* une date de naissance (si vide, la date de naissance du blog sera prise en compte),
|
## WHAT IS BLOGANNIV ?
|
||||||
* l'âge en années,
|
|
||||||
* le nombre de jours restant avant et après l'anniversaire de la date.
|
|
||||||
|
|
||||||
|
_bloganniv_ is a plugin for the open-source
|
||||||
|
web publishing software called Dotclear.
|
||||||
|
|
||||||
|
It adds widget showing:
|
||||||
|
* birth date of the blog,
|
||||||
|
* age (in year) of the blog
|
||||||
|
* days till next birthday of the blog.
|
||||||
|
|
||||||
|
## REQUIREMENTS
|
||||||
|
|
||||||
|
_bloganniv_ requires:
|
||||||
|
|
||||||
|
* permissions to manage widgets
|
||||||
|
* Dotclear 2.24
|
||||||
|
|
||||||
|
## USAGE
|
||||||
|
|
||||||
|
First install _bloganniv_, manualy from a zip package or from
|
||||||
|
Dotaddict repository. (See Dotclear's documentation to know how do this)
|
||||||
|
|
||||||
|
Add and configure "Blog anniv" 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/bloganniv)
|
||||||
|
* Packages & details : [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/bloganniv)
|
||||||
|
|
||||||
|
## CONTRIBUTORS
|
||||||
|
|
||||||
|
* Fran6t (author)
|
||||||
|
* Pierre Van Glabeke
|
||||||
|
* Jean-Christian Denis
|
||||||
|
|
||||||
|
You are welcome to contribute to this code.
|
29
_admin.php
29
_admin.php
|
@ -1,16 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
# ***** BEGIN LICENSE BLOCK *****
|
/**
|
||||||
#
|
* @brief bloganniv, a plugin for Dotclear 2
|
||||||
# This file is part of DotClear.
|
*
|
||||||
#
|
* @package Dotclear
|
||||||
# Plugin Bloganniv by Francis Trautmann
|
* @subpackage Plugin
|
||||||
# Contributor: Pierre Van Glabeke
|
*
|
||||||
# Licensed under the GPL version 2.0 license.
|
* @author Fran6t, Pierre Van Glabeke and Contributors
|
||||||
# A copy of this license is available in LICENSE file at
|
*
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
* @copyright Jean-Crhistian Denis
|
||||||
#
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
# ***** END LICENSE BLOCK *****
|
*/
|
||||||
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) { return; }
|
require __DIR__ . '/_widgets.php';
|
||||||
|
|
||||||
require dirname(__FILE__).'/_widgets.php';
|
|
||||||
|
|
55
_define.php
55
_define.php
|
@ -1,27 +1,32 @@
|
||||||
<?php
|
<?php
|
||||||
# ***** BEGIN LICENSE BLOCK *****
|
/**
|
||||||
#
|
* @brief bloganniv, a plugin for Dotclear 2
|
||||||
# This file is part of DotClear.
|
*
|
||||||
#
|
* @package Dotclear
|
||||||
# Plugin Bloganniv by Francis Trautmann
|
* @subpackage Plugin
|
||||||
# Contributor: Pierre Van Glabeke
|
*
|
||||||
# Licensed under the GPL version 2.0 license.
|
* @author Fran6t, Pierre Van Glabeke and Contributors
|
||||||
# A copy of this license is available in LICENSE file at
|
*
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
* @copyright Jean-Crhistian Denis
|
||||||
#
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
# ***** END LICENSE BLOCK *****
|
*/
|
||||||
if (!defined('DC_RC_PATH')) { return; }
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
/* Name */ "Blog Anniv",
|
'Blog Anniv',
|
||||||
/* Description*/ "Counting the number of days before and after a particular date",
|
'Counting the number of days before and after a particular date',
|
||||||
/* Author */ "Fran6t, Pierre Van Glabeke",
|
'Fran6t, Pierre Van Glabeke and Contributors',
|
||||||
/* Version */ '1.5.1',
|
'1.6',
|
||||||
/* Properties */
|
[
|
||||||
array(
|
'requires' => [['core', '2.24']],
|
||||||
'permissions' => 'blogAnniv',
|
'permissions' => dcCore::app()->auth->makePermissions([
|
||||||
'type' => 'plugin',
|
dcAuth::PERMISSION_ADMIN,
|
||||||
'dc_min' => '2.7',
|
]),
|
||||||
'support' => 'http://www.myouaibe.com/index.php/post/2007/08/23/Plugin-BlogAnniv-pour-DOTCLEAR-2',
|
'type' => 'plugin',
|
||||||
'details' => 'http://plugins.dotaddict.org/dc2/details/bloganniv'
|
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
|
||||||
)
|
'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
|
||||||
);
|
'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
151
_public.php
151
_public.php
|
@ -1,138 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
# ***** BEGIN LICENSE BLOCK *****
|
/**
|
||||||
#
|
* @brief bloganniv, a plugin for Dotclear 2
|
||||||
# This file is part of DotClear.
|
*
|
||||||
#
|
* @package Dotclear
|
||||||
# Plugin Bloganniv by Francis Trautmann
|
* @subpackage Plugin
|
||||||
# Contributor: Pierre Van Glabeke
|
*
|
||||||
# Licensed under the GPL version 2.0 license.
|
* @author Fran6t, Pierre Van Glabeke and Contributors
|
||||||
# A copy of this license is available in LICENSE file at
|
*
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
* @copyright Jean-Crhistian Denis
|
||||||
#
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
# ***** END LICENSE BLOCK *****
|
*/
|
||||||
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) { return; }
|
require __DIR__ . '/_widgets.php';
|
||||||
|
|
||||||
require dirname(__FILE__).'/_widgets.php';
|
|
||||||
|
|
||||||
$core->tpl->addValue('blogAnniv',array('tplBlogAnniv','blogAnniv'));
|
|
||||||
|
|
||||||
class tplBlogAnniv
|
|
||||||
{
|
|
||||||
|
|
||||||
public static function blogAnniv($attr)
|
|
||||||
{
|
|
||||||
$output = '';
|
|
||||||
|
|
||||||
if (isset($attr['text']))
|
|
||||||
{
|
|
||||||
$author = isset($attr['author']) ? ' <cite>'.$attr['author'].'</cite>' : '';
|
|
||||||
|
|
||||||
$output = '<blockquote>'.$attr['text'].$author.'</blockquote>';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function BlogAnnivWidget($w)
|
|
||||||
{
|
|
||||||
global $core;
|
|
||||||
|
|
||||||
if ($w->offline)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Si nous sommes pas en page accueil et que c'est coché page accueil uniquement on fait rien
|
|
||||||
|
|
||||||
if (($w->homeonly == 1 && $core->url->type != 'default') ||
|
|
||||||
($w->homeonly == 2 && $core->url->type == 'default')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$title = $w->title ? html::escapeHTML($w->title) : __('Subscribe');
|
|
||||||
$ftdatecrea = $w->ftdatecrea;
|
|
||||||
//Si la date est vide nous recherchons la date en base
|
|
||||||
if (strlen(rtrim($ftdatecrea))==0){
|
|
||||||
///////////////////////////////////////////////
|
|
||||||
//ACCES BDD
|
|
||||||
//je récupère la date du blog
|
|
||||||
require_once dirname(__FILE__).'/class.dc.dateBlog.php';
|
|
||||||
|
|
||||||
$lc = new dateBlog($GLOBALS['core']->blog);
|
|
||||||
try {
|
|
||||||
$Posts = $lc->getdateBlog();
|
|
||||||
}
|
|
||||||
catch (Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
foreach($Posts->rows() as $k => $v)
|
|
||||||
{
|
|
||||||
$ftdatecrea = html::clean($v['blog_creadt']);
|
|
||||||
$ftdatecrea = substr($ftdatecrea,0,10);
|
|
||||||
$ftdatecrea = str_replace("-","/",$ftdatecrea);
|
|
||||||
list($annee, $mois, $jour) = explode('/', $ftdatecrea);
|
|
||||||
// On remet la date en forme française
|
|
||||||
$ftdatecrea=$jour."/".$mois."/".$annee;
|
|
||||||
#printf($ftdatecrea);
|
|
||||||
#printf(html::clean($v['blog_id']));
|
|
||||||
}
|
|
||||||
//FIN ACCES BDD
|
|
||||||
///////////////////////////////////////////////
|
|
||||||
} else {
|
|
||||||
list($jour, $mois, $annee) = explode('/', $ftdatecrea);
|
|
||||||
}
|
|
||||||
$nbrejours=0;
|
|
||||||
$nbreannee=0;
|
|
||||||
// Test si la date est valide
|
|
||||||
if(@checkdate($mois,$jour,$annee)){
|
|
||||||
// Ok nous pouvons calculer la date anniversaire et le nombre de jours restant avant
|
|
||||||
|
|
||||||
//Extraction des données
|
|
||||||
list($jour2, $mois2, $annee2) = explode('-', date('d-m-Y'));
|
|
||||||
|
|
||||||
//Calcul des timestamp
|
|
||||||
$timestamp1 = mktime(0,0,0,$mois,$jour,$annee2); // La date anniversaire cette année
|
|
||||||
$timestamp2 = mktime(0,0,0,$mois2,$jour2,$annee2);
|
|
||||||
//Affichage du nombre de jour
|
|
||||||
|
|
||||||
//je regarde si la date anniv n'est pas passé
|
|
||||||
if (($timestamp2 - $timestamp1)> 0)
|
|
||||||
{
|
|
||||||
$timestamp1 = mktime(0,0,0,$mois,$jour,$annee2 + 1);
|
|
||||||
$nbrejours = round(abs(mktime(0,0,0,$mois2,$jour2,$annee2) - $timestamp1)/86400);
|
|
||||||
$nbreannee = abs($annee2 - $annee);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$nbrejours = abs($timestamp2 - $timestamp1)/86400;
|
|
||||||
$nbreannee = abs($annee2 - $annee - 1);
|
|
||||||
}
|
|
||||||
// abs($timestamp2 - $timestamp1)/(86400*7); //Affichage du nombre de semaine : 3.85
|
|
||||||
} else {
|
|
||||||
$ftdatecrea= '$ftdatecrea date invalide';
|
|
||||||
}
|
|
||||||
$dispyearborn = $dispyear = "";
|
|
||||||
// Si je dois afficher la date de naissance
|
|
||||||
if ($w->dispyearborn) {
|
|
||||||
$dispyearborn = '<li>'.__('Born:').
|
|
||||||
' <span class="annivne">'.$ftdatecrea.'</span></li>';
|
|
||||||
}
|
|
||||||
// Si je dois afficher l'age en année
|
|
||||||
if ($w->dispyear) {
|
|
||||||
$dispyear = '<li>'.__('Age:').
|
|
||||||
' <span class="annivan">'.$nbreannee.'</span> '.
|
|
||||||
__('year(s)').
|
|
||||||
'</li>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$res =
|
|
||||||
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
|
|
||||||
'<ul>'.
|
|
||||||
$dispyearborn.
|
|
||||||
$dispyear.
|
|
||||||
'<li>'.__('Birthday in').
|
|
||||||
' <span class="annivjrs">'.$nbrejours.'</span> '.
|
|
||||||
__('day(s)').'</li></ul>';
|
|
||||||
|
|
||||||
return $w->renderDiv($w->content_only,'bloganniv '.$w->class,'',$res);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
137
_widgets.php
137
_widgets.php
|
@ -1,40 +1,107 @@
|
||||||
<?php
|
<?php
|
||||||
# ***** BEGIN LICENSE BLOCK *****
|
/**
|
||||||
#
|
* @brief bloganniv, a plugin for Dotclear 2
|
||||||
# This file is part of DotClear.
|
*
|
||||||
#
|
* @package Dotclear
|
||||||
# Plugin Bloganniv by Francis Trautmann
|
* @subpackage Plugin
|
||||||
# Contributor: Pierre Van Glabeke
|
*
|
||||||
# Licensed under the GPL version 2.0 license.
|
* @author Fran6t, Pierre Van Glabeke and Contributors
|
||||||
# A copy of this license is available in LICENSE file at
|
*
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
* @copyright Jean-Crhistian Denis
|
||||||
#
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
# ***** END LICENSE BLOCK *****
|
*/
|
||||||
if (!defined('DC_RC_PATH')) { return; }
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$core->addBehavior('initWidgets',array('blogAnnivWidgets','initWidgets'));
|
dcCore::app()->addBehavior('initWidgets', ['blogAnnivWidgets', 'initWidgets']);
|
||||||
|
|
||||||
class blogAnnivWidgets
|
class blogAnnivWidgets
|
||||||
{
|
{
|
||||||
public static function initWidgets($w)
|
public static function initWidgets($w)
|
||||||
{
|
{
|
||||||
global $core;
|
$w->create(
|
||||||
$w->create('blogAnniv',__('Blog Anniv'),array('tplBlogAnniv','BlogAnnivWidget'),
|
'blogAnniv',
|
||||||
null,
|
__('Blog Anniv'),
|
||||||
__('Counting the number of days before and after a particular date'));
|
['blogAnnivWidgets', 'BlogAnnivWidget'],
|
||||||
$w->blogAnniv->setting('title',__('Title :'),'');
|
null,
|
||||||
$w->blogAnniv->setting('ftdatecrea',__('Born Date (dd/mm/yyyy) or blank:'),'');
|
__('Counting the number of days before and after a particular date')
|
||||||
$w->blogAnniv->setting('dispyearborn',__('Display Born Date'),1,'check');
|
)
|
||||||
$w->blogAnniv->setting('dispyear',__('Display Year(s) Old'),1,'check');
|
->addTitle('')
|
||||||
$w->blogAnniv->setting('homeonly',__('Display on:'),0,'combo',
|
->setting('ftdatecrea', __('Born Date (dd/mm/yyyy) or blank:'), '')
|
||||||
array(
|
->setting('dispyearborn', __('Display Born Date'), 1, 'check')
|
||||||
__('All pages') => 0,
|
->setting('dispyear', __('Display Year(s) Old'), 1, 'check')
|
||||||
__('Home page only') => 1,
|
->addHomeOnly()
|
||||||
__('Except on home page') => 2
|
->addContentOnly()
|
||||||
)
|
->addClass()
|
||||||
);
|
->addOffline();
|
||||||
$w->blogAnniv->setting('content_only',__('Content only'),0,'check');
|
}
|
||||||
$w->blogAnniv->setting('class',__('CSS class:'),'');
|
|
||||||
$w->blogAnniv->setting('offline',__('Offline'),0,'check');
|
public static function BlogAnnivWidget($w)
|
||||||
}
|
{
|
||||||
}
|
if ($w->offline) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$w->checkHomeOnly(dcCore::app()->url->type)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ftdatecrea = $w->ftdatecrea;
|
||||||
|
//Si la date est vide nous recherchons la date en base
|
||||||
|
if (strlen(rtrim($ftdatecrea)) == 0) {
|
||||||
|
$jour = date('d', dcCore::app()->blog->creadt);
|
||||||
|
$mois = date('m', dcCore::app()->blog->creadt);
|
||||||
|
$annee = date('Y', dcCore::app()->blog->creadt);
|
||||||
|
$ftdatecrea = date('d/m/Y', dcCore::app()->blog->creadt);
|
||||||
|
} else {
|
||||||
|
[$jour, $mois, $annee] = explode('/', $ftdatecrea);
|
||||||
|
}
|
||||||
|
|
||||||
|
$jour = (int) $jour;
|
||||||
|
$mois = (int) $mois;
|
||||||
|
$annee = (int) $annee;
|
||||||
|
$nbrejours = 0;
|
||||||
|
$nbreannee = 0;
|
||||||
|
// Test si la date est valide
|
||||||
|
if (@checkdate($mois, $jour, $annee)) {
|
||||||
|
// Ok nous pouvons calculer la date anniversaire et le nombre de jours restant avant
|
||||||
|
|
||||||
|
//Extraction des données
|
||||||
|
$jour2 = (int) date('d');
|
||||||
|
$mois2 = (int) date('m');
|
||||||
|
$annee2 = (int) date('Y');
|
||||||
|
|
||||||
|
//Calcul des timestamp
|
||||||
|
$timestamp1 = mktime(0, 0, 0, $mois, $jour, $annee2); // La date anniversaire cette année
|
||||||
|
$timestamp2 = mktime(0, 0, 0, $mois2, $jour2, $annee2);
|
||||||
|
//Affichage du nombre de jour
|
||||||
|
|
||||||
|
//je regarde si la date anniv n'est pas passé
|
||||||
|
if (($timestamp2 - $timestamp1) > 0) {
|
||||||
|
$timestamp1 = mktime(0, 0, 0, $mois, $jour, $annee2 + 1);
|
||||||
|
$nbrejours = round(abs(mktime(0, 0, 0, $mois2, $jour2, $annee2) - $timestamp1) / 86400);
|
||||||
|
$nbreannee = abs($annee2 - $annee);
|
||||||
|
} else {
|
||||||
|
$nbrejours = abs($timestamp2 - $timestamp1) / 86400;
|
||||||
|
$nbreannee = abs($annee2 - $annee - 1);
|
||||||
|
}
|
||||||
|
// abs($timestamp2 - $timestamp1)/(86400*7); //Affichage du nombre de semaine : 3.85
|
||||||
|
} else {
|
||||||
|
// date invalide
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $w->renderDiv(
|
||||||
|
$w->content_only,
|
||||||
|
'bloganniv ' . $w->class,
|
||||||
|
'',
|
||||||
|
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
|
||||||
|
'<ul>' .
|
||||||
|
($w->dispyearborn ? '<li>' . __('Born:') . ' <span class="annivne">' . $ftdatecrea . '</span></li>' : '') .
|
||||||
|
($w->dispyear ? '<li>' . __('Age:') . ' <span class="annivan">' . $nbreannee . '</span> ' . __('year(s)') . '</li>' : '') .
|
||||||
|
'<li>' . __('Birthday in') . ' <span class="annivjrs">' . $nbrejours . '</span> ' . __('day(s)') . '</li>' .
|
||||||
|
'</ul>'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
<?php
|
|
||||||
# ***** BEGIN LICENSE BLOCK *****
|
|
||||||
#
|
|
||||||
# This file is part of DotClear.
|
|
||||||
#
|
|
||||||
# Plugin Bloganniv by Francis Trautmann
|
|
||||||
# Contributor: Pierre Van Glabeke
|
|
||||||
# Licensed under the GPL version 2.0 license.
|
|
||||||
# A copy of this license is available in LICENSE file at
|
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
||||||
#
|
|
||||||
# ***** END LICENSE BLOCK *****
|
|
||||||
if (!defined('DC_RC_PATH')) {return;}
|
|
||||||
class dateBlog
|
|
||||||
{
|
|
||||||
private $blog;
|
|
||||||
private $con;
|
|
||||||
|
|
||||||
public function __construct($blog)
|
|
||||||
{
|
|
||||||
$this->blog =& $blog;
|
|
||||||
$this->con =& $blog->con;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getdateBlog()
|
|
||||||
{
|
|
||||||
$req = "SELECT blog_creadt,blog_id ".
|
|
||||||
"FROM ".$this->blog->prefix."blog ".
|
|
||||||
"WHERE blog_id = '".$this->blog->con->escape($this->blog->id)."' and blog_status = 1";
|
|
||||||
try {
|
|
||||||
$rs = $this->con->select($req);
|
|
||||||
$rs = $rs->toStatic();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
throw $e;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $rs;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
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="bloganniv">
|
||||||
|
<name>Blog Anniv</name>
|
||||||
|
<version>1.6</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>
|
||||||
|
<da:details>https://plugins.dotaddict.org/dc2/details/bloganniv</da:details>
|
||||||
|
<da:support>https://github.com/JcDenis/bloganniv</da:support>
|
||||||
|
</module>
|
||||||
|
</modules>
|
|
@ -1,14 +1,14 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: \n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Project-Id-Version: bloganniv 1.6\n"
|
||||||
"POT-Creation-Date: \n"
|
"POT-Creation-Date: \n"
|
||||||
"PO-Revision-Date: \n"
|
"PO-Revision-Date: 2022-12-16T21:19:38+00:00\n"
|
||||||
"Last-Translator: brol <contact@brol.info>\n"
|
"Last-Translator: Jean-Crhistian Denis\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=iso-8859-1\n"
|
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"X-Generator: Poedit 1.5.7\n"
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
|
|
||||||
msgid "Counting the number of days before and after a particular date"
|
msgid "Counting the number of days before and after a particular date"
|
||||||
msgstr "Décompte du nombre de jours avant et après une date donnée"
|
msgstr "Décompte du nombre de jours avant et après une date donnée"
|
||||||
|
@ -36,3 +36,4 @@ msgstr "Anniversaire dans"
|
||||||
|
|
||||||
msgid "day(s)"
|
msgid "day(s)"
|
||||||
msgstr "jour(s)"
|
msgstr "jour(s)"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue