summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-09-11 06:48:03 +0000
committerDries Buytaert <dries@buytaert.net>2009-09-11 06:48:03 +0000
commit2729f1c2f0ae6aa790edf1a8be70a74fae04934c (patch)
tree160fa3de22ec22c8b63d4c09e41769cd8902b98e
parent4f3e5cd94085d9a83aa9e52c95bf0fd7aedfb753 (diff)
downloadbrdo-2729f1c2f0ae6aa790edf1a8be70a74fae04934c.tar.gz
brdo-2729f1c2f0ae6aa790edf1a8be70a74fae04934c.tar.bz2
- Patch #569362 by scor, effulgentsia, catch: add attributes and title_attributes() variables for tpl files so that RDFa and Microformats can be implemented.
-rw-r--r--includes/theme.inc8
-rw-r--r--modules/block/block.tpl.php4
-rw-r--r--modules/comment/comment-wrapper.tpl.php2
-rw-r--r--modules/comment/comment.tpl.php4
-rw-r--r--modules/field/field.module16
-rw-r--r--modules/field/theme/field.tpl.php6
-rw-r--r--modules/node/node.tpl.php4
-rw-r--r--themes/garland/block.tpl.php4
-rw-r--r--themes/garland/comment.tpl.php4
-rw-r--r--themes/garland/node.tpl.php4
10 files changed, 40 insertions, 16 deletions
diff --git a/includes/theme.inc b/includes/theme.inc
index 3ac1dc90f..352706eff 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -2042,6 +2042,10 @@ function template_preprocess(&$variables, $hook) {
// Initialize html class attribute for the current hook.
$variables['classes_array'] = array($hook);
+ // Initialize attributes for the top-level template entity and its title.
+ $variables['attributes_array'] = array();
+ $variables['title_attributes_array'] = array();
+
// Set default variables that depend on the database.
$variables['is_admin'] = FALSE;
$variables['is_front'] = FALSE;
@@ -2066,6 +2070,10 @@ function template_preprocess(&$variables, $hook) {
function template_process(&$variables, $hook) {
// Flatten out classes.
$variables['classes'] = implode(' ', $variables['classes_array']);
+
+ // Flatten out attributes and title_attributes.
+ $variables['attributes'] = drupal_attributes($variables['attributes_array']);
+ $variables['title_attributes'] = drupal_attributes($variables['title_attributes_array']);
}
/**
diff --git a/modules/block/block.tpl.php b/modules/block/block.tpl.php
index 77b1fa938..961cb01b0 100644
--- a/modules/block/block.tpl.php
+++ b/modules/block/block.tpl.php
@@ -35,9 +35,9 @@
* @see template_process()
*/
?>
-<div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?>">
+<div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
<?php if ($block->subject): ?>
- <h2><?php print $block->subject ?></h2>
+ <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
<?php endif;?>
<div class="content">
diff --git a/modules/comment/comment-wrapper.tpl.php b/modules/comment/comment-wrapper.tpl.php
index aabf3850f..1d1e1fe9b 100644
--- a/modules/comment/comment-wrapper.tpl.php
+++ b/modules/comment/comment-wrapper.tpl.php
@@ -30,7 +30,7 @@
* @see theme_comment_wrapper()
*/
?>
-<div id="comments" class="<?php print $classes; ?>">
+<div id="comments" class="<?php print $classes; ?>"<?php print $attributes; ?>>
<?php if ($node->type != 'forum'): ?>
<h2 class="comments"><?php print t('Comments'); ?></h2>
<?php endif; ?>
diff --git a/modules/comment/comment.tpl.php b/modules/comment/comment.tpl.php
index cae102f85..e77785590 100644
--- a/modules/comment/comment.tpl.php
+++ b/modules/comment/comment.tpl.php
@@ -44,14 +44,14 @@
* @see theme_comment()
*/
?>
-<div class="<?php print $classes; ?> clearfix">
+<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
<?php print $picture ?>
<?php if ($new): ?>
<span class="new"><?php print $new ?></span>
<?php endif; ?>
- <h3><?php print $title ?></h3>
+ <h3<?php print $title_attributes; ?>><?php print $title ?></h3>
<div class="submitted">
<?php
diff --git a/modules/field/field.module b/modules/field/field.module
index 487ea3595..75dc3d431 100644
--- a/modules/field/field.module
+++ b/modules/field/field.module
@@ -756,8 +756,24 @@ function template_preprocess_field(&$variables) {
),
);
$variables = array_merge($variables, $additions);
+
+ // Initialize attributes for each item.
+ foreach ($variables['items'] as $delta => $item) {
+ $variables['item_attributes_array'][$delta] = array();
+ }
}
/**
+ * Theme process function for field.tpl.php.
+ *
+ * @see field.tpl.php
+ */
+function template_process_field(&$variables) {
+ // Flatten out attributes for each item.
+ foreach ($variables['items'] as $delta => $item) {
+ $variables['item_attributes'][$delta] = drupal_attributes($variables['item_attributes_array'][$delta]);
+ }
+}
+/**
* @} End of "defgroup field"
*/
diff --git a/modules/field/theme/field.tpl.php b/modules/field/theme/field.tpl.php
index 9018f45b5..312c4b844 100644
--- a/modules/field/theme/field.tpl.php
+++ b/modules/field/theme/field.tpl.php
@@ -39,13 +39,13 @@
*/
?>
<?php if ($items) : ?>
- <div class="field <?php print $classes; ?> clearfix">
+ <div class="field <?php print $classes; ?> clearfix"<?php print $attributes; ?>>
<?php if (!$label_hidden) : ?>
- <div class="field-label"><?php print $label ?>:&nbsp;</div>
+ <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div>
<?php endif; ?>
<div class="field-items">
<?php foreach ($items as $delta => $item) : ?>
- <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"><?php print render($item); ?></div>
+ <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>><?php print render($item); ?></div>
<?php endforeach; ?>
</div>
</div>
diff --git a/modules/node/node.tpl.php b/modules/node/node.tpl.php
index c3aa23539..1bc4c2c6e 100644
--- a/modules/node/node.tpl.php
+++ b/modules/node/node.tpl.php
@@ -70,12 +70,12 @@
* @see template_process()
*/
?>
-<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix">
+<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
<?php print $user_picture; ?>
<?php if (!$page): ?>
- <h2><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
+ <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
<?php endif; ?>
<?php if ($display_submitted || !empty($content['links']['terms'])): ?>
diff --git a/themes/garland/block.tpl.php b/themes/garland/block.tpl.php
index 50a79d363..4d9e443e2 100644
--- a/themes/garland/block.tpl.php
+++ b/themes/garland/block.tpl.php
@@ -1,10 +1,10 @@
<?php
// $Id$
?>
-<div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?> clearfix">
+<div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
<?php if (!empty($block->subject)): ?>
- <h2 class="title"><?php print $block->subject ?></h2>
+ <h2 class="title"<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
<?php endif;?>
<div class="content"><?php print $content ?></div>
diff --git a/themes/garland/comment.tpl.php b/themes/garland/comment.tpl.php
index d664d2360..9a8959cc5 100644
--- a/themes/garland/comment.tpl.php
+++ b/themes/garland/comment.tpl.php
@@ -1,7 +1,7 @@
<?php
// $Id$
?>
-<div class="<?php print $classes . ' ' . $zebra; ?>">
+<div class="<?php print $classes . ' ' . $zebra; ?>"<?php print $attributes; ?>>
<div class="clearfix">
@@ -13,7 +13,7 @@
<?php print $picture ?>
- <h3><?php print $title ?></h3>
+ <h3<?php print $title_attributes; ?>><?php print $title ?></h3>
<div class="content">
<?php hide($content['links']); print render($content); ?>
diff --git a/themes/garland/node.tpl.php b/themes/garland/node.tpl.php
index 9895917d1..01038e21b 100644
--- a/themes/garland/node.tpl.php
+++ b/themes/garland/node.tpl.php
@@ -1,12 +1,12 @@
<?php
// $Id$
?>
-<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>">
+<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
<?php print $user_picture; ?>
<?php if (!$page): ?>
- <h2><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
+ <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
<?php endif; ?>
<?php if ($display_submitted): ?>