本文整理汇总了PHP中ChangesList::userCan方法的典型用法代码示例。如果您正苦于以下问题:PHP ChangesList::userCan方法的具体用法?PHP ChangesList::userCan怎么用?PHP ChangesList::userCan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChangesList
的用法示例。
在下文中一共展示了ChangesList::userCan方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLogText
/**
* Generates amount of changes (linking to diff ) & link to history.
*
* @param array $block
* @param array $queryParams
* @param bool $allLogs
* @param bool $isnew
* @param bool $namehidden
* @return string
*/
protected function getLogText($block, $queryParams, $allLogs, $isnew, $namehidden)
{
# Changes message
static $nchanges = array();
static $sinceLastVisitMsg = array();
$n = count($block);
if (!isset($nchanges[$n])) {
$nchanges[$n] = $this->msg('nchanges')->numParams($n)->escaped();
}
$sinceLast = 0;
$unvisitedOldid = null;
/** @var $rcObj RCCacheEntry */
foreach ($block as $rcObj) {
// Same logic as below inside main foreach
if ($rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched) {
$sinceLast++;
$unvisitedOldid = $rcObj->mAttribs['rc_last_oldid'];
}
}
if (!isset($sinceLastVisitMsg[$sinceLast])) {
$sinceLastVisitMsg[$sinceLast] = $this->msg('enhancedrc-since-last-visit')->numParams($sinceLast)->escaped();
}
$currentRevision = 0;
foreach ($block as $rcObj) {
if (!$currentRevision) {
$currentRevision = $rcObj->mAttribs['rc_this_oldid'];
}
}
# Total change link
$links = array();
/** @var $block0 RecentChange */
$block0 = $block[0];
$last = $block[count($block) - 1];
if (!$allLogs) {
if (!ChangesList::userCan($rcObj, Revision::DELETED_TEXT, $this->getUser())) {
$links['total-changes'] = $nchanges[$n];
} elseif ($isnew) {
$links['total-changes'] = $nchanges[$n];
} else {
$links['total-changes'] = Linker::link($block0->getTitle(), $nchanges[$n], array(), $queryParams + array('diff' => $currentRevision, 'oldid' => $last->mAttribs['rc_last_oldid']), array('known', 'noclasses'));
if ($sinceLast > 0 && $sinceLast < $n) {
$links['total-changes-since-last'] = Linker::link($block0->getTitle(), $sinceLastVisitMsg[$sinceLast], array(), $queryParams + array('diff' => $currentRevision, 'oldid' => $unvisitedOldid), array('known', 'noclasses'));
}
}
}
# History
if ($allLogs) {
// don't show history link for logs
} elseif ($namehidden || !$block0->getTitle()->exists()) {
$links['history'] = $this->message['enhancedrc-history'];
} else {
$params = $queryParams;
$params['action'] = 'history';
$links['history'] = Linker::linkKnown($block0->getTitle(), $this->message['enhancedrc-history'], array(), $params);
}
# Allow others to alter, remove or add to these links
Hooks::run('EnhancedChangesList::getLogText', array($this, &$links, $block));
if (!$links) {
return '';
}
$logtext = implode($this->message['pipe-separator'], $links);
$logtext = $this->msg('parentheses')->rawParams($logtext)->escaped();
return ' ' . $logtext;
}
示例2: recentChangesBlockGroup
/**
* Enhanced RC group
*/
protected function recentChangesBlockGroup($block)
{
global $wgRCShowChangedSize;
wfProfileIn(__METHOD__);
# Add the namespace and title of the block as part of the class
if ($block[0]->mAttribs['rc_log_type']) {
# Log entry
$classes = 'mw-collapsible mw-collapsed mw-enhanced-rc ' . Sanitizer::escapeClass('mw-changeslist-log-' . $block[0]->mAttribs['rc_log_type']);
} else {
$classes = 'mw-collapsible mw-collapsed mw-enhanced-rc ' . Sanitizer::escapeClass('mw-changeslist-ns' . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title']);
}
$r = Html::openElement('table', array('class' => $classes)) . Html::openElement('tr');
# Collate list of users
$userlinks = array();
# Other properties
$unpatrolled = false;
$isnew = false;
$curId = $currentRevision = 0;
# Some catalyst variables...
$namehidden = true;
$allLogs = true;
foreach ($block as $rcObj) {
$oldid = $rcObj->mAttribs['rc_last_oldid'];
if ($rcObj->mAttribs['rc_new']) {
$isnew = true;
}
// If all log actions to this page were hidden, then don't
// give the name of the affected page for this block!
if (!$this->isDeleted($rcObj, LogPage::DELETED_ACTION)) {
$namehidden = false;
}
$u = $rcObj->userlink;
if (!isset($userlinks[$u])) {
$userlinks[$u] = 0;
}
if ($rcObj->unpatrolled) {
$unpatrolled = true;
}
if ($rcObj->mAttribs['rc_type'] != RC_LOG) {
$allLogs = false;
}
# Get the latest entry with a page_id and oldid
# since logs may not have these.
if (!$curId && $rcObj->mAttribs['rc_cur_id']) {
$curId = $rcObj->mAttribs['rc_cur_id'];
}
if (!$currentRevision && $rcObj->mAttribs['rc_this_oldid']) {
$currentRevision = $rcObj->mAttribs['rc_this_oldid'];
}
$bot = $rcObj->mAttribs['rc_bot'];
$userlinks[$u]++;
}
# Sort the list and convert to text
krsort($userlinks);
asort($userlinks);
$users = array();
foreach ($userlinks as $userlink => $count) {
$text = $userlink;
$text .= $this->getLanguage()->getDirMark();
if ($count > 1) {
$text .= ' (' . $this->getLanguage()->formatNum($count) . '×)';
}
array_push($users, $text);
}
$users = ' <span class="changedby">[' . implode($this->message['semicolon-separator'], $users) . ']</span>';
# Title for <a> tags
$expandTitle = htmlspecialchars(wfMsg('rc-enhanced-expand'));
$closeTitle = htmlspecialchars(wfMsg('rc-enhanced-hide'));
$tl = "<span class='mw-collapsible-toggle'>" . "<span class='mw-rc-openarrow'>" . "<a href='#' title='{$expandTitle}'>{$this->sideArrow()}</a>" . "</span><span class='mw-rc-closearrow'>" . "<a href='#' title='{$closeTitle}'>{$this->downArrow()}</a>" . "</span></span>";
$r .= "<td>{$tl}</td>";
# Main line
$r .= '<td class="mw-enhanced-rc">' . $this->recentChangesFlags(array('newpage' => $isnew, 'minor' => false, 'unpatrolled' => $unpatrolled, 'bot' => $bot));
# Timestamp
$r .= ' ' . $block[0]->timestamp . ' </td><td>';
# Article link
if ($namehidden) {
$r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
} elseif ($allLogs) {
$r .= $this->maybeWatchedLink($block[0]->link, $block[0]->watched);
} else {
$this->insertArticleLink($r, $block[0], $block[0]->unpatrolled, $block[0]->watched);
}
$r .= $this->getLanguage()->getDirMark();
$queryParams['curid'] = $curId;
# Changes message
$n = count($block);
static $nchanges = array();
if (!isset($nchanges[$n])) {
$nchanges[$n] = wfMsgExt('nchanges', array('parsemag', 'escape'), $this->getLanguage()->formatNum($n));
}
# Total change link
$r .= ' ';
if (!$allLogs) {
$r .= '(';
if (!ChangesList::userCan($rcObj, Revision::DELETED_TEXT, $this->getUser())) {
$r .= $nchanges[$n];
} elseif ($isnew) {
//.........这里部分代码省略.........
示例3: recentChangesBlockGroup
/**
* Enhanced RC group
*/
protected function recentChangesBlockGroup($block)
{
global $wgLang, $wgContLang, $wgRCShowChangedSize;
wfProfileIn(__METHOD__);
$r = '<table cellpadding="0" cellspacing="0" border="0" style="background: none"><tr>';
# Collate list of users
$userlinks = array();
# Other properties
$unpatrolled = false;
$isnew = false;
$curId = $currentRevision = 0;
# Some catalyst variables...
$namehidden = true;
$allLogs = true;
foreach ($block as $rcObj) {
$oldid = $rcObj->mAttribs['rc_last_oldid'];
if ($rcObj->mAttribs['rc_new']) {
$isnew = true;
}
// If all log actions to this page were hidden, then don't
// give the name of the affected page for this block!
if (!$this->isDeleted($rcObj, LogPage::DELETED_ACTION)) {
$namehidden = false;
}
$u = $rcObj->userlink;
if (!isset($userlinks[$u])) {
$userlinks[$u] = 0;
}
if ($rcObj->unpatrolled) {
$unpatrolled = true;
}
if ($rcObj->mAttribs['rc_type'] != RC_LOG) {
$allLogs = false;
}
# Get the latest entry with a page_id and oldid
# since logs may not have these.
if (!$curId && $rcObj->mAttribs['rc_cur_id']) {
$curId = $rcObj->mAttribs['rc_cur_id'];
}
if (!$currentRevision && $rcObj->mAttribs['rc_this_oldid']) {
$currentRevision = $rcObj->mAttribs['rc_this_oldid'];
}
$bot = $rcObj->mAttribs['rc_bot'];
$userlinks[$u]++;
}
# Sort the list and convert to text
krsort($userlinks);
asort($userlinks);
$users = array();
foreach ($userlinks as $userlink => $count) {
$text = $userlink;
$text .= $wgContLang->getDirMark();
if ($count > 1) {
$text .= ' (' . $wgLang->formatNum($count) . '×)';
}
array_push($users, $text);
}
$users = ' <span class="changedby">[' . implode($this->message['semicolon-separator'], $users) . ']</span>';
# ID for JS visibility toggle
$jsid = $this->rcCacheIndex;
# onclick handler to toggle hidden/expanded
$toggleLink = "onclick='toggleVisibility({$jsid}); return false'";
# Title for <a> tags
$expandTitle = htmlspecialchars(wfMsg('rc-enhanced-expand'));
$closeTitle = htmlspecialchars(wfMsg('rc-enhanced-hide'));
$tl = "<span id='mw-rc-openarrow-{$jsid}' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' {$toggleLink} title='{$expandTitle}'>" . $this->sideArrow() . "</a></span>";
$tl .= "<span id='mw-rc-closearrow-{$jsid}' class='mw-changeslist-hidden' style='display:none'><a href='#' {$toggleLink} title='{$closeTitle}'>" . $this->downArrow() . "</a></span>";
$r .= '<td valign="top" style="white-space: nowrap"><tt>' . $tl . ' ';
# Main line
$r .= $this->recentChangesFlags($isnew, false, $unpatrolled, ' ', $bot);
# Timestamp
$r .= ' ' . $block[0]->timestamp . ' </tt></td><td>';
# Article link
if ($namehidden) {
$r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
} else {
if ($allLogs) {
$r .= $this->maybeWatchedLink($block[0]->link, $block[0]->watched);
} else {
$this->insertArticleLink($r, $block[0], $block[0]->unpatrolled, $block[0]->watched);
}
}
$r .= $wgContLang->getDirMark();
$curIdEq = 'curid=' . $curId;
# Changes message
$n = count($block);
static $nchanges = array();
if (!isset($nchanges[$n])) {
$nchanges[$n] = wfMsgExt('nchanges', array('parsemag', 'escape'), $wgLang->formatNum($n));
}
# Total change link
$r .= ' ';
if (!$allLogs) {
$r .= '(';
if (!ChangesList::userCan($rcObj, Revision::DELETED_TEXT)) {
$r .= $nchanges[$n];
} else {
//.........这里部分代码省略.........
示例4: recentChangesBlockGroup
//.........这里部分代码省略.........
}
$r .= $this->getLanguage()->getDirMark();
$queryParams['curid'] = $curId;
# Changes message
static $nchanges = array();
static $sinceLastVisitMsg = array();
$n = count( $block );
if ( !isset( $nchanges[$n] ) ) {
$nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped();
}
$sinceLast = 0;
$unvisitedOldid = null;
foreach ( $block as $rcObj ) {
// Same logic as below inside main foreach
if ( $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ) {
$sinceLast++;
$unvisitedOldid = $rcObj->mAttribs['rc_last_oldid'];
}
}
if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
$sinceLastVisitMsg[$sinceLast] =
$this->msg( 'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
}
# Total change link
$r .= ' ';
$logtext = '';
if ( !$allLogs ) {
if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
$logtext .= $nchanges[$n];
} elseif ( $isnew ) {
$logtext .= $nchanges[$n];
} else {
$logtext .= Linker::link(
$block[0]->getTitle(),
$nchanges[$n],
array(),
$queryParams + array(
'diff' => $currentRevision,
'oldid' => $oldid,
),
array( 'known', 'noclasses' )
);
if ( $sinceLast > 0 && $sinceLast < $n ) {
$logtext .= $this->message['pipe-separator'] . Linker::link(
$block[0]->getTitle(),
$sinceLastVisitMsg[$sinceLast],
array(),
$queryParams + array(
'diff' => $currentRevision,
'oldid' => $unvisitedOldid,
),
array( 'known', 'noclasses' )
);
}
}
}
# History
if ( $allLogs ) {
// don't show history link for logs
示例5: onChangesListInsertDiffHist
/**
* @brief Adjusting recent changes for Wall
*
* @desc This method doesn't let display diff history links
*
* @param ChangesList $list
* @param string $articleLink
* @param string $s
* @param RecentChange $rc
* @param boolean $unpatrolled
*
* @return true because this is a hook
*
* @author Andrzej 'nAndy' Lukaszewski
*/
public function onChangesListInsertDiffHist($list, &$diffLink, &$historyLink, &$s, $rc, $unpatrolled)
{
wfProfileIn(__METHOD__);
$app = F::app();
if (in_array(MWNamespace::getSubject(intval($rc->getAttribute('rc_namespace'))), $app->wg->WallNS)) {
$rcTitle = $rc->getTitle();
if (!$rcTitle instanceof Title) {
//it can be media wiki deletion of an article -- we ignore them
Wikia::log(__METHOD__, false, "WALL_NOTITLE_FOR_DIFF_HIST " . print_r(array($rc), true));
return true;
}
if (in_array($rc->getAttribute('rc_log_action'), $this->rcWallActionTypes)) {
//delete, remove, restore
$parts = explode('/@', $rcTitle->getText());
$isThread = count($parts) === 2 ? true : false;
if ($isThread) {
$wallTitleObj = F::build('Title', array($parts[0], NS_USER_WALL), 'newFromText');
$historyLink = !empty($parts[0]) && $wallTitleObj instanceof Title ? $wallTitleObj->getFullURL(array('action' => 'history')) : '#';
$historyLink = Xml::element('a', array('href' => $historyLink), $app->wf->Msg($this->getMessagePrefix($rc->getAttribute('rc_namespace')) . '-history-link'));
} else {
$wallMessage = F::build('WallMessage', array($rcTitle));
$historyLink = $wallMessage->getMessagePageUrl(true) . '?action=history';
$historyLink = Xml::element('a', array('href' => $historyLink), $app->wf->Msg($this->getMessagePrefix($rc->getAttribute('rc_namespace')) . '-thread-history-link'));
}
$s = '(' . $historyLink . ')';
} else {
//new, edit
if ($rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG) {
$diffLink = $app->wf->Msg('diff');
} else {
if (!ChangesList::userCan($rc, Revision::DELETED_TEXT)) {
$diffLink = $app->wf->Msg('diff');
} else {
$query = array('curid' => $rc->mAttribs['rc_cur_id'], 'diff' => $rc->mAttribs['rc_this_oldid'], 'oldid' => $rc->mAttribs['rc_last_oldid']);
if ($unpatrolled) {
$query['rcid'] = $rc->mAttribs['rc_id'];
}
$diffLink = Xml::element('a', array('href' => $rcTitle->getLocalUrl($query), 'tabindex' => $rc->counter, 'class' => 'known noclasses'), $app->wf->Msg('diff'));
}
}
$wallMessage = F::build('WallMessage', array($rcTitle));
$historyLink = $wallMessage->getMessagePageUrl(true) . '?action=history';
$historyLink = Xml::element('a', array('href' => $historyLink), $app->wf->Msg('hist'));
$s = '(' . $diffLink . $app->wf->Msg('pipe-separator') . $historyLink . ') . . ';
}
}
wfProfileOut(__METHOD__);
return true;
}
示例6: showDiffLinks
/**
* @param RecentChange $cacheEntry
* @param User $user
*
* @return bool
*/
private function showDiffLinks(RecentChange $cacheEntry, User $user)
{
return ChangesList::userCan($cacheEntry, Revision::DELETED_TEXT, $user);
}