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;
}
require dirname(__FILE__).'/_widgets.php';
require dirname(__FILE__) . '/_widgets.php';
# Dashboard item and user preference
$core->addBehavior(
'adminDashboardItems',
array('dcLatestVersionsAdmin', 'adminDashboardItems')
['dcLatestVersionsAdmin', 'adminDashboardItems']
);
$core->addBehavior(
'adminDashboardOptionsForm',
array('dcLatestVersionsAdmin', 'adminDashboardOptionsForm')
['dcLatestVersionsAdmin', 'adminDashboardOptionsForm']
);
$core->addBehavior(
'adminAfterDashboardOptionsUpdate',
array('dcLatestVersionsAdmin', 'adminAfterDashboardOptionsUpdate')
['dcLatestVersionsAdmin', 'adminAfterDashboardOptionsUpdate']
);
/**
@ -43,19 +41,16 @@ 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);
$builds = explode(',', (string) $core->blog->settings->dcLatestVersions->builds);
if (empty($builds)) {
return null;
}
$text = __('<li><a href="%u" title="Download Dotclear %v">%r</a> : %v</li>');
$li = array();
$li = [];
foreach($builds as $build) {
@ -68,40 +63,37 @@ class dcLatestVersionsAdmin
DC_UPDATE_URL,
'dotclear',
$build,
DC_TPL_CACHE.'/versions'
DC_TPL_CACHE . '/versions'
);
if (false === $updater->check('0')) {
//return false;
continue;
}
$li[] = str_replace(
array(
[
'%r',
'%v',
'%u'
),
array(
],
[
$build,
$updater->getVersion(),
$updater->getFileURL()
),
],
$text
);
}
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 class="box small" id="udclatestversionsitems">' .
'<h3>' . html::escapeHTML(__("Dotclear's latest versions")) . '</h3>' .
'<ul>' . implode('', $li) . '</ul>' .
'</div>';
}
@ -117,12 +109,12 @@ class dcLatestVersionsAdmin
$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 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>';
}

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;
}
$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(
'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.6',
'dc_min' => '2.19',
'support' => 'http://forum.dotclear.org/viewforum.php?id=16',
'details' => 'http://plugins.dotaddict.org/dc2/details/dcLatestVersions'
)
'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(
$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;
}
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,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {
return null;
}
@ -21,7 +19,7 @@ $core->blog->settings->addNamespace('dcLatestVersions');
$core->addBehavior(
'initWidgets',
array('dcLatestVersionsWidget', 'adminWidget')
['dcLatestVersionsWidget', 'adminWidget']
);
/**
@ -33,48 +31,27 @@ class dcLatestVersionsWidget
{
public static function adminWidget($w)
{
$w->create(
$w
->create(
'dclatestversionswidget',
__("Dotclear's latest versions"),
array('dcLatestVersionsWidget','publicWidget'),
['dcLatestVersionsWidget','publicWidget'],
null,
__("Show the latest available versions of Dotclear")
);
$w->dclatestversionswidget->setting(
'title',
__('Title:'),
__("Dotclear's latest versions"),
'text'
);
$w->dclatestversionswidget->setting(
)
->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'
);
$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');
->addHomeOnly()
->addContentOnly()
->addClass()
->addOffline();
}
public static function publicWidget($w)
@ -83,14 +60,13 @@ class dcLatestVersionsWidget
$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 == ''
) {
if (($w->homeonly == 1 && !$core->url->isHome($core->url->type))
|| ($w->homeonly == 2 && $core->url->isHome($core->url->type))
|| $w->text == '') {
return null;
}
@ -98,11 +74,10 @@ class dcLatestVersionsWidget
$builds = (string) $core->blog->settings->dcLatestVersions->builds;
$builds = explode(',', $builds);
if (empty($builds)) {
return null;
}
$li = array();
$li = [];
foreach($builds as $build) {
$build = strtolower(trim($build));
@ -114,38 +89,38 @@ class dcLatestVersionsWidget
DC_UPDATE_URL,
'dotclear',
$build,
DC_TPL_CACHE.'/versions'
DC_TPL_CACHE . '/versions'
);
if (false === $updater->check('0')) {
continue;
}
$li[] = '<li>'.str_replace(
array(
$li[] = sprintf('<li>%s</li>', str_replace(
[
'%r',
'%v',
'%u'
),
array(
],
[
$build,
$updater->getVersion(),
$updater->getFileURL()
),
],
$w->text
).'</li>';
));
}
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);
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>