summaryrefslogtreecommitdiff
path: root/modules/search
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-11-21 20:36:36 +0000
committerDries Buytaert <dries@buytaert.net>2010-11-21 20:36:36 +0000
commitc890cb3a95396505f1cbfe03be922cfe67b1261e (patch)
tree65ab26952fe4973b4149293aeab664fa324d44a9 /modules/search
parentfe7e01c60d9d0c540112fa2ffe4265240e2fe0cb (diff)
downloadbrdo-c890cb3a95396505f1cbfe03be922cfe67b1261e.tar.gz
brdo-c890cb3a95396505f1cbfe03be922cfe67b1261e.tar.bz2
- Patch #867114 by jhodgdon, mgifford, sun: search results should add lang tag if language of search result differs.
Diffstat (limited to 'modules/search')
-rw-r--r--modules/search/search-result.tpl.php32
-rw-r--r--modules/search/search.api.php1
-rw-r--r--modules/search/search.pages.inc6
3 files changed, 33 insertions, 6 deletions
diff --git a/modules/search/search-result.tpl.php b/modules/search/search-result.tpl.php
index 667540adb..ee08ab3e7 100644
--- a/modules/search/search-result.tpl.php
+++ b/modules/search/search-result.tpl.php
@@ -18,6 +18,12 @@
* - $info_split: Contains same data as $info, split into a keyed array.
* - $module: The machine-readable name of the module (tab) being searched, such
* as "node" or "user".
+ * - $title_prefix (array): An array containing additional output populated by
+ * modules, intended to be displayed in front of the main title tag that
+ * appears in the template.
+ * - $title_suffix (array): An array containing additional output populated by
+ * modules, intended to be displayed after the main title tag that appears in
+ * the template.
*
* Default keys within $info_split:
* - $info_split['type']: Node type (or item type string supplied by module).
@@ -29,31 +35,45 @@
* - $info_split['upload']: Number of attachments output as "% attachments", %
* being the count. Depends on upload.module.
*
+ * Other variables:
+ * - $classes_array: Array of HTML class attribute values. It is flattened
+ * into a string within the variable $classes.
+ * - $title_attributes_array: Array of HTML attributes for the title. It is
+ * flattened into a string within the variable $title_attributes.
+ * - $content_attributes_array: Array of HTML attributes for the content. It is
+ * flattened into a string within the variable $content_attributes.
+ *
* Since $info_split is keyed, a direct print of the item is possible.
* This array does not apply to user searches so it is recommended to check
- * for their existence before printing. The default keys of 'type', 'user' and
+ * for its existence before printing. The default keys of 'type', 'user' and
* 'date' always exist for node searches. Modules may provide other data.
- *
+ * @code
* <?php if (isset($info_split['comment'])) : ?>
* <span class="info-comment">
* <?php print $info_split['comment']; ?>
* </span>
* <?php endif; ?>
+ * @endcode
*
* To check for all available data within $info_split, use the code below.
- *
+ * @code
* <?php print '<pre>'. check_plain(print_r($info_split, 1)) .'</pre>'; ?>
+ * @endcode
*
+ * @see template_preprocess()
* @see template_preprocess_search_result()
+ * @see template_process()
*/
?>
-<li>
- <h3 class="title">
+<li class="<?php print $classes; ?>"<?php print $attributes; ?>>
+ <?php print render($title_prefix); ?>
+ <h3 class="title"<?php print $title_attributes; ?>>
<a href="<?php print $url; ?>"><?php print $title; ?></a>
</h3>
+ <?php print render($title_suffix); ?>
<div class="search-snippet-info">
<?php if ($snippet) : ?>
- <p class="search-snippet"><?php print $snippet; ?></p>
+ <p class="search-snippet"<?php print $content_attributes; ?>><?php print $snippet; ?></p>
<?php endif; ?>
<?php if ($info) : ?>
<p class="search-info"><?php print $info; ?></p>
diff --git a/modules/search/search.api.php b/modules/search/search.api.php
index 13b812aab..87e9c5b76 100644
--- a/modules/search/search.api.php
+++ b/modules/search/search.api.php
@@ -188,6 +188,7 @@ function hook_search_admin() {
* - 'extra': An array of optional extra information items.
* - 'snippet': An excerpt or preview to show with the result (can be
* generated with search_excerpt()).
+ * - 'language': Language code for the item (usually two characters).
*
* @ingroup search
*/
diff --git a/modules/search/search.pages.inc b/modules/search/search.pages.inc
index c78c60aaf..f796f6d24 100644
--- a/modules/search/search.pages.inc
+++ b/modules/search/search.pages.inc
@@ -105,9 +105,15 @@ function template_preprocess_search_results(&$variables) {
* @see search-result.tpl.php
*/
function template_preprocess_search_result(&$variables) {
+ global $language;
+
$result = $variables['result'];
$variables['url'] = check_url($result['link']);
$variables['title'] = check_plain($result['title']);
+ if (isset($result['language']) && $result['language'] != $language->language && $result['language'] != LANGUAGE_NONE) {
+ $variables['title_attributes_array']['xml:lang'] = $result['language'];
+ $variables['content_attributes_array']['xml:lang'] = $result['language'];
+ }
$info = array();
if (!empty($result['module'])) {