2007-07-11 15:15:40 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Code required only when rendering the available updates report.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-04-13 15:23:03 +00:00
|
|
|
* Returns HTML for the project status report.
|
|
|
|
*
|
2010-10-03 22:43:16 +00:00
|
|
|
* @param array $variables
|
2010-04-13 15:23:03 +00:00
|
|
|
* An associative array containing:
|
|
|
|
* - data: An array of data about each project's status.
|
2007-12-06 09:58:34 +00:00
|
|
|
*
|
|
|
|
* @ingroup themeable
|
2007-07-11 15:15:40 +00:00
|
|
|
*/
|
2009-10-09 01:00:08 +00:00
|
|
|
function theme_update_report($variables) {
|
|
|
|
$data = $variables['data'];
|
|
|
|
|
2013-06-05 14:24:40 +00:00
|
|
|
$last = Drupal::state()->get('update.last_check') ?: 0;
|
2013-08-13 10:53:04 +00:00
|
|
|
$update_last_check = array(
|
|
|
|
'#theme' => 'update_last_check',
|
|
|
|
'#last' => $last,
|
|
|
|
);
|
|
|
|
$output = drupal_render($update_last_check);
|
2007-07-11 15:15:40 +00:00
|
|
|
|
|
|
|
if (!is_array($data)) {
|
2008-04-14 17:48:46 +00:00
|
|
|
$output .= '<p>' . $data . '</p>';
|
2007-07-11 15:15:40 +00:00
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
$header = array();
|
|
|
|
$rows = array();
|
|
|
|
|
2013-08-14 16:54:28 +00:00
|
|
|
$notification_level = Drupal::config('update.settings')->get('notification.threshold');
|
2007-07-11 15:15:40 +00:00
|
|
|
|
2009-10-08 15:40:34 +00:00
|
|
|
// Create an array of status values keyed by module or theme name, since
|
|
|
|
// we'll need this while generating the report if we have to cross reference
|
|
|
|
// anything (e.g. subthemes which have base themes missing an update).
|
|
|
|
foreach ($data as $project) {
|
|
|
|
foreach ($project['includes'] as $key => $name) {
|
|
|
|
$status[$key] = $project['status'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-11 15:15:40 +00:00
|
|
|
foreach ($data as $project) {
|
|
|
|
switch ($project['status']) {
|
|
|
|
case UPDATE_CURRENT:
|
|
|
|
$class = 'ok';
|
2013-08-13 10:53:04 +00:00
|
|
|
$uri = 'core/misc/watchdog-ok.png';
|
|
|
|
$text = t('ok');
|
2007-07-11 15:15:40 +00:00
|
|
|
break;
|
2009-04-29 03:57:21 +00:00
|
|
|
case UPDATE_UNKNOWN:
|
2009-10-13 02:14:05 +00:00
|
|
|
case UPDATE_FETCH_PENDING:
|
2009-06-06 06:26:13 +00:00
|
|
|
case UPDATE_NOT_FETCHED:
|
2009-04-29 03:57:21 +00:00
|
|
|
$class = 'unknown';
|
2013-08-13 10:53:04 +00:00
|
|
|
$uri = 'core/misc/watchdog-warning.png';
|
|
|
|
$text = t('warning');
|
2009-04-29 03:57:21 +00:00
|
|
|
break;
|
2007-07-11 15:15:40 +00:00
|
|
|
case UPDATE_NOT_SECURE:
|
2008-01-10 14:14:54 +00:00
|
|
|
case UPDATE_REVOKED:
|
|
|
|
case UPDATE_NOT_SUPPORTED:
|
2009-04-29 03:57:21 +00:00
|
|
|
$class = 'error';
|
2013-08-13 10:53:04 +00:00
|
|
|
$uri = 'core/misc/watchdog-error.png';
|
|
|
|
$text = t('error');
|
2009-04-29 03:57:21 +00:00
|
|
|
break;
|
|
|
|
case UPDATE_NOT_CHECKED:
|
2007-07-11 15:15:40 +00:00
|
|
|
case UPDATE_NOT_CURRENT:
|
|
|
|
default:
|
|
|
|
$class = 'warning';
|
2013-08-13 10:53:04 +00:00
|
|
|
$uri = 'core/misc/watchdog-warning.png';
|
|
|
|
$text = t('warning');
|
2007-07-11 15:15:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-08-13 10:53:04 +00:00
|
|
|
$icon = array(
|
|
|
|
'#theme' => 'image',
|
|
|
|
'#width' => 18,
|
|
|
|
'#height' => 18,
|
|
|
|
'#uri' => $uri,
|
|
|
|
'#alt' => $text,
|
|
|
|
'#title' => $text,
|
|
|
|
);
|
|
|
|
|
2007-07-11 15:15:40 +00:00
|
|
|
$row = '<div class="version-status">';
|
2013-08-13 10:53:04 +00:00
|
|
|
$update_status_label = array('#theme' => 'update_status_label', '#status' => $project['status']);
|
|
|
|
$status_label = drupal_render($update_status_label);
|
2009-10-08 15:40:34 +00:00
|
|
|
$row .= !empty($status_label) ? $status_label : check_plain($project['reason']);
|
2013-08-13 10:53:04 +00:00
|
|
|
$row .= '<span class="icon">' . drupal_render($icon) . '</span>';
|
2007-07-11 15:15:40 +00:00
|
|
|
$row .= "</div>\n";
|
|
|
|
|
|
|
|
$row .= '<div class="project">';
|
|
|
|
if (isset($project['title'])) {
|
|
|
|
if (isset($project['link'])) {
|
|
|
|
$row .= l($project['title'], $project['link']);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$row .= check_plain($project['title']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$row .= check_plain($project['name']);
|
|
|
|
}
|
2008-04-14 17:48:46 +00:00
|
|
|
$row .= ' ' . check_plain($project['existing_version']);
|
2007-07-11 15:15:40 +00:00
|
|
|
if ($project['install_type'] == 'dev' && !empty($project['datestamp'])) {
|
2008-04-14 17:48:46 +00:00
|
|
|
$row .= ' <span class="version-date">(' . format_date($project['datestamp'], 'custom', 'Y-M-d') . ')</span>';
|
2007-07-11 15:15:40 +00:00
|
|
|
}
|
|
|
|
$row .= "</div>\n";
|
|
|
|
|
2010-10-03 22:43:16 +00:00
|
|
|
$versions_inner = '';
|
|
|
|
$security_class = array();
|
|
|
|
$version_class = array();
|
2007-07-11 15:15:40 +00:00
|
|
|
if (isset($project['recommended'])) {
|
2008-08-28 08:12:29 +00:00
|
|
|
if ($project['status'] != UPDATE_CURRENT || $project['existing_version'] !== $project['recommended']) {
|
2007-07-11 15:15:40 +00:00
|
|
|
|
|
|
|
// First, figure out what to recommend.
|
|
|
|
// If there's only 1 security update and it has the same version we're
|
|
|
|
// recommending, give it the same CSS class as if it was recommended,
|
|
|
|
// but don't print out a separate "Recommended" line for this project.
|
2008-08-28 08:12:29 +00:00
|
|
|
if (!empty($project['security updates']) && count($project['security updates']) == 1 && $project['security updates'][0]['version'] === $project['recommended']) {
|
2010-10-03 22:43:16 +00:00
|
|
|
$security_class[] = 'version-recommended';
|
|
|
|
$security_class[] = 'version-recommended-strong';
|
2007-07-11 15:15:40 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-08-22 14:34:23 +00:00
|
|
|
$version_class[] = 'version-recommended';
|
2007-07-11 15:15:40 +00:00
|
|
|
// Apply an extra class if we're displaying both a recommended
|
|
|
|
// version and anything else for an extra visual hint.
|
2008-08-28 08:12:29 +00:00
|
|
|
if ($project['recommended'] !== $project['latest_version']
|
2007-07-11 15:15:40 +00:00
|
|
|
|| !empty($project['also'])
|
|
|
|
|| ($project['install_type'] == 'dev'
|
2009-05-24 17:39:35 +00:00
|
|
|
&& isset($project['dev_version'])
|
|
|
|
&& $project['latest_version'] !== $project['dev_version']
|
|
|
|
&& $project['recommended'] !== $project['dev_version'])
|
2007-07-11 15:15:40 +00:00
|
|
|
|| (isset($project['security updates'][0])
|
2009-05-24 17:39:35 +00:00
|
|
|
&& $project['recommended'] !== $project['security updates'][0])
|
2007-07-11 15:15:40 +00:00
|
|
|
) {
|
2009-08-22 14:34:23 +00:00
|
|
|
$version_class[] = 'version-recommended-strong';
|
2007-07-11 15:15:40 +00:00
|
|
|
}
|
2013-08-13 10:53:04 +00:00
|
|
|
$update_version = array(
|
|
|
|
'#theme' => 'update_version',
|
|
|
|
'#version' => $project['releases'][$project['recommended']],
|
|
|
|
'#tag' => t('Recommended version:'),
|
|
|
|
'#class' => $version_class,
|
|
|
|
);
|
|
|
|
$versions_inner .= drupal_render($update_version);
|
2007-07-11 15:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Now, print any security updates.
|
|
|
|
if (!empty($project['security updates'])) {
|
2010-10-03 22:43:16 +00:00
|
|
|
$security_class[] = 'version-security';
|
2007-07-11 15:15:40 +00:00
|
|
|
foreach ($project['security updates'] as $security_update) {
|
2013-08-13 10:53:04 +00:00
|
|
|
$update_version = array(
|
|
|
|
'#theme' => 'update_version',
|
|
|
|
'#version' => $security_update,
|
|
|
|
'#tag' => t('Security update:'),
|
|
|
|
'#class' => $security_class,
|
|
|
|
);
|
|
|
|
$versions_inner .= drupal_render($update_version);
|
2007-07-11 15:15:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-28 08:12:29 +00:00
|
|
|
if ($project['recommended'] !== $project['latest_version']) {
|
2013-08-13 10:53:04 +00:00
|
|
|
$update_version = array(
|
|
|
|
'#theme' => 'update_version',
|
|
|
|
'#version' => $project['releases'][$project['latest_version']],
|
|
|
|
'#tag' => t('Latest version:'),
|
|
|
|
'#class' => array('version-latest'),
|
|
|
|
);
|
|
|
|
$versions_inner .= drupal_render($update_version);
|
2007-07-11 15:15:40 +00:00
|
|
|
}
|
|
|
|
if ($project['install_type'] == 'dev'
|
|
|
|
&& $project['status'] != UPDATE_CURRENT
|
2008-01-10 14:14:54 +00:00
|
|
|
&& isset($project['dev_version'])
|
2008-08-28 08:12:29 +00:00
|
|
|
&& $project['recommended'] !== $project['dev_version']) {
|
2013-08-13 10:53:04 +00:00
|
|
|
$update_version = array(
|
|
|
|
'#theme' => 'update_version',
|
|
|
|
'#version' => $project['releases'][$project['dev_version']],
|
|
|
|
'#tag' => t('Development version:'),
|
|
|
|
'#class' => array('version-latest'),
|
|
|
|
);
|
|
|
|
$versions_inner .= drupal_render($update_version);
|
2007-07-11 15:15:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($project['also'])) {
|
|
|
|
foreach ($project['also'] as $also) {
|
2013-08-13 10:53:04 +00:00
|
|
|
$update_version = array(
|
|
|
|
'#theme' => 'update_version',
|
|
|
|
'#version' => $project['releases'][$also],
|
|
|
|
'#tag' => t('Also available:'),
|
|
|
|
'#class' => array('version-also-available'),
|
|
|
|
);
|
|
|
|
$versions_inner .= drupal_render($update_version);
|
2007-07-11 15:15:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-03 22:43:16 +00:00
|
|
|
if (!empty($versions_inner)) {
|
|
|
|
$row .= "<div class=\"versions\">\n" . $versions_inner . "</div>\n";
|
|
|
|
}
|
2007-07-11 15:15:40 +00:00
|
|
|
$row .= "<div class=\"info\">\n";
|
|
|
|
if (!empty($project['extra'])) {
|
2008-04-14 17:48:46 +00:00
|
|
|
$row .= '<div class="extra">' . "\n";
|
2007-07-11 15:15:40 +00:00
|
|
|
foreach ($project['extra'] as $key => $value) {
|
2009-08-22 14:34:23 +00:00
|
|
|
$row .= '<div class="' . implode(' ', $value['class']) . '">';
|
2008-04-14 17:48:46 +00:00
|
|
|
$row .= check_plain($value['label']) . ': ';
|
2010-08-17 13:50:52 +00:00
|
|
|
$row .= drupal_placeholder($value['data']);
|
2007-07-11 15:15:40 +00:00
|
|
|
$row .= "</div>\n";
|
|
|
|
}
|
|
|
|
$row .= "</div>\n"; // extra div.
|
|
|
|
}
|
|
|
|
|
|
|
|
$row .= '<div class="includes">';
|
|
|
|
sort($project['includes']);
|
2009-08-24 00:42:34 +00:00
|
|
|
if (!empty($project['disabled'])) {
|
|
|
|
sort($project['disabled']);
|
|
|
|
// Make sure we start with a clean slate for each project in the report.
|
|
|
|
$includes_items = array();
|
|
|
|
$row .= t('Includes:');
|
|
|
|
$includes_items[] = t('Enabled: %includes', array('%includes' => implode(', ', $project['includes'])));
|
|
|
|
$includes_items[] = t('Disabled: %disabled', array('%disabled' => implode(', ', $project['disabled'])));
|
2013-08-13 10:53:04 +00:00
|
|
|
$item_list = array(
|
|
|
|
'#theme' => 'item_list',
|
|
|
|
'#items' => $includes_items,
|
|
|
|
);
|
|
|
|
$row .= drupal_render($item_list);
|
2009-08-24 00:42:34 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$row .= t('Includes: %includes', array('%includes' => implode(', ', $project['includes'])));
|
|
|
|
}
|
2007-07-11 15:15:40 +00:00
|
|
|
$row .= "</div>\n";
|
|
|
|
|
2009-10-08 15:40:34 +00:00
|
|
|
if (!empty($project['base_themes'])) {
|
|
|
|
$row .= '<div class="basethemes">';
|
|
|
|
asort($project['base_themes']);
|
|
|
|
$base_themes = array();
|
|
|
|
foreach ($project['base_themes'] as $base_key => $base_theme) {
|
2013-08-13 10:53:04 +00:00
|
|
|
$update_status_label = array(
|
|
|
|
'#theme' => 'update_status_label',
|
|
|
|
'#status' => $status[$base_key],
|
|
|
|
);
|
2009-10-08 15:40:34 +00:00
|
|
|
switch ($status[$base_key]) {
|
|
|
|
case UPDATE_NOT_SECURE:
|
|
|
|
case UPDATE_REVOKED:
|
|
|
|
case UPDATE_NOT_SUPPORTED:
|
2013-08-13 10:53:04 +00:00
|
|
|
$base_themes[] = t('%base_theme (!base_label)', array('%base_theme' => $base_theme, '!base_label' => drupal_render($update_status_label)));
|
2009-10-08 15:40:34 +00:00
|
|
|
break;
|
2010-01-30 07:59:26 +00:00
|
|
|
|
2009-10-08 15:40:34 +00:00
|
|
|
default:
|
2010-08-17 13:50:52 +00:00
|
|
|
$base_themes[] = drupal_placeholder($base_theme);
|
2009-10-08 15:40:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$row .= t('Depends on: !basethemes', array('!basethemes' => implode(', ', $base_themes)));
|
|
|
|
$row .= "</div>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($project['sub_themes'])) {
|
|
|
|
$row .= '<div class="subthemes">';
|
|
|
|
sort($project['sub_themes']);
|
|
|
|
$row .= t('Required by: %subthemes', array('%subthemes' => implode(', ', $project['sub_themes'])));
|
|
|
|
$row .= "</div>\n";
|
|
|
|
}
|
|
|
|
|
2007-07-11 15:15:40 +00:00
|
|
|
$row .= "</div>\n"; // info div.
|
|
|
|
|
|
|
|
if (!isset($rows[$project['project_type']])) {
|
|
|
|
$rows[$project['project_type']] = array();
|
|
|
|
}
|
2009-10-05 02:26:36 +00:00
|
|
|
$row_key = isset($project['title']) ? drupal_strtolower($project['title']) : drupal_strtolower($project['name']);
|
|
|
|
$rows[$project['project_type']][$row_key] = array(
|
2009-08-22 14:34:23 +00:00
|
|
|
'class' => array($class),
|
2007-07-11 15:15:40 +00:00
|
|
|
'data' => array($row),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$project_types = array(
|
|
|
|
'core' => t('Drupal core'),
|
|
|
|
'module' => t('Modules'),
|
|
|
|
'theme' => t('Themes'),
|
2009-08-24 00:42:34 +00:00
|
|
|
'module-disabled' => t('Disabled modules'),
|
|
|
|
'theme-disabled' => t('Disabled themes'),
|
2007-07-11 15:15:40 +00:00
|
|
|
);
|
|
|
|
foreach ($project_types as $type_name => $type_label) {
|
|
|
|
if (!empty($rows[$type_name])) {
|
2009-10-05 02:26:36 +00:00
|
|
|
ksort($rows[$type_name]);
|
2008-04-14 17:48:46 +00:00
|
|
|
$output .= "\n<h3>" . $type_label . "</h3>\n";
|
2013-08-13 10:53:04 +00:00
|
|
|
$table = array(
|
|
|
|
'#theme' => 'table',
|
|
|
|
'#header' => $header,
|
|
|
|
'#rows' => $rows[$type_name],
|
|
|
|
'#attributes' => array(
|
|
|
|
'class' => array('update'),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
$output .= drupal_render($table);
|
2007-07-11 15:15:40 +00:00
|
|
|
}
|
|
|
|
}
|
2013-06-07 10:48:55 +00:00
|
|
|
drupal_add_css(drupal_get_path('module', 'update') . '/css/update.admin.css');
|
2007-07-11 15:15:40 +00:00
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
2009-10-08 15:40:34 +00:00
|
|
|
/**
|
2010-04-13 15:23:03 +00:00
|
|
|
* Returns HTML for a label to display for a project's update status.
|
2009-10-08 15:40:34 +00:00
|
|
|
*
|
2010-10-03 22:43:16 +00:00
|
|
|
* @param array $variables
|
2009-10-09 01:00:08 +00:00
|
|
|
* An associative array containing:
|
|
|
|
* - status: The integer code for a project's current update status.
|
2009-10-08 15:40:34 +00:00
|
|
|
*
|
|
|
|
* @see update_calculate_project_data()
|
2012-06-06 15:33:53 +00:00
|
|
|
* @ingroup themeable
|
2009-10-08 15:40:34 +00:00
|
|
|
*/
|
2009-10-09 01:00:08 +00:00
|
|
|
function theme_update_status_label($variables) {
|
|
|
|
switch ($variables['status']) {
|
2009-10-08 15:40:34 +00:00
|
|
|
case UPDATE_NOT_SECURE:
|
|
|
|
return '<span class="security-error">' . t('Security update required!') . '</span>';
|
|
|
|
|
|
|
|
case UPDATE_REVOKED:
|
|
|
|
return '<span class="revoked">' . t('Revoked!') . '</span>';
|
|
|
|
|
|
|
|
case UPDATE_NOT_SUPPORTED:
|
|
|
|
return '<span class="not-supported">' . t('Not supported!') . '</span>';
|
|
|
|
|
|
|
|
case UPDATE_NOT_CURRENT:
|
|
|
|
return '<span class="not-current">' . t('Update available') . '</span>';
|
|
|
|
|
|
|
|
case UPDATE_CURRENT:
|
|
|
|
return '<span class="current">' . t('Up to date') . '</span>';
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-06 09:58:34 +00:00
|
|
|
/**
|
2010-04-13 15:23:03 +00:00
|
|
|
* Returns HTML for the version display of a project.
|
|
|
|
*
|
2010-10-03 22:43:16 +00:00
|
|
|
* @param array $variables
|
2010-04-13 15:23:03 +00:00
|
|
|
* An associative array containing:
|
|
|
|
* - version: An array of data about the latest released version, containing:
|
|
|
|
* - version: The version number.
|
|
|
|
* - release_link: The URL for the release notes.
|
|
|
|
* - date: The date of the release.
|
|
|
|
* - download_link: The URL for the downloadable file.
|
|
|
|
* - tag: The title of the project.
|
|
|
|
* - class: A string containing extra classes for the wrapping table.
|
2007-12-06 09:58:34 +00:00
|
|
|
*
|
|
|
|
* @ingroup themeable
|
|
|
|
*/
|
2009-10-09 01:00:08 +00:00
|
|
|
function theme_update_version($variables) {
|
|
|
|
$version = $variables['version'];
|
|
|
|
$tag = $variables['tag'];
|
2010-10-03 22:43:16 +00:00
|
|
|
$class = implode(' ', $variables['class']);
|
2009-10-09 01:00:08 +00:00
|
|
|
|
2007-07-11 15:15:40 +00:00
|
|
|
$output = '';
|
2008-04-14 17:48:46 +00:00
|
|
|
$output .= '<table class="version ' . $class . '">';
|
2007-07-11 15:15:40 +00:00
|
|
|
$output .= '<tr>';
|
2008-04-14 17:48:46 +00:00
|
|
|
$output .= '<td class="version-title">' . $tag . "</td>\n";
|
2007-07-11 15:15:40 +00:00
|
|
|
$output .= '<td class="version-details">';
|
|
|
|
$output .= l($version['version'], $version['release_link']);
|
2008-04-14 17:48:46 +00:00
|
|
|
$output .= ' <span class="version-date">(' . format_date($version['date'], 'custom', 'Y-M-d') . ')</span>';
|
2007-07-11 15:15:40 +00:00
|
|
|
$output .= "</td>\n";
|
|
|
|
$output .= '<td class="version-links">';
|
|
|
|
$links = array();
|
|
|
|
$links['update-download'] = array(
|
|
|
|
'title' => t('Download'),
|
|
|
|
'href' => $version['download_link'],
|
|
|
|
);
|
|
|
|
$links['update-release-notes'] = array(
|
|
|
|
'title' => t('Release notes'),
|
|
|
|
'href' => $version['release_link'],
|
|
|
|
);
|
2013-08-13 10:53:04 +00:00
|
|
|
$links__update_version = array(
|
|
|
|
'#theme' => 'links__update_version',
|
|
|
|
'#links' => $links,
|
|
|
|
);
|
|
|
|
$output .= drupal_render($links__update_version);
|
2007-07-11 15:15:40 +00:00
|
|
|
$output .= '</td>';
|
|
|
|
$output .= '</tr>';
|
|
|
|
$output .= "</table>\n";
|
|
|
|
return $output;
|
|
|
|
}
|