diff --git a/CHANGELOG.md b/CHANGELOG.md index 92a0b51..f8fd9a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,19 +1,23 @@ -v1.8.1 - 29-06-2015 - Pierre Van Glabeke +1.9 - 2022.12.17 +* update to dotclear 2.24 +* fix phpstan errors + +1.8.1 - 2015.06.29 - Pierre Van Glabeke * correction validation html -v1.8 - 08-06-2015 - Pierre Van Glabeke +1.8 - 2015.06.08 - Pierre Van Glabeke * ajout lien vers toutes les archives -v1.7 - 28-05-2015 - Kozlika & Nikrou +1.7 - 2015.05.28 - Kozlika & Nikrou * suppression d'image et gestion de l'indicateur via css * ajout de classes sur chaque liste (année/mois) * application de la class .open sur l'item ouvert par défaut * application de la class .open sur l'item correspondant au mois actif en cas de consulation des archives -v1.6 - 25-04-2015 - Pierre Van Glabeke +1.6 - 2015.04.25 - Pierre Van Glabeke * modif appel css * ajout localisation * ajout identification widget -v1.5 - 14-12-2014 - Pierre Van Glabeke +1.5 - 2014.12.14 - Pierre Van Glabeke * compatibilité dc2.7 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 9ee38ee..51b481f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,44 @@ -# shortArchives +# README -Widget d'affichage des archives pour le blog des news de Dotclear. Le principe de l'accordéon originel revisité pour un affichage des mois à côté de la date "ouverte". +[![Release](https://img.shields.io/github/v/release/JcDenis/shortArchives)](https://github.com/JcDenis/shortArchives/releases) +[![Date](https://img.shields.io/github/release-date/JcDenis/shortArchives)](https://github.com/JcDenis/shortArchives/releases) +[![Issues](https://img.shields.io/github/issues/JcDenis/shortArchives)](https://github.com/JcDenis/shortArchives/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/shortArchives) +[![License](https://img.shields.io/github/license/JcDenis/shortArchives)](https://github.com/JcDenis/shortArchives/blob/master/LICENSE) -Todo: +## WHAT IS SHORTARCHIVES ? -* Ajouter les attributs ARIA kivonbien. +_shortArchives_ is a plugin for the open-source +web publishing software called Dotclear. + +Add a public widget that list links to archives by year. + +## REQUIREMENTS + + _shortArchives_ requires: + + * content admin permissions to manage widgets + * Dotclear 2.24 + +## USAGE + +First install _shortArchives_, manualy from a zip package or from +Dotaddict repository. (See Dotclear's documentation to know how do this) + +You should add widget to show lunar phases on your blog. + +## LINKS + + * License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html) + * Source & contribution : [GitHub Page](https://github.com/JcDenis/shortArchives) + * Packages & details : [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/shortArchives) + * Discuss and help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?pid=321044#p321044) + +## CONTRIBUTORS + + * annso (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 5d76ab5..0448cf0 100644 --- a/_admin.php +++ b/_admin.php @@ -1,15 +1,17 @@ registerModule( - /* Name */ "shortArchives", - /* Description*/ "Display blog archives in an accordion menu, sorted by year", - /* Author */ "annso, Pierre Van Glabeke", - /* Version */ "1.8.1", - /* Properties */ - array( - 'permissions' => 'usage,contentadmin', - 'type' => 'plugin', - 'dc_min' => '2.7', - 'support' => 'http://forum.dotclear.org/viewtopic.php?pid=321044#p321044', - 'details' => 'http://plugins.dotaddict.org/dc2/details/shortArchives' - ) -); \ No newline at end of file + 'shortArchives', + 'Display blog archives in an accordion menu, sorted by year', + 'annso, Pierre Van Glabeke and Contributors', + '1.9', + [ + 'requires' => [['core', '2.24']], + 'permissions' => dcCore::app()->auth->makePermissions([ + dcAuth::PERMISSION_ADMIN, + ]), + 'type' => 'plugin', + 'support' => 'http://forum.dotclear.org/viewtopic.php?pid=321044#p321044', + 'details' => 'http://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 d67ce7e..1b8fd4e 100644 --- a/_public.php +++ b/_public.php @@ -1,93 +1,23 @@ addBehavior('publicHeadContent',array('publicShortArchives','publicHeadContent')); - -class publicShortArchives -{ - public static function publicHeadContent($core) - { - $url = $core->blog->getQmarkURL().'pf='.basename(dirname(__FILE__)); - echo ''."\n"; - echo '\n"; - } +/** + * @brief shortArchives, a plugin for Dotclear 2 + * + * @package Dotclear + * @subpackage Plugin + * + * @author annso, Pierre Van Glabeke and Contributors + * + * @copyright Jean-Crhistian Denis + * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html + */ +if (!defined('DC_RC_PATH')) { + return null; } -class tplShortArchives -{ - public static function shortArchivesWidgets($w) - { - global $core; +require __DIR__ . '/_widgets.php'; - if ($w->offline) - return; - - if (($w->homeonly == 1 && $core->url->type != 'default') || - ($w->homeonly == 2 && $core->url->type == 'default')) { - return; - } - - $params = array(); - $params['type'] = 'month'; - $rs = $core->blog->getDates($params); - unset($params); - if ($rs->isEmpty()) { - return; - } - - $active_year = null; - if (($core->url->type == 'archive') && preg_match('`^/([0-9]{4})/([0-9]{2})$`',$core->url->args,$matches)) { - $active_year = $matches[1]; - } - - $posts = array(); - while ($rs->fetch()) { - $posts[dt::dt2str(__('%Y'),$rs->dt)][] = array('url' => $rs->url($core), - 'date' => html::escapeHTML(dt::dt2str(__('%B'),$rs->dt)), - 'nbpost' => $rs->nb_post); - } - - $res = - ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : ''). - '
    '; - - foreach($posts as $annee => $post) { - if (!is_null($active_year) && $active_year == $annee) { - $res .= '
  • '; - } else { - $res .= '
  • '; - } - $res .= ''.$annee.'
      '; - for($i=0; $i'.$post[$i]['date'].''. - ($w->postcount ? ' ('.$post[$i]['nbpost'].')' : ''). - ''; - } - $res .= '
  • '; - } - $res .= '
