本文整理汇总了PHP中SearchEngine::getOpenSearchTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchEngine::getOpenSearchTemplate方法的具体用法?PHP SearchEngine::getOpenSearchTemplate怎么用?PHP SearchEngine::getOpenSearchTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchEngine
的用法示例。
在下文中一共展示了SearchEngine::getOpenSearchTemplate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wfMessage
// 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>';
示例2: 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,