| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: update.report.inc,v 1.10.2.6 2009/11/06 07:26:21 goba Exp $ 3 4 /** 5 * @file 6 * Code required only when rendering the available updates report. 7 */ 8 9 /** 10 * Menu callback. Generate a page about the update status of projects. 11 */ 12 function update_status() { 13 if ($available = update_get_available(TRUE)) { 14 module_load_include('inc', 'update', 'update.compare'); 15 $data = update_calculate_project_data($available); 16 return theme('update_report', $data); 17 } 18 else { 19 return theme('update_report', _update_no_data()); 20 } 21 } 22 23 /** 24 * Theme project status report. 25 * 26 * @ingroup themeable 27 */ 28 function theme_update_report($data) { 29 $last = variable_get('update_last_check', 0); 30 $output = '<div class="update checked">'. ($last ? t('Last checked: @time ago', array('@time' => format_interval(time() - $last))) : t('Last checked: never')); 31 $output .= ' <span class="check-manually">('. l(t('Check manually'), 'admin/reports/updates/check') .')</span>'; 32 $output .= "</div>\n"; 33 34 if (!is_array($data)) { 35 $output .= '<p>'. $data .'</p>'; 36 return $output; 37 } 38 39 $header = array(); 40 $rows = array(); 41 42 $notification_level = variable_get('update_notification_threshold', 'all'); 43 44 foreach ($data as $project) { 45 switch ($project['status']) { 46 case UPDATE_CURRENT: 47 $class = 'ok'; 48 $icon = theme('image', 'misc/watchdog-ok.png', t('ok'), t('ok')); 49 break; 50 case UPDATE_UNKNOWN: 51 case UPDATE_NOT_FETCHED: 52 $class = 'unknown'; 53 $icon = theme('image', 'misc/watchdog-warning.png', t('warning'), t('warning')); 54 break; 55 case UPDATE_NOT_SECURE: 56 case UPDATE_REVOKED: 57 case UPDATE_NOT_SUPPORTED: 58 $class = 'error'; 59 $icon = theme('image', 'misc/watchdog-error.png', t('error'), t('error')); 60 break; 61 case UPDATE_NOT_CHECKED: 62 case UPDATE_NOT_CURRENT: 63 default: 64 $class = 'warning'; 65 $icon = theme('image', 'misc/watchdog-warning.png', t('warning'), t('warning')); 66 break; 67 } 68 69 $row = '<div class="version-status">'; 70 switch ($project['status']) { 71 case UPDATE_NOT_SECURE: 72 $row .= '<span class="security-error">'. t('Security update required!') .'</span>'; 73 break; 74 case UPDATE_REVOKED: 75 $row .= '<span class="revoked">'. t('Revoked!') .'</span>'; 76 break; 77 case UPDATE_NOT_SUPPORTED: 78 $row .= '<span class="not-supported">'. t('Not supported!') .'</span>'; 79 break; 80 case UPDATE_NOT_CURRENT: 81 $row .= '<span class="not-current">'. t('Update available') .'</span>'; 82 break; 83 case UPDATE_CURRENT: 84 $row .= '<span class="current">'. t('Up to date') .'</span>'; 85 break; 86 default: 87 $row .= check_plain($project['reason']); 88 break; 89 } 90 $row .= '<span class="icon">'. $icon .'</span>'; 91 $row .= "</div>\n"; 92 93 $row .= '<div class="project">'; 94 if (isset($project['title'])) { 95 if (isset($project['link'])) { 96 $row .= l($project['title'], $project['link']); 97 } 98 else { 99 $row .= check_plain($project['title']); 100 } 101 } 102 else { 103 $row .= check_plain($project['name']); 104 } 105 $row .= ' '. check_plain($project['existing_version']); 106 if ($project['install_type'] == 'dev' && !empty($project['datestamp'])) { 107 $row .= ' <span class="version-date">('. format_date($project['datestamp'], 'custom', 'Y-M-d') .')</span>'; 108 } 109 $row .= "</div>\n"; 110 111 $row .= "<div class=\"versions\">\n"; 112 113 if (isset($project['recommended'])) { 114 if ($project['status'] != UPDATE_CURRENT || $project['existing_version'] !== $project['recommended']) { 115 116 // First, figure out what to recommend. 117 // If there's only 1 security update and it has the same version we're 118 // recommending, give it the same CSS class as if it was recommended, 119 // but don't print out a separate "Recommended" line for this project. 120 if (!empty($project['security updates']) && count($project['security updates']) == 1 && $project['security updates'][0]['version'] === $project['recommended']) { 121 $security_class = ' version-recommended version-recommended-strong'; 122 } 123 else { 124 $security_class = ''; 125 $version_class = 'version-recommended'; 126 // Apply an extra class if we're displaying both a recommended 127 // version and anything else for an extra visual hint. 128 if ($project['recommended'] !== $project['latest_version'] 129 || !empty($project['also']) 130 || ($project['install_type'] == 'dev' 131 && isset($project['dev_version']) 132 && $project['latest_version'] !== $project['dev_version'] 133 && $project['recommended'] !== $project['dev_version']) 134 || (isset($project['security updates'][0]) 135 && $project['recommended'] !== $project['security updates'][0]) 136 ) { 137 $version_class .= ' version-recommended-strong'; 138 } 139 $row .= theme('update_version', $project['releases'][$project['recommended']], t('Recommended version:'), $version_class); 140 } 141 142 // Now, print any security updates. 143 if (!empty($project['security updates'])) { 144 foreach ($project['security updates'] as $security_update) { 145 $row .= theme('update_version', $security_update, t('Security update:'), 'version-security'. $security_class); 146 } 147 } 148 } 149 150 if ($project['recommended'] !== $project['latest_version']) { 151 $row .= theme('update_version', $project['releases'][$project['latest_version']], t('Latest version:'), 'version-latest'); 152 } 153 if ($project['install_type'] == 'dev' 154 && $project['status'] != UPDATE_CURRENT 155 && isset($project['dev_version']) 156 && $project['recommended'] !== $project['dev_version']) { 157 $row .= theme('update_version', $project['releases'][$project['dev_version']], t('Development version:'), 'version-latest'); 158 } 159 } 160 161 if (isset($project['also'])) { 162 foreach ($project['also'] as $also) { 163 $row .= theme('update_version', $project['releases'][$also], t('Also available:'), 'version-also-available'); 164 } 165 } 166 167 $row .= "</div>\n"; // versions div. 168 169 $row .= "<div class=\"info\">\n"; 170 if (!empty($project['extra'])) { 171 $row .= '<div class="extra">'."\n"; 172 foreach ($project['extra'] as $key => $value) { 173 $row .= '<div class="'. $value['class'] .'">'; 174 $row .= check_plain($value['label']) .': '; 175 $row .= theme('placeholder', $value['data']); 176 $row .= "</div>\n"; 177 } 178 $row .= "</div>\n"; // extra div. 179 } 180 181 $row .= '<div class="includes">'; 182 sort($project['includes']); 183 $row .= t('Includes: %includes', array('%includes' => implode(', ', $project['includes']))); 184 $row .= "</div>\n"; 185 186 if (!empty($project['base_themes'])) { 187 $row .= '<div class="basethemes">'; 188 sort($project['base_themes']); 189 // We use !dependencies and manually call theme('placeholder') here to 190 // avoid breakding the D6 string freeze. This identical string is 191 // already in modules/system/system.admin.inc. 192 $row .= t('Depends on: !dependencies', array('!dependencies' => theme('placeholder', implode(', ', $project['base_themes'])))); 193 $row .= "</div>\n"; 194 } 195 196 if (!empty($project['sub_themes'])) { 197 $row .= '<div class="subthemes">'; 198 sort($project['sub_themes']); 199 // We use !required and manually call theme('placeholder') here to avoid 200 // breakding the D6 string freeze. This identical string is already in 201 // modules/system/system.admin.inc. 202 $row .= t('Required by: !required', array('!required' => theme('placeholder', implode(', ', $project['sub_themes'])))); 203 $row .= "</div>\n"; 204 } 205 206 $row .= "</div>\n"; // info div. 207 208 if (!isset($rows[$project['project_type']])) { 209 $rows[$project['project_type']] = array(); 210 } 211 $row_key = isset($project['title']) ? drupal_strtolower($project['title']) : drupal_strtolower($project['name']); 212 $rows[$project['project_type']][$row_key] = array( 213 'class' => $class, 214 'data' => array($row), 215 ); 216 } 217 218 $project_types = array( 219 'core' => t('Drupal core'), 220 'module' => t('Modules'), 221 'theme' => t('Themes'), 222 'disabled-module' => t('Disabled modules'), 223 'disabled-theme' => t('Disabled themes'), 224 ); 225 foreach ($project_types as $type_name => $type_label) { 226 if (!empty($rows[$type_name])) { 227 ksort($rows[$type_name]); 228 $output .= "\n<h3>". $type_label ."</h3>\n"; 229 $output .= theme('table', $header, $rows[$type_name], array('class' => 'update')); 230 } 231 } 232 drupal_add_css(drupal_get_path('module', 'update') .'/update.css'); 233 return $output; 234 } 235 236 /** 237 * Theme the version display of a project. 238 * 239 * @ingroup themeable 240 */ 241 function theme_update_version($version, $tag, $class) { 242 $output = ''; 243 $output .= '<table class="version '. $class .'">'; 244 $output .= '<tr>'; 245 $output .= '<td class="version-title">'. $tag ."</td>\n"; 246 $output .= '<td class="version-details">'; 247 $output .= l($version['version'], $version['release_link']); 248 $output .= ' <span class="version-date">('. format_date($version['date'], 'custom', 'Y-M-d') .')</span>'; 249 $output .= "</td>\n"; 250 $output .= '<td class="version-links">'; 251 $links = array(); 252 $links['update-download'] = array( 253 'title' => t('Download'), 254 'href' => $version['download_link'], 255 ); 256 $links['update-release-notes'] = array( 257 'title' => t('Release notes'), 258 'href' => $version['release_link'], 259 ); 260 $output .= theme('links', $links); 261 $output .= '</td>'; 262 $output .= '</tr>'; 263 $output .= "</table>\n"; 264 return $output; 265 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |