當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SpecialPage::getName方法代碼示例

本文整理匯總了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;
 }
開發者ID:micha6554,項目名稱:mediawiki-extensions-MobileFrontend,代碼行數:57,代碼來源:MobileFrontend.hooks.php


注:本文中的SpecialPage::getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。