diff --git a/CHANGELOG b/CHANGELOG deleted file mode 100644 index 3055fe4..0000000 --- a/CHANGELOG +++ /dev/null @@ -1,15 +0,0 @@ -2020-09-18 - Pierre Van Glabeke -* modif _admin.php (merci à nanart) - -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/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..6e4d1b5 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,20 @@ +2021.08.27 +- cleanup (PSR2,short array, ...) +- enhance widget style +- update license + +2020.09.18 - Pierre Van Glabeke +- modif admin.php (merci à nanart) + +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/README.md b/README.md index 4fd59d5..0804ced 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,14 @@ 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. + +## MORE + + * License : GNU GPL v2 + * Source & contribution : [GitHub Page](https://github.com/JcDenis/dcLatestVersions) + * Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/dcLatestVersions) + +## CONTRIBUTORS + + * Jean-Chirstian Denis + * Pierre Van Glabeke diff --git a/_admin.php b/_admin.php index 3232b61..d0a0ce8 100644 --- a/_admin.php +++ b/_admin.php @@ -3,8 +3,7 @@ # # This file is part of dcLatestVersions, a plugin for Dotclear 2. # -# Copyright (c) 2009-2015 Jean-Christian Denis and contributors -# contact@jcdenis.fr http://jcd.lv +# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # # Licensed under the GPL version 2.0 license. # A copy of this license is available in LICENSE file or at @@ -13,24 +12,23 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_CONTEXT_ADMIN')) { - - return null; + return null; } -require dirname(__FILE__).'/_widgets.php'; +require dirname(__FILE__) . '/_widgets.php'; # Dashboard item and user preference $core->addBehavior( - 'adminDashboardItems', - array('dcLatestVersionsAdmin', 'adminDashboardItems') + 'adminDashboardItems', + ['dcLatestVersionsAdmin', 'adminDashboardItems'] ); $core->addBehavior( - 'adminDashboardOptionsForm', - array('dcLatestVersionsAdmin', 'adminDashboardOptionsForm') + 'adminDashboardOptionsForm', + ['dcLatestVersionsAdmin', 'adminDashboardOptionsForm'] ); $core->addBehavior( - 'adminAfterDashboardOptionsUpdate', - array('dcLatestVersionsAdmin', 'adminAfterDashboardOptionsUpdate') + 'adminAfterDashboardOptionsUpdate', + ['dcLatestVersionsAdmin', 'adminAfterDashboardOptionsUpdate'] ); /** @@ -40,98 +38,92 @@ $core->addBehavior( */ class dcLatestVersionsAdmin { - public static function adminDashboardItems(dcCore $core, $__dashboard_items) - { - if (!$core->auth->user_prefs->dashboard->get('dcLatestVersionsItems')) { + public static function adminDashboardItems(dcCore $core, $__dashboard_items) + { + if (!$core->auth->user_prefs->dashboard->get('dcLatestVersionsItems')) { + return null; + } - return null; - } + $builds = explode(',', (string) $core->blog->settings->dcLatestVersions->builds); + if (empty($builds)) { + return null; + } - $builds = (string) $core->blog->settings->dcLatestVersions->builds; - $builds = explode(',', $builds); - if (empty($builds)) { + $text = __('
  • %r : %v
  • '); + $li = []; - return null; - } + foreach($builds as $build) { - $text = __('
  • %r : %v
  • '); - $li = array(); + $build = strtolower(trim($build)); + if (empty($build)) { + continue; + } - foreach($builds as $build) { + $updater = new dcUpdate( + DC_UPDATE_URL, + 'dotclear', + $build, + DC_TPL_CACHE . '/versions' + ); - $build = strtolower(trim($build)); - if (empty($build)) { - continue; - } + if (false === $updater->check('0')) { + continue; + } - $updater = new dcUpdate( - DC_UPDATE_URL, - 'dotclear', - $build, - DC_TPL_CACHE.'/versions' - ); + $li[] = str_replace( + [ + '%r', + '%v', + '%u' + ], + [ + $build, + $updater->getVersion(), + $updater->getFileURL() + ], + $text + ); + } - if (false === $updater->check('0')) { + if (empty($li)) { + return null; + } + + # Display + $__dashboard_items[0][] = + '
    ' . + '

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

    ' . + '' . + '
    '; + } - //return false; - continue; - } + 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'); - $li[] = str_replace( - array( - '%r', - '%v', - '%u' - ), - array( - $build, - $updater->getVersion(), - $updater->getFileURL() - ), - $text - ); - } + echo + '
    ' . + '

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

    ' . + '

    ' . + '
    '; + } - if (empty($li)) { - - return null; - } - - # Display - $__dashboard_items[0][] = - '
    '. - '

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

    '. - ''. - '
    '; - } - - 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' - ); - } + 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 index cfa3b84..c49d5c3 100644 --- a/_define.php +++ b/_define.php @@ -3,8 +3,7 @@ # # This file is part of dcLatestVersions, a plugin for Dotclear 2. # -# Copyright (c) 2009-2015 Jean-Christian Denis and contributors -# contact@jcdenis.fr http://jcd.lv +# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # # Licensed under the GPL version 2.0 license. # A copy of this license is available in LICENSE file or at @@ -13,25 +12,20 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_RC_PATH')) { - - return null; + return null; } - + $this->registerModule( - /* Name */ - "dcLatestVersions", - /* Description*/ - "Show the latest available versions of Dotclear", - /* Author */ - "Jean-Christian Denis, Pierre Van Glabeke", - /* Version */ - '2020-09-18', - /* 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' - ) + 'dcLatestVersions', + 'Show the latest available versions of Dotclear', + 'Jean-Christian Denis, Pierre Van Glabeke', + '2021.08.27', + [ + 'permissions' => 'usage,contentadmin', + 'type' => 'plugin', + 'dc_min' => '2.19', + 'support' => 'http://forum.dotclear.org/viewforum.php?id=16', + 'details' => 'http://plugins.dotaddict.org/dc2/details/dcLatestVersions', + 'repository' => 'https://raw.githubusercontent.com/JcDenis/dcLatestVersions/master/dcstore.xml' + ] ); \ No newline at end of file diff --git a/_install.php b/_install.php index 6e64a94..91a64cd 100644 --- a/_install.php +++ b/_install.php @@ -3,8 +3,7 @@ # # This file is part of dcLatestVersions, a plugin for Dotclear 2. # -# Copyright (c) 2009-2015 Jean-Christian Denis and contributors -# contact@jcdenis.fr http://jcd.lv +# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # # Licensed under the GPL version 2.0 license. # A copy of this license is available in LICENSE file or at @@ -13,37 +12,28 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_CONTEXT_ADMIN')) { - return null; } # -- Module specs -- - -$dc_min = '2.6'; +$dc_min = '2.19'; $mod_id = 'dcLatestVersions'; -$mod_conf = array( - array( - 'builds', - "List of Dotclear's builds", - 'stable,unstable,testing,sexy', - 'string' - ) -); +$mod_conf = [[ + 'builds', + "List of Dotclear's builds", + 'stable,unstable,testing,sexy', + 'string' +]]; # -- Nothing to change below -- - try { - # Check module version if (version_compare( $core->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)) { @@ -51,7 +41,6 @@ try { '%s requires Dotclear %s', $mod_id, $dc_min )); } - # Set module settings $core->blog->settings->addNamespace($mod_id); foreach($mod_conf as $v) { @@ -59,17 +48,14 @@ try { $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 index d915a5b..07744f3 100644 --- a/_public.php +++ b/_public.php @@ -3,8 +3,7 @@ # # This file is part of dcLatestVersions, a plugin for Dotclear 2. # -# Copyright (c) 2009-2015 Jean-Christian Denis and contributors -# contact@jcdenis.fr http://jcd.lv +# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # # Licensed under the GPL version 2.0 license. # A copy of this license is available in LICENSE file or at @@ -13,8 +12,7 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_RC_PATH')) { - - return null; + return null; } -require dirname(__FILE__).'/_widgets.php'; \ No newline at end of file +require dirname(__FILE__) . '/_widgets.php'; \ No newline at end of file diff --git a/_widgets.php b/_widgets.php index d9e6028..f269b4e 100644 --- a/_widgets.php +++ b/_widgets.php @@ -3,8 +3,7 @@ # # This file is part of dcLatestVersions, a plugin for Dotclear 2. # -# Copyright (c) 2009-2015 Jean-Christian Denis and contributors -# contact@jcdenis.fr http://jcd.lv +# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # # Licensed under the GPL version 2.0 license. # A copy of this license is available in LICENSE file or at @@ -13,15 +12,14 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_RC_PATH')) { - - return null; + return null; } $core->blog->settings->addNamespace('dcLatestVersions'); $core->addBehavior( - 'initWidgets', - array('dcLatestVersionsWidget', 'adminWidget') + 'initWidgets', + ['dcLatestVersionsWidget', 'adminWidget'] ); /** @@ -31,121 +29,98 @@ $core->addBehavior( */ 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 adminWidget($w) + { + $w + ->create( + 'dclatestversionswidget', + __("Dotclear's latest versions"), + ['dcLatestVersionsWidget','publicWidget'], + null, + __("Show the latest available versions of Dotclear") + ) + ->addTitle( + __("Dotclear's latest versions") + ) + ->setting( + 'text', + __('Text (%r = release, %v = version, %u = url):'), + __('%r: %v'), + 'text' + ) + ->addHomeOnly() + ->addContentOnly() + ->addClass() + ->addOffline(); + } - public static function publicWidget($w) - { - global $core; + public static function publicWidget($w) + { + global $core; - $core->blog->settings->addNamespace('dcLatestVersions'); + $core->blog->settings->addNamespace('dcLatestVersions'); - if ($w->offline) - return; + if ($w->offline) { + return null; + } - # Nothing to display - if ($w->homeonly == 1 && $core->url->type != 'default' - || $w->homeonly == 2 && $core->url->type == 'default' - || $w->text == '' - ) { - return null; - } + if (($w->homeonly == 1 && !$core->url->isHome($core->url->type)) + || ($w->homeonly == 2 && $core->url->isHome($core->url->type)) + || $w->text == '') { + return null; + } - # Builds to check - $builds = (string) $core->blog->settings->dcLatestVersions->builds; - $builds = explode(',', $builds); - if (empty($builds)) { + # Builds to check + $builds = (string) $core->blog->settings->dcLatestVersions->builds; + $builds = explode(',', $builds); + if (empty($builds)) { + return null; + } - return null; - } + $li = []; + foreach($builds as $build) { - $li = array(); - foreach($builds as $build) { + $build = strtolower(trim($build)); + if (empty($build)) { + continue; + } - $build = strtolower(trim($build)); - if (empty($build)) { - continue; - } + $updater = new dcUpdate( + DC_UPDATE_URL, + 'dotclear', + $build, + DC_TPL_CACHE . '/versions' + ); - $updater = new dcUpdate( - DC_UPDATE_URL, - 'dotclear', - $build, - DC_TPL_CACHE.'/versions' - ); + if (false === $updater->check('0')) { + continue; + } - if (false === $updater->check('0')) { - continue; - } + $li[] = sprintf('
  • %s
  • ', str_replace( + [ + '%r', + '%v', + '%u' + ], + [ + $build, + $updater->getVersion(), + $updater->getFileURL() + ], + $w->text + )); + } - $li[] = '
  • '.str_replace( - array( - '%r', - '%v', - '%u' - ), - array( - $build, - $updater->getVersion(), - $updater->getFileURL() - ), - $w->text - ).'
  • '; - } + if (empty($li)) { + return null; + } - if (empty($li)) { - - return null; - } - - # Display - $res = - ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : ''). - ''; - - return $w->renderDiv($w->content_only,'dclatestversionswidget '.$w->class,'',$res); - } + # Display + return $w->renderDiv( + $w->content_only, + 'dclatestversionswidget '. $w->class, + '', + ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . sprintf('', implode('',$li)) + ); + } } \ No newline at end of file diff --git a/dcstore.xml b/dcstore.xml new file mode 100644 index 0000000..940d4b2 --- /dev/null +++ b/dcstore.xml @@ -0,0 +1,13 @@ + + +dcLatestVersions +2021.08.27 +Jean-Christian Denis, Pierre Van Glabeke +Show the latest available versions of Dotclear +https://github.com/JcDenis/dcLatestVersions/releases/download/v2021.08.27/plugin-dcLatestVersions.zip +2.19 +http://plugins.dotaddict.org/dc2/details/dcLatestVersions + +http://forum.dotclear.org/viewforum.php?id=16 + + \ No newline at end of file