commit f8e4cf67ea6b65a304ea72ec82527557da352aa4 Author: Joel Pittet Date: Fri Apr 12 19:44:22 2013 -0700 update_version 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..f3aec6a --- /dev/null +++ b/core/modules/update/templates/update-version.html.twig @@ -0,0 +1,32 @@ +{# +/** + * @file + * Default theme implementation for the version display of a project. + * + * Available variables: + * - 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. + * + * @see template_preprocess + * @see template_preprocess_update_version + * + * @ingroup themeable + */ +#} + + + {{ tag }} + + {{ version_link }} + {{ version_date }} + + + {{ version_links }} + + + diff --git a/core/modules/update/update.module b/core/modules/update/update.module index 21d317c..e9b8663 100644 --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -265,11 +265,10 @@ function update_theme() { 'variables' => array('data' => NULL), // 'template' => 'update-report', ), - // @todo convert to #type=>table and remove this theme function. - // @see http://drupal.org/node/1938934. 'update_version' => array( - 'variables' => array('version' => NULL, 'tag' => NULL, 'class' => array()), + 'variables' => array('version' => NULL, 'tag' => NULL), '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 b56e615..6bbd9cd 100644 --- a/core/modules/update/update.report.inc +++ b/core/modules/update/update.report.inc @@ -151,32 +151,52 @@ function theme_update_report($variables) { ) { $version_class[] = 'version-recommended-strong'; } - $versions_inner .= theme('update_version', array('version' => $project['releases'][$project['recommended']], 'tag' => t('Recommended version:'), 'class' => $version_class)); + $versions_inner .= theme('update_version', array( + 'version' => $project['releases'][$project['recommended']], + 'tag' => t('Recommended version:'), + 'attributes' => array('class' => $version_class), + )); } // Now, print any security updates. if (!empty($project['security updates'])) { $security_class[] = 'version-security'; foreach ($project['security updates'] as $security_update) { - $versions_inner .= theme('update_version', array('version' => $security_update, 'tag' => t('Security update:'), 'class' => $security_class)); + $versions_inner .= theme('update_version', array( + 'version' => $security_update, + 'tag' => t('Security update:'), + 'attributes' => array('class' => $security_class), + )); } } } if ($project['recommended'] !== $project['latest_version']) { - $versions_inner .= theme('update_version', array('version' => $project['releases'][$project['latest_version']], 'tag' => t('Latest version:'), 'class' => array('version-latest'))); + $versions_inner .= theme('update_version', array( + 'version' => $project['releases'][$project['latest_version']], + 'tag' => t('Latest version:'), + 'attributes' => array('class' => array('version-latest')), + )); } if ($project['install_type'] == 'dev' && $project['status'] != UPDATE_CURRENT && isset($project['dev_version']) && $project['recommended'] !== $project['dev_version']) { - $versions_inner .= theme('update_version', array('version' => $project['releases'][$project['dev_version']], 'tag' => t('Development version:'), 'class' => array('version-latest'))); + $versions_inner .= theme('update_version', array( + 'version' => $project['releases'][$project['dev_version']], + 'tag' => t('Development version:'), + 'attributes' => array('class' => array('version-latest')), + )); } } if (isset($project['also'])) { foreach ($project['also'] as $also) { - $versions_inner .= theme('update_version', array('version' => $project['releases'][$also], 'tag' => t('Also available:'), 'class' => array('version-also-available'))); + $versions_inner .= theme('update_version', array( + 'version' => $project['releases'][$also], + 'tag' => t('Also available:'), + 'attributes' => array('class' => array('version-also-available')), + )); } } @@ -305,7 +325,9 @@ function template_preprocess_update_status_label(&$variables) { } /** - * Returns HTML for the version display of a project. + * Prepare variables for the version display of a project. + * + * Default template: update-version.html.twig. * * @param array $variables * An associative array containing: @@ -315,36 +337,28 @@ function template_preprocess_update_status_label(&$variables) { * - 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. - * - * @ingroup themeable - */ -function theme_update_version($variables) { +*/ +function template_preprocess_update_version(&$variables) { $version = $variables['version']; - $tag = $variables['tag']; - $class = implode(' ', $variables['class']); + // Add version to the classes. + $variables['attributes']['class'][] = 'version'; + // Convert the attributes array to an Attribute object. + $variables['attributes'] = new Attribute($variables['attributes']); + + $variables['version_link'] = l($version['version'], $version['release_link']); + $variables['version_date'] = format_date($version['date'], 'custom', 'Y-M-d'); - $output = ''; - $output .= ''; - $output .= ''; - $output .= '\n"; - $output .= '\n"; - $output .= ''; - $output .= ''; - $output .= "
' . $tag . "'; - $output .= l($version['version'], $version['release_link']); - $output .= ' (' . format_date($version['date'], 'custom', 'Y-M-d') . ')'; - $output .= "
\n"; - return $output; + $variables['version_links'] = array( + '#theme' => 'links__update_version', + '#links' => $links, + ); }