Index: modules/search/search.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.module,v
retrieving revision 1.185
diff -u -r1.185 search.module
--- modules/search/search.module 31 Jul 2006 11:25:54 -0000 1.185
+++ modules/search/search.module 2 Aug 2006 22:39:49 -0000
@@ -240,6 +240,49 @@
}
/**
+ * Implementation of hook_form_alter().
+ */
+function search_form_alter($form_id, &$form) {
+ $theme = arg(4);
+ if ('system_theme_settings' == $form_id && empty($theme)) {
+ $settings = theme_get_settings('');
+ if (!isset($settings['search_result_display_settings'])) {
+ $display_settings = array('date', 'author', 'content_type', 'extras');
+ }
+ else {
+ $display_settings = array();
+ foreach ($settings['search_result_display_settings'] as $key => $value) {
+ if ($value) {
+ $display_settings[] = $key;
+ }
+ }
+ }
+
+ // Display settings:
+ $form['search_result_settings'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Show in search results'),
+ '#description' => t('Select which additional information, besides title and teaser, should be displayed for each search result.'),
+ '#collapsible' => FALSE,
+ '#collapsed' => FALSE,
+ '#weight' => -1,
+ '#prefix' => '
',
+ '#suffix' => '
'
+ );
+ $form['search_result_settings']['search_result_display_settings'] = array(
+ '#type' => 'checkboxes',
+ '#default_value' => $display_settings,
+ '#options' => array(
+ 'date' => t('Date'),
+ 'author' => t('Author'),
+ 'content_type' => t('Content type'),
+ 'extras' => t('Module-provided fields')
+ )
+ );
+ }
+}
+
+/**
* Menu callback: confirm wiping of the index.
*/
function search_wipe_confirm() {
@@ -1228,16 +1271,30 @@
function theme_search_item($item, $type) {
$output = ' '. check_plain($item['title']) .'';
$info = array();
- if ($item['type']) {
+
+ $settings = theme_get_settings('');
+ if (!isset($settings['search_result_display_settings'])) {
+ $display_settings = array('date', 'author', 'content_type', 'extras');
+ }
+ else {
+ $display_settings = array();
+ foreach ($settings['search_result_display_settings'] as $key => $value) {
+ if ($value) {
+ $display_settings[] = $key;
+ }
+ }
+ }
+
+ if ($item['type'] && in_array('content_type', $display_settings)) {
$info[] = $item['type'];
}
- if ($item['user']) {
+ if ($item['user'] && in_array('author', $display_settings)) {
$info[] = $item['user'];
}
- if ($item['date']) {
+ if ($item['date'] && in_array('date', $display_settings)) {
$info[] = format_date($item['date'], 'small');
}
- if (is_array($item['extra'])) {
+ if (is_array($item['extra']) && in_array('extras', $display_settings)) {
$info = array_merge($info, $item['extra']);
}
$output .= ' '. ($item['snippet'] ? ''. $item['snippet'] . '
' : '') . '' . implode(' - ', $info) .'
';