cleanup 2021

master
Jean-Christian Paul Denis 2021-08-27 17:53:07 +02:00
parent 0df4067d6a
commit 5793a5a927
9 changed files with 243 additions and 269 deletions

View File

@ -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

20
CHANGELOG.md 100644
View File

@ -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

View File

@ -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

View File

@ -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 = __('<li><a href="%u" title="Download Dotclear %v">%r</a> : %v</li>');
$li = [];
return null;
}
foreach($builds as $build) {
$text = __('<li><a href="%u" title="Download Dotclear %v">%r</a> : %v</li>');
$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][] =
'<div class="box small" id="udclatestversionsitems">' .
'<h3>' . html::escapeHTML(__("Dotclear's latest versions")) . '</h3>' .
'<ul>' . implode('', $li) . '</ul>' .
'</div>';
}
//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
'<div class="fieldset">' .
'<h4>' . __("Dotclear's latest versions") . '</h4>' .
'<p><label class="classic" for="dcLatestVersionsItems">' .
form::checkbox('dcLatestVersionsItems', 1, $pref) . ' ' .
__("Show Dotclear's latest versions on dashboards.") .
'</label></p>' .
'</div>';
}
if (empty($li)) {
return null;
}
# Display
$__dashboard_items[0][] =
'<div class="box small" id="udclatestversionsitems">'.
'<h3>'.html::escapeHTML(__("Dotclear's latest versions")).'</h3>'.
'<ul>'.implode('', $li).'</ul>'.
'</div>';
}
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
'<div class="fieldset">'.
'<h4>'.__("Dotclear's latest versions").'</h4>'.
'<p><label class="classic" for="dcLatestVersionsItems">'.
form::checkbox('dcLatestVersionsItems', 1, $pref).' '.
__("Show Dotclear's latest versions on dashboards.").
'</label></p>'.
'</div>';
}
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'
);
}
}

View File

@ -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'
]
);

View File

@ -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;
}

View File

@ -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';
require dirname(__FILE__) . '/_widgets.php';

View File

@ -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):'),
__('<strong>%r: </strong> <a href="%u" title="Download Dotclear %v">%v</a>'),
'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):'),
__('<strong>%r: </strong> <a href="%u" title="Download Dotclear %v">%v</a>'),
'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('<li>%s</li>', str_replace(
[
'%r',
'%v',
'%u'
],
[
$build,
$updater->getVersion(),
$updater->getFileURL()
],
$w->text
));
}
$li[] = '<li>'.str_replace(
array(
'%r',
'%v',
'%u'
),
array(
$build,
$updater->getVersion(),
$updater->getFileURL()
),
$w->text
).'</li>';
}
if (empty($li)) {
return null;
}
if (empty($li)) {
return null;
}
# Display
$res =
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
'<ul>'.implode('',$li).'</ul>';
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('<ul>%s</ul>', implode('',$li))
);
}
}

13
dcstore.xml 100644
View File

@ -0,0 +1,13 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="dcLatestVersions">
<name>dcLatestVersions</name>
<version>2021.08.27</version>
<author>Jean-Christian Denis, Pierre Van Glabeke</author>
<desc>Show the latest available versions of Dotclear</desc>
<file>https://github.com/JcDenis/dcLatestVersions/releases/download/v2021.08.27/plugin-dcLatestVersions.zip</file>
<da:dcmin>2.19</da:dcmin>
<da:details>http://plugins.dotaddict.org/dc2/details/dcLatestVersions</da:details>
<da:section></da:section>
<da:support>http://forum.dotclear.org/viewforum.php?id=16</da:support>
</module>
</modules>