MediaWiki  1.23.12
opensearch_desc.php
Go to the documentation of this file.
1 <?php
23 require_once __DIR__ . '/includes/WebStart.php';
24 
25 if ( $wgRequest->getVal( 'ctype' ) == 'application/xml' ) {
26  // Makes testing tweaks about a billion times easier
27  $ctype = 'application/xml';
28 } else {
29  $ctype = 'application/opensearchdescription+xml';
30 }
31 
32 $response = $wgRequest->response();
33 $response->header( "Content-type: $ctype" );
34 
35 // Set an Expires header so that squid can cache it for a short time
36 // Short enough so that the sysadmin barely notices when $wgSitename is changed
37 $expiryTime = 600; # 10 minutes
38 $response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expiryTime ) . ' GMT' );
39 $response->header( 'Cache-control: max-age=600' );
40 
41 print '<?xml version="1.0"?>';
42 print Xml::openElement( 'OpenSearchDescription',
43  array(
44  'xmlns' => 'http://a9.com/-/spec/opensearch/1.1/',
45  'xmlns:moz' => 'http://www.mozilla.org/2006/browser/search/' ) );
46 
47 // The spec says the ShortName must be no longer than 16 characters,
48 // but 16 is *realllly* short. In practice, browsers don't appear to care
49 // when we give them a longer string, so we're no longer attempting to trim.
50 //
51 // Note: ShortName and the <link title=""> need to match; they are used as
52 // a key for identifying if the search engine has been added already, *and*
53 // as the display name presented to the end-user.
54 //
55 // Behavior seems about the same between Firefox and IE 7/8 here.
56 // 'Description' doesn't appear to be used by either.
57 $fullName = wfMessage( 'opensearch-desc' )->inContentLanguage()->text();
58 print Xml::element( 'ShortName', null, $fullName );
59 print Xml::element( 'Description', null, $fullName );
60 
61 // By default we'll use the site favicon.
62 // Double-check if IE supports this properly?
63 print Xml::element( 'Image',
64  array(
65  'height' => 16,
66  'width' => 16,
67  'type' => 'image/x-icon' ),
68  wfExpandUrl( $wgFavicon, PROTO_CURRENT ) );
69 
70 $urls = array();
71 
72 // General search template. Given an input term, this should bring up
73 // search results or a specific found page.
74 // At least Firefox and IE 7 support this.
75 $searchPage = SpecialPage::getTitleFor( 'Search' );
76 $urls[] = array(
77  'type' => 'text/html',
78  'method' => 'get',
79  'template' => $searchPage->getCanonicalURL( 'search={searchTerms}' ) );
80 
81 if ( $wgEnableAPI ) {
82  // JSON interface for search suggestions.
83  // Supported in Firefox 2 and later.
84  $urls[] = array(
85  'type' => 'application/x-suggestions+json',
86  'method' => 'get',
87  'template' => SearchEngine::getOpenSearchTemplate() );
88 }
89 
90 // Allow hooks to override the suggestion URL settings in a more
91 // general way than overriding the whole search engine...
92 wfRunHooks( 'OpenSearchUrls', array( &$urls ) );
93 
94 foreach ( $urls as $attribs ) {
95  print Xml::element( 'Url', $attribs );
96 }
97 
98 // And for good measure, add a link to the straight search form.
99 // This is a custom format extension for Firefox, which otherwise
100 // sends you to the domain root if you hit "enter" with an empty
101 // search box.
102 print Xml::element( 'moz:SearchForm', null,
103  $searchPage->getCanonicalURL() );
104 
105 print '</OpenSearchDescription>';
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
$response
$response
Definition: opensearch_desc.php:32
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
Definition: SpecialPage.php:74
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:109
SearchEngine\getOpenSearchTemplate
static getOpenSearchTemplate()
Get OpenSearch suggestion template.
Definition: SearchEngine.php:523
PROTO_CURRENT
const PROTO_CURRENT
Definition: Defines.php:270
wfMessage
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:39
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4058
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
$expiryTime
$expiryTime
Definition: opensearch_desc.php:37
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
$attribs
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition: hooks.txt:1530
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:544