Index: opensearchplugin.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/opensearchplugin/Attic/opensearchplugin.module,v retrieving revision 1.2.2.1.2.2 diff -u -r1.2.2.1.2.2 opensearchplugin.module --- opensearchplugin.module 16 Feb 2008 19:49:04 -0000 1.2.2.1.2.2 +++ opensearchplugin.module 5 Jun 2008 07:17:55 -0000 @@ -29,6 +29,17 @@ )); } +/** + * Implementation of hook_theme(). + */ +function opensearchplugin_theme() { + return array( + 'opensearchplugin_output' => array( + 'arguments' => array('info' => NULL), + ), + ); +} + /* * Implementation of hook_menu(). */ @@ -84,65 +95,79 @@ return system_settings_form($form); } -/* - * Outputs the definition of the OpenSearch plugin +/** + * Outputs the definition of the OpenSearch plugin. */ function opensearchplugin_output() { - // Farm the variables - $shortname = variable_get('site_name', 'Drupal'); - $longname = variable_get('site_name', 'Drupal'); - $description = variable_get('site_slogan', ''); - $tags = ''; // associated meta tags - $contact = ''; // contact email address - $htmlsearch = url("search/node/", array('absolute' => TRUE)); // search query - $language = '*'; // website language - $adultcontent = 'false'; // if website contains adult material - $syndicationright = 'open'; // open, limited, private or closed - $attribution = ''; // copyright information - $developer = ''; // who developed the website - $searchform = url('search', array('absolute' => TRUE)); // search page url - $icon = variable_get('opensearchplugin_image', ''); - $iconwidth = variable_get('opensearchplugin_image_width', 16); - $iconheight = variable_get('opensearchplugin_image_height', 16); - + // Farm the variables. + $info['short_name'] = variable_get('site_name', 'Drupal'); + $info['long_name'] = variable_get('site_name', 'Drupal'); + $info['description'] = variable_get('site_slogan', ''); + $info['tags'] = ''; // Associated meta tags. + $info['contact'] = variable_get('site_mail', ini_get('sendmail_from')); // Contact email address. + $info['html_search'] = url("search/node/", array('absolute' => TRUE)); // search query. + $info['language'] = '*'; // Website language + $info['adult_content'] = 'false'; // If website contains adult material. + $info['syndication_right'] = 'open'; // Open, limited, private or closed. + $info['attribution'] = ''; // Copyright information. + $info['developer'] = ''; // Who developed the website. + $info['search_form'] = url('search', array('absolute' => TRUE)); // Search page URL. + $info['icon'] = variable_get('opensearchplugin_image', ''); + $info['icon_width'] = variable_get('opensearchplugin_image_width', 16); + $info['icon_height'] = variable_get('opensearchplugin_image_height', 16); + + return theme('opensearchplugin_output', $info); +} + +/** + * Theme the Open Search Description output. + * + * @param $info + * An array. + * @ingroup themeable + */ +function theme_opensearchplugin_output($info) { + extract($info, EXTR_SKIP); // Extract the variables to the local namespace. + if (empty($icon)) { - theme(); // prepare the theme - $icon = theme_get_setting('favicon'); // the icon to use + $icon = theme_get_setting('favicon'); // The icon to use. if (!empty($icon)) { global $base_url; $url = parse_url($base_url); $icon = $url['scheme'] .'://'. $url['host'] . $icon; } } - // Check if the icon is choosen + // Check if the icon is choosen. if (!empty($icon)) { - $iconwidth = empty($iconwidth) ? '' : " width=\"$iconwidth\""; - $iconheight = empty($iconheight) ? '' : " height=\"$iconheight\""; - $icon = ''. $icon .''; + $icon_width = empty($icon_width) ? '' : " width=\"$icon_width\""; + $icon_height = empty($icon_height) ? '' : " height=\"$icon_height\""; + $icon = ''. $icon .''; } - + // Output specification based on // http://www.opensearch.org/Specifications/OpenSearch/1.1 - $output = ' - - $shortname - $description - $tags - $contact - - $searchform - $longname - $icon - $developer - $attribution - $syndicationright - $adultcontent - $language - UTF-8 - UTF-8 - "; - drupal_set_header('Content-Type: text/xml'); - echo $output; - module_invoke_all('exit'); - exit; + $output = << + + $short_name + $description + $tags + $contact + + $search_form + $long_name + $icon + $developer + $attribution + $syndication_right + $adult_content + $language + UTF-8 + UTF-8 + + +EOT; + + drupal_set_header('Content-Type: text/xml; charset=utf-8'); + print $output; }