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


PHP Block::getByName方法代码示例

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


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

示例1: getBlockInfo

 /**
  * Get basic info about a given block
  * @param Block $block
  * @return array Array containing several keys:
  *  - blockid - ID of the block
  *  - blockedby - username of the blocker
  *  - blockedbyid - user ID of the blocker
  *  - blockreason - reason provided for the block
  *  - blockedtimestamp - timestamp for when the block was placed/modified
  *  - blockexpiry - expiry time of the block
  */
 public static function getBlockInfo(Block $block)
 {
     global $wgContLang;
     $vals = array();
     $vals['blockid'] = $block->getId();
     $vals['blockedby'] = $block->getByName();
     $vals['blockedbyid'] = $block->getBy();
     $vals['blockreason'] = $block->mReason;
     $vals['blockedtimestamp'] = wfTimestamp(TS_ISO_8601, $block->mTimestamp);
     $vals['blockexpiry'] = $wgContLang->formatExpiry($block->getExpiry(), TS_ISO_8601, 'infinite');
     return $vals;
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:23,代码来源:ApiQueryUserInfo.php

示例2: __construct

 public function __construct(Block $block)
 {
     global $wgLang, $wgRequest;
     $blocker = $block->getBlocker();
     if ($blocker instanceof User) {
         // local user
         $blockerUserpage = $block->getBlocker()->getUserPage();
         $link = "[[{$blockerUserpage->getPrefixedText()}|{$blockerUserpage->getText()}]]";
     } else {
         // foreign user
         $link = $blocker;
     }
     $reason = $block->mReason;
     if ($reason == '') {
         $reason = wfMsg('blockednoreason');
     }
     /* $ip returns who *is* being blocked, $intended contains who was meant to be blocked.
      * This could be a username, an IP range, or a single IP. */
     $intended = $block->getTarget();
     parent::__construct('blockedtitle', $block->mAuto ? 'autoblockedtext' : 'blockedtext', array($link, $reason, $wgRequest->getIP(), $block->getByName(), $block->getId(), $wgLang->formatExpiry($block->mExpiry), $intended, $wgLang->timeanddate(wfTimestamp(TS_MW, $block->mTimestamp), true)));
 }
开发者ID:yusufchang,项目名称:app,代码行数:21,代码来源:Exception.php

示例3: getBlockedStatus

 /**
  * Get blocking information
  * @param $bFromSlave Bool Whether to check the slave database first. To
  *                    improve performance, non-critical checks are done
  *                    against slaves. Check when actually saving should be
  *                    done against master.
  */
 private function getBlockedStatus($bFromSlave = true)
 {
     global $wgProxyWhitelist, $wgUser;
     if (-1 != $this->mBlockedby) {
         return;
     }
     wfProfileIn(__METHOD__);
     wfDebug(__METHOD__ . ": checking...\n");
     // Initialize data...
     // Otherwise something ends up stomping on $this->mBlockedby when
     // things get lazy-loaded later, causing false positive block hits
     // due to -1 !== 0. Probably session-related... Nothing should be
     // overwriting mBlockedby, surely?
     $this->load();
     # We only need to worry about passing the IP address to the Block generator if the
     # user is not immune to autoblocks/hardblocks, and they are the current user so we
     # know which IP address they're actually coming from
     if (!$this->isAllowed('ipblock-exempt') && $this->getID() == $wgUser->getID()) {
         $ip = $this->getRequest()->getIP();
     } else {
         $ip = null;
     }
     # User/IP blocking
     $block = Block::newFromTarget($this->getName(), $ip, !$bFromSlave);
     # Proxy blocking
     if (!$block instanceof Block && $ip !== null && !$this->isAllowed('proxyunbannable') && !in_array($ip, $wgProxyWhitelist)) {
         # Local list
         if (self::isLocallyBlockedProxy($ip)) {
             $block = new Block();
             $block->setBlocker(wfMsg('proxyblocker'));
             $block->mReason = wfMsg('proxyblockreason');
             $block->setTarget($ip);
         } elseif ($this->isAnon() && $this->isDnsBlacklisted($ip)) {
             $block = new Block();
             $block->setBlocker(wfMsg('sorbs'));
             $block->mReason = wfMsg('sorbsreason');
             $block->setTarget($ip);
         }
     }
     if ($block instanceof Block) {
         wfDebug(__METHOD__ . ": Found block.\n");
         $this->mBlock = $block;
         $this->mBlockedby = $block->getByName();
         $this->mBlockreason = $block->mReason;
         $this->mHideName = $block->mHideName;
         $this->mAllowUsertalk = !$block->prevents('editownusertalk');
     } else {
         $this->mBlockedby = '';
         $this->mHideName = 0;
         $this->mAllowUsertalk = false;
     }
     # Extensions
     wfRunHooks('GetBlockedStatus', array(&$this));
     wfProfileOut(__METHOD__);
 }
开发者ID:slackfaith,项目名称:deadbrain_site,代码行数:62,代码来源:User.php

示例4: Area

}
?>
		
		<div id="headerNav">
			<?php 
