本文整理汇总了PHP中SearchEngine::userNamespaces方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchEngine::userNamespaces方法的具体用法?PHP SearchEngine::userNamespaces怎么用?PHP SearchEngine::userNamespaces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchEngine
的用法示例。
在下文中一共展示了SearchEngine::userNamespaces方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Set up basic search parameters from the request and user settings.
* Typically you'll pass $wgRequest and $wgUser.
*
* @param WebRequest $request
* @param User $user
* @public
*/
function __construct(&$request, &$user)
{
list($this->limit, $this->offset) = $request->getLimitOffset(20, 'searchlimit');
$this->mPrefix = $request->getVal('prefix', '');
# Extract requested namespaces
$this->namespaces = $this->powerSearch($request);
if (empty($this->namespaces)) {
$this->namespaces = SearchEngine::userNamespaces($user);
}
$this->searchRedirects = $request->getcheck('redirs') ? true : false;
$this->searchAdvanced = $request->getVal('advanced');
$this->active = 'advanced';
$this->sk = $user->getSkin();
$this->didYouMeanHtml = '';
# html of did you mean... link
$this->fulltext = $request->getVal('fulltext');
}
示例2: makeGlobalVariablesScript
/**
* Make a <script> tag containing global variables
* @param array $data Associative array containing one element:
* skinname => the skin name
* The odd calling convention is for backwards compatibility
*/
static function makeGlobalVariablesScript($data)
{
global $wgScript, $wgStylePath, $wgUser;
global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
global $wgUseAjax, $wgAjaxWatch;
global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
global $wgRestrictionTypes, $wgLivePreview;
global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
$ns = $wgTitle->getNamespace();
$nsname = isset($wgCanonicalNamespaceNames[$ns]) ? $wgCanonicalNamespaceNames[$ns] : $wgTitle->getNsText();
$separatorTransTable = $wgContLang->separatorTransformTable();
$separatorTransTable = $separatorTransTable ? $separatorTransTable : array();
$compactSeparatorTransTable = array(implode("\t", array_keys($separatorTransTable)), implode("\t", $separatorTransTable));
$digitTransTable = $wgContLang->digitTransformTable();
$digitTransTable = $digitTransTable ? $digitTransTable : array();
$compactDigitTransTable = array(implode("\t", array_keys($digitTransTable)), implode("\t", $digitTransTable));
$vars = array('skin' => $data['skinname'], 'stylepath' => $wgStylePath, 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScript' => $wgScript, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgCanonicalNamespace' => $nsname, 'wgCanonicalSpecialPageName' => SpecialPage::resolveAlias($wgTitle->getDBkey()), 'wgNamespaceNumber' => $wgTitle->getNamespace(), 'wgPageName' => $wgTitle->getPrefixedDBKey(), 'wgTitle' => $wgTitle->getText(), 'wgAction' => $wgRequest->getText('action', 'view'), 'wgArticleId' => $wgTitle->getArticleId(), 'wgIsArticle' => $wgOut->isArticle(), 'wgUserName' => $wgUser->isAnon() ? NULL : $wgUser->getName(), 'wgUserGroups' => $wgUser->isAnon() ? NULL : $wgUser->getEffectiveGroups(), 'wgUserLanguage' => $wgLang->getCode(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgBreakFrames' => $wgBreakFrames, 'wgCurRevisionId' => isset($wgArticle) ? $wgArticle->getLatest() : 0, 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgSeparatorTransformTable' => $compactSeparatorTransTable, 'wgDigitTransformTable' => $compactDigitTransTable);
if ($wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption('disablesuggest', false)) {
$vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
$vars['wgDBname'] = $wgDBname;
$vars['wgSearchNamespaces'] = SearchEngine::userNamespaces($wgUser);
$vars['wgMWSuggestMessages'] = array(wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled'));
}
foreach ($wgRestrictionTypes as $type) {
$vars['wgRestriction' . ucfirst($type)] = $wgTitle->getRestrictions($type);
}
if ($wgLivePreview && $wgUser->getOption('uselivepreview')) {
$vars['wgLivepreviewMessageLoading'] = wfMsg('livepreview-loading');
$vars['wgLivepreviewMessageReady'] = wfMsg('livepreview-ready');
$vars['wgLivepreviewMessageFailed'] = wfMsg('livepreview-failed');
$vars['wgLivepreviewMessageError'] = wfMsg('livepreview-error');
}
if ($wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn()) {
$msgs = (object) array();
foreach (array('watch', 'unwatch', 'watching', 'unwatching') as $msgName) {
$msgs->{$msgName . 'Msg'} = wfMsg($msgName);
}
$vars['wgAjaxWatch'] = $msgs;
}
wfRunHooks('MakeGlobalVariablesScript', array(&$vars));
return self::makeVariablesScript($vars);
}
示例3: load
/**
* Set up basic search parameters from the request and user settings.
*
* @see tests/phpunit/includes/specials/SpecialSearchTest.php
*/
public function load() {
$request = $this->getRequest();
list( $this->limit, $this->offset ) = $request->getLimitOffset( 20, 'searchlimit' );
$this->mPrefix = $request->getVal( 'prefix', '' );
$user = $this->getUser();
# Extract manually requested namespaces
$nslist = $this->powerSearch( $request );
if ( !count( $nslist ) ) {
# Fallback to user preference
$nslist = SearchEngine::userNamespaces( $user );
}
$profile = null;
if ( !count( $nslist ) ) {
$profile = 'default';
}
$profile = $request->getVal( 'profile', $profile );
$profiles = $this->getSearchProfiles();
if ( $profile === null ) {
// BC with old request format
$profile = 'advanced';
foreach ( $profiles as $key => $data ) {
if ( $nslist === $data['namespaces'] && $key !== 'advanced' ) {
$profile = $key;
}
}
$this->namespaces = $nslist;
} elseif ( $profile === 'advanced' ) {
$this->namespaces = $nslist;
} else {
if ( isset( $profiles[$profile]['namespaces'] ) ) {
$this->namespaces = $profiles[$profile]['namespaces'];
} else {
// Unknown profile requested
$profile = 'default';
$this->namespaces = $profiles['default']['namespaces'];
}
}
// Redirects defaults to true, but we don't know whether it was ticked of or just missing
$default = $request->getBool( 'profile' ) ? 0 : 1;
$this->searchRedirects = $request->getBool( 'redirs', $default ) ? 1 : 0;
$this->didYouMeanHtml = ''; # html of did you mean... link
$this->fulltext = $request->getVal( 'fulltext' );
$this->profile = $profile;
}
示例4: load
/**
* Set up basic search parameters from the request and user settings.
*
* @see tests/phpunit/includes/specials/SpecialSearchTest.php
*/
public function load()
{
$request = $this->getRequest();
list($this->limit, $this->offset) = $request->getLimitOffset(20, '');
$this->mPrefix = $request->getVal('prefix', '');
$user = $this->getUser();
# Extract manually requested namespaces
$nslist = $this->powerSearch($request);
if (!count($nslist)) {
# Fallback to user preference
$nslist = SearchEngine::userNamespaces($user);
}
$profile = null;
if (!count($nslist)) {
$profile = 'default';
}
$profile = $request->getVal('profile', $profile);
$profiles = $this->getSearchProfiles();
if ($profile === null) {
// BC with old request format
$profile = 'advanced';
foreach ($profiles as $key => $data) {
if ($nslist === $data['namespaces'] && $key !== 'advanced') {
$profile = $key;
}
}
$this->namespaces = $nslist;
} elseif ($profile === 'advanced') {
$this->namespaces = $nslist;
} else {
if (isset($profiles[$profile]['namespaces'])) {
$this->namespaces = $profiles[$profile]['namespaces'];
} else {
// Unknown profile requested
$profile = 'default';
$this->namespaces = $profiles['default']['namespaces'];
}
}
$this->fulltext = $request->getVal('fulltext');
$this->profile = $profile;
}
示例5: getJSVars
/**
* Get an array containing the variables to be set in mw.config in JavaScript.
*
* DO NOT CALL THIS FROM OUTSIDE OF THIS CLASS OR Skin::makeGlobalVariablesScript().
* This is only public until that function is removed. You have been warned.
*
* Do not add things here which can be evaluated in ResourceLoaderStartupScript
* - in other words, page-indendent/site-wide variables (without state).
* You will only be adding bloat to the html page and causing page caches to
* have to be purged on configuration changes.
*/
public function getJSVars()
{
global $wgUseAjax, $wgEnableMWSuggest, $wgContLang;
$title = $this->getTitle();
$ns = $title->getNamespace();
$nsname = MWNamespace::exists($ns) ? MWNamespace::getCanonicalName($ns) : $title->getNsText();
if ($ns == NS_SPECIAL) {
list($canonicalName, ) = SpecialPageFactory::resolveAlias($title->getDBkey());
} else {
$canonicalName = false;
# bug 21115
}
$vars = array('wgCanonicalNamespace' => $nsname, 'wgCanonicalSpecialPageName' => $canonicalName, 'wgNamespaceNumber' => $title->getNamespace(), 'wgPageName' => $title->getPrefixedDBKey(), 'wgTitle' => $title->getText(), 'wgCurRevisionId' => $title->getLatestRevID(), 'wgArticleId' => $title->getArticleId(), 'wgIsArticle' => $this->isArticle(), 'wgAction' => $this->getRequest()->getText('action', 'view'), 'wgUserName' => $this->getUser()->isAnon() ? null : $this->getUser()->getName(), 'wgUserGroups' => $this->getUser()->getEffectiveGroups(), 'wgCategories' => $this->getCategories(), 'wgBreakFrames' => $this->getFrameOptions() == 'DENY');
if ($wgContLang->hasVariants()) {
$vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
}
foreach ($title->getRestrictionTypes() as $type) {
$vars['wgRestriction' . ucfirst($type)] = $title->getRestrictions($type);
}
if ($wgUseAjax && $wgEnableMWSuggest && !$this->getUser()->getOption('disablesuggest', false)) {
$vars['wgSearchNamespaces'] = SearchEngine::userNamespaces($this->getUser());
}
if ($title->isMainPage()) {
$vars['wgIsMainPage'] = true;
}
// Allow extensions to add their custom variables to the mw.config map.
// Use the 'ResourceLoaderGetConfigVars' hook if the variable is not
// page-dependant but site-wide (without state).
// Alternatively, you may want to use OutputPage->addJsConfigVars() instead.
wfRunHooks('MakeGlobalVariablesScript', array(&$vars));
// Merge in variables from addJsConfigVars last
return array_merge($vars, $this->mJsConfigVars);
}
示例6: makeGlobalVariablesScript
/**
* Make a <script> tag containing global variables
* @param $skinName string Name of the skin
* The odd calling convention is for backwards compatibility
* @todo FIXME: Make this not depend on $wgTitle!
*
* Do not add things here which can be evaluated in ResourceLoaderStartupScript - in other words, without state.
* You will only be adding bloat to the page and causing page caches to have to be purged on configuration changes.
*/
static function makeGlobalVariablesScript($skinName)
{
global $wgTitle, $wgUser, $wgRequest, $wgArticle, $wgOut, $wgUseAjax, $wgEnableMWSuggest;
$ns = $wgTitle->getNamespace();
$nsname = MWNamespace::exists($ns) ? MWNamespace::getCanonicalName($ns) : $wgTitle->getNsText();
$vars = array('wgCanonicalNamespace' => $nsname, 'wgCanonicalSpecialPageName' => $ns == NS_SPECIAL ? SpecialPage::resolveAlias($wgTitle->getDBkey()) : false, 'wgNamespaceNumber' => $wgTitle->getNamespace(), 'wgPageName' => $wgTitle->getPrefixedDBKey(), 'wgTitle' => $wgTitle->getText(), 'wgAction' => $wgRequest->getText('action', 'view'), 'wgArticleId' => $wgTitle->getArticleId(), 'wgIsArticle' => $wgOut->isArticle(), 'wgUserName' => $wgUser->isAnon() ? null : $wgUser->getName(), 'wgUserGroups' => $wgUser->getEffectiveGroups(), 'wgCurRevisionId' => isset($wgArticle) ? $wgArticle->getLatest() : 0, 'wgCategories' => $wgOut->getCategories(), 'wgBreakFrames' => $wgOut->getFrameOptions() == 'DENY');
foreach ($wgTitle->getRestrictionTypes() as $type) {
$vars['wgRestriction' . ucfirst($type)] = $wgTitle->getRestrictions($type);
}
if ($wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption('disablesuggest', false)) {
$vars['wgSearchNamespaces'] = SearchEngine::userNamespaces($wgUser);
}
// Allow extensions to add their custom variables to the global JS variables
wfRunHooks('MakeGlobalVariablesScript', array(&$vars));
return self::makeVariablesScript($vars);
}
示例7: getJSVars
/**
* Get an array containing the variables to be set in mw.config in JavaScript.
*
* DO NOT CALL THIS FROM OUTSIDE OF THIS CLASS OR Skin::makeGlobalVariablesScript().
* This is only public until that function is removed. You have been warned.
*
* Do not add things here which can be evaluated in ResourceLoaderStartupScript
* - in other words, page-independent/site-wide variables (without state).
* You will only be adding bloat to the html page and causing page caches to
* have to be purged on configuration changes.
* @return array
*/
public function getJSVars()
{
global $wgUseAjax, $wgEnableMWSuggest;
$latestRevID = 0;
$pageID = 0;
$canonicalName = false;
# bug 21115
$title = $this->getTitle();
$ns = $title->getNamespace();
$nsname = MWNamespace::exists($ns) ? MWNamespace::getCanonicalName($ns) : $title->getNsText();
// Get the relevant title so that AJAX features can use the correct page name
// when making API requests from certain special pages (bug 34972).
$relevantTitle = $this->getSkin()->getRelevantTitle();
if ($ns == NS_SPECIAL) {
list($canonicalName, ) = SpecialPageFactory::resolveAlias($title->getDBkey());
} elseif ($this->canUseWikiPage()) {
$wikiPage = $this->getWikiPage();
$latestRevID = $wikiPage->getLatest();
$pageID = $wikiPage->getId();
}
$lang = $title->getPageLanguage();
// Pre-process information
$separatorTransTable = $lang->separatorTransformTable();
$separatorTransTable = $separatorTransTable ? $separatorTransTable : array();
$compactSeparatorTransTable = array(implode("\t", array_keys($separatorTransTable)), implode("\t", $separatorTransTable));
$digitTransTable = $lang->digitTransformTable();
$digitTransTable = $digitTransTable ? $digitTransTable : array();
$compactDigitTransTable = array(implode("\t", array_keys($digitTransTable)), implode("\t", $digitTransTable));
$vars = array('wgCanonicalNamespace' => $nsname, 'wgCanonicalSpecialPageName' => $canonicalName, 'wgNamespaceNumber' => $title->getNamespace(), 'wgPageName' => $title->getPrefixedDBKey(), 'wgTitle' => $title->getText(), 'wgCurRevisionId' => $latestRevID, 'wgArticleId' => $pageID, 'wgIsArticle' => $this->isArticle(), 'wgAction' => Action::getActionName($this->getContext()), 'wgUserName' => $this->getUser()->isAnon() ? null : $this->getUser()->getName(), 'wgUserGroups' => $this->getUser()->getEffectiveGroups(), 'wgCategories' => $this->getCategories(), 'wgBreakFrames' => $this->getFrameOptions() == 'DENY', 'wgPageContentLanguage' => $lang->getCode(), 'wgSeparatorTransformTable' => $compactSeparatorTransTable, 'wgDigitTransformTable' => $compactDigitTransTable, 'wgRelevantPageName' => $relevantTitle->getPrefixedDBKey());
if ($lang->hasVariants()) {
$vars['wgUserVariant'] = $lang->getPreferredVariant();
}
foreach ($title->getRestrictionTypes() as $type) {
$vars['wgRestriction' . ucfirst($type)] = $title->getRestrictions($type);
}
if ($wgUseAjax && $wgEnableMWSuggest && !$this->getUser()->getOption('disablesuggest', false)) {
$vars['wgSearchNamespaces'] = SearchEngine::userNamespaces($this->getUser());
}
if ($title->isMainPage()) {
$vars['wgIsMainPage'] = true;
}
if ($this->mRedirectedFrom) {
$vars['wgRedirectedFrom'] = $this->mRedirectedFrom->getPrefixedDBKey();
}
// Allow extensions to add their custom variables to the mw.config map.
// Use the 'ResourceLoaderGetConfigVars' hook if the variable is not
// page-dependant but site-wide (without state).
// Alternatively, you may want to use OutputPage->addJsConfigVars() instead.
wfRunHooks('MakeGlobalVariablesScript', array(&$vars, $this));
// Merge in variables from addJsConfigVars last
return array_merge($vars, $this->mJsConfigVars);
}
示例8: __construct
/**
* Set up basic search parameters from the request and user settings.
* Typically you'll pass $wgRequest and $wgUser.
*
* @param WebRequest $request
* @param User $user
* @public
*/
function __construct(&$request, &$user)
{
list($this->limit, $this->offset) = $request->getLimitOffset(20, 'searchlimit');
$this->mPrefix = $request->getVal('prefix', '');
$this->namespaces = $this->powerSearch($request);
if (empty($this->namespaces)) {
$this->namespaces = SearchEngine::userNamespaces($user);
}
$this->searchRedirects = $request->getcheck('redirs') ? true : false;
}
示例9: makeGlobalVariablesScript
/**
* Make a <script> tag containing global variables
* @param $skinName string Name of the skin
* The odd calling convention is for backwards compatibility
* @TODO @FIXME Make this not depend on $wgTitle!
*/
static function makeGlobalVariablesScript($skinName)
{
if (is_array($skinName)) {
# Weird back-compat stuff.
$skinName = $skinName['skinname'];
}
global $wgScript, $wgTitle, $wgStylePath, $wgUser, $wgScriptExtension;
global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
global $wgOut, $wgArticle;
global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
global $wgUseAjax, $wgAjaxWatch;
global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
global $wgRestrictionTypes;
global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
global $wgSitename;
$ns = $wgTitle->getNamespace();
$nsname = MWNamespace::exists($ns) ? MWNamespace::getCanonicalName($ns) : $wgTitle->getNsText();
$separatorTransTable = $wgContLang->separatorTransformTable();
$separatorTransTable = $separatorTransTable ? $separatorTransTable : array();
$compactSeparatorTransTable = array(implode("\t", array_keys($separatorTransTable)), implode("\t", $separatorTransTable));
$digitTransTable = $wgContLang->digitTransformTable();
$digitTransTable = $digitTransTable ? $digitTransTable : array();
$compactDigitTransTable = array(implode("\t", array_keys($digitTransTable)), implode("\t", $digitTransTable));
$mainPage = Title::newFromText(wfMsgForContent('mainpage'));
$vars = array('skin' => $skinName, 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgCanonicalNamespace' => $nsname, 'wgCanonicalSpecialPageName' => $ns == NS_SPECIAL ? SpecialPage::resolveAlias($wgTitle->getDBkey()) : false, 'wgNamespaceNumber' => $wgTitle->getNamespace(), 'wgPageName' => $wgTitle->getPrefixedDBKey(), 'wgTitle' => $wgTitle->getText(), 'wgAction' => $wgRequest->getText('action', 'view'), 'wgArticleId' => $wgTitle->getArticleId(), 'wgIsArticle' => $wgOut->isArticle(), 'wgUserName' => $wgUser->isAnon() ? null : $wgUser->getName(), 'wgUserGroups' => $wgUser->isAnon() ? null : $wgUser->getEffectiveGroups(), 'wgUserLanguage' => $wgLang->getCode(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgBreakFrames' => $wgBreakFrames, 'wgCurRevisionId' => isset($wgArticle) ? $wgArticle->getLatest() : 0, 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgSeparatorTransformTable' => $compactSeparatorTransTable, 'wgDigitTransformTable' => $compactDigitTransTable, 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null, 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $wgContLang->getNamespaceIds(), 'wgSiteName' => $wgSitename, 'wgCategories' => $wgOut->getCategories());
if ($wgContLang->hasVariants()) {
$vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
}
// if on upload page output the extension list & js_upload
if (SpecialPage::resolveAlias($wgTitle->getDBkey()) == 'Upload') {
global $wgFileExtensions, $wgAjaxUploadInterface;
$vars['wgFileExtensions'] = $wgFileExtensions;
}
if ($wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption('disablesuggest', false)) {
$vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
$vars['wgDBname'] = $wgDBname;
$vars['wgSearchNamespaces'] = SearchEngine::userNamespaces($wgUser);
$vars['wgMWSuggestMessages'] = array(wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled'));
}
foreach ($wgRestrictionTypes as $type) {
$vars['wgRestriction' . ucfirst($type)] = $wgTitle->getRestrictions($type);
}
if ($wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn()) {
$msgs = (object) array();
foreach (array('watch', 'unwatch', 'watching', 'unwatching', 'tooltip-ca-watch', 'tooltip-ca-unwatch') as $msgName) {
$msgs->{$msgName . 'Msg'} = wfMsg($msgName);
}
$vars['wgAjaxWatch'] = $msgs;
}
// Allow extensions to add their custom variables to the global JS variables
wfRunHooks('MakeGlobalVariablesScript', array(&$vars));
return self::makeVariablesScript($vars);
}