'; - - if ($core->url->getBase('archive') && !is_null($w->allarchivesslinktitle) && $w->allarchivesslinktitle !== '') - { - $res .= - '

'. - html::escapeHTML($w->allarchivesslinktitle).'

'; - } - - return $w->renderDiv($w->content_only,'shortArchives '.$w->class,'',$res); - } -} +dcCore::app()->addBehavior('publicHeadContent', function () { + echo + dcUtils::jsModuleLoad(basename(__DIR__) . '/js/accordion.js') . + dcUtils::cssModuleLoad(basename(__DIR__) . '/css/shortArchives.css'); +}); diff --git a/_widgets.php b/_widgets.php index 979dfd9..871732b 100644 --- a/_widgets.php +++ b/_widgets.php @@ -1,37 +1,98 @@ addBehavior('initWidgets',array('shortArchivesWidgets','initWidgets')); +dcCore::app()->addBehavior('initWidgets', ['shortArchivesWidgets','initWidgets']); class shortArchivesWidgets { - public static function initWidgets($w) - { - $w->create('shortArchives',__('Short Archives'), array('tplShortArchives','shortArchivesWidgets'), - null, - __('Blog Archive List an accordion menu, sorted by year')); - $w->shortArchives->setting('title',__('Title:'),__('Archives')); - $w->shortArchives->setting('postcount',__('With entries counts'),1,'check'); - $w->shortArchives->setting('allarchivesslinktitle',__('Link to all archives:'),__('All archives')); - $w->shortArchives->setting('homeonly',__('Display on:'),0,'combo', - array( - __('All pages') => 0, - __('Home page only') => 1, - __('Except on home page') => 2 - ) - ); - $w->shortArchives->setting('content_only',__('Content only'),0,'check'); - $w->shortArchives->setting('class',__('CSS class:'),''); - $w->shortArchives->setting('offline',__('Offline'),0,'check'); - } -} \ No newline at end of file + public static function initWidgets($w) + { + $w->create( + 'shortArchives', + __('Short Archives'), + ['shortArchivesWidgets', 'shortArchivesWidgets'], + null, + __('Blog Archive List an accordion menu, sorted by year') + ) + ->addTitle(__('Archives')) + ->setting('postcount', __('With entries counts'), 1, 'check') + ->setting('allarchivesslinktitle', __('Link to all archives:'), __('All archives')) + ->addHomeOnly() + ->addContentOnly() + ->addClass() + ->addOffline(); + } + + public static function shortArchivesWidgets($w) + { + if ($w->offline) { + return; + } + + if (!$w->checkHomeOnly(dcCore::app()->url->type)) { + return; + } + + $rs = dcCore::app()->blog->getDates(['type' => 'month']); + if ($rs->isEmpty()) { + return; + } + + $active_year = null; + if ((dcCore::app()->url->type == 'archive') && preg_match('`^/([0-9]{4})/([0-9]{2})$`', dcCore::app()->url->args, $matches)) { + $active_year = $matches[1]; + } + + $posts = []; + while ($rs->fetch()) { + $posts[dt::dt2str(__('%Y'), $rs->dt)][] = [ + 'url' => $rs->url(), + 'date' => html::escapeHTML(dt::dt2str(__('%B'), $rs->dt)), + 'nbpost' => $rs->nb_post, + ]; + } + + $res = '
    '; + + foreach ($posts as $annee => $post) { + if (!is_null($active_year) && $active_year == $annee) { + $res .= '
  • '; + } else { + $res .= '
  • '; + } + $res .= '' . $annee . '
      '; + for ($i = 0; $i < sizeof($post); $i++) { + $res .= '
    • ' . $post[$i]['date'] . '' . + ($w->postcount ? ' (' . $post[$i]['nbpost'] . ')' : '') . + '
    • '; + } + $res .= '
  • '; + } + $res .= '
