当前位置: 首页>>代码示例>>PHP>>正文


PHP SearchEngine::searchableNamespaces方法代码示例

本文整理汇总了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;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:37,代码来源:SearchController.class.php

示例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;
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:11,代码来源:SpecialSearch.php

示例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";
 }
开发者ID:BackupTheBerlios,项目名称:blahtex,代码行数:20,代码来源:SpecialSearch.php

示例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";
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:26,代码来源:LuceneSearch_body.php

示例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;
 }
开发者ID:slackfaith,项目名称:deadbrain_site,代码行数:27,代码来源:User.php

示例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;
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:52,代码来源:SpecialSearch.php

示例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;
 }
开发者ID:h4ck3rm1k3,项目名称:mediawiki,代码行数:26,代码来源:SearchEngine.php

示例8: getSearchableNamespacesFromSearchEngine

 /**
  * Returns searchable namespaces from MediaWiki.
  * @return array
  */
 public function getSearchableNamespacesFromSearchEngine()
 {
     return \SearchEngine::searchableNamespaces();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:8,代码来源:MediaWikiService.php

示例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;
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:16,代码来源:SpecialSearch.php

示例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;
 }
开发者ID:Rikuforever,项目名称:wiki,代码行数:20,代码来源:Hooks.php

示例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';
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:21,代码来源:WikiaSearchConfig.class.php

示例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;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:13,代码来源:Hooks.php

示例13: testGetSearchableNamespacesFromSearchEngine

 /**
  * @group Slow
  * @slowExecutionTime 0.09002 ms
  * @covers Wikia\Search\MediaWikiService::getSearchableNamespacesFromSearchEngine
  */
 public function testGetSearchableNamespacesFromSearchEngine()
 {
     $this->assertEquals(\SearchEngine::searchableNamespaces(), (new MediaWikiService())->getSearchableNamespacesFromSearchEngine());
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:9,代码来源:MediaWikiServiceTest.php

示例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;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:17,代码来源:SearchEngine.php

示例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;
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:25,代码来源:SearchEngine.php


注:本文中的SearchEngine::searchableNamespaces方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。