addBehavior(
'adminDashboardItems',
array('dcLatestVersionsAdmin', 'adminDashboardItems')
);
$core->addBehavior(
'adminDashboardOptionsForm',
array('dcLatestVersionsAdmin', 'adminDashboardOptionsForm')
);
$core->addBehavior(
'adminAfterDashboardOptionsUpdate',
array('dcLatestVersionsAdmin', 'adminAfterDashboardOptionsUpdate')
);
/**
* @ingroup DC_PLUGIN_DCLATESTVERSIONS
* @brief Display latest versions of Dotclear - admin methods.
* @since 2.6
*/
class dcLatestVersionsAdmin
{
public static function adminDashboardItems(dcCore $core, $__dashboard_items)
{
if (!$core->auth->user_prefs->dashboard->get('dcLatestVersionsItems')) {
return null;
}
$builds = (string) $core->blog->settings->dcLatestVersions->builds;
$builds = explode(',', $builds);
if (empty($builds)) {
return null;
}
$text = __('
%r : %v');
$li = array();
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')) {
return false;
}
$li[] = str_replace(
array(
'%r',
'%v',
'%u'
),
array(
$build,
$updater->getVersion(),
$updater->getFileURL()
),
$text
);
}
if (empty($li)) {
return null;
}
# Display
$__dashboard_items[0][] =
''.
'
'.html::escapeHTML(__("Dotclear's latest versions")).'
'.
'
'.
'
';
}
public static function adminDashboardOptionsForm(dcCore $core)
{
if (!$core->auth->user_prefs->dashboard->prefExists('dcLatestVersionsItems')) {
$core->auth->user_prefs->dashboard->put(
'dcLatestVersionsItems',
false,
'boolean'
);
}
$pref = $core->auth->user_prefs->dashboard->get('dcLatestVersionsItems');
echo
''.
'
'.__("Dotclear's latest versions").'
'.
'
'.
'
';
}
public static function adminAfterDashboardOptionsUpdate($user_id)
{
$GLOBALS['core']->auth->user_prefs->dashboard->put(
'dcLatestVersionsItems',
!empty($_POST['dcLatestVersionsItems']),
'boolean'
);
}
}