'; + + if (dcCore::app()->url->getBase('archive') && !is_null($w->allarchivesslinktitle) && $w->allarchivesslinktitle !== '') { + $res .= '

' . + html::escapeHTML($w->allarchivesslinktitle) . '

'; + } + + return $w->renderDiv( + $w->content_only, + 'shortArchives ' . $w->class, + '', + ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . $res + ); + } +} diff --git a/dcstore.xml b/dcstore.xml new file mode 100644 index 0000000..9876e07 --- /dev/null +++ b/dcstore.xml @@ -0,0 +1,13 @@ + + + + shortArchives + 1.9 + annso, Pierre Van Glabeke and Contributors + Display blog archives in an accordion menu, sorted by year + https://github.com/JcDenis/shortArchives/releases/download/v1.9/plugin-shortArchives.zip + 2.24 + http://plugins.dotaddict.org/dc2/details/shortArchives + http://forum.dotclear.org/viewtopic.php?pid=321044#p321044 + + diff --git a/locales/fr/main.po b/locales/fr/main.po index 3b71915..b910e27 100644 --- a/locales/fr/main.po +++ b/locales/fr/main.po @@ -1,16 +1,14 @@ msgid "" msgstr "" "Content-Type: text/plain; charset=UTF-8\n" -"Project-Id-Version: \n" +"Project-Id-Version: shortArchives 1.9\n" "POT-Creation-Date: \n" -"PO-Revision-Date: \n" -"Last-Translator: brol \n" +"PO-Revision-Date: 2022-12-16T22:00:09+00:00\n" +"Last-Translator: Jean-Crhistian Denis\n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Transfer-Encoding: 8bit\n" - -msgid "Display blog archives in an accordion menu, sorted by year" -msgstr "Afficher les archives du blog dans un menu accordéon, trié par années" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" msgid "Blog Archive List an accordion menu, sorted by year" msgstr "Liste des archives du blog dans un menu accordéon, trié par années" @@ -21,3 +19,6 @@ msgstr "Lien vers toutes les archives :" msgid "All archives" msgstr "Toutes les archives" +msgid "Display blog archives in an accordion menu, sorted by year" +msgstr "Afficher les archives du blog dans un menu accordéon, trié par années" +