00001 <?php
00002
00003
00012 function update_status() {
00013 if ($available = update_get_available(TRUE)) {
00014 module_load_include('inc', 'update', 'update.compare');
00015 $data = update_calculate_project_data($available);
00016 return theme('update_report', $data);
00017 }
00018 else {
00019 return theme('update_report', _update_no_data());
00020 }
00021 }
00022
00028 function theme_update_report($data) {
00029 $last = variable_get('update_last_check', 0);
00030 $output = '<div class="update checked">' . ($last ? t('Last checked: @time ago', array('@time' => format_interval(time() - $last))) : t('Last checked: never'));
00031 $output .= ' <span class="check-manually">(' . l(t('Check manually'), 'admin/reports/updates/check') . ')</span>';
00032 $output .= "</div>\n";
00033
00034 if (!is_array($data)) {
00035 $output .= '<p>' . $data . '</p>';
00036 return $output;
00037 }
00038
00039 $header = array();
00040 $rows = array();
00041
00042 $notification_level = variable_get('update_notification_threshold', 'all');
00043
00044 foreach ($data as $project) {
00045 switch ($project['status']) {
00046 case UPDATE_CURRENT:
00047 $class = 'ok';
00048 $icon = theme('image', 'misc/watchdog-ok.png', t('ok'), t('ok'));
00049 break;
00050 case UPDATE_NOT_SECURE:
00051 case UPDATE_REVOKED:
00052 case UPDATE_NOT_SUPPORTED:
00053 case UPDATE_NOT_CURRENT:
00054 if ($notification_level == 'all'
00055 || $project['status'] != UPDATE_NOT_CURRENT) {
00056 $class = 'error';
00057 $icon = theme('image', 'misc/watchdog-error.png', t('error'), t('error'));
00058 break;
00059 }
00060
00061 default:
00062 $class = 'warning';
00063 $icon = theme('image', 'misc/watchdog-warning.png', t('warning'), t('warning'));
00064 break;
00065 }
00066
00067 $row = '<div class="version-status">';
00068 switch ($project['status']) {
00069 case UPDATE_NOT_SECURE:
00070 $row .= '<span class="security-error">' . t('Security update required!') . '</span>';
00071 break;
00072 case UPDATE_REVOKED:
00073 $row .= '<span class="revoked">' . t('Revoked!') . '</span>';
00074 break;
00075 case UPDATE_NOT_SUPPORTED:
00076 $row .= '<span class="not-supported">' . t('Not supported!') . '</span>';
00077 break;
00078 case UPDATE_NOT_CURRENT:
00079 $row .= '<span class="not-current">' . t('Update available') . '</span>';
00080 break;
00081 case UPDATE_CURRENT:
00082 $row .= '<span class="current">' . t('Up to date') . '</span>';
00083 break;
00084 default:
00085 $row .= check_plain($project['reason']);
00086 break;
00087 }
00088 $row .= '<span class="icon">' . $icon . '</span>';
00089 $row .= "</div>\n";
00090
00091 $row .= '<div class="project">';
00092 if (isset($project['title'])) {
00093 if (isset($project['link'])) {
00094 $row .= l($project['title'], $project['link']);
00095 }
00096 else {
00097 $row .= check_plain($project['title']);
00098 }
00099 }
00100 else {
00101 $row .= check_plain($project['name']);
00102 }
00103 $row .= ' ' . check_plain($project['existing_version']);
00104 if ($project['install_type'] == 'dev' && !empty($project['datestamp'])) {
00105 $row .= ' <span class="version-date">(' . format_date($project['datestamp'], 'custom', 'Y-M-d') . ')</span>';
00106 }
00107 $row .= "</div>\n";
00108
00109 $row .= "<div class=\"versions\">\n";
00110
00111 if (isset($project['recommended'])) {
00112 if ($project['status'] != UPDATE_CURRENT || $project['existing_version'] != $project['recommended']) {
00113
00114
00115
00116
00117
00118 if (!empty($project['security updates']) && count($project['security updates']) == 1 && $project['security updates'][0]['version'] == $project['recommended']) {
00119 $security_class = ' version-recommended version-recommended-strong';
00120 }
00121 else {
00122 $security_class = '';
00123 $version_class = 'version-recommended';
00124
00125
00126 if ($project['recommended'] != $project['latest_version']
00127 || !empty($project['also'])
00128 || ($project['install_type'] == 'dev'
00129 && isset($project['dev_version'])
00130 && $project['latest_version'] != $project['dev_version']
00131 && $project['recommended'] != $project['dev_version'])
00132 || (isset($project['security updates'][0])
00133 && $project['recommended'] != $project['security updates'][0])
00134 ) {
00135 $version_class .= ' version-recommended-strong';
00136 }
00137 $row .= theme('update_version', $project['releases'][$project['recommended']], t('Recommended version:'), $version_class);
00138 }
00139
00140
00141 if (!empty($project['security updates'])) {
00142 foreach ($project['security updates'] as $security_update) {
00143 $row .= theme('update_version', $security_update, t('Security update:'), 'version-security' . $security_class);
00144 }
00145 }
00146 }
00147
00148 if ($project['recommended'] != $project['latest_version']) {
00149 $row .= theme('update_version', $project['releases'][$project['latest_version']], t('Latest version:'), 'version-latest');
00150 }
00151 if ($project['install_type'] == 'dev'
00152 && $project['status'] != UPDATE_CURRENT
00153 && isset($project['dev_version'])
00154 && $project['recommended'] != $project['dev_version']) {
00155 $row .= theme('update_version', $project['releases'][$project['dev_version']], t('Development version:'), 'version-latest');
00156 }
00157 }
00158
00159 if (isset($project['also'])) {
00160 foreach ($project['also'] as $also) {
00161 $row .= theme('update_version', $project['releases'][$also], t('Also available:'), 'version-also-available');
00162 }
00163 }
00164
00165 $row .= "</div>\n";
00166
00167 $row .= "<div class=\"info\">\n";
00168 if (!empty($project['extra'])) {
00169 $row .= '<div class="extra">' . "\n";
00170 foreach ($project['extra'] as $key => $value) {
00171 $row .= '<div class="' . $value['class'] . '">';
00172 $row .= check_plain($value['label']) . ': ';
00173 $row .= theme('placeholder', $value['data']);
00174 $row .= "</div>\n";
00175 }
00176 $row .= "</div>\n";
00177 }
00178
00179 $row .= '<div class="includes">';
00180 sort($project['includes']);
00181 $row .= t('Includes: %includes', array('%includes' => implode(', ', $project['includes'])));
00182 $row .= "</div>\n";
00183
00184 $row .= "</div>\n";
00185
00186 if (!isset($rows[$project['project_type']])) {
00187 $rows[$project['project_type']] = array();
00188 }
00189 $rows[$project['project_type']][] = array(
00190 'class' => $class,
00191 'data' => array($row),
00192 );
00193 }
00194
00195 $project_types = array(
00196 'core' => t('Drupal core'),
00197 'module' => t('Modules'),
00198 'theme' => t('Themes'),
00199 'disabled-module' => t('Disabled modules'),
00200 'disabled-theme' => t('Disabled themes'),
00201 );
00202 foreach ($project_types as $type_name => $type_label) {
00203 if (!empty($rows[$type_name])) {
00204 $output .= "\n<h3>" . $type_label . "</h3>\n";
00205 $output .= theme('table', $header, $rows[$type_name], array('class' => 'update'));
00206 }
00207 }
00208 drupal_add_css(drupal_get_path('module', 'update') . '/update.css');
00209 return $output;
00210 }
00211
00217 function theme_update_version($version, $tag, $class) {
00218 $output = '';
00219 $output .= '<table class="version ' . $class . '">';
00220 $output .= '<tr>';
00221 $output .= '<td class="version-title">' . $tag . "</td>\n";
00222 $output .= '<td class="version-details">';
00223 $output .= l($version['version'], $version['release_link']);
00224 $output .= ' <span class="version-date">(' . format_date($version['date'], 'custom', 'Y-M-d') . ')</span>';
00225 $output .= "</td>\n";
00226 $output .= '<td class="version-links">';
00227 $links = array();
00228 $links['update-download'] = array(
00229 'title' => t('Download'),
00230 'href' => $version['download_link'],
00231 );
00232 $links['update-release-notes'] = array(
00233 'title' => t('Release notes'),
00234 'href' => $version['release_link'],
00235 );
00236 $output .= theme('links', $links);
00237 $output .= '</td>';
00238 $output .= '</tr>';
00239 $output .= "</table>\n";
00240 return $output;
00241 }