本文整理汇总了PHP中SearchEngine::searchableNamespaces方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchEngine::searchableNamespaces方法的具体用法?PHP SearchEngine::searchableNamespaces怎么用?PHP SearchEngine::searchableNamespaces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchEngine
的用法示例。
在下文中一共展示了SearchEngine::searchableNamespaces方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNamespaceFromRequest
protected function getNamespaceFromRequest()
{
$user = $this->wg->User;
$searchableNamespaces = SearchEngine::searchableNamespaces();
$namespaces = array();
foreach ($searchableNamespaces as $i => $name) {
if ($this->getVal('ns' . $i, false)) {
$namespaces[] = $i;
}
}
if (empty($namespaces)) {
if ($user->getGlobalPreference('searchAllNamespaces')) {
$namespaces = array_keys($searchableNamespaces);
} else {
// this is mostly needed for unit testing
$defaultProfile = !empty($this->wg->DefaultSearchProfile) ? $this->wg->DefaultSearchProfile : 'default';
switch ($defaultProfile) {
case SEARCH_PROFILE_ADVANCED:
//There is no Config::setQuery call so it will always return default...
//There is no Config::setQuery call so it will always return default...
case SEARCH_PROFILE_DEFAULT:
$namespaces = \SearchEngine::defaultNamespaces();
break;
case SEARCH_PROFILE_IMAGES:
$namespaces = array(NS_FILE);
break;
case SEARCH_PROFILE_USERS:
$namespaces = array(NS_USER);
break;
case SEARCH_PROFILE_ALL:
$namespaces = \SearchEngine::searchableNamespaces();
break;
}
}
}
return $namespaces;
}
示例2: getSearchProfiles
protected function getSearchProfiles()
{
// Builds list of Search Types (profiles)
$nsAllSet = array_keys(SearchEngine::searchableNamespaces());
$profiles = array('default' => array('message' => 'searchprofile-articles', 'tooltip' => 'searchprofile-articles-tooltip', 'namespaces' => SearchEngine::defaultNamespaces(), 'namespace-messages' => SearchEngine::namespacesAsText(SearchEngine::defaultNamespaces())), 'images' => array('message' => 'searchprofile-images', 'tooltip' => 'searchprofile-images-tooltip', 'namespaces' => array(NS_FILE)), 'help' => array('message' => 'searchprofile-project', 'tooltip' => 'searchprofile-project-tooltip', 'namespaces' => SearchEngine::helpNamespaces(), 'namespace-messages' => SearchEngine::namespacesAsText(SearchEngine::helpNamespaces())), 'all' => array('message' => 'searchprofile-everything', 'tooltip' => 'searchprofile-everything-tooltip', 'namespaces' => $nsAllSet), 'advanced' => array('message' => 'searchprofile-advanced', 'tooltip' => 'searchprofile-advanced-tooltip', 'namespaces' => $this->namespaces, 'parameters' => array('advanced' => 1)));
wfRunHooks('SpecialSearchProfiles', array(&$profiles));
foreach ($profiles as &$data) {
sort($data['namespaces']);
}
return $profiles;
}
示例3: powerSearchBox
function powerSearchBox($term)
{
$namespaces = '';
foreach (SearchEngine::searchableNamespaces() as $ns => $name) {
$checked = in_array($ns, $this->namespaces) ? ' checked="checked"' : '';
$name = str_replace('_', ' ', $name);
if ('' == $name) {
$name = wfMsg('blanknamespace');
}
$namespaces .= " <label><input type='checkbox' value=\"1\" name=\"" . "ns{$ns}\"{$checked} />{$name}</label>\n";
}
$checked = $this->searchRedirects ? ' checked="checked"' : '';
$redirect = "<input type='checkbox' value='1' name=\"redirs\"{$checked} />\n";
$searchField = "<input type='text' name=\"search\" value=\"" . htmlspecialchars($term) . "\" width=\"80\" />\n";
$searchButton = '<input type="submit" name="searchx" value="' . htmlspecialchars(wfMsg('powersearch')) . "\" />\n";
$ret = wfMsg('powersearchtext', $namespaces, $redirect, $searchField, '', '', '', '', '', $searchButton);
$title = Title::makeTitle(NS_SPECIAL, 'Search');
$action = $title->escapeLocalURL();
return "<br /><br />\n<form id=\"powersearch\" method=\"get\" " . "action=\"{$action}\">\n{$ret}\n</form>\n";
}
示例4: showFullDialog
function showFullDialog($term)
{
global $wgContLang, $wgLuceneSearchExactCase;
$namespaces = '';
foreach (SearchEngine::searchableNamespaces() as $ns => $name) {
$checked = in_array($ns, $this->namespaces) ? ' checked="checked"' : '';
$name = str_replace('_', ' ', $name);
if ('' == $name) {
$name = wfMsg('blanknamespace');
}
$namespaces .= " <label><input type='checkbox' value=\"1\" name=\"" . "ns{$ns}\"{$checked} />{$name}</label>\n";
}
$searchField = "<input type='text' name=\"search\" value=\"" . htmlspecialchars($term) . "\" size=\"16\" />\n";
$searchButton = '<input type="submit" name="fulltext" value="' . htmlspecialchars(wfMsg('powersearch')) . "\" />\n";
if ($wgLuceneSearchExactCase) {
$exactSearch = '<input type="submit" name="fulltext" value="' . htmlspecialchars(wfMsg('searchexactcase')) . "\" />\n";
} else {
$exactSearch = "";
}
$redirect = '';
# What's this for?
$ret = wfMsg('lucenepowersearchtext', $namespaces, $redirect, $searchField, '', '', '', '', '', $searchButton, $exactSearch);
$title = Title::makeTitle(NS_SPECIAL, 'Search');
$action = $title->escapeLocalURL();
return "<br /><br />\n<form id=\"powersearch\" method=\"get\" " . "action=\"{$action}\">\n{$ret}\n</form>\n";
}
示例5: getDefaultOptions
/**
* Combine the language default options with any site-specific options
* and add the default language variants.
*
* @return Array of String options
*/
public static function getDefaultOptions()
{
global $wgNamespacesToBeSearchedDefault, $wgDefaultUserOptions, $wgContLang, $wgDefaultSkin;
$defOpt = $wgDefaultUserOptions;
# default language setting
$variant = $wgContLang->getDefaultVariant();
$defOpt['variant'] = $variant;
$defOpt['language'] = $variant;
foreach (SearchEngine::searchableNamespaces() as $nsnum => $nsname) {
$defOpt['searchNs' . $nsnum] = !empty($wgNamespacesToBeSearchedDefault[$nsnum]);
}
$defOpt['skin'] = $wgDefaultSkin;
// FIXME: Ideally we'd cache the results of this function so the hook is only run once,
// but that breaks the parser tests because they rely on being able to change $wgContLang
// mid-request and see that change reflected in the return value of this function.
// Which is insane and would never happen during normal MW operation, but is also not
// likely to get fixed unless and until we context-ify everything.
// See also https://www.mediawiki.org/wiki/Special:Code/MediaWiki/101488#c25275
wfRunHooks('UserGetDefaultOptions', array(&$defOpt));
return $defOpt;
}
示例6: getSearchProfiles
/**
* @return array
*/
protected function getSearchProfiles() {
// Builds list of Search Types (profiles)
$nsAllSet = array_keys( SearchEngine::searchableNamespaces() );
$profiles = array(
'default' => array(
'message' => 'searchprofile-articles',
'tooltip' => 'searchprofile-articles-tooltip',
'namespaces' => SearchEngine::defaultNamespaces(),
'namespace-messages' => SearchEngine::namespacesAsText(
SearchEngine::defaultNamespaces()
),
),
'images' => array(
'message' => 'searchprofile-images',
'tooltip' => 'searchprofile-images-tooltip',
'namespaces' => array( NS_FILE ),
),
'help' => array(
'message' => 'searchprofile-project',
'tooltip' => 'searchprofile-project-tooltip',
'namespaces' => SearchEngine::helpNamespaces(),
'namespace-messages' => SearchEngine::namespacesAsText(
SearchEngine::helpNamespaces()
),
),
'all' => array(
'message' => 'searchprofile-everything',
'tooltip' => 'searchprofile-everything-tooltip',
'namespaces' => $nsAllSet,
),
'advanced' => array(
'message' => 'searchprofile-advanced',
'tooltip' => 'searchprofile-advanced-tooltip',
'namespaces' => self::NAMESPACES_CURRENT,
)
);
wfRunHooks( 'SpecialSearchProfiles', array( &$profiles ) );
foreach ( $profiles as &$data ) {
if ( !is_array( $data['namespaces'] ) ) {
continue;
}
sort( $data['namespaces'] );
}
return $profiles;
}
示例7: userNamespaces
/**
* Extract default namespaces to search from the given user's
* settings, returning a list of index numbers.
*
* @param $user User
* @return Array
*/
public static function userNamespaces($user)
{
global $wgSearchEverythingOnlyLoggedIn;
$searchableNamespaces = SearchEngine::searchableNamespaces();
// get search everything preference, that can be set to be read for logged-in users
// it overrides other options
if (!$wgSearchEverythingOnlyLoggedIn || $user->isLoggedIn()) {
if ($user->getOption('searcheverything')) {
return array_keys($searchableNamespaces);
}
}
$arr = array();
foreach ($searchableNamespaces as $ns => $name) {
if ($user->getOption('searchNs' . $ns)) {
$arr[] = $ns;
}
}
return $arr;
}
示例8: getSearchableNamespacesFromSearchEngine
/**
* Returns searchable namespaces from MediaWiki.
* @return array
*/
public function getSearchableNamespacesFromSearchEngine()
{
return \SearchEngine::searchableNamespaces();
}
示例9: shortDialog
function shortDialog($term)
{
global $wgScript;
$out = Xml::openElement('form', array('id' => 'search', 'method' => 'get', 'action' => $wgScript));
$searchTitle = SpecialPage::getTitleFor('Search');
$out .= Xml::hidden('title', $searchTitle->getPrefixedText());
$out .= Xml::input('search', 50, $term, array('type' => 'text', 'id' => 'searchText')) . ' ';
foreach (SearchEngine::searchableNamespaces() as $ns => $name) {
if (in_array($ns, $this->namespaces)) {
$out .= Xml::hidden("ns{$ns}", '1');
}
}
$out .= Xml::submitButton(wfMsg('searchbutton'), array('name' => 'fulltext'));
$out .= Xml::closeElement('form');
return $out;
}
示例10: customiseSearchProfiles
static function customiseSearchProfiles(&$profiles)
{
$namespaces = array(NS_LQT_THREAD, NS_LQT_SUMMARY);
// Add odd namespaces
foreach (SearchEngine::searchableNamespaces() as $ns => $nsName) {
if ($ns % 2 == 1) {
$namespaces[] = $ns;
}
}
$insert = array('threads' => array('message' => 'searchprofile-threads', 'tooltip' => 'searchprofile-threads-tooltip', 'namespaces' => $namespaces, 'namespace-messages' => SearchEngine::namespacesAsText($namespaces)));
// Insert translations before 'all'
$index = array_search('all', array_keys($profiles));
// Or just at the end if all is not found
if ($index === false) {
wfWarn('"all" not found in search profiles');
$index = count($profiles);
}
$profiles = array_merge(array_slice($profiles, 0, $index), $insert, array_slice($profiles, $index));
return true;
}
示例11: getActiveTab
/**
* Uses search profiles to determine the active tab in the view
* @return string
*/
public function getActiveTab()
{
if ($this->getAdvanced()) {
return 'advanced';
}
$searchableNamespaces = array_keys(SearchEngine::searchableNamespaces());
$nsVals = $this->getNamespaces();
if (empty($nsVals)) {
return $this->wg->User->getOption('searchAllNamespaces') ? 'all' : 'default';
}
foreach ($this->getSearchProfiles() as $name => $profile) {
if (!count(array_diff($nsVals, $profile['namespaces'])) && !count(array_diff($profile['namespaces'], $nsVals))) {
return $name;
}
}
return 'advanced';
}
示例12: customiseSearchProfiles
static function customiseSearchProfiles(&$profiles)
{
$namespaces = array(NS_LQT_THREAD, NS_LQT_SUMMARY);
// Add odd namespaces
foreach (SearchEngine::searchableNamespaces() as $ns => $nsName) {
if ($ns % 2 == 1) {
$namespaces[] = $ns;
}
}
$insert = array('threads' => array('message' => 'searchprofile-threads', 'tooltip' => 'searchprofile-threads-tooltip', 'namespaces' => $namespaces, 'namespace-messages' => SearchEngine::namespacesAsText($namespaces)));
$profiles = wfArrayInsertAfter($profiles, $insert, 'help');
return true;
}
示例13: testGetSearchableNamespacesFromSearchEngine
/**
* @group Slow
* @slowExecutionTime 0.09002 ms
* @covers Wikia\Search\MediaWikiService::getSearchableNamespacesFromSearchEngine
*/
public function testGetSearchableNamespacesFromSearchEngine()
{
$this->assertEquals(\SearchEngine::searchableNamespaces(), (new MediaWikiService())->getSearchableNamespacesFromSearchEngine());
}
示例14: userNamespaces
/**
* Extract default namespaces to search from the given user's
* settings, returning a list of index numbers.
*
* @param user $user
* @return array
*/
public static function userNamespaces($user)
{
$arr = array();
foreach (SearchEngine::searchableNamespaces() as $ns => $name) {
if ($user->getOption('searchNs' . $ns)) {
$arr[] = $ns;
}
}
return $arr;
}
示例15: userNamespaces
/**
* Extract default namespaces to search from the given user's
* settings, returning a list of index numbers.
*
* @param $user User
* @return Array
*/
public static function userNamespaces($user)
{
global $wgSearchEverythingOnlyLoggedIn;
// get search everything preference, that can be set to be read for logged-in users
$searcheverything = false;
if ($wgSearchEverythingOnlyLoggedIn && $user->isLoggedIn() || !$wgSearchEverythingOnlyLoggedIn) {
$searcheverything = $user->getOption('searcheverything');
}
// searcheverything overrides other options
if ($searcheverything) {
return array_keys(SearchEngine::searchableNamespaces());
}
$arr = Preferences::loadOldSearchNs($user);
$searchableNamespaces = SearchEngine::searchableNamespaces();
$arr = array_intersect($arr, array_keys($searchableNamespaces));
// Filter
return $arr;
}