2015-04-22 15:07:20 +00:00
|
|
|
<?php
|
2022-11-20 17:33:02 +00:00
|
|
|
/**
|
|
|
|
* @brief dcLatestVersions, a plugin for Dotclear 2
|
|
|
|
*
|
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
|
|
|
*
|
|
|
|
* @author Jean-Christian Denis, Pierre Van Glabeke
|
|
|
|
*
|
|
|
|
* @copyright Jean-Crhistian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2015-04-22 15:07:20 +00:00
|
|
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
2021-08-27 15:53:07 +00:00
|
|
|
return null;
|
2015-04-22 15:07:20 +00:00
|
|
|
}
|
|
|
|
|
2022-11-16 22:03:38 +00:00
|
|
|
require __DIR__ . '/_widgets.php';
|
2015-04-22 15:07:20 +00:00
|
|
|
|
2022-11-30 22:58:37 +00:00
|
|
|
dcCore::app()->addBehavior('adminDashboardItemsV2', function($__dashboard_items) {
|
|
|
|
if (!dcCore::app()->auth->user_prefs->dashboard->get('dcLatestVersionsItems')) {
|
|
|
|
return null;
|
|
|
|
}
|
2021-08-27 15:53:07 +00:00
|
|
|
|
2022-11-30 22:58:37 +00:00
|
|
|
$builds = explode(',', (string) dcCore::app()->blog->settings->dcLatestVersions->builds);
|
|
|
|
if (empty($builds)) {
|
|
|
|
return null;
|
|
|
|
}
|
2021-08-27 15:53:07 +00:00
|
|
|
|
2022-11-30 22:58:37 +00:00
|
|
|
$text = __('<li><a href="%u" title="Download Dotclear %v">%r</a> : %v</li>');
|
|
|
|
$li = [];
|
2021-08-27 15:53:07 +00:00
|
|
|
|
2022-11-30 22:58:37 +00:00
|
|
|
foreach ($builds as $build) {
|
|
|
|
$build = strtolower(trim($build));
|
|
|
|
if (empty($build)) {
|
|
|
|
continue;
|
2021-08-27 15:53:07 +00:00
|
|
|
}
|
|
|
|
|
2022-11-30 22:58:37 +00:00
|
|
|
$updater = new dcUpdate(
|
|
|
|
DC_UPDATE_URL,
|
|
|
|
'dotclear',
|
|
|
|
$build,
|
|
|
|
DC_TPL_CACHE . '/versions'
|
|
|
|
);
|
|
|
|
|
|
|
|
if (false === $updater->check('0')) {
|
|
|
|
continue;
|
2021-08-27 15:53:07 +00:00
|
|
|
}
|
2022-11-16 22:03:38 +00:00
|
|
|
|
2022-11-30 22:58:37 +00:00
|
|
|
$li[] = str_replace(
|
|
|
|
[
|
|
|
|
'%r',
|
|
|
|
'%v',
|
|
|
|
'%u',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
$build,
|
|
|
|
$updater->getVersion(),
|
|
|
|
$updater->getFileURL(),
|
|
|
|
],
|
|
|
|
$text
|
|
|
|
);
|
2021-08-27 15:53:07 +00:00
|
|
|
}
|
|
|
|
|
2022-11-30 22:58:37 +00:00
|
|
|
if (empty($li)) {
|
|
|
|
return null;
|
2021-08-27 15:53:07 +00:00
|
|
|
}
|
|
|
|
|
2022-11-30 22:58:37 +00:00
|
|
|
# Display
|
|
|
|
$__dashboard_items[0][] = '<div class="box small" id="udclatestversionsitems">' .
|
|
|
|
'<h3>' . html::escapeHTML(__("Dotclear's latest versions")) . '</h3>' .
|
|
|
|
'<ul>' . implode('', $li) . '</ul>' .
|
|
|
|
'</div>';
|
|
|
|
});
|
|
|
|
|
|
|
|
dcCore::app()->addBehavior('adminDashboardOptionsFormV2', function() {
|
|
|
|
if (!dcCore::app()->auth->user_prefs->dashboard->prefExists('dcLatestVersionsItems')) {
|
2022-11-16 22:03:38 +00:00
|
|
|
dcCore::app()->auth->user_prefs->dashboard->put(
|
2021-08-27 15:53:07 +00:00
|
|
|
'dcLatestVersionsItems',
|
2022-11-30 22:58:37 +00:00
|
|
|
false,
|
2021-08-27 15:53:07 +00:00
|
|
|
'boolean'
|
|
|
|
);
|
|
|
|
}
|
2022-11-30 22:58:37 +00:00
|
|
|
$pref = dcCore::app()->auth->user_prefs->dashboard->get('dcLatestVersionsItems');
|
|
|
|
|
|
|
|
echo
|
|
|
|
'<div class="fieldset">' .
|
|
|
|
'<h4>' . __("Dotclear's latest versions") . '</h4>' .
|
|
|
|
'<p><label class="classic" for="dcLatestVersionsItems">' .
|
|
|
|
form::checkbox('dcLatestVersionsItems', 1, $pref) . ' ' .
|
|
|
|
__("Show Dotclear's latest versions on dashboards.") .
|
|
|
|
'</label></p>' .
|
|
|
|
'</div>';
|
|
|
|
});
|
|
|
|
|
|
|
|
dcCore::app()->addBehavior('adminAfterDashboardOptionsUpdate', function($user_id) {
|
|
|
|
dcCore::app()->auth->user_prefs->dashboard->put(
|
|
|
|
'dcLatestVersionsItems',
|
|
|
|
!empty($_POST['dcLatestVersionsItems']),
|
|
|
|
'boolean'
|
|
|
|
);
|
|
|
|
});
|