| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
use MediaWiki\Html\Html; |
| 22 |
use MediaWiki\MainConfigNames; |
| 23 |
use MediaWiki\MediaWikiServices; |
| 24 |
use MediaWiki\Parser\Sanitizer; |
| 25 |
use MediaWiki\Revision\RevisionRecord; |
| 26 |
use MediaWiki\SpecialPage\SpecialPage; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
class OldChangesList extends ChangesList { |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) { |
| 46 |
$classes = $this->getHTMLClasses( $rc, $watched ); |
| 47 |
|
| 48 |
if ( $linenumber ) { |
| 49 |
if ( $linenumber & 1 ) { |
| 50 |
$classes[] = 'mw-line-odd'; |
| 51 |
} else { |
| 52 |
$classes[] = 'mw-line-even'; |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
$html = $this->formatChangeLine( $rc, $classes, $watched ); |
| 57 |
|
| 58 |
if ( $this->watchlist ) { |
| 59 |
$classes[] = Sanitizer::escapeClass( 'watchlist-' . |
| 60 |
$rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] ); |
| 61 |
} |
| 62 |
|
| 63 |
$attribs = $this->getDataAttributes( $rc ); |
| 64 |
|
| 65 |
if ( !$this->getHookRunner()->onOldChangesListRecentChangesLine( |
| 66 |
$this, $html, $rc, $classes, $attribs ) |
| 67 |
) { |
| 68 |
return false; |
| 69 |
} |
| 70 |
$attribs = array_filter( $attribs, |
| 71 |
[ Sanitizer::class, 'isReservedDataAttribute' ], |
| 72 |
ARRAY_FILTER_USE_KEY |
| 73 |
); |
| 74 |
|
| 75 |
$dateheader = ''; |
| 76 |
$this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] ); |
| 77 |
|
| 78 |
$html = $this->getHighlightsContainerDiv() . $html; |
| 79 |
$attribs['class'] = $classes; |
| 80 |
|
| 81 |
return $dateheader . Html::rawElement( 'li', $attribs, $html ) . "\n"; |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
private function formatChangeLine( RecentChange $rc, array &$classes, $watched ) { |
| 92 |
$html = ''; |
| 93 |
$unpatrolled = $this->showAsUnpatrolled( $rc ); |
| 94 |
|
| 95 |
if ( $rc->mAttribs['rc_log_type'] ) { |
| 96 |
$logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] ); |
| 97 |
$this->insertLog( $html, $logtitle, $rc->mAttribs['rc_log_type'], false ); |
| 98 |
$flags = $this->recentChangesFlags( [ 'unpatrolled' => $unpatrolled, |
| 99 |
'bot' => $rc->mAttribs['rc_bot'] ], '' ); |
| 100 |
if ( $flags !== '' ) { |
| 101 |
$html .= ' ' . $flags; |
| 102 |
} |
| 103 |
|
| 104 |
} elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) { |
| 105 |
[ $name, $htmlubpage ] = MediaWikiServices::getInstance()->getSpecialPageFactory()-> |
| 106 |
resolveAlias( $rc->mAttribs['rc_title'] ); |
| 107 |
if ( $name == 'Log' ) { |
| 108 |
$this->insertLog( $html, $rc->getTitle(), $htmlubpage ?? '', false ); |
| 109 |
} |
| 110 |
|
| 111 |
} else { |
| 112 |
$this->insertDiffHist( $html, $rc ); |
| 113 |
|
| 114 |
$html .= $this->recentChangesFlags( |
| 115 |
[ |
| 116 |
'newpage' => $rc->mAttribs['rc_type'] == RC_NEW, |
| 117 |
'minor' => $rc->mAttribs['rc_minor'], |
| 118 |
'unpatrolled' => $unpatrolled, |
| 119 |
'bot' => $rc->mAttribs['rc_bot'] |
| 120 |
], |
| 121 |
'' |
| 122 |
); |
| 123 |
$html .= $this->getArticleLink( $rc, $unpatrolled, $watched ); |
| 124 |
} |
| 125 |
|
| 126 |
$this->insertTimestamp( $html, $rc ); |
| 127 |
|
| 128 |
if ( $this->getConfig()->get( MainConfigNames::RCShowChangedSize ) ) { |
| 129 |
$cd = $this->formatCharacterDifference( $rc ); |
| 130 |
if ( $cd !== '' ) { |
| 131 |
$html .= $cd . ' <span class="mw-changeslist-separator"></span> '; |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
if ( $rc->mAttribs['rc_type'] == RC_LOG ) { |
| 136 |
$html .= $this->insertLogEntry( $rc ); |
| 137 |
} elseif ( $this->isCategorizationWithoutRevision( $rc ) ) { |
| 138 |
$html .= $this->insertComment( $rc ); |
| 139 |
} else { |
| 140 |
|
| 141 |
$this->insertUserRelatedLinks( $html, $rc ); |
| 142 |
$html .= $this->insertComment( $rc ); |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
$this->insertTags( $html, $rc, $classes ); |
| 147 |
|
| 148 |
$this->insertRollback( $html, $rc ); |
| 149 |
|
| 150 |
$this->insertExtra( $html, $rc, $classes ); |
| 151 |
|
| 152 |
|
| 153 |
if ( $rc->numberofWatchingusers > 0 ) { |
| 154 |
$html .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers ); |
| 155 |
} |
| 156 |
|
| 157 |
$titleText = $rc->getTitle(); |
| 158 |
if ( !ChangesList::userCan( $rc, RevisionRecord::DELETED_TEXT, $this->getAuthority() ) ) { |
| 159 |
$titleText = $this->msg( 'rev-deleted-event' )->escaped(); |
| 160 |
} |
| 161 |
|
| 162 |
|
| 163 |
$html = Html::rawElement( 'span', [ |
| 164 |
'class' => 'mw-changeslist-line-inner', |
| 165 |
'data-target-page' => $titleText, |
| 166 |
], $html ); |
| 167 |
if ( is_callable( $this->changeLinePrefixer ) ) { |
| 168 |
$prefix = call_user_func( $this->changeLinePrefixer, $rc, $this, false ); |
| 169 |
$html = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-line-prefix' ], $prefix ) . $html; |
| 170 |
} |
| 171 |
|
| 172 |
return $html; |
| 173 |
} |
| 174 |
} |