本文整理汇总了PHP中SpecialPage::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP SpecialPage::getName方法的具体用法?PHP SpecialPage::getName怎么用?PHP SpecialPage::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpecialPage
的用法示例。
在下文中一共展示了SpecialPage::getName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onSpecialPageBeforeExecute
/**
* Invocation of hook SpecialPageBeforeExecute
*
* We use this hook to ensure that login/account creation pages
* are redirected to HTTPS if they are not accessed via HTTPS and
* $wgSecureLogin == true - but only when using the
* mobile site.
*
* @param SpecialPage $special
* @param string $subpage
* @return bool
*/
public static function onSpecialPageBeforeExecute(SpecialPage $special, $subpage)
{
$mobileContext = MobileContext::singleton();
$isMobileView = $mobileContext->shouldDisplayMobileView();
$context = $special->getContext();
$out = $context->getOutput();
$secureLogin = $context->getConfig()->get('SecureLogin');
$request = $special->getContext()->getRequest();
$skin = $out->getSkin()->getSkinName();
$name = $special->getName();
// Ensure desktop version of Special:Preferences page gets mobile targeted modules
// FIXME: Upstream to core (?)
if ($skin === 'minerva') {
if ($name === 'Preferences') {
$out->addModules('skins.minerva.special.preferences.scripts');
}
// Add default warning message to Special:UserLogin and Special:UserCreate
// if no warning message set.
if ($name === 'Userlogin' && !$request->getVal('warning', null) && !$context->getUser()->isLoggedIn()) {
$request->setVal('warning', 'mobile-frontend-generic-login-new');
}
}
if ($isMobileView) {
if ($name === 'Search') {
$out->addModuleStyles('skins.minerva.special.search.styles');
} elseif ($name === 'Userlogin') {
$out->addModuleStyles('skins.minerva.special.userlogin.styles');
$out->addModules('mobile.special.userlogin.scripts');
// make sure we're on https if we're supposed to be and currently aren't.
// most of this is lifted from https redirect code in SpecialUserlogin::execute()
// also, checking for 'https' in $wgServer is a little funky, but this is what
// is done on the WMF cluster (see config in CommonSettings.php)
if ($secureLogin && WebRequest::detectProtocol() != 'https') {
// get the https url and redirect
$query = $special->getContext()->getRequest()->getQueryValues();
if (isset($query['title'])) {
unset($query['title']);
}
$url = $mobileContext->getMobileUrl($special->getFullTitle()->getFullURL($query), true);
$special->getContext()->getOutput()->redirect($url);
}
}
}
return true;
}