From e8dcbd4ee1fe7da0a5c34e734592f857c43b290c Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 18 Nov 2004 11:37:14 +0000 Subject: [PATCH] Less obtrusive RC patrol feature, also works with enhanced RC, disable client side cache for Special:Recentchanges if $wgUseRCPatrol --- includes/Skin.php | 93 +++++++++++++++++++++++-------- includes/SpecialRecentchanges.php | 16 ++++-- skins/common/common.css | 8 ++- skins/monobook/main.css | 5 ++ 4 files changed, 92 insertions(+), 30 deletions(-) diff --git a/includes/Skin.php b/includes/Skin.php index b63119f214..9bb6a52001 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1977,7 +1977,7 @@ class Skin { if ( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { $r .= '  '; } else { - # M & N (minor & new) + # M, N and ! $M = wfMsg( 'minoreditletter' ); $N = wfMsg( 'newpageletter' ); @@ -1991,6 +1991,11 @@ class Skin { } else { $r .= ' ' ; } + if ( $rcObj->unpatrolled ) { + $r .= '!'; + } else { + $r .= ' '; + } } # Timestamp @@ -2036,12 +2041,20 @@ class Skin { # Collate list of users $isnew = false ; + $unpatrolled = false; $userlinks = array () ; foreach ( $block AS $rcObj ) { $oldid = $rcObj->mAttribs['rc_last_oldid']; - if ( $rcObj->mAttribs['rc_new'] ) $isnew = true ; + if ( $rcObj->mAttribs['rc_new'] ) { + $isnew = true ; + } $u = $rcObj->userlink ; - if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ; + if ( !isset ( $userlinks[$u] ) ) { + $userlinks[$u] = 0 ; + } + if ( $rcObj->unpatrolled ) { + $unpatrolled = true; + } $userlinks[$u]++ ; } @@ -2072,6 +2085,11 @@ class Skin { if ( $isnew ) $r .= $N ; else $r .= ' ' ; $r .= ' ' ; # Minor + if ( $unpatrolled ) { + $r .= "!"; + } else { + $r .= " "; + } # Timestamp $r .= ' '.$block[0]->timestamp.' ' ; @@ -2107,11 +2125,25 @@ class Skin { $r .= ''; $r .= '       ' ; - if ( $rc_new ) $r .= $N ; - else $r .= ' ' ; - if ( $rc_minor ) $r .= $M ; - else $r .= ' ' ; - $r .= '' ; + if ( $rc_new ) { + $r .= $N ; + } else { + $r .= ' ' ; + } + + if ( $rc_minor ) { + $r .= $M ; + } else { + $r .= ' ' ; + } + + if ( $rcObj->unpatrolled ) { + $r .= "!"; + } else { + $r .= " "; + } + + $r .= ' ' ; $o = '' ; if ( $rc_last_oldid != 0 ) { @@ -2183,6 +2215,10 @@ class Skin { extract( $rc->mAttribs ); $curIdEq = 'curid=' . $rc_cur_id; + # Should patrol-related stuff be shown? + $unpatrolled = $wgUseRCPatrol && $wgUser->getID() != 0 && + ( !$wgOnlySysopsCanPatrol || $wgUser->isAllowed('patrol') ) && $rc_patrolled == 0; + # Make date header if necessary $date = $wgContLang->date( $rc_timestamp, true); $uidate = $wgLang->date( $rc_timestamp, true); @@ -2194,12 +2230,7 @@ class Skin { $this->rclistOpen = true; } - # If this edit has not yet been patrolled, make it stick out - if ( !$wgUseRCPatrol || $rc_patrolled ) { - $s .= '
  • '; - } else { - $s .= '
  • '; - } + $s .= '
  • '; if ( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { # Diff @@ -2222,8 +2253,7 @@ class Skin { if ( $rc_type == RC_NEW || $rc_type == RC_LOG ) { $diffLink = wfMsg( 'diff' ); } else { - if ( $wgUseRCPatrol && $rc_patrolled == 0 && $wgUser->getID() != 0 && - ( $wgUser->isAllowed('protect') || !$wgOnlySysopsCanPatrol ) ) + if ( $unpatrolled ) $rcidparam = "&rcid={$rc_id}"; else $rcidparam = ""; @@ -2237,15 +2267,15 @@ class Skin { $s .= $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ); $s .= ') . . '; - # M and N (minor and new) + # M, N and ! (minor, new and unpatrolled) if ( $rc_minor ) { $s .= ' '.wfMsg( "minoreditletter" ).''; } if ( $rc_type == RC_NEW ) { $s .= ''.wfMsg( "newpageletter" ).''; } + if ( !$rc_patrolled ) { $s .= ' !'; } # Article link # If it's a new article, there is no diff link, but if it hasn't been # patrolled yet, we need to give users a way to do so - if ( $wgUseRCPatrol && $rc_type == RC_NEW && $rc_patrolled == 0 && - $wgUser->getID() != 0 && ( $wgUser->isAllowed('patrol') || !$wgOnlySysopsCanPatrol ) ) + if ( $unpatrolled && $rc_type == RC_NEW ) $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" ); else $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '' ); @@ -2296,14 +2326,15 @@ class Skin { $rc_comment=$this->formatComment($rc_comment,$rc->getTitle()); $s .= $wgContLang->emphasize(' (' . $rc_comment . ')'); } - $s .= "
  • \n"; + $s .= "
  • \n"; return $s; } function recentChangesLineNew( &$baseRC, $watched = false ) { global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds; - + global $wgUseRCPatrol, $wgOnlySysopsCanPatrol; + # Create a specialised object $rc = RCCacheEntry::newFromParent( $baseRC ) ; @@ -2322,7 +2353,15 @@ class Skin { $ret .= "

    {$uidate}

    \n"; $this->lastdate = $date; } - + + # Should patrol-related stuff be shown? + if ( $wgUseRCPatrol && $wgUser->getID() != 0 && + ( !$wgOnlySysopsCanPatrol || $wgUser->isAllowed('patrol') )) { + $rc->unpatrolled = !$rc_patrolled; + } else { + $rc->unpatrolled = false; + } + # Make article link if ( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { $msg = ( $rc_type == RC_MOVE ) ? "1movedto2" : "1movedto2_redir"; @@ -2333,6 +2372,9 @@ class Skin { $logtype = $matches[1]; $logname = LogPage::logName( $logtype ); $clink = '(' . $this->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')'; + } elseif ( $rc->unpatrolled && $rc_type == RC_NEW ) { + # Unpatrolled new page, give rc_id in query + $clink = $this->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" ); } else { $clink = $this->makeKnownLinkObj( $rc->getTitle(), '' ) ; } @@ -2355,11 +2397,16 @@ class Skin { # Make "last" link $titleObj = $rc->getTitle(); + if ( $rc->unpatrolled ) { + $rcIdQuery = "&rcid={$rc_id}"; + } else { + $rcIdQuery = ''; + } if ( $rc_last_oldid == 0 || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { $lastLink = wfMsg( 'last' ); } else { $lastLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'last' ), - $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid ); + $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery ); } # Make user link (or user contributions for unregistered users) diff --git a/includes/SpecialRecentchanges.php b/includes/SpecialRecentchanges.php index 9914924f95..d58ae0c149 100644 --- a/includes/SpecialRecentchanges.php +++ b/includes/SpecialRecentchanges.php @@ -16,7 +16,7 @@ require_once( 'Feed.php' ); function wfSpecialRecentchanges( $par ) { global $wgUser, $wgOut, $wgLang, $wgContLang, $wgTitle, $wgMemc, $wgDBname; global $wgRequest, $wgSitename, $wgLanguageCode, $wgContLanguageCode; - global $wgFeedClasses; + global $wgFeedClasses, $wgUseRCPatrol; $fname = 'wfSpecialRecentchanges'; # Get query parameters @@ -50,12 +50,18 @@ function wfSpecialRecentchanges( $par ) { $dbr =& wfGetDB( DB_SLAVE ); extract( $dbr->tableNames( 'recentchanges', 'watchlist' ) ); - $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, $fname ); + # 10 seconds server-side caching max $wgOut->setSquidMaxage( 10 ); - if( $lastmod && $wgOut->checkLastModified( $lastmod ) ){ - # Client cache fresh and headers sent, nothing more to do. - return; + + # Get last modified date, for client caching + # Don't use this if we are using the patrol feature, patrol changes don't update the timestamp + if ( !$wgUseRCPatrol ) { + $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, $fname ); + if( $lastmod && $wgOut->checkLastModified( $lastmod ) ){ + # Client cache fresh and headers sent, nothing more to do. + return; + } } # Output header diff --git a/skins/common/common.css b/skins/common/common.css index fa8d81671f..93aca6a6de 100644 --- a/skins/common/common.css +++ b/skins/common/common.css @@ -204,7 +204,11 @@ div.townBox dl dd { color: red; font-weight: bold; } - .sharedUploadNotice { font-style: italic; -} \ No newline at end of file +} +span.unpatrolled { + font-weight:bold; + color:red; +} + diff --git a/skins/monobook/main.css b/skins/monobook/main.css index 3e711f65c5..6c6a56902b 100644 --- a/skins/monobook/main.css +++ b/skins/monobook/main.css @@ -924,6 +924,11 @@ div.patrollink { span.newpage, span.minor, span.searchmatch { font-weight: bold; } +span.unpatrolled { + font-weight:bold; + color:red; +} + span.searchmatch { color: red; } -- 2.20.1