use abstract plugin name, fix phpstan error

This commit is contained in:
Jean-Christian Denis 2022-12-20 22:18:58 +01:00
parent 67c433ee20
commit 946d2b6fc8
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
2 changed files with 17 additions and 27 deletions

View file

@ -7,7 +7,7 @@
* *
* @author Jean-Christian Denis, Pierre Van Glabeke * @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 * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
@ -16,18 +16,17 @@ if (!defined('DC_CONTEXT_ADMIN')) {
require __DIR__ . '/_widgets.php'; 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')) { if (!dcCore::app()->auth->user_prefs->dashboard->get('dcLatestVersionsItems')) {
return null; return null;
} }
$builds = explode(',', (string) dcCore::app()->blog->settings->dcLatestVersions->builds); $builds = explode(',', (string) dcCore::app()->blog->settings->get(basename(__DIR__))->get('builds'));
if (empty($builds)) { if (empty($builds[0])) {
return null; return null;
} }
$text = __('<li><a href="%u" title="Download Dotclear %v">%r</a> : %v</li>'); $li = [];
$li = [];
foreach ($builds as $build) { foreach ($builds as $build) {
$build = strtolower(trim($build)); $build = strtolower(trim($build));
@ -46,18 +45,12 @@ dcCore::app()->addBehavior('adminDashboardItemsV2', function($__dashboard_items)
continue; continue;
} }
$li[] = str_replace( $li[] = sprintf(
[ '<li><a href="%1$s" title="%2$s">%3$s</a> : %4$s</li>',
'%r', $updater->getFileURL(),
'%v', sprintf(__('Download Dotclear %s'), $updater->getVersion()),
'%u', $build,
], $updater->getVersion()
[
$build,
$updater->getVersion(),
$updater->getFileURL(),
],
$text
); );
} }
@ -72,7 +65,7 @@ dcCore::app()->addBehavior('adminDashboardItemsV2', function($__dashboard_items)
'</div>'; '</div>';
}); });
dcCore::app()->addBehavior('adminDashboardOptionsFormV2', function() { dcCore::app()->addBehavior('adminDashboardOptionsFormV2', function () {
if (!dcCore::app()->auth->user_prefs->dashboard->prefExists('dcLatestVersionsItems')) { if (!dcCore::app()->auth->user_prefs->dashboard->prefExists('dcLatestVersionsItems')) {
dcCore::app()->auth->user_prefs->dashboard->put( dcCore::app()->auth->user_prefs->dashboard->put(
'dcLatestVersionsItems', 'dcLatestVersionsItems',
@ -92,7 +85,7 @@ dcCore::app()->addBehavior('adminDashboardOptionsFormV2', function() {
'</div>'; '</div>';
}); });
dcCore::app()->addBehavior('adminAfterDashboardOptionsUpdate', function($user_id) { dcCore::app()->addBehavior('adminAfterDashboardOptionsUpdate', function ($user_id) {
dcCore::app()->auth->user_prefs->dashboard->put( dcCore::app()->auth->user_prefs->dashboard->put(
'dcLatestVersionsItems', 'dcLatestVersionsItems',
!empty($_POST['dcLatestVersionsItems']), !empty($_POST['dcLatestVersionsItems']),

View file

@ -7,14 +7,14 @@
* *
* @author Jean-Christian Denis, Pierre Van Glabeke * @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 * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
dcCore::app()->blog->settings->addNamespace('dcLatestVersions'); dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
dcCore::app()->addBehavior( dcCore::app()->addBehavior(
'initWidgets', 'initWidgets',
@ -55,8 +55,6 @@ class dcLatestVersionsWidget
public static function publicWidget($w) public static function publicWidget($w)
{ {
dcCore::app()->blog->settings->addNamespace('dcLatestVersions');
if ($w->offline) { if ($w->offline) {
return null; return null;
} }
@ -66,9 +64,8 @@ class dcLatestVersionsWidget
} }
# Builds to check # Builds to check
$builds = (string) dcCore::app()->blog->settings->dcLatestVersions->builds; $builds = explode(',', (string) dcCore::app()->blog->settings->get(basename(__DIR__))->get('builds'));
$builds = explode(',', $builds); if (empty($builds[0])) {
if (empty($builds)) {
return null; return null;
} }