create( 'dclatestversionswidget', My::name(), [self::class, 'parseWidget'], null, __('Show the latest available versions of Dotclear') ) ->addTitle( My::name() ) ->setting( 'text', __('Text (%r = release, %v = version, %u = url):'), __('%r: %v'), 'text' ) ->addHomeOnly() ->addContentOnly() ->addClass() ->addOffline(); } public static function parseWidget(WidgetsElement $w): string { if ($w->offline || !$w->checkHomeOnly(dcCore::app()->url->type) || $w->text == '') { return ''; } // nullsafe PHP < 8.0 if (is_null(dcCore::app()->blog)) { return ''; } # Builds to check $builds = explode(',', (string) dcCore::app()->blog->settings->get(My::id())->get('builds')); if (empty($builds[0])) { return ''; } $li = []; foreach ($builds as $build) { $build = strtolower(trim($build)); if (empty($build)) { continue; } $updater = new dcUpdate( DC_UPDATE_URL, 'dotclear', $build, DC_TPL_CACHE . '/versions' ); if (false === $updater->check('0')) { continue; } $li[] = sprintf('