Issue #2264833 by lokeoke, joelpittet: Convert theme_update_version to update-version.html.twig.

8.0.x
Alex Pott 2014-08-04 12:16:48 +01:00
parent 7e394b02a9
commit 4f5d858269
3 changed files with 42 additions and 50 deletions

View File

@ -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>

View File

@ -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',
),
);
}

View File

@ -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;
}