*/ $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', ['height' => 16, 'width' => 16, 'type' => 'image/x-icon'], wfExpandUrl($wgFavicon, PROTO_CURRENT)); $urls = []; // 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[] = ['type' => 'text/html', 'method' => 'get', 'template' => $searchPage->getCanonicalURL('search={searchTerms}')]; foreach ($wgOpenSearchTemplates as $type => $template) { if (!$template && $wgEnableAPI) { $template = ApiOpenSearch::getOpenSearchTemplate($type); } if ($template) { $urls[] = ['type' => $type, 'method' => 'get', 'template' => $template]; } } // Allow hooks to override the suggestion URL settings in a more // general way than overriding the whole search engine... Hooks::run('OpenSearchUrls', [&$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.
public function getParamDescription() { return parent::getParamDescription() + array( 'format' => 'Output format defaults to JSON, with expanded XML optional.', ); }
/** * Get OpenSearch suggestion template * * @deprecated since 1.25 * @return string */ public static function getOpenSearchTemplate() { wfDeprecated(__METHOD__, '1.25'); return ApiOpenSearch::getOpenSearchTemplate('application/x-suggestions+json'); }