From ae6e76c8fbd72334066b1c9e63d5df08c309f196 Mon Sep 17 00:00:00 2001 From: brol Date: Wed, 22 Apr 2015 17:07:20 +0200 Subject: [PATCH] 2015-03-11 --- CHANGELOG | 12 ++++ LICENSE | 23 ++++--- README.md | 25 +++++++- _admin.php | 136 ++++++++++++++++++++++++++++++++++++++++ _define.php | 37 +++++++++++ _install.php | 75 ++++++++++++++++++++++ _public.php | 20 ++++++ _widgets.php | 151 +++++++++++++++++++++++++++++++++++++++++++++ locales/fr/main.po | 42 +++++++++++++ 9 files changed, 506 insertions(+), 15 deletions(-) create mode 100644 CHANGELOG create mode 100644 _admin.php create mode 100644 _define.php create mode 100644 _install.php create mode 100644 _public.php create mode 100644 _widgets.php create mode 100644 locales/fr/main.po diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..d62985c --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,12 @@ +2015-03-11 - Pierre Van Glabeke +* ajout mode hors ligne et codage titre widget (widget) +* encodage UNIX (LF) +* modif url de support +* modifs localisation +* suppression icône + +2013.11.18 - Jean-Christian Denis +* First hg release + +2013.07.22 - Jean-Christian Denis +* First release \ 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 92b98c9..4fd59d5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,23 @@ -# dcLatestVersions -Afficher les dernières versions disponibles de Dotclear +# README -Ce plugin ajoute simplement un élément sur le tableau de bord l'administration et un widget coté public indiquant les dernières versions (nightly build) de Dotclear. +## WHAT IS DCLATESTVERSION ? + +"Dotclear's latest versions" is a plugin for the open-source +web publishing software called Dotclear. + +Simply show visitors last versions of nightly build of Dotclear. + +## REQUIREMENTS + + dcLatestVersions requires: + + * permissions to manage widgets + * Dotclear 2.6 + +## USAGE + +First install dcLatestVersions, manualy from a zip package or from +Dotaddict repository. (See Dotclear's documentation to know how do this) + +Add and configure "Dotclear's latest versions" from widgets manager. +You can add a dashboard item by enable it from your dashboard preferences. diff --git a/_admin.php b/_admin.php new file mode 100644 index 0000000..f0b7590 --- /dev/null +++ b/_admin.php @@ -0,0 +1,136 @@ +addBehavior( + 'adminDashboardItems', + array('dcLatestVersionsAdmin', 'adminDashboardItems') +); +$core->addBehavior( + 'adminDashboardOptionsForm', + array('dcLatestVersionsAdmin', 'adminDashboardOptionsForm') +); +$core->addBehavior( + 'adminAfterDashboardOptionsUpdate', + array('dcLatestVersionsAdmin', 'adminAfterDashboardOptionsUpdate') +); + +/** + * @ingroup DC_PLUGIN_DCLATESTVERSIONS + * @brief Display latest versions of Dotclear - admin methods. + * @since 2.6 + */ +class dcLatestVersionsAdmin +{ + public static function adminDashboardItems(dcCore $core, $__dashboard_items) + { + if (!$core->auth->user_prefs->dashboard->get('dcLatestVersionsItems')) { + + return null; + } + + $builds = (string) $core->blog->settings->dcLatestVersions->builds; + $builds = explode(',', $builds); + if (empty($builds)) { + + return null; + } + + $text = __('
  • %r : %v
  • '); + $li = array(); + + foreach($builds as $build) { + + $build = strtolower(trim($build)); + if (empty($build)) { + continue; + } + + $updater = new dcUpdate( + DC_UPDATE_URL, + 'dotclear', + $build, + DC_TPL_CACHE.'/versions' + ); + + if (false === $updater->check('0')) { + + return false; + } + + $li[] = str_replace( + array( + '%r', + '%v', + '%u' + ), + array( + $build, + $updater->getVersion(), + $updater->getFileURL() + ), + $text + ); + } + + if (empty($li)) { + + return null; + } + + # Display + $__dashboard_items[0][] = + '
    '. + '

    '.html::escapeHTML(__("Dotclear's latest versions")).'

    '. + '
      '.implode('', $li).'
    '. + '
    '; + } + + public static function adminDashboardOptionsForm(dcCore $core) + { + if (!$core->auth->user_prefs->dashboard->prefExists('dcLatestVersionsItems')) { + $core->auth->user_prefs->dashboard->put( + 'dcLatestVersionsItems', + false, + 'boolean' + ); + } + $pref = $core->auth->user_prefs->dashboard->get('dcLatestVersionsItems'); + + echo + '
    '. + '

    '.__("Dotclear's latest versions").'

    '. + '

    '. + '
    '; + } + + public static function adminAfterDashboardOptionsUpdate($user_id) + { + $GLOBALS['core']->auth->user_prefs->dashboard->put( + 'dcLatestVersionsItems', + !empty($_POST['dcLatestVersionsItems']), + 'boolean' + ); + } +} \ No newline at end of file diff --git a/_define.php b/_define.php new file mode 100644 index 0000000..a953a0f --- /dev/null +++ b/_define.php @@ -0,0 +1,37 @@ +registerModule( + /* Name */ + "dcLatestVersions", + /* Description*/ + "Show the latest available versions of Dotclear", + /* Author */ + "Jean-Christian Denis, Pierre Van Glabeke", + /* Version */ + '2015-03-11', + /* Properies */ + array( + 'permissions' => 'usage,contentadmin', + 'type' => 'plugin', + 'dc_min' => '2.6', + 'support' => 'http://forum.dotclear.org/viewforum.php?id=16', + 'details' => 'http://plugins.dotaddict.org/dc2/details/dcLatestVersions' + ) +); \ No newline at end of file diff --git a/_install.php b/_install.php new file mode 100644 index 0000000..6e64a94 --- /dev/null +++ b/_install.php @@ -0,0 +1,75 @@ +getVersion($mod_id), + $core->plugins->moduleInfo($mod_id, 'version'), + '>=' + )) { + + return null; + } + + # Check Dotclear version + if (!method_exists('dcUtils', 'versionsCompare') + || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) { + throw new Exception(sprintf( + '%s requires Dotclear %s', $mod_id, $dc_min + )); + } + + # Set module settings + $core->blog->settings->addNamespace($mod_id); + foreach($mod_conf as $v) { + $core->blog->settings->{$mod_id}->put( + $v[0], $v[2], $v[3], $v[1], false, true + ); + } + + # Set module version + $core->setVersion( + $mod_id, + $core->plugins->moduleInfo($mod_id, 'version') + ); + + return true; +} +catch (Exception $e) { + $core->error->add($e->getMessage()); + + return false; +} \ No newline at end of file diff --git a/_public.php b/_public.php new file mode 100644 index 0000000..d915a5b --- /dev/null +++ b/_public.php @@ -0,0 +1,20 @@ +blog->settings->addNamespace('dcLatestVersions'); + +$core->addBehavior( + 'initWidgets', + array('dcLatestVersionsWidget', 'adminWidget') +); + +/** + * @ingroup DC_PLUGIN_DCLATESTVERSIONS + * @brief Display latest versions of Dotclear - widget methods. + * @since 2.6 + */ +class dcLatestVersionsWidget +{ + public static function adminWidget($w) + { + $w->create( + 'dclatestversionswidget', + __("Dotclear's latest versions"), + array('dcLatestVersionsWidget','publicWidget'), + null, + __("Show the latest available versions of Dotclear") + ); + $w->dclatestversionswidget->setting( + 'title', + __('Title:'), + __("Dotclear's latest versions"), + 'text' + ); + $w->dclatestversionswidget->setting( + 'text', + __('Text (%r = release, %v = version, %u = url):'), + __('%r: %v'), + 'text' + ); + $w->dclatestversionswidget->setting( + 'homeonly', + __('Display on:'), + 0, + 'combo', + array( + __('All pages') => 0, + __('Home page only') => 1, + __('Except on home page') => 2 + ) + ); + $w->dclatestversionswidget->setting( + 'content_only', + __('Content only'), + 0, + 'check' + ); + $w->dclatestversionswidget->setting( + 'class', + __('CSS class:'), + '' + ); + $w->dclatestversionswidget->setting('offline',__('Offline'),0,'check'); + } + + public static function publicWidget($w) + { + global $core; + + $core->blog->settings->addNamespace('dcLatestVersions'); + + if ($w->offline) + return; + + # Nothing to display + if ($w->homeonly == 1 && $core->url->type != 'default' + || $w->homeonly == 2 && $core->url->type == 'default' + || $w->text == '' + ) { + return null; + } + + # Builds to check + $builds = (string) $core->blog->settings->dcLatestVersions->builds; + $builds = explode(',', $builds); + if (empty($builds)) { + + return null; + } + + $li = array(); + foreach($builds as $build) { + + $build = strtolower(trim($build)); + if (empty($build)) { + continue; + } + + $updater = new dcUpdate( + DC_UPDATE_URL, + 'dotclear', + $build, + DC_TPL_CACHE.'/versions' + ); + + if (false === $updater->check('0')) { + continue; + } + + $li[] = '
  • '.str_replace( + array( + '%r', + '%v', + '%u' + ), + array( + $build, + $updater->getVersion(), + $updater->getFileURL() + ), + $w->text + ).'
  • '; + } + + if (empty($li)) { + + return null; + } + + # Display + $res = + ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : ''). + '
      '.implode('',$li).'
    '; + + return $w->renderDiv($w->content_only,'dclatestversionswidget '.$w->class,'',$res); + } +} \ No newline at end of file diff --git a/locales/fr/main.po b/locales/fr/main.po new file mode 100644 index 0000000..ad8dfed --- /dev/null +++ b/locales/fr/main.po @@ -0,0 +1,42 @@ +# Language: Français +# Module: dcLatestVersions - 2013.11.18 +# Date: 2013-11-18 23:07:16 +# Translated with translater 2013.05.11 + +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Project-Id-Version: dcLatestVersions 2013.11.18\n" +"POT-Creation-Date: \n" +"PO-Revision-Date: 2013-11-18T23:07:16+00:00\n" +"Last-Translator: Jean-Christian Denis\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Transfer-Encoding: 8bit\n" + +#: _admin.php:57 +msgid "
  • %r : %v
  • " +msgstr "
  • %r : %v
  • " + +#: _admin.php:102 +#: _admin.php:120 +#: _widgets.php:32 +#: _widgets.php:40 +msgid "Dotclear's latest versions" +msgstr "Dernières versions de Dotclear" + +#: _admin.php:123 +msgid "Show Dotclear's latest versions on dashboards." +msgstr "Afficher les dernières versions de Dotclear sur le tableau de bord" + +#: _widgets.php:35 +msgid "Show the latest available versions of Dotclear" +msgstr "Afficher les dernières versions disponibles de Dotclear" + +#: _widgets.php:45 +msgid "Text (%r = release, %v = version, %u = url):" +msgstr "Texte (%r = type, %v = version, %u = url) :" + +#: _widgets.php:46 +msgid "%r: %v" +msgstr "%r : %v" \ No newline at end of file