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

@ -5,7 +5,6 @@
* Enables semantically enriched output for Drupal sites in the form of RDFa.
*/
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Template\Attribute;
@ -39,7 +38,7 @@ function rdf_help($route_name, RouteMatchInterface $route_match) {
* themes are coded to be RDFa compatible.
*/
/**
* Returns the RDF mapping object associated to a bundle.
* Returns the RDF mapping object associated with a bundle.
*
* The function reads the rdf_mapping object from the current configuration,
* or returns a ready-to-use empty one if no configuration entry exists yet for
@ -247,6 +246,9 @@ function rdf_comment_storage_load($comments) {
*/
function rdf_theme() {
return array(
'rdf_wrapper' => array(
'variables' => array('attributes' => array(), 'content' => NULL),
),
'rdf_metadata' => array(
'variables' => array('metadata' => array()),
),
@ -267,6 +269,27 @@ function rdf_preprocess_html(&$variables) {
}
}
/**
* Implements hook_preprocess_HOOK() for UID field templates.
*/
function rdf_preprocess_field__node__uid(&$variables) {
_rdf_set_field_rel_attribute($variables);
}
/**
* Transforms the field property attribute into a rel attribute.
*/
function _rdf_set_field_rel_attribute(&$variables) {
// Swap the regular field property attribute and use the rel attribute
// instead so that it plays well with the RDFa markup when only a link is
// present in the field output, for example in the case of the uid field.
if (!empty($variables['attributes']['property'])) {
$variables['attributes']['rel'] = $variables['attributes']['property'];
unset($variables['attributes']['property']);
}
}
/**
* Implements hook_preprocess_HOOK() for node templates.
*/
@ -294,12 +317,6 @@ function rdf_preprocess_node(&$variables) {
);
}
// Adds RDFa markup for the relation between the node and its author.
$author_mapping = $mapping->getPreparedFieldMapping('uid');
if (!empty($author_mapping['properties']) && $variables['display_submitted']) {
$variables['author_attributes']['rel'] = $author_mapping['properties'];
}
// Adds RDFa markup for the date.
$created_mapping = $mapping->getPreparedFieldMapping('created');
if (!empty($created_mapping) && $variables['display_submitted']) {
@ -416,7 +433,7 @@ function rdf_preprocess_username(&$variables) {
// Long usernames are truncated by template_preprocess_username(). Store the
// full name in the content attribute so it can be extracted in RDFa.
if ($variables['truncated']) {
$variables['attributes']['content'] = SafeMarkup::checkPlain($variables['name_raw']);
$variables['attributes']['content'] = $variables['name_raw'];
}
}
@ -440,11 +457,19 @@ function rdf_preprocess_comment(&$variables) {
// Adds RDFa markup for the relation between the comment and its author.
$author_mapping = $mapping->getPreparedFieldMapping('uid');
if (!empty($author_mapping)) {
$author_attributes = array('rel' => $author_mapping['properties']);
// Wraps the author variable and the submitted variable which are both
// available in comment.html.twig.
$variables['author'] = SafeMarkup::set('<span ' . new Attribute($author_attributes) . '>' . $variables['author'] . '</span>');
$variables['submitted'] = SafeMarkup::set('<span ' . new Attribute($author_attributes) . '>' . $variables['submitted'] . '</span>');
$author_attributes = ['rel' => $author_mapping['properties']];
// Wraps the 'author' and 'submitted' variables which are both available in
// comment.html.twig.
$variables['author'] = [
'#theme' => 'rdf_wrapper',
'#content' => $variables['author'],
'#attributes' => $author_attributes,
];
$variables['submitted'] = [
'#theme' => 'rdf_wrapper',
'#content' => $variables['submitted'],
'#attributes' => $author_attributes,
];
}
// Adds RDFa markup for the date of the comment.
$created_mapping = $mapping->getPreparedFieldMapping('created');
@ -457,11 +482,12 @@ function rdf_preprocess_comment(&$variables) {
'#theme' => 'rdf_metadata',
'#metadata' => array($date_attributes),
);
$created_metadata_markup = drupal_render($rdf_metadata);
// Appends the markup to the created variable and the submitted variable
// which are both available in comment.html.twig.
$variables['created'] = SafeMarkup::set(SafeMarkup::escape($variables['created']) . $created_metadata_markup);
$variables['submitted'] = SafeMarkup::set($variables['submitted'] . $created_metadata_markup);
// Ensure the original variable is represented as a render array.
$created = !is_array($variables['created']) ? ['#markup' => $variables['created']] : $variables['created'];
$submitted = !is_array($variables['submitted']) ? ['#markup' => $variables['submitted']] : $variables['submitted'];
// Make render array and RDF metadata available in comment.html.twig.
$variables['created'] = [$created, $rdf_metadata];
$variables['submitted'] = [$submitted, $rdf_metadata];
}
$title_mapping = $mapping->getPreparedFieldMapping('subject');
if (!empty($title_mapping)) {