Jump to content

Wikia code/includes/specials/SpecialRecentchanges.php

From mediawiki.org
--- D:\Programming\SVN\mediawiki\branches\REL1_16\phase3\includes\specials\SpecialRecentchanges.php	2011-07-18 22:31:17.711914100 +0100
+++ D:\Programming\SVN\wikia\trunk\includes\specials\SpecialRecentchanges.php	2011-08-17 15:28:16.358398400 +0100
@@ -31,6 +31,7 @@
 		$opts->add( 'hideliu',       false );
 		$opts->add( 'hidepatrolled', $wgUser->getBoolOption( 'hidepatrolled' ) );
 		$opts->add( 'hidemyself',    false );
+		$opts->add( 'hideenhanced', !$wgUser->getOption( 'usenewrc' ) );
 
 		$opts->add( 'namespace', '', FormOptions::INTNULL );
 		$opts->add( 'invert', false );
@@ -48,10 +49,19 @@
 	 */
 	public function setup( $parameters ) {
 		global $wgRequest;
+		global $wgUser;
 
 		$opts = $this->getDefaultOptions();
 		$opts->fetchValuesFromRequest( $wgRequest );
 
+		$wgUser->setOption( 'usenewrc', !$opts['hideenhanced'] );
+
+		if( $wgUser->isLoggedIn() ) {
+			if( $wgUser->getOption( 'usenewrc' ) != !$opts['hideenhanced'] ) {
+				$wgUser->saveSettings();
+			}
+		}
+
 		// Give precedence to subpage syntax
 		if( $parameters !== null ) {
 			$this->parseParameters( $parameters, $opts );
@@ -99,7 +109,17 @@
 		$feedFormat = $wgRequest->getVal( 'feed' );
 
 		# 10 seconds server-side caching max
+		// modified by Emil, 10 secs is not enough for us
+		// so the most popular URLs are cached longer and purged on every edit
+		if( $wgRequest->getFullRequestURL() == SpecialPage::getTitleFor('RecentChanges')->getInternalURL()
+		 || $wgRequest->getFullRequestURL() == SpecialPage::getTitleFor('RecentChanges')->getInternalURL('feed=rss')
+		 || $wgRequest->getFullRequestURL() == SpecialPage::getTitleFor('RecentChanges')->getInternalURL('feed=atom') ) {
+			global $wgSquidMaxage;
+			$wgOut->setSquidMaxage( $wgSquidMaxage );
+		} else {
+			// all others are treated old-fashion
 		$wgOut->setSquidMaxage( 10 );
+		}
 		# Check if the client has a cached version
 		$lastmod = $this->checkLastModified( $feedFormat );
 		if( $lastmod === false ) {
@@ -171,6 +191,7 @@
 			if( 'hidepatrolled' === $bit ) $opts['hidepatrolled'] = true;
 			if( 'hideanons' === $bit ) $opts['hideanons'] = true;
 			if( 'hidemyself' === $bit ) $opts['hidemyself'] = true;
+			if ( 'hideenhanced' === $bit ) $opts['hideenhanced'] = true;
 
 			if( is_numeric( $bit ) ) $opts['limit'] =  $bit;
 
@@ -690,6 +711,8 @@
 			array( 'hidepatrolled' => 1-$options['hidepatrolled'] ), $nondefaults);
 		$myselfLink = $this->makeOptionsLink( $showhide[1-$options['hidemyself']],
 			array( 'hidemyself' => 1-$options['hidemyself'] ), $nondefaults);
+		$enhancedLink = $this->makeOptionsLink( $showhide[1-$options['hideenhanced']],
+			array( 'hideenhanced' => 1-$options['hideenhanced'] ), $nondefaults);
 
 		$links[] = wfMsgHtml( 'rcshowhideminor', $minorLink );
 		$links[] = wfMsgHtml( 'rcshowhidebots', $botLink );
@@ -698,6 +721,8 @@
 		if( $wgUser->useRCPatrol() )
 			$links[] = wfMsgHtml( 'rcshowhidepatr', $patrLink );
 		$links[] = wfMsgHtml( 'rcshowhidemine', $myselfLink );
+		$links[] = wfMsgHtml( 'rcshowhideenhanced', $enhancedLink );
+		wfRunHooks( 'SpecialRecentChangesLinks', array( $this, &$links, &$defaults, &$nondefaults ) );
 		$hl = $wgLang->pipeList( $links );
 
 		// show from this onward link