X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fchanges%2FEnhancedChangesList.php;h=1727da02aa10d167c1b3776b5d6332d7c0a0b6ed;hb=2082fd8bab7414a6471ccbb98a939ecb3c7ae13a;hp=433adb375c75b3924ab785255e830f2e15ac1dec;hpb=584775e59d553b3447f615422e1b929506470f97;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index 433adb375c..1727da02aa 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -42,8 +42,10 @@ class EnhancedChangesList extends ChangesList { 'jquery.makeCollapsible', 'mediawiki.icon', ) ); + return ''; } + /** * Format a line for enhanced recentchange (aka with javascript and block of lines). * @@ -55,14 +57,14 @@ class EnhancedChangesList extends ChangesList { public function recentChangesLine( &$baseRC, $watched = false ) { wfProfileIn( __METHOD__ ); - # Create a specialised object - $rc = RCCacheEntry::newFromParent( $baseRC ); - - $curIdEq = array( 'curid' => $rc->mAttribs['rc_cur_id'] ); - # If it's a new day, add the headline and flush the cache - $date = $this->getLanguage()->userDate( $rc->mAttribs['rc_timestamp'], $this->getUser() ); + $date = $this->getLanguage()->userDate( + $baseRC->mAttribs['rc_timestamp'], + $this->getUser() + ); + $ret = ''; + if ( $date != $this->lastdate ) { # Process current cache $ret = $this->recentChangesBlock(); @@ -71,53 +73,62 @@ class EnhancedChangesList extends ChangesList { $this->lastdate = $date; } + # Create a specialised object + $cacheEntry = RCCacheEntry::newFromParent( $baseRC ); + + $curIdEq = array( 'curid' => $cacheEntry->mAttribs['rc_cur_id'] ); + # Should patrol-related stuff be shown? - $rc->unpatrolled = $this->showAsUnpatrolled( $rc ); + $cacheEntry->unpatrolled = $this->showAsUnpatrolled( $cacheEntry ); $showdifflinks = true; + # Make article link - $type = $rc->mAttribs['rc_type']; - $logType = $rc->mAttribs['rc_log_type']; + $type = $cacheEntry->mAttribs['rc_type']; + $logType = $cacheEntry->mAttribs['rc_log_type']; + // Page moves, very old style, not supported anymore if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) { // New unpatrolled pages - } elseif ( $rc->unpatrolled && $type == RC_NEW ) { - $clink = Linker::linkKnown( $rc->getTitle() ); + } elseif ( $cacheEntry->unpatrolled && $type == RC_NEW ) { + $clink = Linker::linkKnown( $cacheEntry->getTitle() ); // Log entries } elseif ( $type == RC_LOG ) { if ( $logType ) { $logtitle = SpecialPage::getTitleFor( 'Log', $logType ); $logpage = new LogPage( $logType ); $logname = $logpage->getName()->escaped(); - $clink = $this->msg( 'parentheses' )->rawParams( Linker::linkKnown( $logtitle, $logname ) )->escaped(); + $clink = $this->msg( 'parentheses' ) + ->rawParams( Linker::linkKnown( $logtitle, $logname ) )->escaped(); } else { - $clink = Linker::link( $rc->getTitle() ); + $clink = Linker::link( $cacheEntry->getTitle() ); } $watched = false; // Log entries (old format) and special pages - } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) { + } elseif ( $cacheEntry->mAttribs['rc_namespace'] == NS_SPECIAL ) { wfDebug( "Unexpected special page in recentchanges\n" ); $clink = ''; // Edits } else { - $clink = Linker::linkKnown( $rc->getTitle() ); + $clink = Linker::linkKnown( $cacheEntry->getTitle() ); } # Don't show unusable diff links - if ( !ChangesList::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) { + if ( !ChangesList::userCan( $cacheEntry, Revision::DELETED_TEXT, $this->getUser() ) ) { $showdifflinks = false; } - $time = $this->getLanguage()->userTime( $rc->mAttribs['rc_timestamp'], $this->getUser() ); - $rc->watched = $watched; - $rc->link = $clink; - $rc->timestamp = $time; - $rc->numberofWatchingusers = $baseRC->numberofWatchingusers; + $time = $this->getLanguage()->userTime( $cacheEntry->mAttribs['rc_timestamp'], $this->getUser() ); + + $cacheEntry->watched = $watched; + $cacheEntry->link = $clink; + $cacheEntry->timestamp = $time; + $cacheEntry->numberofWatchingusers = $baseRC->numberofWatchingusers; # Make "cur" and "diff" links. Do not use link(), it is too slow if # called too many times (50% of CPU time on RecentChanges!). - $thisOldid = $rc->mAttribs['rc_this_oldid']; - $lastOldid = $rc->mAttribs['rc_last_oldid']; + $thisOldid = $cacheEntry->mAttribs['rc_this_oldid']; + $lastOldid = $cacheEntry->mAttribs['rc_last_oldid']; $querycur = $curIdEq + array( 'diff' => '0', 'oldid' => $thisOldid ); $querydiff = $curIdEq + array( 'diff' => $thisOldid, 'oldid' => $lastOldid ); @@ -129,13 +140,13 @@ class EnhancedChangesList extends ChangesList { if ( $type != RC_NEW ) { $curLink = $this->message['cur']; } else { - $curUrl = htmlspecialchars( $rc->getTitle()->getLinkURL( $querycur ) ); + $curUrl = htmlspecialchars( $cacheEntry->getTitle()->getLinkURL( $querycur ) ); $curLink = "counter}\">{$this->message['cur']}"; } $diffLink = $this->message['diff']; } else { - $diffUrl = htmlspecialchars( $rc->getTitle()->getLinkURL( $querydiff ) ); - $curUrl = htmlspecialchars( $rc->getTitle()->getLinkURL( $querycur ) ); + $diffUrl = htmlspecialchars( $cacheEntry->getTitle()->getLinkURL( $querydiff ) ); + $curUrl = htmlspecialchars( $cacheEntry->getTitle()->getLinkURL( $querycur ) ); $diffLink = "counter}\">{$this->message['diff']}"; $curLink = "counter}\">{$this->message['cur']}"; } @@ -146,29 +157,38 @@ class EnhancedChangesList extends ChangesList { } elseif ( in_array( $type, array( RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT ) ) ) { $lastLink = $this->message['last']; } else { - $lastLink = Linker::linkKnown( $rc->getTitle(), $this->message['last'], + $lastLink = Linker::linkKnown( $cacheEntry->getTitle(), $this->message['last'], array(), $curIdEq + array( 'diff' => $thisOldid, 'oldid' => $lastOldid ) ); } # Make user links - if ( $this->isDeleted( $rc, Revision::DELETED_USER ) ) { - $rc->userlink = ' ' . $this->msg( 'rev-deleted-user' )->escaped() . ''; + if ( $this->isDeleted( $cacheEntry, Revision::DELETED_USER ) ) { + $cacheEntry->userlink = ' ' . + $this->msg( 'rev-deleted-user' )->escaped() . ''; } else { - $rc->userlink = Linker::userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] ); - $rc->usertalklink = Linker::userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] ); + $cacheEntry->userlink = Linker::userLink( + $cacheEntry->mAttribs['rc_user'], + $cacheEntry->mAttribs['rc_user_text'] + ); + + $cacheEntry->usertalklink = Linker::userToolLinks( + $cacheEntry->mAttribs['rc_user'], + $cacheEntry->mAttribs['rc_user_text'] + ); } - $rc->lastlink = $lastLink; - $rc->curlink = $curLink; - $rc->difflink = $diffLink; + $cacheEntry->lastlink = $lastLink; + $cacheEntry->curlink = $curLink; + $cacheEntry->difflink = $diffLink; # Put accumulated information into the cache, for later display # Page moves go on their own line - $title = $rc->getTitle(); + $title = $cacheEntry->getTitle(); $secureName = $title->getPrefixedDBkey(); + if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) { # Use an @ character to prevent collision with page names - $this->rc_cache['@@' . ( $this->rcMoveIndex++ )] = array( $rc ); + $this->rc_cache['@@' . ( $this->rcMoveIndex++ )] = array( $cacheEntry ); } else { # Logs are grouped by type if ( $type == RC_LOG ) { @@ -178,7 +198,7 @@ class EnhancedChangesList extends ChangesList { $this->rc_cache[$secureName] = array(); } - array_push( $this->rc_cache[$secureName], $rc ); + array_push( $this->rc_cache[$secureName], $cacheEntry ); } wfProfileOut( __METHOD__ ); @@ -200,10 +220,10 @@ class EnhancedChangesList extends ChangesList { if ( $block[0]->mAttribs['rc_log_type'] ) { # Log entry $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-' - . $block[0]->mAttribs['rc_log_type'] . '-' . $block[0]->mAttribs['rc_title'] ); + . $block[0]->mAttribs['rc_log_type'] . '-' . $block[0]->mAttribs['rc_title'] ); } else { $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' - . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] ); + . $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'; @@ -268,7 +288,9 @@ class EnhancedChangesList extends ChangesList { $text = $userlink; $text .= $this->getLanguage()->getDirMark(); if ( $count > 1 ) { - $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->formatNum( $count ) . '×' )->escaped(); + // @todo FIXME: Hardcoded '×'. Should be a message. + $formattedCount = $this->getLanguage()->formatNum( $count ) . '×'; + $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $formattedCount )->escaped(); } array_push( $users, $text ); } @@ -278,7 +300,8 @@ class EnhancedChangesList extends ChangesList { implode( $this->message['semicolon-separator'], $users ) )->escaped() . ''; - $tl = ''; + $tl = ''; $r .= "$tl"; # Main line @@ -294,7 +317,8 @@ class EnhancedChangesList extends ChangesList { # Article link if ( $namehidden ) { - $r .= ' ' . $this->msg( 'rev-deleted-event' )->escaped() . ''; + $r .= ' ' . + $this->msg( 'rev-deleted-event' )->escaped() . ''; } elseif ( $allLogs ) { $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched ); } else { @@ -409,6 +433,7 @@ class EnhancedChangesList extends ChangesList { $r .= $users; $r .= $this->numberofWatchingusers( $block[0]->numberofWatchingusers ); + $r .= ''; # Sub-entries foreach ( $block as $rcObj ) { @@ -443,11 +468,11 @@ class EnhancedChangesList extends ChangesList { } else { $link = Linker::linkKnown( - $rcObj->getTitle(), - $rcObj->timestamp, - array(), - $params - ); + $rcObj->getTitle(), + $rcObj->timestamp, + array(), + $params + ); if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) { $link = '' . $link . ' '; } @@ -455,7 +480,11 @@ class EnhancedChangesList extends ChangesList { $r .= $link . ''; if ( !$type == RC_LOG || $type == RC_NEW ) { - $r .= ' ' . $this->msg( 'parentheses' )->rawParams( $rcObj->curlink . $this->message['pipe-separator'] . $rcObj->lastlink )->escaped(); + $r .= ' ' . $this->msg( 'parentheses' )->rawParams( + $rcObj->curlink . + $this->message['pipe-separator'] . + $rcObj->lastlink + )->escaped(); } $r .= ' . . '; @@ -504,6 +533,7 @@ class EnhancedChangesList extends ChangesList { $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' ); $encAlt = htmlspecialchars( $alt ); $encTitle = htmlspecialchars( $title ); + return "\"$encAlt\""; } @@ -514,6 +544,7 @@ class EnhancedChangesList extends ChangesList { */ protected function sideArrow() { $dir = $this->getLanguage()->isRTL() ? 'l' : 'r'; + return $this->arrow( $dir, '+', $this->msg( 'rc-enhanced-expand' )->text() ); } @@ -552,10 +583,10 @@ class EnhancedChangesList extends ChangesList { if ( $logType ) { # Log entry $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-' - . $logType . '-' . $rcObj->mAttribs['rc_title'] ); + . $logType . '-' . $rcObj->mAttribs['rc_title'] ); } else { $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' . - $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] ); + $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] ); } $classes[] = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched'; @@ -580,19 +611,21 @@ class EnhancedChangesList extends ChangesList { $logPage = new LogPage( $logType ); $logTitle = SpecialPage::getTitleFor( 'Log', $logType ); $logName = $logPage->getName()->escaped(); - $r .= $this->msg( 'parentheses' )->rawParams( Linker::linkKnown( $logTitle, $logName ) )->escaped(); + $r .= $this->msg( 'parentheses' ) + ->rawParams( Linker::linkKnown( $logTitle, $logName ) )->escaped(); } else { $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled, $rcObj->watched ); } # Diff and hist links if ( $type != RC_LOG ) { $query['action'] = 'history'; - $r .= ' ' . $this->msg( 'parentheses' )->rawParams( $rcObj->difflink . $this->message['pipe-separator'] . Linker::linkKnown( - $rcObj->getTitle(), - $this->message['hist'], - array(), - $query - ) )->escaped(); + $r .= ' ' . $this->msg( 'parentheses' ) + ->rawParams( $rcObj->difflink . $this->message['pipe-separator'] . Linker::linkKnown( + $rcObj->getTitle(), + $this->message['hist'], + array(), + $query + ) )->escaped(); } $r .= ' . . '; # Character diff @@ -630,7 +663,7 @@ class EnhancedChangesList extends ChangesList { * @return string */ protected function recentChangesBlock() { - if ( count ( $this->rc_cache ) == 0 ) { + if ( count( $this->rc_cache ) == 0 ) { return ''; } @@ -658,5 +691,4 @@ class EnhancedChangesList extends ChangesList { public function endRecentChangesList() { return $this->recentChangesBlock() . parent::endRecentChangesList(); } - }