From 4f5d858269646511d6a2a7f7ce2b9d01522c8f3d Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Mon, 4 Aug 2014 12:16:48 +0100
Subject: [PATCH] Issue #2264833 by lokeoke, joelpittet: Convert
 theme_update_version to update-version.html.twig.

---
 .../update/templates/update-version.html.twig | 38 ++++++++++++++
 core/modules/update/update.module             |  5 +-
 core/modules/update/update.report.inc         | 49 -------------------
 3 files changed, 42 insertions(+), 50 deletions(-)
 create mode 100644 core/modules/update/templates/update-version.html.twig

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 000000000000..d1a80633d7a8
--- /dev/null
+++ b/core/modules/update/templates/update-version.html.twig
@@ -0,0 +1,38 @@
+{#
+/**
+ * @file
+ * Default theme implementation for the version display of a project.
+ *
+ * Available variables:
+ * - attributes: HTML attributes suitable for a container element.
+ * - title: The title of the project.
+ * - version:  A list of data about the latest released version, containing:
+ *   - version: The version number.
+ *   - date: The date of the release.
+ *   - download_link: The URL for the downloadable file.
+ *   - release_link: The URL for the release notes.
+ *
+ * @see template_preprocess_update_version()
+ *
+ * @ingroup themeable
+ */
+#}
+<table class="{{ attributes.class }} version"{{ attributes|without('class') }}>
+  <tr>
+    <td class="version-title">{{ title }}</td>
+    <td class="version-details">
+      <a href="{{ version.release_link }}">{{ version.version }}</a>
+      <span class="version-date">({{ version.date|date('Y-M-d') }})</span>
+    </td>
+    <td class="version-links">
+      <ul class="links">
+        <li class="download">
+          <a href="{{ version.download_link }}">{{ 'Download'|t }}</a>
+        </li>
+        <li class="release-notes">
+          <a href="{{ version.release_link }}">{{ 'Release notes'|t }}</a>
+        </li>
+      </ul>
+    </td>
+  </tr>
+</table>
diff --git a/core/modules/update/update.module b/core/modules/update/update.module
index 7ef5afd598aa..ec3e1b4e1057 100644
--- a/core/modules/update/update.module
+++ b/core/modules/update/update.module
@@ -189,8 +189,11 @@ function update_theme() {
       'template' => 'update-project-status',
     ),
     'update_version' => array(
-      'variables' => array('version' => NULL, 'tag' => NULL, 'class' => array()),
+      'variables' => array('version' => NULL, 'title' => NULL, 'attributes' => array()),
       'file' => 'update.report.inc',
+      // We are using template instead of '#type' => 'table' here to keep markup
+      // out of preprocess and allow for easier changes to markup.
+      'template' => 'update-version',
     ),
   );
 }
diff --git a/core/modules/update/update.report.inc b/core/modules/update/update.report.inc
index bf3d6ae03395..62fa61339f4f 100644
--- a/core/modules/update/update.report.inc
+++ b/core/modules/update/update.report.inc
@@ -352,52 +352,3 @@ function template_preprocess_update_project_status(&$variables) {
     '#title' => $text,
   );
 }
-
-/**
- * Returns HTML for the version display of a project.
- *
- * @param array $variables
- *   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.
- *
- * @ingroup themeable
- */
-function theme_update_version($variables) {
-  $version = $variables['version'];
-  $tag = $variables['tag'];
-  $class = implode(' ', $variables['class']);
-
-  $output = '';
-  $output .= '<table class="version ' . $class . '">';
-  $output .= '<tr>';
-  $output .= '<td class="version-title">' . $tag . "</td>\n";
-  $output .= '<td class="version-details">';
-  $output .= l($version['version'], $version['release_link']);
-  $output .= ' <span class="version-date">(' . format_date($version['date'], 'custom', 'Y-M-d') . ')</span>';
-  $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'],
-  );
-  $links__update_version = array(
-    '#theme' => 'links__update_version',
-    '#links' => $links,
-  );
-  $output .= drupal_render($links__update_version);
-  $output .= '</td>';
-  $output .= '</tr>';
-  $output .= "</table>\n";
-  return $output;
-}
-- 
GitLab