Beispiel #1
0
// Behavior seems about the same between Firefox and IE 7/8 here.
// 'Description' doesn't appear to be used by either.
$fullName = wfMessage('opensearch-desc')->inContentLanguage()->text();
print Xml::element('ShortName', null, $fullName);
print Xml::element('Description', null, $fullName);
// By default we'll use the site favicon.
// Double-check if IE supports this properly?
print Xml::element('Image', array('height' => 16, 'width' => 16, 'type' => 'image/x-icon'), wfExpandUrl($wgFavicon, PROTO_CURRENT));
$urls = array();
// General search template. Given an input term, this should bring up
// search results or a specific found page.
// At least Firefox and IE 7 support this.
$searchPage = SpecialPage::getTitleFor('Search');
$urls[] = array('type' => 'text/html', 'method' => 'get', 'template' => $searchPage->getCanonicalURL('search={searchTerms}'));
if ($wgEnableAPI) {
    // JSON interface for search suggestions.
    // Supported in Firefox 2 and later.
    $urls[] = array('type' => 'application/x-suggestions+json', 'method' => 'get', 'template' => SearchEngine::getOpenSearchTemplate());
}
// Allow hooks to override the suggestion URL settings in a more
// general way than overriding the whole search engine...
wfRunHooks('OpenSearchUrls', array(&$urls));
foreach ($urls as $attribs) {
    print Xml::element('Url', $attribs);
}
// And for good measure, add a link to the straight search form.
// This is a custom format extension for Firefox, which otherwise
// sends you to the domain root if you hit "enter" with an empty
// search box.
print Xml::element('moz:SearchForm', null, $searchPage->getCanonicalURL());
print '</OpenSearchDescription>';
Beispiel #2
0
// General search template. Given an input term, this should bring up
// search results or a specific found page.
// At least Firefox and IE 7 support this.
$searchPage = SpecialPage::getTitleFor( 'Search' );
$urls[] = array(
	'type' => 'text/html',
	'method' => 'get',
	'template' => $searchPage->getCanonicalURL( 'search={searchTerms}' ) );

if( $wgEnableAPI ) {
	// JSON interface for search suggestions.
	// Supported in Firefox 2 and later.
	$urls[] = array(
		'type' => 'application/x-suggestions+json',
		'method' => 'get',
		'template' => SearchEngine::getOpenSearchTemplate() );
}

// Allow hooks to override the suggestion URL settings in a more
// general way than overriding the whole search engine...
wfRunHooks( 'OpenSearchUrls', array( &$urls ) );

foreach( $urls as $attribs ) {
	print Xml::element( 'Url', $attribs );
}

// And for good measure, add a link to the straight search form.
// This is a custom format extension for Firefox, which otherwise
// sends you to the domain root if you hit "enter" with an empty
// search box.
print Xml::element( 'moz:SearchForm', null,