53 private string $favicon;
56 private array $templates;
61 $this->urlUtils = $urlUtils;
65 $ctype = $this->getContentType();
72 $expiryTime = 600; # 10 minutes
73 $response->setHeader(
'Expires', gmdate(
'D, d M Y H:i:s', time() + $expiryTime ) .
' GMT' );
74 $response->setHeader(
'Cache-control',
'max-age=600' );
78 $body->write(
'<?xml version="1.0"?>' );
81 'xmlns' =>
'http://a9.com/-/spec/opensearch/1.1/',
82 'xmlns:moz' =>
'http://www.mozilla.org/2006/browser/search/' ] ) );
94 $fullName =
wfMessage(
'opensearch-desc' )->inContentLanguage()->text();
95 $body->write(
Xml::element(
'ShortName',
null, $fullName ) );
96 $body->write(
Xml::element(
'Description',
null, $fullName ) );
104 'type' =>
'image/x-icon'
106 (
string)$this->urlUtils->expand( $this->favicon,
PROTO_CURRENT )
116 'type' =>
'text/html',
118 'template' => $searchPage->getCanonicalURL(
'search={searchTerms}' ) ];
122 foreach ( $this->templates as $type => $template ) {
131 'template' => $template,
140 foreach ( $urls as $attribs ) {
149 $searchPage->getCanonicalURL() ) );
153 $response->setBody( $body );
164 private function getContentType(): string {
166 if (
$params[
'ctype'] ==
'application/xml' ) {
168 return 'application/xml';
171 $acceptHeader = $this->
getRequest()->getHeader(
'accept' );
173 if ( $acceptHeader ) {
174 $parser =
new HttpAcceptParser();
175 $acceptableTypes = $parser->parseAccept( $acceptHeader[0] );
177 foreach ( $acceptableTypes as $acc ) {
178 if ( $acc[
'type'] ===
'application/xml' ) {
179 return 'application/xml';
184 return 'application/opensearchdescription+xml';
190 self::PARAM_SOURCE =>
'query',
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
array $params
The job parameters.
static getOpenSearchTemplate( $type)
Fetch the template for a type.
A class containing constants representing the names of configuration variables.
const OpenSearchTemplates
Name constant for the OpenSearchTemplates setting, for use with Config::get()
const Favicon
Name constant for the Favicon setting, for use with Config::get()
This class contains schema declarations for all configuration variables known to MediaWiki core.
Parent class for all special pages.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...