/** * 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; }
/** * 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) { $r .= $nchanges[$n]; } else { $params = $queryParams; $params['diff'] = $currentRevision; $params['oldid'] = $oldid; $r .= Linker::link($block[0]->getTitle(), $nchanges[$n], array(), $params, array('known', 'noclasses')); } } # History if ($allLogs) { // don't show history link for logs } elseif ($namehidden || !$block[0]->getTitle()->exists()) { $r .= $this->message['pipe-separator'] . $this->message['hist'] . ')'; } else { $params = $queryParams; $params['action'] = 'history'; $r .= $this->message['pipe-separator'] . Linker::linkKnown($block[0]->getTitle(), $this->message['hist'], array(), $params) . ')'; } $r .= ' . . '; # Character difference (does not apply if only log items) if ($wgRCShowChangedSize && !$allLogs) { $last = 0; $first = count($block) - 1; # Some events (like logs) have an "empty" size, so we need to skip those... while ($last < $first && $block[$last]->mAttribs['rc_new_len'] === null) { $last++; } while ($first > $last && $block[$first]->mAttribs['rc_old_len'] === null) { $first--; } # Get net change $chardiff = $rcObj->getCharacterDifference($block[$first]->mAttribs['rc_old_len'], $block[$last]->mAttribs['rc_new_len']); if ($chardiff == '') { $r .= ' '; } else { $r .= ' ' . $chardiff . ' . . '; } } $r .= $users; $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers); # Sub-entries foreach ($block as $rcObj) { # Classes to apply -- TODO implement $classes = array(); $type = $rcObj->mAttribs['rc_type']; #$r .= '<tr><td valign="top">'.$this->spacerArrow(); $r .= '<tr><td></td><td class="mw-enhanced-rc">'; $r .= $this->recentChangesFlags(array('newpage' => $rcObj->mAttribs['rc_new'], 'minor' => $rcObj->mAttribs['rc_minor'], 'unpatrolled' => $rcObj->unpatrolled, 'bot' => $rcObj->mAttribs['rc_bot'])); $r .= ' </td><td class="mw-enhanced-rc-nested"><span class="mw-enhanced-rc-time">'; $params = $queryParams; if ($rcObj->mAttribs['rc_this_oldid'] != 0) { $params['oldid'] = $rcObj->mAttribs['rc_this_oldid']; } # Log timestamp if ($type == RC_LOG) { $link = $rcObj->timestamp; # Revision link } elseif (!ChangesList::userCan($rcObj, Revision::DELETED_TEXT, $this->getUser())) { $link = '<span class="history-deleted">' . $rcObj->timestamp . '</span> '; } else { if ($rcObj->unpatrolled && $type == RC_NEW) { $params['rcid'] = $rcObj->mAttribs['rc_id']; } $link = Linker::linkKnown($rcObj->getTitle(), $rcObj->timestamp, array(), $params); if ($this->isDeleted($rcObj, Revision::DELETED_TEXT)) { $link = '<span class="history-deleted">' . $link . '</span> '; } } $r .= $link . '</span>'; if (!$type == RC_LOG || $type == RC_NEW) { $r .= ' ('; $r .= $rcObj->curlink; $r .= $this->message['pipe-separator']; $r .= $rcObj->lastlink; $r .= ')'; } $r .= ' . . '; # Character diff if ($wgRCShowChangedSize && $rcObj->getCharacterDifference()) { $r .= $rcObj->getCharacterDifference() . ' . . '; } if ($rcObj->mAttribs['rc_type'] == RC_LOG) { $r .= $this->insertLogEntry($rcObj); } else { # User links $r .= $rcObj->userlink; $r .= $rcObj->usertalklink; $r .= $this->insertComment($rcObj); } # Rollback $this->insertRollback($r, $rcObj); # Tags $this->insertTags($r, $rcObj, $classes); $r .= "</td></tr>\n"; } $r .= "</table>\n"; $this->rcCacheIndex++; wfProfileOut(__METHOD__); return $r; }
/** * 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 { if ($isnew) { $r .= $nchanges[$n]; } else { $r .= $this->skin->makeKnownLinkObj($block[0]->getTitle(), $nchanges[$n], $curIdEq . "&diff={$currentRevision}&oldid={$oldid}"); } } } # History if ($allLogs) { // don't show history link for logs } else { if ($namehidden || !$block[0]->getTitle()->exists()) { $r .= $this->message['semicolon-separator'] . $this->message['hist'] . ')'; } else { $r .= $this->message['semicolon-separator'] . $this->skin->makeKnownLinkObj($block[0]->getTitle(), $this->message['hist'], $curIdEq . '&action=history') . ')'; } } $r .= ' . . '; # Character difference (does not apply if only log items) if ($wgRCShowChangedSize && !$allLogs) { $last = 0; $first = count($block) - 1; # Some events (like logs) have an "empty" size, so we need to skip those... while ($last < $first && $block[$last]->mAttribs['rc_new_len'] === NULL) { $last++; } while ($first > $last && $block[$first]->mAttribs['rc_old_len'] === NULL) { $first--; } # Get net change $chardiff = $rcObj->getCharacterDifference($block[$first]->mAttribs['rc_old_len'], $block[$last]->mAttribs['rc_new_len']); if ($chardiff == '') { $r .= ' '; } else { $r .= ' ' . $chardiff . ' . . '; } } $r .= $users; $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers); $r .= "</td></tr></table>\n"; # Sub-entries $r .= '<div id="mw-rc-subentries-' . $jsid . '" class="mw-changeslist-hidden">'; $r .= '<table cellpadding="0" cellspacing="0" border="0" style="background: none">'; foreach ($block as $rcObj) { # Extract fields from DB into the function scope (rc_xxxx variables) // FIXME: Would be good to replace this extract() call with something // that explicitly initializes variables. # Classes to apply -- TODO implement $classes = array(); extract($rcObj->mAttribs); #$r .= '<tr><td valign="top">'.$this->spacerArrow(); $r .= '<tr><td valign="top">'; $r .= '<tt>' . $this->spacerIndent() . $this->spacerIndent(); $r .= $this->recentChangesFlags($rc_new, $rc_minor, $rcObj->unpatrolled, ' ', $rc_bot); $r .= ' </tt></td><td valign="top">'; $o = ''; if ($rc_this_oldid != 0) { $o = 'oldid=' . $rc_this_oldid; } # Log timestamp if ($rc_type == RC_LOG) { $link = '<tt>' . $rcObj->timestamp . '</tt> '; # Revision link } else { if (!ChangesList::userCan($rcObj, Revision::DELETED_TEXT)) { $link = '<span class="history-deleted"><tt>' . $rcObj->timestamp . '</tt></span> '; } else { $rcIdEq = $rcObj->unpatrolled && $rc_type == RC_NEW ? '&rcid=' . $rcObj->mAttribs['rc_id'] : ''; $link = '<tt>' . $this->skin->makeKnownLinkObj($rcObj->getTitle(), $rcObj->timestamp, $curIdEq . '&' . $o . $rcIdEq) . '</tt>'; if ($this->isDeleted($rcObj, Revision::DELETED_TEXT)) { $link = '<span class="history-deleted">' . $link . '</span> '; } } } $r .= $link; if (!$rc_type == RC_LOG || $rc_type == RC_NEW) { $r .= ' ('; $r .= $rcObj->curlink; $r .= $this->message['semicolon-separator']; $r .= $rcObj->lastlink; $r .= ')'; } $r .= ' . . '; # Character diff if ($wgRCShowChangedSize) { $r .= $rcObj->getCharacterDifference() == '' ? '' : $rcObj->getCharacterDifference() . ' . . '; } # User links $r .= $rcObj->userlink; $r .= $rcObj->usertalklink; // log action $this->insertAction($r, $rcObj); // log comment $this->insertComment($r, $rcObj); # Rollback $this->insertRollback($r, $rcObj); # Tags $this->insertTags($r, $rcObj, $classes); # Mark revision as deleted if (!$rc_log_type && $this->isDeleted($rcObj, Revision::DELETED_TEXT)) { $r .= ' <tt>' . wfMsgHtml('deletedrev') . '</tt>'; } $r .= "</td></tr>\n"; } $r .= "</table></div>\n"; $this->rcCacheIndex++; wfProfileOut(__METHOD__); return $r; }
/** * Enhanced RC group * @return string */ protected function recentChangesBlockGroup( $block ) { global $wgRCShowChangedSize; wfProfileIn( __METHOD__ ); # Add the namespace and title of the block as part of the class $classes = array( 'mw-collapsible', 'mw-collapsed', 'mw-enhanced-rc' ); if ( $block[0]->mAttribs['rc_log_type'] ) { # Log entry $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-' . $block[0]->mAttribs['rc_log_type'] ); } else { $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] ); } $classes[] = $block[0]->watched && $block[0]->mAttribs['rc_timestamp'] >= $block[0]->watched ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched'; $r = Html::openElement( 'table', array( 'class' => $classes ) ) . Html::openElement( 'tr' ); # Collate list of users $userlinks = array(); # Other properties $unpatrolled = false; $isnew = false; $allBots = true; $allMinors = true; $curId = $currentRevision = 0; # Some catalyst variables... $namehidden = true; $allLogs = true; foreach ( $block as $rcObj ) { $oldid = $rcObj->mAttribs['rc_last_oldid']; if ( $rcObj->mAttribs['rc_type'] == 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']; } if ( !$rcObj->mAttribs['rc_bot'] ) { $allBots = false; } if ( !$rcObj->mAttribs['rc_minor'] ) { $allMinors = false; } $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->msg( 'parentheses' )->rawParams( $this->getLanguage()->formatNum( $count ) . '×' )->escaped(); } array_push( $users, $text ); } $users = ' <span class="changedby">' . $this->msg( 'brackets' )->rawParams( implode( $this->message['semicolon-separator'], $users ) )->escaped() . '</span>'; $tl = '<span class="mw-collapsible-toggle mw-collapsible-arrow mw-enhancedchanges-arrow mw-enhancedchanges-arrow-space"></span>'; $r .= "<td>$tl</td>"; # Main line $r .= '<td class="mw-enhanced-rc">' . $this->recentChangesFlags( array( 'newpage' => $isnew, # show, when one have this flag 'minor' => $allMinors, # show only, when all have this flag 'unpatrolled' => $unpatrolled, # show, when one have this flag 'bot' => $allBots, # show only, when all have this flag ) ); # Timestamp $r .= ' ' . $block[0]->timestamp . ' </td><td>'; # Article link if ( $namehidden ) { $r .= ' <span class="history-deleted">' . $this->msg( 'rev-deleted-event' )->escaped() . '</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 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 } elseif ( $namehidden || !$block[0]->getTitle()->exists() ) { $logtext .= $this->message['pipe-separator'] . $this->message['enhancedrc-history']; } else { $params = $queryParams; $params['action'] = 'history'; $logtext .= $this->message['pipe-separator'] . Linker::linkKnown( $block[0]->getTitle(), $this->message['enhancedrc-history'], array(), $params ); } if ( $logtext !== '' ) { $r .= $this->msg( 'parentheses' )->rawParams( $logtext )->escaped(); } $r .= ' <span class="mw-changeslist-separator">. .</span> '; # Character difference (does not apply if only log items) if ( $wgRCShowChangedSize && !$allLogs ) { $last = 0; $first = count( $block ) - 1; # Some events (like logs) have an "empty" size, so we need to skip those... while ( $last < $first && $block[$last]->mAttribs['rc_new_len'] === null ) { $last++; } while ( $first > $last && $block[$first]->mAttribs['rc_old_len'] === null ) { $first--; } # Get net change $chardiff = $this->formatCharacterDifference( $block[$first], $block[$last] ); if ( $chardiff == '' ) { $r .= ' '; } else { $r .= ' ' . $chardiff . ' <span class="mw-changeslist-separator">. .</span> '; } } $r .= $users; $r .= $this->numberofWatchingusers( $block[0]->numberofWatchingusers ); # Sub-entries foreach ( $block as $rcObj ) { # Classes to apply -- TODO implement $classes = array(); $type = $rcObj->mAttribs['rc_type']; $trClass = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ? ' class="mw-enhanced-watched"' : ''; $r .= '<tr' . $trClass . '><td></td><td class="mw-enhanced-rc">'; $r .= $this->recentChangesFlags( array( 'newpage' => $type == RC_NEW, 'minor' => $rcObj->mAttribs['rc_minor'], 'unpatrolled' => $rcObj->unpatrolled, 'bot' => $rcObj->mAttribs['rc_bot'], ) ); $r .= ' </td><td class="mw-enhanced-rc-nested"><span class="mw-enhanced-rc-time">'; $params = $queryParams; if ( $rcObj->mAttribs['rc_this_oldid'] != 0 ) { $params['oldid'] = $rcObj->mAttribs['rc_this_oldid']; } # Log timestamp if ( $type == RC_LOG ) { $link = $rcObj->timestamp; # Revision link } elseif ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) { $link = '<span class="history-deleted">' . $rcObj->timestamp . '</span> '; } else { $link = Linker::linkKnown( $rcObj->getTitle(), $rcObj->timestamp, array(), $params ); if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) { $link = '<span class="history-deleted">' . $link . '</span> '; } } $r .= $link . '</span>'; if ( !$type == RC_LOG || $type == RC_NEW ) { $r .= ' ' . $this->msg( 'parentheses' )->rawParams( $rcObj->curlink . $this->message['pipe-separator'] . $rcObj->lastlink )->escaped(); } $r .= ' <span class="mw-changeslist-separator">. .</span> '; # Character diff if ( $wgRCShowChangedSize ) { $cd = $this->formatCharacterDifference( $rcObj ); if ( $cd !== '' ) { $r .= $cd . ' <span class="mw-changeslist-separator">. .</span> '; } } if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) { $r .= $this->insertLogEntry( $rcObj ); } else { # User links $r .= $rcObj->userlink; $r .= $rcObj->usertalklink; $r .= $this->insertComment( $rcObj ); } # Rollback $this->insertRollback( $r, $rcObj ); # Tags $this->insertTags( $r, $rcObj, $classes ); $r .= "</td></tr>\n"; } $r .= "</table>\n"; $this->rcCacheIndex++; wfProfileOut( __METHOD__ ); return $r; }
/** * @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; }
/** * @param RecentChange $cacheEntry * @param User $user * * @return bool */ private function showDiffLinks(RecentChange $cacheEntry, User $user) { return ChangesList::userCan($cacheEntry, Revision::DELETED_TEXT, $user); }