Issue #1939090 by 2ndmile, hefox, Cottser, shanethehat, steveoliver, jenlampton, mr.baileys, derheap: Convert theme_tablesort_indicator() to Twig.

8.0.x
Alex Pott 2013-06-18 00:25:44 +02:00
parent 9dabd6de1c
commit 9ee90ca16d
2 changed files with 42 additions and 8 deletions

View File

@ -2213,20 +2213,34 @@ function theme_table($variables) {
}
/**
* Returns HTML for a sort icon.
* Prepares variables for tablesort indicator templates.
*
* @param $variables
* Default template: tablesort-indicator.html.twig.
*
* @param array $variables
* An associative array containing:
* - style: Set to either 'asc' or 'desc', this determines which icon to
* show.
* - style: Set to either 'asc' or 'desc'. This determines which icon to show.
*/
function theme_tablesort_indicator($variables) {
if ($variables['style'] == "asc") {
return theme('image', array('uri' => 'core/misc/arrow-asc.png', 'width' => 13, 'height' => 13, 'alt' => t('sort ascending'), 'title' => t('sort ascending')));
function template_preprocess_tablesort_indicator(&$variables) {
// Provide the image attributes for an ascending or descending image.
if ($variables['style'] == 'asc') {
$variables['uri'] = 'core/misc/arrow-asc.png';
$alt_title = t('sort ascending');
}
else {
return theme('image', array('uri' => 'core/misc/arrow-desc.png', 'width' => 13, 'height' => 13, 'alt' => t('sort descending'), 'title' => t('sort descending')));
$variables['uri'] = 'core/misc/arrow-desc.png';
$alt_title = t('sort descending');
}
// Add the image element.
$variables['image'] = array(
'#theme' => 'image',
'#uri' => $variables['uri'],
'#width' => 13,
'#height' => 13,
'#alt' => $alt_title,
'#title' => $alt_title,
);
}
/**
@ -3141,6 +3155,7 @@ function drupal_common_theme() {
),
'tablesort_indicator' => array(
'variables' => array('style' => NULL),
'template' => 'tablesort-indicator',
),
'mark' => array(
'variables' => array('mark_type' => MARK_NEW),

View File

@ -0,0 +1,19 @@
{#
/**
* @file
* Default theme implementation for displaying a tablesort indicator.
*
* Available variables:
* - image: A renderable image element.
* - style: Either 'asc' or 'desc', indicating the sorting direction.
* - uri: URI to ascending or descending image.
*
* @see template_preprocess()
* @see template_preprocess_tablesort_indicator()
*
* @ingroup themeable
*/
#}
{% spaceless %}
{{ image }}
{% endspaceless %}