use abstract plugin name, fix phpstan error

master
Jean-Christian Paul 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
*
* @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 = __('<li><a href="%u" title="Download Dotclear %v">%r</a> : %v</li>');
$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(
'<li><a href="%1$s" title="%2$s">%3$s</a> : %4$s</li>',
$updater->getFileURL(),
sprintf(__('Download Dotclear %s'), $updater->getVersion()),
$build,
$updater->getVersion()
);
}
@ -72,7 +65,7 @@ dcCore::app()->addBehavior('adminDashboardItemsV2', function($__dashboard_items)
'</div>';
});
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() {
'</div>';
});
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']),

View File

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