addBehavior('adminDashboardItemsV2', function ($__dashboard_items) {
if (!dcCore::app()->auth->user_prefs->dashboard->get('dcLatestVersionsItems')) {
return null;
}
$builds = explode(',', (string) dcCore::app()->blog->settings->get(basename(__DIR__))->get('builds'));
if (empty($builds[0])) {
return null;
}
$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(
'
%3$s : %4$s',
$updater->getFileURL(),
sprintf(__('Download Dotclear %s'), $updater->getVersion()),
$build,
$updater->getVersion()
);
}
if (empty($li)) {
return null;
}
# Display
$__dashboard_items[0][] = '' .
'
' . html::escapeHTML(__("Dotclear's latest versions")) . '
' .
'
' .
'
';
});
dcCore::app()->addBehavior('adminDashboardOptionsFormV2', function () {
if (!dcCore::app()->auth->user_prefs->dashboard->prefExists('dcLatestVersionsItems')) {
dcCore::app()->auth->user_prefs->dashboard->put(
'dcLatestVersionsItems',
false,
'boolean'
);
}
$pref = dcCore::app()->auth->user_prefs->dashboard->get('dcLatestVersionsItems');
echo
'' .
'
' . __("Dotclear's latest versions") . '
' .
'
' .
'
';
});
dcCore::app()->addBehavior('adminAfterDashboardOptionsUpdate', function ($user_id) {
dcCore::app()->auth->user_prefs->dashboard->put(
'dcLatestVersionsItems',
!empty($_POST['dcLatestVersionsItems']),
'boolean'
);
});