當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。