$a = new Area('Header Nav');
$a->display($c);
?>
		</div>
		
		<h1 id="logo"><!--
			--><a href="<?php 
echo DIR_REL;
?>
/"><?php 
$block = Block::getByName('My_Site_Name');
if ($block && $block->bID) {
    $block->display();
} else {
    echo h(SITE);
}
?>
</a><!--
		--></h1>

		<?php 
// we use the "is edit mode" check because, in edit mode, the bottom of the area overlaps the item below it, because
// we're using absolute positioning. So in edit mode we add a bit of space so everything looks nice.
?>

		<div class="spacer"></div>
开发者ID:vipkailiai,项目名称:FCVOVA,代码行数:31,代码来源:header.php

示例5: userBlockedMessage

 /**
  * Output a message that informs the user that they cannot create an account because
  * there is a block on them or their IP which prevents account creation.  Note that
  * User::isBlockedFromCreateAccount(), which gets this block, ignores the 'hardblock'
  * setting on blocks (bug 13611).
  * @param Block $block The block causing this error
  * @throws ErrorPageError
  */
 function userBlockedMessage(Block $block)
 {
     # Let's be nice about this, it's likely that this feature will be used
     # for blocking large numbers of innocent people, e.g. range blocks on
     # schools. Don't blame it on the user. There's a small chance that it
     # really is the user's fault, i.e. the username is blocked and they
     # haven't bothered to log out before trying to create an account to
     # evade it, but we'll leave that to their guilty conscience to figure
     # out.
     $errorParams = array($block->getTarget(), $block->mReason ? $block->mReason : $this->msg('blockednoreason')->text(), $block->getByName());
     if ($block->getType() === Block::TYPE_RANGE) {
         $errorMessage = 'cantcreateaccount-range-text';
         $errorParams[] = $this->getRequest()->getIP();
     } else {
         $errorMessage = 'cantcreateaccount-text';
     }
     throw new ErrorPageError('cantcreateaccounttitle', $errorMessage, $errorParams);
 }
开发者ID:natebrunette,项目名称:sphericalcow,代码行数:26,代码来源:SpecialUserlogin.php

示例6: userBlockedMessage

	/**
	 * Output a message that informs the user that they cannot create an account because
	 * there is a block on them or their IP which prevents account creation. Note that
	 * User::isBlockedFromCreateAccount(), which gets this block, ignores the 'hardblock'
	 * setting on blocks (bug 13611).
	 * @param $block Block the block causing this error
	 */
	function userBlockedMessage( Block $block ) {
		global $wgOut;

		# Let's be nice about this, it's likely that this feature will be used
		# for blocking large numbers of innocent people, e.g. range blocks on
		# schools. Don't blame it on the user. There's a small chance that it
		# really is the user's fault, i.e. the username is blocked and they
		# haven't bothered to log out before trying to create an account to
		# evade it, but we'll leave that to their guilty conscience to figure
		# out.

		$wgOut->setPageTitle( wfMsg( 'cantcreateaccounttitle' ) );

		$block_reason = $block->mReason;
		if ( strval( $block_reason ) === '' ) {
			$block_reason = wfMsg( 'blockednoreason' );
		}

		$wgOut->addWikiMsg(
			'cantcreateaccount-text',
			$block->getTarget(),
			$block_reason,
			$block->getByName()
		);

		$wgOut->returnToMain( false );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:34,代码来源:SpecialUserSignup.php


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