本文整理汇总了PHP中SpecialPage::resolveAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP SpecialPage::resolveAlias方法的具体用法?PHP SpecialPage::resolveAlias怎么用?PHP SpecialPage::resolveAlias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpecialPage
的用法示例。
在下文中一共展示了SpecialPage::resolveAlias方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wfCreatePageConfirmEdit
function wfCreatePageConfirmEdit(&$captcha, &$editPage, $newtext, $section, $merged, &$result)
{
global $wgTitle, $wgCreatePageCoverRedLinks;
// Enable only if the configuration global is set to true,
// only for Special:CreatePage and only when ConfirmEdit is installed
$canonspname = SpecialPage::resolveAlias($wgTitle->getDBkey());
if (!$wgCreatePageCoverRedLinks) {
return true;
}
if ($canonspname != 'CreatePage') {
return true;
}
if (!class_exists('SimpleCaptcha')) {
return true;
}
if ($captcha->shouldCheck($editPage, $newtext, $section, $merged)) {
if ($captcha->passCaptcha()) {
$result = true;
return false;
} else {
// display CAP page
$mainform = new CreatePageCreatePlateForm();
$mainform->showForm('', false, array(&$captcha, 'editCallback'));
$editor = new CreatePageMultiEditor($_SESSION['article_createplate']);
$editor->generateForm($newtext);
$result = false;
return false;
}
} else {
return true;
}
}
示例2: efDspHook
function efDspHook(&$list)
{
global $wgDisabledSpecialPages;
foreach ($wgDisabledSpecialPages as $page) {
$title = efDspMakeTitle($page);
if (!$title) {
continue;
}
$canonicalName = SpecialPage::resolveAlias($title->getDBkey());
if (!efDspWhitelisted($canonicalName) && isset($list[$canonicalName])) {
unset($list[$canonicalName]);
}
}
return true;
}
示例3: 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);
}
示例4: fixSpecialName
/**
* If the Title refers to a special page alias which is not the local default,
* returns a new Title which points to the local default. Otherwise, returns $this.
*/
public function fixSpecialName()
{
if ($this->getNamespace() == NS_SPECIAL) {
$canonicalName = SpecialPage::resolveAlias($this->mDbkeyform);
if ($canonicalName) {
$localName = SpecialPage::getLocalNameFor($canonicalName);
if ($localName != $this->mDbkeyform) {
return Title::makeTitle(NS_SPECIAL, $localName);
}
}
}
return $this;
}
示例5: execute
public function execute($par)
{
global $wgRequest, $wgOut, $wgUser, $wgOptInSurvey;
global $wgOptInFeedBackSurvey, $wgOptInBrowserSurvey;
$par = $wgRequest->getVal('from', $par);
$this->mOriginTitle = Title::newFromText($par);
// Verify that $this->mOriginTitle is not Special:Userlogout
if ($this->mOriginTitle && $this->mOriginTitle->getNamespace() == NS_SPECIAL && SpecialPage::resolveAlias($this->mOriginTitle->getText()) == 'Userlogout') {
$this->mOriginTitle = null;
}
if ($this->mOriginTitle) {
$this->mOrigin = $this->mOriginTitle->getPrefixedDBKey();
$this->mOriginQuery = $wgRequest->getVal('fromquery');
$this->mOriginLink = $wgUser->getSkin()->link($this->mOriginTitle, null, array(), $this->mOriginQuery);
$this->mOriginURL = $this->mOriginTitle->getLinkUrl($this->mOriginQuery);
}
$this->setHeaders();
if (self::isOptedIn($wgUser)) {
if ($wgRequest->getVal('opt') == 'out') {
// Just opted out
$wgOut->setPageTitle(wfMsg('optin-title-justoptedout'));
} else {
if ($wgRequest->getVal('opt') == 'feedback') {
// Giving feedback
$wgOut->setPageTitle(wfMsg('optin-title-feedback'));
} else {
if ($wgRequest->getVal('opt') == 'in') {
// Just opted in and reloaded... or something
$wgOut->setPagetitle(wfMsg('optin-title-justoptedin'));
} else {
// About to opt out
$wgOut->setPageTitle(wfMsg('optin-title-optedin'));
}
}
}
} else {
if ($wgRequest->getVal('opt') == 'in' && $wgUser->isLoggedIn()) {
// Will be opted in in this request
$wgOut->setPageTitle(wfMsg('optin-title-justoptedin'));
} else {
// About to opt in
$wgOut->setPageTitle(wfMsg('optin-title-optedout'));
}
}
if ($wgRequest->getCheck('opt') && $wgUser->isLoggedIn()) {
if ($wgRequest->getVal('opt') === 'in') {
if (self::checkToken() && !self::isOptedIn($wgUser)) {
self::optIn($wgUser);
$wgOut->addWikiMsg('optin-success-in');
global $wgJsMimeType, $wgOptInStyleVersion;
UsabilityInitiativeHooks::initialize();
UsabilityInitiativeHooks::addScript('OptIn/OptIn.js', $wgOptInStyleVersion);
$url = $this->getTitle()->getLinkUrl();
$wgOut->addHTML(Xml::tags('script', array('type' => $wgJsMimeType), '$j(document).ready( function() { $j.post( "' . $url . '", optInGetPOSTData() ); } );'));
} else {
if (self::isOptedIn($wgUser)) {
// User is already opted in but
// reloaded the page or tried to opt in
// again. Fake success
$wgOut->addWikiMsg('optin-success-in');
} else {
// Token didn't match
$this->showForm(self::isOptedIn($wgUser) ? 'out' : 'in');
}
}
} else {
if ($wgRequest->getVal('opt') == 'feedback' && self::isOptedIn($wgUser)) {
if ($wgRequest->wasPosted()) {
$this->saveSurvey($wgOptInFeedBackSurvey, 'feedback');
$wgOut->addWikiMsg('optin-success-feedback');
} else {
$this->showForm('feedback');
}
} else {
if ($wgRequest->getVal('opt') == 'browser' && self::isOptedIn($wgUser)) {
$this->saveSurvey($wgOptInBrowserSurvey, 'in');
$wgOut->disable();
} else {
// Opt out
if (self::checkToken() && self::isOptedIn($wgUser)) {
self::optOut($wgUser);
$this->saveSurvey($wgOptInSurvey, 'out');
$wgOut->addWikiMsg('optin-success-out');
} else {
$this->showForm(self::isOptedIn($wgUser) ? 'out' : 'in');
}
}
}
}
if ($this->mOriginTitle) {
$wgOut->addHTML(wfMsg('returnto', $this->mOriginLink));
}
} else {
$this->showForm(self::isOptedIn($wgUser) ? 'out' : 'in');
}
}
示例6: 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;
global $wgUseAjax, $wgAjaxWatch;
global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
$ns = $wgTitle->getNamespace();
$nsname = isset($wgCanonicalNamespaceNames[$ns]) ? $wgCanonicalNamespaceNames[$ns] : $wgTitle->getNsText();
$vars = array('skin' => $data['skinname'], 'stylepath' => $wgStylePath, 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScript' => $wgScript, 'wgServer' => $wgServer, 'wgCanonicalNamespace' => $nsname, 'wgCanonicalSpecialPageName' => SpecialPage::resolveAlias($wgTitle->getDBkey()), 'wgNamespaceNumber' => $wgTitle->getNamespace(), 'wgPageName' => $wgTitle->getPrefixedDBKey(), 'wgTitle' => $wgTitle->getText(), 'wgAction' => $wgRequest->getText('action', 'view'), 'wgRestrictionEdit' => $wgTitle->getRestrictions('edit'), 'wgRestrictionMove' => $wgTitle->getRestrictions('move'), '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);
global $wgLivePreview;
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 ($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn()) {
$msgs = (object) array();
foreach (array('watch', 'unwatch', 'watching', 'unwatching') as $msgName) {
$msgs->{$msgName . 'Msg'} = wfMsg($msgName);
}
$vars['wgAjaxWatch'] = $msgs;
}
return self::makeVariablesScript($vars);
}
示例7: testCanonicalRedirect
/**
* @param $request WebRequest
* @param $title Title
* @param $output OutputPage
* @return bool
* @throws HttpError
*/
public function testCanonicalRedirect($request, $title, $output)
{
global $wgUsePathInfo, $wgMobileDomain;
$xDevice = isset($_SERVER['HTTP_X_DEVICE']) ? $_SERVER['HTTP_X_DEVICE'] : '';
if (empty($xDevice)) {
return true;
// Let the redirect happen
} else {
if ($title->getNamespace() == NS_SPECIAL) {
list($name, $subpage) = SpecialPage::resolveAlias($title->getDBkey());
if ($name) {
$title = SpecialPage::getTitleFor($name, $subpage);
}
}
$targetUrl = wfExpandUrl($title->getFullURL(), PROTO_CURRENT);
// Redirect to canonical url, make it a 301 to allow caching
if ($targetUrl == $request->getFullRequestURL()) {
$message = "Redirect loop detected!\n\n" . "This means the wiki got confused about what page was " . "requested; this sometimes happens when moving a wiki " . "to a new server or changing the server configuration.\n\n";
if ($wgUsePathInfo) {
$message .= "The wiki is trying to interpret the page " . "title from the URL path portion (PATH_INFO), which " . "sometimes fails depending on the web server. Try " . "setting \"\$wgUsePathInfo = false;\" in your " . "LocalSettings.php, or check that \$wgArticlePath " . "is correct.";
} else {
$message .= "Your web server was detected as possibly not " . "supporting URL path components (PATH_INFO) correctly; " . "check your LocalSettings.php for a customized " . "\$wgArticlePath setting and/or toggle \$wgUsePathInfo " . "to true.";
}
throw new HttpError(500, $message);
} else {
$parsedUrl = wfParseUrl($targetUrl);
if (stristr($parsedUrl['host'], $wgMobileDomain) === false) {
$hostParts = explode('.', $parsedUrl['host']);
$parsedUrl['host'] = $hostParts[0] . $wgMobileDomain . $hostParts[1] . '.' . $hostParts[2];
}
$fragmentDelimiter = !empty($parsedUrl['fragment']) ? '#' : '';
$queryDelimiter = !empty($parsedUrl['query']) ? '?' : '';
$targetUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $parsedUrl['path'] . $queryDelimiter . $parsedUrl['query'] . $fragmentDelimiter . $parsedUrl['fragment'];
$output->setSquidMaxage(1200);
$output->redirect($targetUrl, '301');
}
return false;
// Prevent the redirect from occuring
}
}
示例8: 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);
}
示例9: 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 $wgStylePath, $wgUser;
global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
global $wgBreakFrames;
$ns = $wgTitle->getNamespace();
$nsname = isset($wgCanonicalNamespaceNames[$ns]) ? $wgCanonicalNamespaceNames[$ns] : $wgTitle->getNsText();
$vars = array('skin' => $data['skinname'], 'stylepath' => $wgStylePath, 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgServer' => $wgServer, 'wgCanonicalNamespace' => $nsname, 'wgCanonicalSpecialPageName' => SpecialPage::resolveAlias($wgTitle->getDBKey()), 'wgNamespaceNumber' => $wgTitle->getNamespace(), 'wgPageName' => $wgTitle->getPrefixedDBKey(), 'wgTitle' => $wgTitle->getText(), 'wgArticleId' => $wgTitle->getArticleId(), 'wgIsArticle' => $wgOut->isArticle(), 'wgUserName' => $wgUser->isAnon() ? NULL : $wgUser->getName(), 'wgUserLanguage' => $wgLang->getCode(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgBreakFrames' => $wgBreakFrames, 'wgCurRevisionId' => isset($wgArticle) ? $wgArticle->getLatest() : 0);
return self::makeVariablesScript($vars);
}
示例10: setupAdCSS
/**
* This just adds the relevant ad CSS file under certain conditions.
* The actual logic is elsewhere.
*
* @param $out Object: OutputPage instance
* @param $sk Object: instance of Skin or one of its child classes
* @return Boolean: true
*/
public static function setupAdCSS( &$out, &$sk ) {
global $wgAdConfig, $wgRequest, $wgUser;
if( !$wgAdConfig['enabled'] ) {
return true;
}
// In order for us to load ad-related CSS, the user must either be very
// new (=not autoconfirmed) or have supplied the forceads parameter in
// the URL
if(
!$wgUser->isAllowed( 'autoconfirmed' ) ||
$wgRequest->getVal( 'forceads' )
)
{
$title = $out->getTitle();
$namespace = $title->getNamespace();
// Okay, the variable name sucks but anyway...normal page != not login page
$isNormalPage = $title instanceof Title &&
SpecialPage::resolveAlias( $title->getDBkey() ) !== 'Userlogin';
// Load ad CSS file when ads are enabled
if(
$isNormalPage &&
in_array( $namespace, $wgAdConfig['namespaces'] )
)
{
if ( get_class( $sk ) == 'SkinMonaco' ) { // Monaco
$out->addModuleStyles( 'ext.ShoutWikiAds.monaco' );
} elseif( get_class( $sk ) == 'SkinMonoBook' ) { // Monobook
if ( $wgAdConfig['right-column'] ) {
$out->addModuleStyles( 'ext.ShoutWikiAds.monobook.skyscraper' );
}
if ( $wgAdConfig['toolbox-button'] ) {
$out->addModuleStyles( 'ext.ShoutWikiAds.monobook.button' );
}
} elseif ( get_class( $sk ) == 'SkinTruglass' ) { // Truglass
$out->addModuleStyles( 'ext.ShoutWikiAds.truglass' );
}
}
}
return true;
}
示例11: 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);
}
示例12: wfGadgetsBeforePageDisplay
function wfGadgetsBeforePageDisplay(&$out)
{
global $wgUser, $wgTitle;
if (!$wgUser->isLoggedIn()) {
return true;
}
//disable all gadgets on Special:Preferences
if ($wgTitle->getNamespace() == NS_SPECIAL) {
$name = SpecialPage::resolveAlias($wgTitle->getText());
if ($name == "Preferences") {
return true;
}
}
$gadgets = wfLoadGadgets();
if (!$gadgets) {
return true;
}
$done = array();
foreach ($gadgets as $gname => $code) {
$tname = "gadget-{$gname}";
if ($wgUser->getOption($tname)) {
wfApplyGadgetCode($code, $out, $done);
}
}
return true;
}
示例13: execute
public function execute( $par ) {
global $wgRequest, $wgOut, $wgUser, $wgPrefSwitchSurveys, $wgPrefSwitchStyleVersion, $wgPrefSwitchGlobalOptOut;
// Get the origin from the request
$par = $wgRequest->getVal( 'from', $par );
$this->originTitle = Title::newFromText( $par );
// $this->originTitle should never be Special:Userlogout
if (
$this->originTitle &&
$this->originTitle->getNamespace() == NS_SPECIAL &&
SpecialPage::resolveAlias( $this->originTitle->getText() ) == 'Userlogout'
) {
$this->originTitle = null;
}
// Get some other useful information about the origin
if ( $this->originTitle ) {
$this->origin = $this->originTitle->getPrefixedDBKey();
$this->originQuery = $wgRequest->getVal( 'fromquery' );
$this->originLink = $wgUser->getSkin()->link( $this->originTitle, null, array(), $this->originQuery );
$this->originLinkUrl = $this->originTitle->getLinkUrl( $this->originQuery );
$this->originFullUrl = $this->originTitle->getFullUrl( $this->originQuery );
}
// Begin output
$this->setHeaders();
$wgOut->addModules( 'ext.prefSwitch' );
$wgOut->addHtml( '<div class="plainlinks">' );
// Handle various modes
if ( $wgRequest->getCheck( 'mode' ) && $wgUser->isLoggedIn() ) {
switch ( $wgRequest->getVal( 'mode' ) ) {
case 'on':
// Switch on
if ( self::checkToken() && !self::isSwitchedOn( $wgUser ) ) {
self::switchOn( $wgUser );
$wgOut->addWikiMsg( 'prefswitch-success-on' );
} else {
$this->render( 'main' );
}
break;
case 'off':
// Switch off
if ( self::checkToken() && self::isSwitchedOn( $wgUser ) && $wgRequest->wasPosted() ) {
self::switchOff( $wgUser, $wgPrefSwitchGlobalOptOut && in_array( 'yes', $wgRequest->getArray( 'prefswitch-survey-global', array() ) ) );
PrefSwitchSurvey::save( 'off', $wgPrefSwitchSurveys['feedback'] );
$wgOut->addWikiMsg( 'prefswitch-success-off' );
} elseif ( !self::isSwitchedOn( $wgUser ) ) {
// User is already switched off then reloaded the page or tried to switch off again
$wgOut->addWikiMsg( 'prefswitch-success-off' );
} else {
$this->render( 'off' );
}
break;
case 'feedback':
if ( self::checkToken() && self::isSwitchedOn( $wgUser ) && $wgRequest->wasPosted() ) {
PrefSwitchSurvey::save( 'feedback', $wgPrefSwitchSurveys['feedback'] );
$wgOut->addWikiMsg( 'prefswitch-success-feedback' );
} else {
$this->render( 'feedback' );
}
break;
default:
$this->render( 'main' );
break;
}
} else {
$this->render( 'main' );
}
// Always show a way back
if ( $this->originTitle && $this->originFullUrl ) {
$wgOut->addWikiMsg( 'prefswitch-return', $this->originFullUrl, $this->originTitle );
}
// Set page title
if ( self::isSwitchedOn( $wgUser ) ) {
switch ( $wgRequest->getVal( 'mode' ) ) {
case 'off':
// About to switch off
$wgOut->setPageTitle( wfMsg( 'prefswitch-title-off' ) );
break;
case 'feedback':
// Giving feedback
$wgOut->setPageTitle( wfMsg( 'prefswitch-title-feedback' ) );
break;
case 'on':
// Just switched on, and reloaded... or something
$wgOut->setPageTitle( wfMsg( 'prefswitch-title-switched-on' ) );
break;
default:
// About to switch off
$wgOut->setPageTitle( wfMsg( 'prefswitch-title-on' ) );
break;
}
} else {
switch ( $wgRequest->getVal( 'mode' ) ) {
case 'on':
// About to switch on
$wgOut->setPageTitle( wfMsg( 'prefswitch-title-switched-on' ) );
break;
case 'off':
// Just switched off
$wgOut->setPageTitle( wfMsg( 'prefswitch-title-switched-off' ) );
break;
default:
//.........这里部分代码省略.........
示例14: smwfQIAddHTMLHeader
function smwfQIAddHTMLHeader(&$out)
{
global $wgTitle;
if ($wgTitle->getNamespace() != NS_SPECIAL) {
return true;
}
global $smwgHaloScriptPath, $smwgDeployVersion, $smwgScriptPath, $srfgScriptPath;
$jsm = SMWResourceManager::SINGLETON();
if (!isset($smwgDeployVersion) || $smwgDeployVersion === false) {
//$jsm->addScriptIf($smwgHaloScriptPath . '/scripts/prototype.js', "all", -1, NS_SPECIAL.":QueryInterface");
$jsm->addScriptIf($smwgHaloScriptPath . '/scripts/Language/SMW_Language.js', "all", -1, NS_SPECIAL . ":QueryInterface");
smwfHaloAddJSLanguageScripts($jsm, "all", -1, NS_SPECIAL . ":QueryInterface");
$jsm->addScriptIf($smwgHaloScriptPath . '/scripts/Logger/smw_logger.js', "all", -1, NS_SPECIAL . ":QueryInterface");
$jsm->addScriptIf($smwgHaloScriptPath . '/scripts/OntologyBrowser/generalTools.js', "all", -1, NS_SPECIAL . ":QueryInterface");
$jsm->addScriptIf($smwgHaloScriptPath . '/scripts/QueryInterface/Query.js', "all", -1, NS_SPECIAL . ":QueryInterface");
$jsm->addScriptIf($smwgHaloScriptPath . '/scripts/QueryInterface/QIHelper.js', "all", -1, NS_SPECIAL . ":QueryInterface");
$jsm->addScriptIf($smwgScriptPath . '/skins/SMW_tooltip.js', "all", -1, NS_SPECIAL . ":QueryInterface");
} else {
//$jsm->addScriptIf($smwgHaloScriptPath . '/scripts/prototype.js', "all", -1, NS_SPECIAL.":QueryInterface");
smwfHaloAddJSLanguageScripts($jsm, "all", -1, NS_SPECIAL . ":QueryInterface");
$jsm->addScriptIf($smwgHaloScriptPath . '/scripts/deployGeneralTools.js', "all", -1, NS_SPECIAL . ":QueryInterface");
$jsm->addScriptIf($smwgHaloScriptPath . '/scripts/QueryInterface/deployQueryInterface.js', "all", -1, NS_SPECIAL . ":QueryInterface");
}
// add scripts required by query printers
$canonicalName = SpecialPage::resolveAlias($wgTitle->getDBkey());
if ($canonicalName == 'QueryInterface') {
global $smwgResultFormats, $wgOut;
if (isset($smwgResultFormats)) {
$resultFormatsUnique = array_unique($smwgResultFormats);
foreach ($resultFormatsUnique as $format => $formatclass) {
try {
$rc = new ReflectionClass($formatclass);
if ($rc->hasMethod("getScripts")) {
$qp = new $formatclass($format, false);
$scriptsToLoad = $qp->getScripts();
foreach ($scriptsToLoad as $script) {
$wgOut->addScript($script);
}
}
if ($rc->hasMethod("getStylesheets")) {
$qp = new $formatclass($format, false);
$styleSheetsToLoad = $qp->getStylesheets();
foreach ($styleSheetsToLoad as $css) {
$wgOut->addLink($css);
}
}
} catch (ReflectionException $e) {
// igore
}
}
}
}
$jsm->addCSSIf($smwgScriptPath . '/skins/SMW_custom.css', "all", -1, NS_SPECIAL . ":QueryInterface");
$jsm->addCSSIf($smwgHaloScriptPath . '/skins/QueryInterface/treeview.css', "all", -1, NS_SPECIAL . ":QueryInterface");
$jsm->addCSSIf($smwgHaloScriptPath . '/skins/QueryInterface/qi.css', "all", -1, NS_SPECIAL . ":QueryInterface");
return true;
// do not load other scripts or CSS
}