diff --git a/core/modules/update/templates/update-version.html.twig b/core/modules/update/templates/update-version.html.twig new file mode 100644 index 0000000..cde77d2 --- /dev/null +++ b/core/modules/update/templates/update-version.html.twig @@ -0,0 +1,21 @@ +{# +/** + * @file + * Default theme implementation for the version display of a project. + * + * Available variables: + * - table: The update version table. + * - title: The title of the project. + * - version: A list 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. + * - attributes: HTML attributes for the update versions table. + * + * @see template_preprocess_update_version() + * + * @ingroup themeable + */ +#} +{{ table }} diff --git a/core/modules/update/update.module b/core/modules/update/update.module index 6341857..97af32e 100644 --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -180,8 +180,9 @@ function update_theme() { 'file' => 'update.report.inc', ), 'update_version' => array( - 'variables' => array('version' => NULL, 'tag' => NULL, 'class' => array()), + 'variables' => array('version' => NULL, 'title' => NULL, 'attributes' => array()), 'file' => 'update.report.inc', + 'template' => 'update-version', ), 'update_status_label' => array( 'variables' => array('status' => NULL), diff --git a/core/modules/update/update.report.inc b/core/modules/update/update.report.inc index 6a06cbe..1257a58 100644 --- a/core/modules/update/update.report.inc +++ b/core/modules/update/update.report.inc @@ -137,8 +137,8 @@ function theme_update_report($variables) { $update_version = array( '#theme' => 'update_version', '#version' => $project['releases'][$project['recommended']], - '#tag' => t('Recommended version:'), - '#class' => $version_class, + '#title' => t('Recommended version:'), + '#attributes' => array('class' => $version_class), ); $versions_inner .= drupal_render($update_version); } @@ -150,8 +150,8 @@ function theme_update_report($variables) { $update_version = array( '#theme' => 'update_version', '#version' => $security_update, - '#tag' => t('Security update:'), - '#class' => $security_class, + '#title' => t('Security update:'), + '#attributes' => array('class' => $security_class), ); $versions_inner .= drupal_render($update_version); } @@ -162,8 +162,8 @@ function theme_update_report($variables) { $update_version = array( '#theme' => 'update_version', '#version' => $project['releases'][$project['latest_version']], - '#tag' => t('Latest version:'), - '#class' => array('version-latest'), + '#title' => t('Latest version:'), + '#attributes' => array('class' => array('version-latest')), ); $versions_inner .= drupal_render($update_version); } @@ -174,8 +174,8 @@ function theme_update_report($variables) { $update_version = array( '#theme' => 'update_version', '#version' => $project['releases'][$project['dev_version']], - '#tag' => t('Development version:'), - '#class' => array('version-latest'), + '#title' => t('Development version:'), + '#attributes' => array('class' => array('version-latest')), ); $versions_inner .= drupal_render($update_version); } @@ -186,8 +186,8 @@ function theme_update_report($variables) { $update_version = array( '#theme' => 'update_version', '#version' => $project['releases'][$also], - '#tag' => t('Also available:'), - '#class' => array('version-also-available'), + '#title' => t('Also available:'), + '#attributes' => array('class' => array('version-also-available')), ); $versions_inner .= drupal_render($update_version); } @@ -346,41 +346,54 @@ function theme_update_status_label($variables) { * - 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. + * - title: The title of the project. + * - attributes: An array containing attributes for the wrapping table. * * @ingroup themeable */ -function theme_update_version($variables) { +function template_preprocess_update_version(&$variables) { $version = $variables['version']; - $tag = $variables['tag']; - $class = implode(' ', $variables['class']); - - $output = ''; - $output .= '
' . $tag . " | \n"; - $output .= ''; - $output .= l($version['version'], $version['release_link']); - $output .= ' (' . format_date($version['date'], 'custom', 'Y-M-d') . ')'; - $output .= " | \n"; - $output .= ''; - $links = array(); - $links['update-download'] = array( + + $links['download'] = array( 'title' => t('Download'), 'href' => $version['download_link'], ); - $links['update-release-notes'] = array( + $links['release-notes'] = array( 'title' => t('Release notes'), 'href' => $version['release_link'], ); - $links__update_version = array( - '#theme' => 'links__update_version', - '#links' => $links, + + // Add a class attribute to the table. + $variables['attributes']['class'][] = 'version'; + + $variables['table'] = array( + '#type' => 'table', + '#attributes' => $variables['attributes'], + ); + + // Build row. + $variables['table'][] = array( + 'title' => array( + '#wrapper_attributes' => array('class' => array('version-title')), + '#markup' => $variables['title'], + ), + 'details' => array( + '#wrapper_attributes' => array('class' => array('version-details')), + array( + array( + '#markup' => l($version['version'], $version['release_link']), + ), + array( + '#prefix' => ' ', + '#markup' => format_date($version['date'], 'custom', 'Y-M-d'), + '#suffix' => '', + ), + ), + ), + 'links' => array( + '#theme' => 'links__update_version', + '#links' => $links, + '#wrapper_attributes' => array('class' => array('version-links')), + ), ); - $output .= drupal_render($links__update_version); - $output .= ' | '; - $output .= '