当前位置: 首页>>代码示例>>PHP>>正文


PHP SpecialPage::getContext方法代码示例

本文整理汇总了PHP中SpecialPage::getContext方法的典型用法代码示例。如果您正苦于以下问题:PHP SpecialPage::getContext方法的具体用法?PHP SpecialPage::getContext怎么用?PHP SpecialPage::getContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpecialPage的用法示例。


在下文中一共展示了SpecialPage::getContext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

 /**
  * @param SpecialPage $page
  * @param array $conds
  */
 function __construct($page, $conds)
 {
     $this->page = $page;
     $this->conds = $conds;
     $this->mDefaultDirection = IndexPager::DIR_DESCENDING;
     parent::__construct($page->getContext());
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:11,代码来源:BlockListPager.php

示例2: testRequireLoginNotAnon

 public function testRequireLoginNotAnon()
 {
     $specialPage = new SpecialPage('Watchlist', 'viewmywatchlist');
     $user = User::newFromName("UTSysop");
     $specialPage->getContext()->setUser($user);
     $specialPage->requireLogin();
     // no exception thrown, logged in use can access special page
     $this->assertTrue(true);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:9,代码来源:SpecialPageTest.php

示例3: 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

示例4: getUserLinks

 /**
  * Links to different places.
  *
  * @note This function is also called in DeletedContributionsPage
  * @param SpecialPage $sp SpecialPage instance, for context
  * @param User $target Target user object
  * @return array
  */
 public static function getUserLinks(SpecialPage $sp, User $target)
 {
     $id = $target->getId();
     $username = $target->getName();
     $userpage = $target->getUserPage();
     $talkpage = $target->getTalkPage();
     $linkRenderer = $sp->getLinkRenderer();
     $tools['user-talk'] = $linkRenderer->makeLink($talkpage, $sp->msg('sp-contributions-talk')->text());
     if ($id !== null || $id === null && IP::isIPAddress($username)) {
         if ($sp->getUser()->isAllowed('block')) {
             # Block / Change block / Unblock links
             if ($target->isBlocked() && $target->getBlock()->getType() != Block::TYPE_AUTO) {
                 $tools['block'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Block', $username), $sp->msg('change-blocklink')->text());
                 $tools['unblock'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Unblock', $username), $sp->msg('unblocklink')->text());
             } else {
                 # User is not blocked
                 $tools['block'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Block', $username), $sp->msg('blocklink')->text());
             }
         }
         # Block log link
         $tools['log-block'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Log', 'block'), $sp->msg('sp-contributions-blocklog')->text(), [], ['page' => $userpage->getPrefixedText()]);
         # Suppression log link (bug 59120)
         if ($sp->getUser()->isAllowed('suppressionlog')) {
             $tools['log-suppression'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Log', 'suppress'), $sp->msg('sp-contributions-suppresslog', $username)->text(), [], ['offender' => $username]);
         }
     }
     # Uploads
     $tools['uploads'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Listfiles', $username), $sp->msg('sp-contributions-uploads')->text());
     # Other logs link
     $tools['logs'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Log', $username), $sp->msg('sp-contributions-logs')->text());
     # Add link to deleted user contributions for priviledged users
     if ($sp->getUser()->isAllowed('deletedhistory')) {
         $tools['deletedcontribs'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('DeletedContributions', $username), $sp->msg('sp-contributions-deleted', $username)->text());
     }
     # Add a link to change user rights for privileged users
     $userrightsPage = new UserrightsPage();
     $userrightsPage->setContext($sp->getContext());
     if ($userrightsPage->userCanChangeRights($target)) {
         $tools['userrights'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Userrights', $username), $sp->msg('sp-contributions-userrights')->text());
     }
     Hooks::run('ContributionsToolLinks', [$id, $userpage, &$tools, $sp]);
     return $tools;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:51,代码来源:SpecialContributions.php


注:本文中的SpecialPage::getContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。