prepare to DC 2.24

master
Jean-Christian Paul Denis 2022-11-16 23:03:38 +01:00
parent 5793a5a927
commit 8b441a2989
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
5 changed files with 111 additions and 99 deletions

View File

@ -1,10 +1,11 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of dcLatestVersions, a plugin for Dotclear 2.
#
#
# 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
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@ -15,18 +16,18 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
require dirname(__FILE__) . '/_widgets.php';
require __DIR__ . '/_widgets.php';
# Dashboard item and user preference
$core->addBehavior(
'adminDashboardItems',
dcCore::app()->addBehavior(
'adminDashboardItemsV2',
['dcLatestVersionsAdmin', 'adminDashboardItems']
);
$core->addBehavior(
'adminDashboardOptionsForm',
dcCore::app()->addBehavior(
'adminDashboardOptionsFormV2',
['dcLatestVersionsAdmin', 'adminDashboardOptionsForm']
);
$core->addBehavior(
dcCore::app()->addBehavior(
'adminAfterDashboardOptionsUpdate',
['dcLatestVersionsAdmin', 'adminAfterDashboardOptionsUpdate']
);
@ -38,22 +39,21 @@ $core->addBehavior(
*/
class dcLatestVersionsAdmin
{
public static function adminDashboardItems(dcCore $core, $__dashboard_items)
public static function adminDashboardItems($__dashboard_items)
{
if (!$core->auth->user_prefs->dashboard->get('dcLatestVersionsItems')) {
if (!dcCore::app()->auth->user_prefs->dashboard->get('dcLatestVersionsItems')) {
return null;
}
$builds = explode(',', (string) $core->blog->settings->dcLatestVersions->builds);
$builds = explode(',', (string) dcCore::app()->blog->settings->dcLatestVersions->builds);
if (empty($builds)) {
return null;
}
$text = __('<li><a href="%u" title="Download Dotclear %v">%r</a> : %v</li>');
$li = [];
foreach($builds as $build) {
$li = [];
foreach ($builds as $build) {
$build = strtolower(trim($build));
if (empty($build)) {
continue;
@ -74,12 +74,12 @@ class dcLatestVersionsAdmin
[
'%r',
'%v',
'%u'
'%u',
],
[
$build,
$updater->getVersion(),
$updater->getFileURL()
$updater->getFileURL(),
],
$text
);
@ -88,27 +88,26 @@ class dcLatestVersionsAdmin
if (empty($li)) {
return null;
}
# Display
$__dashboard_items[0][] =
'<div class="box small" id="udclatestversionsitems">' .
$__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)
public static function adminDashboardOptionsForm()
{
if (!$core->auth->user_prefs->dashboard->prefExists('dcLatestVersionsItems')) {
$core->auth->user_prefs->dashboard->put(
if (!dcCore::app()->auth->user_prefs->dashboard->prefExists('dcLatestVersionsItems')) {
dcCore::app()->auth->user_prefs->dashboard->put(
'dcLatestVersionsItems',
false,
'boolean'
);
}
$pref = $core->auth->user_prefs->dashboard->get('dcLatestVersionsItems');
$pref = dcCore::app()->auth->user_prefs->dashboard->get('dcLatestVersionsItems');
echo
echo
'<div class="fieldset">' .
'<h4>' . __("Dotclear's latest versions") . '</h4>' .
'<p><label class="classic" for="dcLatestVersionsItems">' .
@ -120,10 +119,10 @@ class dcLatestVersionsAdmin
public static function adminAfterDashboardOptionsUpdate($user_id)
{
$GLOBALS['core']->auth->user_prefs->dashboard->put(
dcCore::app()->auth->user_prefs->dashboard->put(
'dcLatestVersionsItems',
!empty($_POST['dcLatestVersionsItems']),
'boolean'
);
}
}
}

View File

@ -1,10 +1,11 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of dcLatestVersions, a plugin for Dotclear 2.
#
#
# 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
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@ -19,13 +20,16 @@ $this->registerModule(
'dcLatestVersions',
'Show the latest available versions of Dotclear',
'Jean-Christian Denis, Pierre Van Glabeke',
'2021.08.27',
'2022.11.12',
[
'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'
'requires' => [['core', '2.24']],
'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_USAGE,
dcAuth::PERMISSION_CONTENT_ADMIN,
]),
'type' => 'plugin',
'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

@ -1,10 +1,11 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of dcLatestVersions, a plugin for Dotclear 2.
#
#
# 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
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@ -12,50 +13,59 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
return null;
}
# -- Module specs --
$dc_min = '2.19';
$mod_id = 'dcLatestVersions';
$dc_min = '2.24';
$mod_id = 'dcLatestVersions';
$mod_conf = [[
'builds',
"List of Dotclear's builds",
'stable,unstable,testing,sexy',
'string'
'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)) {
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;
# Check module version
if (version_compare(
dcCore::app()->getVersion($mod_id),
dcCore::app()->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
dcCore::app()->blog->settings->addNamespace($mod_id);
foreach ($mod_conf as $v) {
dcCore::app()->blog->settings->{$mod_id}->put(
$v[0],
$v[2],
$v[3],
$v[1],
false,
true
);
}
# Set module version
dcCore::app()->setVersion(
$mod_id,
dcCore::app()->plugins->moduleInfo($mod_id, 'version')
);
return true;
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
return false;
}
catch (Exception $e) {
$core->error->add($e->getMessage());
return false;
}

View File

@ -1,10 +1,11 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of dcLatestVersions, a plugin for Dotclear 2.
#
#
# 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
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@ -15,4 +16,4 @@ if (!defined('DC_RC_PATH')) {
return null;
}
require dirname(__FILE__) . '/_widgets.php';
require dirname(__FILE__) . '/_widgets.php';

View File

@ -1,10 +1,11 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of dcLatestVersions, a plugin for Dotclear 2.
#
#
# 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
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@ -15,9 +16,9 @@ if (!defined('DC_RC_PATH')) {
return null;
}
$core->blog->settings->addNamespace('dcLatestVersions');
dcCore::app()->blog->settings->addNamespace('dcLatestVersions');
$core->addBehavior(
dcCore::app()->addBehavior(
'initWidgets',
['dcLatestVersionsWidget', 'adminWidget']
);
@ -37,7 +38,7 @@ class dcLatestVersionsWidget
__("Dotclear's latest versions"),
['dcLatestVersionsWidget','publicWidget'],
null,
__("Show the latest available versions of Dotclear")
__('Show the latest available versions of Dotclear')
)
->addTitle(
__("Dotclear's latest versions")
@ -56,30 +57,27 @@ class dcLatestVersionsWidget
public static function publicWidget($w)
{
global $core;
$core->blog->settings->addNamespace('dcLatestVersions');
dcCore::app()->blog->settings->addNamespace('dcLatestVersions');
if ($w->offline) {
return null;
}
if (($w->homeonly == 1 && !$core->url->isHome($core->url->type))
|| ($w->homeonly == 2 && $core->url->isHome($core->url->type))
if (($w->homeonly == 1 && !dcCore::app()->url->isHome(dcCore::app()->url->type))
|| ($w->homeonly == 2 && dcCore::app()->url->isHome(dcCore::app()->url->type))
|| $w->text == '') {
return null;
}
# Builds to check
$builds = (string) $core->blog->settings->dcLatestVersions->builds;
$builds = (string) dcCore::app()->blog->settings->dcLatestVersions->builds;
$builds = explode(',', $builds);
if (empty($builds)) {
return null;
}
$li = [];
foreach($builds as $build) {
foreach ($builds as $build) {
$build = strtolower(trim($build));
if (empty($build)) {
continue;
@ -100,12 +98,12 @@ class dcLatestVersionsWidget
[
'%r',
'%v',
'%u'
'%u',
],
[
$build,
$updater->getVersion(),
$updater->getFileURL()
$updater->getFileURL(),
],
$w->text
));
@ -117,10 +115,10 @@ class dcLatestVersionsWidget
# Display
return $w->renderDiv(
$w->content_only,
'dclatestversionswidget '. $w->class,
'',
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . sprintf('<ul>%s</ul>', implode('',$li))
$w->content_only,
'dclatestversionswidget ' . $w->class,
'',
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . sprintf('<ul>%s</ul>', implode('', $li))
);
}
}
}