From 946d2b6fc8e000cc25baf5921836e7869af77f01 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Tue, 20 Dec 2022 22:18:58 +0100 Subject: [PATCH] use abstract plugin name, fix phpstan error --- _admin.php | 33 +++++++++++++-------------------- _widgets.php | 11 ++++------- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/_admin.php b/_admin.php index 3732b1c..54155a5 100644 --- a/_admin.php +++ b/_admin.php @@ -7,7 +7,7 @@ * * @author Jean-Christian Denis, Pierre Van Glabeke * - * @copyright Jean-Crhistian Denis + * @copyright Jean-Christian Denis * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html */ if (!defined('DC_CONTEXT_ADMIN')) { @@ -16,18 +16,17 @@ if (!defined('DC_CONTEXT_ADMIN')) { require __DIR__ . '/_widgets.php'; -dcCore::app()->addBehavior('adminDashboardItemsV2', function($__dashboard_items) { +dcCore::app()->addBehavior('adminDashboardItemsV2', function ($__dashboard_items) { if (!dcCore::app()->auth->user_prefs->dashboard->get('dcLatestVersionsItems')) { return null; } - $builds = explode(',', (string) dcCore::app()->blog->settings->dcLatestVersions->builds); - if (empty($builds)) { + $builds = explode(',', (string) dcCore::app()->blog->settings->get(basename(__DIR__))->get('builds')); + if (empty($builds[0])) { return null; } - $text = __('
  • %r : %v
  • '); - $li = []; + $li = []; foreach ($builds as $build) { $build = strtolower(trim($build)); @@ -46,18 +45,12 @@ dcCore::app()->addBehavior('adminDashboardItemsV2', function($__dashboard_items) continue; } - $li[] = str_replace( - [ - '%r', - '%v', - '%u', - ], - [ - $build, - $updater->getVersion(), - $updater->getFileURL(), - ], - $text + $li[] = sprintf( + '
  • %3$s : %4$s
  • ', + $updater->getFileURL(), + sprintf(__('Download Dotclear %s'), $updater->getVersion()), + $build, + $updater->getVersion() ); } @@ -72,7 +65,7 @@ dcCore::app()->addBehavior('adminDashboardItemsV2', function($__dashboard_items) ''; }); -dcCore::app()->addBehavior('adminDashboardOptionsFormV2', function() { +dcCore::app()->addBehavior('adminDashboardOptionsFormV2', function () { if (!dcCore::app()->auth->user_prefs->dashboard->prefExists('dcLatestVersionsItems')) { dcCore::app()->auth->user_prefs->dashboard->put( 'dcLatestVersionsItems', @@ -92,7 +85,7 @@ dcCore::app()->addBehavior('adminDashboardOptionsFormV2', function() { ''; }); -dcCore::app()->addBehavior('adminAfterDashboardOptionsUpdate', function($user_id) { +dcCore::app()->addBehavior('adminAfterDashboardOptionsUpdate', function ($user_id) { dcCore::app()->auth->user_prefs->dashboard->put( 'dcLatestVersionsItems', !empty($_POST['dcLatestVersionsItems']), diff --git a/_widgets.php b/_widgets.php index d0debc8..7d672aa 100644 --- a/_widgets.php +++ b/_widgets.php @@ -7,14 +7,14 @@ * * @author Jean-Christian Denis, Pierre Van Glabeke * - * @copyright Jean-Crhistian Denis + * @copyright Jean-Christian Denis * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html */ if (!defined('DC_RC_PATH')) { return null; } -dcCore::app()->blog->settings->addNamespace('dcLatestVersions'); +dcCore::app()->blog->settings->addNamespace(basename(__DIR__)); dcCore::app()->addBehavior( 'initWidgets', @@ -55,8 +55,6 @@ class dcLatestVersionsWidget public static function publicWidget($w) { - dcCore::app()->blog->settings->addNamespace('dcLatestVersions'); - if ($w->offline) { return null; } @@ -66,9 +64,8 @@ class dcLatestVersionsWidget } # Builds to check - $builds = (string) dcCore::app()->blog->settings->dcLatestVersions->builds; - $builds = explode(',', $builds); - if (empty($builds)) { + $builds = explode(',', (string) dcCore::app()->blog->settings->get(basename(__DIR__))->get('builds')); + if (empty($builds[0])) { return null; }