From e7d739a6ea203351a01d0fdd432add858e6ea04b Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Fri, 24 May 2013 10:34:06 -0700 Subject: [PATCH] Issue #1843764 by joelpittet, Cottser, dmouse, shanethehat, jwilson3: Convert views/templates/views-view-summary-unformatted.tpl.php to twig. --- .../views-view-summary-unformatted.html.twig | 34 +++++++++++++++++++ .../views-view-summary-unformatted.tpl.php | 20 ----------- core/modules/views/views.theme.inc | 28 ++++++++++----- 3 files changed, 54 insertions(+), 28 deletions(-) create mode 100644 core/modules/views/templates/views-view-summary-unformatted.html.twig delete mode 100644 core/modules/views/templates/views-view-summary-unformatted.tpl.php diff --git a/core/modules/views/templates/views-view-summary-unformatted.html.twig b/core/modules/views/templates/views-view-summary-unformatted.html.twig new file mode 100644 index 00000000000..77f68a8ba2a --- /dev/null +++ b/core/modules/views/templates/views-view-summary-unformatted.html.twig @@ -0,0 +1,34 @@ +{# +/** + * @file + * Default theme implementation for unformatted summary links. + * + * Available variables: + * - rows: The rows contained in this view. + * - url: The URL to this row's content. + * - count: The number of items this summary item represents. + * - separator: A separator between each row. + * - row_classes: HTML attributes for a row, either containing an 'active' class + * or no attributes, that correlate to each row by ID. + * - options: Flags indicating how each row should be displayed. This contains: + * - count: A flag indicating whether the row's 'count' should be displayed. + * - inline: A flag indicating whether the item should be wrapped in an inline + * or block level HTML element. + * + * @see template_preprocess() + * @see template_preprocess_views_view_summary_unformatted() + * + * @ingroup themeable + */ +#} +{% for id, row in rows %} + {{ options.inline ? ' + {% if row.separator -%} + {{ row.separator }} + {%- endif %} + {{ row.link }} + {% if options.count %} + ({{ row.count }}) + {% endif %} + {{ options.inline ? '' : '' }} +{% endfor %} diff --git a/core/modules/views/templates/views-view-summary-unformatted.tpl.php b/core/modules/views/templates/views-view-summary-unformatted.tpl.php deleted file mode 100644 index 2280a711c95..00000000000 --- a/core/modules/views/templates/views-view-summary-unformatted.tpl.php +++ /dev/null @@ -1,20 +0,0 @@ - - $row): ?> - '; ?> - separator)): ?>separator; ?> - >link; ?> - - (count; ?>) - - ' : ''; ?> - diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index cb3c37a47d1..95a24b45e82 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -396,11 +396,20 @@ function template_preprocess_views_view_summary(&$vars) { } /** - * Template preprocess theme function to print summary basically - * unformatted. + * Prepares variables for unformatted summary view templates. + * + * Default template: views-view-summary-unformatted.html.twig. + * + * @param array $vars + * An associative array containing: + * - view: A ViewExecutable object. + * - rows: The raw row data. + * - options: An array of options. Each option contains: + * - separator: A string to be placed between inline fields to keep them + * visually distinct. */ function template_preprocess_views_view_summary_unformatted(&$vars) { - $view = $vars['view']; + $view = $vars['view']; $argument = $view->argument[$view->build_info['summary_level']]; $vars['row_classes'] = array(); @@ -412,12 +421,15 @@ function template_preprocess_views_view_summary_unformatted(&$vars) { $count = 0; $active_urls = drupal_map_assoc(array( - url(current_path(), array('alias' => TRUE)), // force system path - url(current_path()), // could be an alias + // Force system path. + url(current_path(), array('alias' => TRUE)), + // Could be an alias. + url(current_path()), )); - // Collect all arguments foreach row, to be able to alter them for example by the validator. - // This is not done per single argument value, because this could cause performance problems. + // Collect all arguments for each row, to be able to alter them for example + // by the validator. This is not done per single argument value, because + // this could cause performance problems. $row_args = array(); foreach ($vars['rows'] as $id => $row) { $row_args[$id] = $argument->summary_argument($row); @@ -425,7 +437,7 @@ function template_preprocess_views_view_summary_unformatted(&$vars) { $argument->process_summary_arguments($row_args); foreach ($vars['rows'] as $id => $row) { - // only false on first time: + // Only false on first time. if ($count++) { $vars['rows'][$id]->separator = filter_xss_admin($vars['options']['separator']); }