Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023

This commit is contained in:
Pantheon Automation 2015-09-04 13:20:09 -07:00 committed by Greg Anderson
parent 2720a9ec4b
commit f3791f1da3
1898 changed files with 54300 additions and 11481 deletions

View file

@ -6,7 +6,6 @@
*/
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Url;
@ -90,6 +89,9 @@ function template_preprocess_views_view_fields(&$variables) {
$object = new stdClass();
$object->handler = $view->field[$id];
$object->inline = !empty($variables['options']['inline'][$id]);
// Set up default value of the flag that indicates whether to display a
// colon after the label.
$object->has_label_colon = FALSE;
$object->element_type = $object->handler->elementType(TRUE, !$variables['options']['default_field_elements'], $object->inline);
if ($object->element_type) {
@ -101,18 +103,7 @@ function template_preprocess_views_view_fields(&$variables) {
if ($classes = $object->handler->elementClasses($row->index)) {
$attributes['class'][] = $classes;
}
$attributes = new Attribute($attributes);
$pre = '<' . $object->element_type;
$pre .= $attributes;
$field_output = $pre . '>' . $field_output . '</' . $object->element_type . '>';
}
// Protect ourselves somewhat for backward compatibility. This will
// prevent old templates from producing invalid HTML when no element type
// is selected.
if (empty($object->element_type)) {
$object->element_type = 'span';
$object->element_attributes = new Attribute($attributes);
}
$object->content = $field_output;
@ -130,16 +121,14 @@ function template_preprocess_views_view_fields(&$variables) {
$object->class = Html::cleanCssIdentifier($id);
$previous_inline = $object->inline;
$object->inline_html = $object->handler->elementWrapperType(TRUE, TRUE);
if ($object->inline_html === '' && $variables['options']['default_field_elements']) {
$object->inline_html = $object->inline ? 'span' : 'div';
// Set up field wrapper element.
$object->wrapper_element = $object->handler->elementWrapperType(TRUE, TRUE);
if ($object->wrapper_element === '' && $variables['options']['default_field_elements']) {
$object->wrapper_element = $object->inline ? 'span' : 'div';
}
// Set up the wrapper HTML.
$object->wrapper_prefix = '';
$object->wrapper_suffix = '';
if ($object->inline_html) {
// Set up field wrapper attributes if field wrapper was set.
if ($object->wrapper_element) {
$attributes = array();
if ($object->handler->options['element_default_classes']) {
$attributes['class'][] = 'views-field';
@ -149,26 +138,24 @@ function template_preprocess_views_view_fields(&$variables) {
if ($classes = $object->handler->elementWrapperClasses($row->index)) {
$attributes['class'][] = $classes;
}
$attributes = new Attribute($attributes);
$object->wrapper_prefix = '<' . $object->inline_html;
$object->wrapper_prefix .= $attributes;
$object->wrapper_prefix .= '>';
$object->wrapper_suffix = '</' . $object->inline_html . '>';
$object->wrapper_attributes = new Attribute($attributes);
}
// Set up the label for the value and the HTML to make it easier
// on the template.
$object->label = SafeMarkup::checkPlain($view->field[$id]->label());
$object->label_html = '';
// Set up field label
$object->label = $view->field[$id]->label();
// Set up field label wrapper and its attributes.
if ($object->label) {
$object->label_html .= $object->label;
// Add a colon in a label suffix.
if ($object->handler->options['element_label_colon']) {
$object->label_html .= ': ';
$object->has_label_colon = TRUE;
}
$object->elementLabelType = $object->handler->elementLabelType(TRUE, !$variables['options']['default_field_elements']);
if ($object->elementLabelType) {
// Set up label HTML element.
$object->label_element = $object->handler->elementLabelType(TRUE, !$variables['options']['default_field_elements']);
// Set up label attributes.
if ($object->label_element) {
$attributes = array();
if ($object->handler->options['element_default_classes']) {
$attributes['class'][] = 'views-label';
@ -179,13 +166,7 @@ function template_preprocess_views_view_fields(&$variables) {
if ($element_label_class) {
$attributes['class'][] = $element_label_class;
}
$attributes = new Attribute($attributes);
$pre = '<' . $object->elementLabelType;
$pre .= $attributes;
$pre .= '>';
$object->label_html = $pre . $object->label_html . '</' . $object->elementLabelType . '>';
$object->label_attributes = new Attribute($attributes);
}
}
@ -219,12 +200,32 @@ function theme_views_view_fields($variables) {
if (!empty($field->separator)) {
$output .= $field->separator;
}
$output .= $field->wrapper_prefix;
$output .= $field->label_html;
$wrapper_element = Html::escape($field->wrapper_element);
if ($wrapper_element) {
$output .= '<' . $wrapper_element . $field->wrapper_attributes . '>';
if (isset($field->label_element) && !empty($field->label_element)) {
$label_element = Html::escape($field->label_element);
$output .= '<' . $label_element . $field->label_attributes . '>';
}
$output .= Html::escape($field->label);
if ($field->has_label_colon) {
$output .= ': ';
}
if (isset($label_element)) {
$output .= '</' . $label_element . '>';
}
}
$element_type = Html::escape($field->element_type);
if ($element_type) {
$output .= '<' . $element_type . $field->element_attributes . '>';
}
$output .= $field->content;
$output .= $field->wrapper_suffix;
if ($element_type) {
$output .= '</' . $element_type . '>';
}
if ($wrapper_element) {
$output .= '</' . $wrapper_element . '>';
}
}
return $output;
@ -467,7 +468,7 @@ function template_preprocess_views_view_table(&$variables) {
// Render the header labels.
if ($field == $column && empty($fields[$field]->options['exclude'])) {
$label = SafeMarkup::checkPlain(!empty($fields[$field]) ? $fields[$field]->label() : '');
$label = !empty($fields[$field]) ? $fields[$field]->label() : '';
if (empty($options['info'][$field]['sortable']) || !$fields[$field]->clickSortable()) {
$variables['header'][$field]['content'] = $label;
}
@ -480,23 +481,23 @@ function template_preprocess_views_view_table(&$variables) {
$title = t('sort by @s', array('@s' => $label));
if ($active == $field) {
$tablesort_indicator = array(
$variables['header'][$field]['sort_indicator'] = array(
'#theme' => 'tablesort_indicator',
'#style' => $initial,
);
$markup = drupal_render($tablesort_indicator);
$label = SafeMarkup::set($label . $markup);
}
$query['order'] = $field;
$query['sort'] = $initial;
$link_options = array(
'attributes' => array('title' => $title),
'query' => $query,
);
// It is ok to specify no URL path here as we will always reload the
// current page.
$variables['header'][$field]['content'] = \Drupal::l($label, new Url('<none>', [], $link_options));
$url = new Url('<none>', [], $link_options);
$variables['header'][$field]['url'] = $url->toString();
$variables['header'][$field]['content'] = $label;
$variables['header'][$field]['title'] = $title;
}
$variables['header'][$field]['default_classes'] = $fields[$field]->options['element_default_classes'];
@ -519,7 +520,7 @@ function template_preprocess_views_view_table(&$variables) {
if ($variables['header'][$field]['content']) {
$element_label_type = $fields[$field]->elementLabelType(TRUE, TRUE);
if ($element_label_type) {
$variables['header'][$field]['content'] = '<' . $element_label_type . '>' . $variables['header'][$field]['content'] . '</' . $element_label_type . '>';
$variables['header'][$field]['wrapper_element'] = $element_label_type;
}
// Improves accessibility of complex tables.
$variables['header'][$field]['attributes']['id'] = Html::getUniqueId('view-' . $field . '-table-column');
@ -576,27 +577,25 @@ function template_preprocess_views_view_table(&$variables) {
if (!empty($fields[$field])) {
$field_output = $handler->getField($num, $field);
$element_type = $fields[$field]->elementType(TRUE, TRUE);
if ($element_type) {
$field_output = SafeMarkup::set('<' . $element_type . '>' . SafeMarkup::escape($field_output) . '</' . $element_type . '>');
$column_reference['wrapper_element'] = $fields[$field]->elementType(TRUE, TRUE);
if (!isset($column_reference['content'])) {
$column_reference['content'] = [];
}
// Only bother with separators and stuff if the field shows up.
if (!empty($field_output)) {
// Place the field into the column, along with an optional separator.
if (!empty($column_reference['content'])) {
if (!empty($options['info'][$column]['separator'])) {
$safe_content = SafeMarkup::escape($column_reference['content']);
$safe_separator = Xss::filterAdmin($options['info'][$column]['separator']);
$column_reference['content'] = SafeMarkup::set($safe_content . $safe_separator);
}
// Place the field into the column, along with an optional separator.
if (trim($field_output) != '') {
if (!empty($column_reference['content']) && !empty($options['info'][$column]['separator'])) {
$column_reference['content'][] = [
'separator' => ['#markup' => $options['info'][$column]['separator']],
'field_output' => ['#markup' => $field_output]
];
}
else {
$column_reference['content'] = '';
$column_reference['content'][] = [
'field_output' => ['#markup' => $field_output]
];
}
$safe_content = SafeMarkup::escape($column_reference['content']);
$safe_field_output = SafeMarkup::escape($field_output);
$column_reference['content'] = SafeMarkup::set($safe_content . $safe_field_output);
}
}
$column_reference['attributes'] = new Attribute($column_reference['attributes']);
@ -633,7 +632,7 @@ function template_preprocess_views_view_table(&$variables) {
if (empty($variables['rows']) && !empty($options['empty_table'])) {
$build = $view->display_handler->renderArea('empty');
$variables['rows'][0]['columns'][0]['content'] = drupal_render($build);
$variables['rows'][0]['columns'][0]['content'][0]['field_output'] = $build;
$variables['rows'][0]['attributes'] = new Attribute(array('class' => 'odd'));
// Calculate the amounts of rows with output.
$variables['rows'][0]['columns'][0]['attributes'] = new Attribute(array(
@ -650,7 +649,7 @@ function template_preprocess_views_view_table(&$variables) {
// Add the caption to the list if set.
if (!empty($handler->options['caption'])) {
$variables['caption'] = Xss::filterAdmin($handler->options['caption']);
$variables['caption'] = ['#markup' => $handler->options['caption']];
$variables['caption_needed'] = TRUE;
}
else {
@ -855,7 +854,7 @@ function template_preprocess_views_view_rss(&$variables) {
// The RSS 2.0 "spec" doesn't indicate HTML can be used in the description.
// We strip all HTML tags, but need to prevent double encoding from properly
// escaped source data (such as &amp becoming &amp;amp;).
$variables['description'] = SafeMarkup::checkPlain(Html::decodeEntities(strip_tags($style->getDescription())));
$variables['description'] = Html::decodeEntities(strip_tags($style->getDescription()));
if ($view->display_handler->getOption('sitename_title')) {
$title = $config->get('name');
@ -866,7 +865,7 @@ function template_preprocess_views_view_rss(&$variables) {
else {
$title = $view->getTitle();
}
$variables['title'] = SafeMarkup::checkPlain($title);
$variables['title'] = $title;
// Figure out which display which has a path we're using for this feed. If
// there isn't one, use the global $base_url
@ -892,7 +891,7 @@ function template_preprocess_views_view_rss(&$variables) {
$variables['link'] = $url_string;
}
$variables['langcode'] = SafeMarkup::checkPlain(\Drupal::languageManager()->getCurrentLanguage()->getId());
$variables['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->getId();
$variables['namespaces'] = new Attribute($style->namespaces);
$variables['items'] = $items;
$variables['channel_elements'] = \Drupal::service('renderer')->render($style->channel_elements);
@ -957,7 +956,7 @@ function template_preprocess_views_view_opml(&$variables) {
else {
$title = $view->getTitle();
}
$variables['title'] = SafeMarkup::checkPlain($title);
$variables['title'] = $title;
$variables['items'] = $items;
$variables['updated'] = gmdate(DATE_RFC2822, REQUEST_TIME);