From c4022ad99604d10afe6324eed247c9d364ca3800 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Fri, 16 Dec 2022 22:27:11 +0100 Subject: [PATCH] release 1.6 for dotclear 2.24 --- CHANGELOG.md | 24 ++++--- LICENSE | 23 +++---- README.md | 49 ++++++++++++-- _admin.php | 29 ++++---- _define.php | 55 ++++++++------- _public.php | 151 +++++------------------------------------- _widgets.php | 137 ++++++++++++++++++++++++++++---------- class.dc.dateBlog.php | 41 ------------ dcstore.xml | 13 ++++ locales/fr/main.po | 11 +-- 10 files changed, 249 insertions(+), 284 deletions(-) delete mode 100644 class.dc.dateBlog.php create mode 100644 dcstore.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a89bd5..30d2217 100644 --- a/CHANGELOG.md +++ b/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 * modifs localisation -v 1.5 - Pierre Van Glabeke +1.5 - Pierre Van Glabeke * compatibilité dc2.7 -v 1.4.1 - Pierre Van Glabeke +1.4.1 - Pierre Van Glabeke * Ajustements settings * 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) -v 1.3.1 +1.3.1 * Ajout choix affichage page pour le widget (content only + css) -v 1.3 +1.3 * Ajout choix affichage page pour le widget * Correction de traduction -v 1.2 +1.2 * Ajout du piochage automatique de la date du blog si non saisie dans le widget * Ajout @ devant la fonction checkdate pour eviter un warning -v 1.1 +1.1 * Compatibilité dc2.2 * Localisation * 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 \ No newline at end of file diff --git a/LICENSE b/LICENSE index 8cdb845..d511905 100644 --- a/LICENSE +++ b/LICENSE @@ -1,12 +1,12 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 - Copyright (C) 1989, 1991 Free Software Foundation, Inc., + Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble + Preamble The licenses for most software are designed to take away your 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 modification follow. - GNU GENERAL PUBLIC LICENSE + GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 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 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 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 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 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 the "copyright" line and a pointer to where the full notice is found. - {description} - Copyright (C) {year} {fullname} + + Copyright (C) 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 @@ -329,7 +329,7 @@ necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. - {signature of Ty Coon}, 1 April 1989 + , 1 April 1989 Ty Coon, President of Vice 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 library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. - diff --git a/README.md b/README.md index 61a695d..e74fb9d 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,46 @@ -# bloganniv -Décompte du nombre de jours avant et après une date donnée +# README -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), -* l'âge en années, -* le nombre de jours restant avant et après l'anniversaire de la date. +## WHAT IS BLOGANNIV ? +_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. \ No newline at end of file diff --git a/_admin.php b/_admin.php index d1b0c5b..9b33927 100644 --- a/_admin.php +++ b/_admin.php @@ -1,16 +1,17 @@ registerModule( - /* Name */ "Blog Anniv", - /* Description*/ "Counting the number of days before and after a particular date", - /* Author */ "Fran6t, Pierre Van Glabeke", - /* Version */ '1.5.1', - /* Properties */ - array( - 'permissions' => 'blogAnniv', - 'type' => 'plugin', - 'dc_min' => '2.7', - 'support' => 'http://www.myouaibe.com/index.php/post/2007/08/23/Plugin-BlogAnniv-pour-DOTCLEAR-2', - 'details' => 'http://plugins.dotaddict.org/dc2/details/bloganniv' - ) -); \ No newline at end of file + 'Blog Anniv', + 'Counting the number of days before and after a particular date', + 'Fran6t, Pierre Van Glabeke and Contributors', + '1.6', + [ + 'requires' => [['core', '2.24']], + 'permissions' => dcCore::app()->auth->makePermissions([ + dcAuth::PERMISSION_ADMIN, + ]), + 'type' => 'plugin', + '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', + ] +); diff --git a/_public.php b/_public.php index 2ab54e5..209018d 100644 --- a/_public.php +++ b/_public.php @@ -1,138 +1,17 @@ tpl->addValue('blogAnniv',array('tplBlogAnniv','blogAnniv')); - -class tplBlogAnniv -{ - - public static function blogAnniv($attr) - { - $output = ''; - - if (isset($attr['text'])) - { - $author = isset($attr['author']) ? ' '.$attr['author'].'' : ''; - - $output = '
'.$attr['text'].$author.'
'; - } - - 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 = '
  • '.__('Born:'). - ' '.$ftdatecrea.'
  • '; - } - // Si je dois afficher l'age en année - if ($w->dispyear) { - $dispyear = '
  • '.__('Age:'). - ' '.$nbreannee.' '. - __('year(s)'). - '
  • '; - } - - $res = - ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : ''). - '
      '. - $dispyearborn. - $dispyear. - '
    • '.__('Birthday in'). - ' '.$nbrejours.' '. - __('day(s)').'
    '; - - return $w->renderDiv($w->content_only,'bloganniv '.$w->class,'',$res); - - } -} \ No newline at end of file +require __DIR__ . '/_widgets.php'; diff --git a/_widgets.php b/_widgets.php index fdf2a6d..313634b 100644 --- a/_widgets.php +++ b/_widgets.php @@ -1,40 +1,107 @@ addBehavior('initWidgets',array('blogAnnivWidgets','initWidgets')); +dcCore::app()->addBehavior('initWidgets', ['blogAnnivWidgets', 'initWidgets']); class blogAnnivWidgets { - public static function initWidgets($w) - { - global $core; - $w->create('blogAnniv',__('Blog Anniv'),array('tplBlogAnniv','BlogAnnivWidget'), - null, - __('Counting the number of days before and after a particular date')); - $w->blogAnniv->setting('title',__('Title :'),''); - $w->blogAnniv->setting('ftdatecrea',__('Born Date (dd/mm/yyyy) or blank:'),''); - $w->blogAnniv->setting('dispyearborn',__('Display Born Date'),1,'check'); - $w->blogAnniv->setting('dispyear',__('Display Year(s) Old'),1,'check'); - $w->blogAnniv->setting('homeonly',__('Display on:'),0,'combo', - array( - __('All pages') => 0, - __('Home page only') => 1, - __('Except on home page') => 2 - ) - ); - $w->blogAnniv->setting('content_only',__('Content only'),0,'check'); - $w->blogAnniv->setting('class',__('CSS class:'),''); - $w->blogAnniv->setting('offline',__('Offline'),0,'check'); - } -} \ No newline at end of file + public static function initWidgets($w) + { + $w->create( + 'blogAnniv', + __('Blog Anniv'), + ['blogAnnivWidgets', 'BlogAnnivWidget'], + null, + __('Counting the number of days before and after a particular date') + ) + ->addTitle('') + ->setting('ftdatecrea', __('Born Date (dd/mm/yyyy) or blank:'), '') + ->setting('dispyearborn', __('Display Born Date'), 1, 'check') + ->setting('dispyear', __('Display Year(s) Old'), 1, 'check') + ->addHomeOnly() + ->addContentOnly() + ->addClass() + ->addOffline(); + } + + 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)) : '') . + '
      ' . + ($w->dispyearborn ? '
    • ' . __('Born:') . ' ' . $ftdatecrea . '
    • ' : '') . + ($w->dispyear ? '
    • ' . __('Age:') . ' ' . $nbreannee . ' ' . __('year(s)') . '
    • ' : '') . + '
    • ' . __('Birthday in') . ' ' . $nbrejours . ' ' . __('day(s)') . '
    • ' . + '
    ' + ); + } +} diff --git a/class.dc.dateBlog.php b/class.dc.dateBlog.php deleted file mode 100644 index 9df0596..0000000 --- a/class.dc.dateBlog.php +++ /dev/null @@ -1,41 +0,0 @@ -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; - - } -} \ No newline at end of file diff --git a/dcstore.xml b/dcstore.xml new file mode 100644 index 0000000..288fccf --- /dev/null +++ b/dcstore.xml @@ -0,0 +1,13 @@ + + + + Blog Anniv + 1.6 + Fran6t, Pierre Van Glabeke and Contributors + Counting the number of days before and after a particular date + https://github.com/JcDenis/bloganniv/releases/download/v1.6/plugin-bloganniv.zip + 2.24 + https://plugins.dotaddict.org/dc2/details/bloganniv + https://github.com/JcDenis/bloganniv + + diff --git a/locales/fr/main.po b/locales/fr/main.po index 9680049..c80d38a 100644 --- a/locales/fr/main.po +++ b/locales/fr/main.po @@ -1,14 +1,14 @@ msgid "" msgstr "" -"Project-Id-Version: \n" +"Content-Type: text/plain; charset=UTF-8\n" +"Project-Id-Version: bloganniv 1.6\n" "POT-Creation-Date: \n" -"PO-Revision-Date: \n" -"Last-Translator: brol \n" +"PO-Revision-Date: 2022-12-16T21:19:38+00:00\n" +"Last-Translator: Jean-Crhistian Denis\n" "Language-Team: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=iso-8859-1\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" 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)" msgstr "jour(s)" +