Issue #1810710 by Berdir, Fabianx: Remove copying of node properties wholesale into theme variables.
parent
719023ff58
commit
b7f577a2a8
|
@ -725,15 +725,15 @@ function locale_system_file_system_settings_submit(&$form, $form_state) {
|
|||
* Implements hook_preprocess_HOOK() for node.tpl.php.
|
||||
*/
|
||||
function locale_preprocess_node(&$variables) {
|
||||
if ($variables['langcode'] != LANGUAGE_NOT_SPECIFIED) {
|
||||
if ($variables['node']->langcode != LANGUAGE_NOT_SPECIFIED) {
|
||||
$language_interface = language(LANGUAGE_TYPE_INTERFACE);
|
||||
|
||||
$node_language = language_load($variables['langcode']);
|
||||
$node_language = language_load($variables['node']->langcode);
|
||||
if ($node_language->langcode != $language_interface->langcode) {
|
||||
// If the node language was different from the page language, we should
|
||||
// add markup to identify the language. Otherwise the page language is
|
||||
// inherited.
|
||||
$variables['attributes']['lang'] = $variables['langcode'];
|
||||
$variables['attributes']['lang'] = $variables['node']->langcode;
|
||||
if ($node_language->direction != $language_interface->direction) {
|
||||
// If text direction is different form the page's text direction, add
|
||||
// direction information as well.
|
||||
|
|
|
@ -1179,8 +1179,14 @@ function template_preprocess_node(&$variables) {
|
|||
$variables['label'] = check_plain($node->label());
|
||||
$variables['page'] = $variables['view_mode'] == 'full' && node_is_page($node);
|
||||
|
||||
// Flatten the node entity's member fields.
|
||||
$variables = array_merge((array) $node, $variables);
|
||||
// Make useful flags and node data available.
|
||||
// @todo: The comment properties only exist if comment.module is enabled, but
|
||||
// are documented in node.tpl.php, so we make sure that they are set.
|
||||
// Consider removing them.
|
||||
$properties = array('type', 'comment_count', 'uid', 'created', 'promote', 'sticky', 'status', 'comment');
|
||||
foreach ($properties as $property) {
|
||||
$variables[$property] = isset($node->$property) ? $node->$property : NULL;
|
||||
}
|
||||
|
||||
// Helpful $content variable for templates.
|
||||
$variables += array('content' => array());
|
||||
|
@ -1208,13 +1214,13 @@ function template_preprocess_node(&$variables) {
|
|||
|
||||
// Gather node classes.
|
||||
$variables['attributes']['class'][] = drupal_html_class('node-' . $node->type);
|
||||
if ($variables['promote']) {
|
||||
if ($node->promote) {
|
||||
$variables['attributes']['class'][] = 'promoted';
|
||||
}
|
||||
if ($variables['sticky']) {
|
||||
if ($node->sticky) {
|
||||
$variables['attributes']['class'][] = 'sticky';
|
||||
}
|
||||
if (!$variables['status']) {
|
||||
if (!$node->status) {
|
||||
$variables['attributes']['class'][] = 'unpublished';
|
||||
}
|
||||
if ($variables['view_mode']) {
|
||||
|
|
|
@ -58,8 +58,6 @@
|
|||
* - $sticky: Flags for sticky post setting.
|
||||
* - $status: Flag for published status.
|
||||
* - $comment: State of comment settings for the node.
|
||||
* - $readmore: Flags true if the teaser content of the node cannot hold the
|
||||
* main body content.
|
||||
* - $is_front: Flags true when presented in the front page.
|
||||
* - $logged_in: Flags true when the current user is a logged-in member.
|
||||
* - $is_admin: Flags true when the current user is an administrator.
|
||||
|
|
|
@ -527,7 +527,7 @@ function rdf_preprocess_node(&$variables) {
|
|||
$element = array(
|
||||
'#tag' => 'meta',
|
||||
'#attributes' => array(
|
||||
'content' => $variables['title'],
|
||||
'content' => $variables['label'],
|
||||
'about' => $variables['node_url'],
|
||||
),
|
||||
);
|
||||
|
@ -538,18 +538,18 @@ function rdf_preprocess_node(&$variables) {
|
|||
}
|
||||
|
||||
// Adds RDFa markup for the date.
|
||||
if (!empty($variables['rdf_mapping']['created'])) {
|
||||
$date_attributes = rdf_rdfa_attributes($variables['rdf_mapping']['created'], $variables['created']);
|
||||
if (!empty($variables['node']->rdf_mapping['created'])) {
|
||||
$date_attributes = rdf_rdfa_attributes($variables['node']->rdf_mapping['created'], $variables['node']->created);
|
||||
$variables['rdf_template_variable_attributes']['date'] = $date_attributes;
|
||||
if ($variables['submitted']) {
|
||||
$variables['rdf_template_variable_attributes']['submitted'] = $date_attributes;
|
||||
}
|
||||
}
|
||||
// Adds RDFa markup for the relation between the node and its author.
|
||||
if (!empty($variables['rdf_mapping']['uid'])) {
|
||||
$variables['rdf_template_variable_attributes']['name']['rel'] = $variables['rdf_mapping']['uid']['predicates'];
|
||||
if (!empty($variables['node']->rdf_mapping['uid'])) {
|
||||
$variables['rdf_template_variable_attributes']['name']['rel'] = $variables['node']->rdf_mapping['uid']['predicates'];
|
||||
if ($variables['submitted']) {
|
||||
$variables['rdf_template_variable_attributes']['submitted']['rel'] = $variables['rdf_mapping']['uid']['predicates'];
|
||||
$variables['rdf_template_variable_attributes']['submitted']['rel'] = $variables['node']->rdf_mapping['uid']['predicates'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,8 +58,6 @@
|
|||
* - $sticky: Flags for sticky post setting.
|
||||
* - $status: Flag for published status.
|
||||
* - $comment: State of comment settings for the node.
|
||||
* - $readmore: Flags true if the teaser content of the node cannot hold the
|
||||
* main body content.
|
||||
* - $is_front: Flags true when presented in the front page.
|
||||
* - $logged_in: Flags true when the current user is a logged-in member.
|
||||
* - $is_admin: Flags true when the current user is an administrator.
|
||||
|
|
Loading…
Reference in New Issue