X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialRecentchanges.php;h=85b93b0910c8bda0815f8c1450c1eb782ebdaa9a;hb=5bd492d51c9d3ec0c60c8c10c39b0441accd3baf;hp=da5d5f0072676ce2a05e6c19401db6b2218d1b2c;hpb=4dc7c3188d11a5c2feffe46940e4f9ef955c627f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index da5d5f0072..85b93b0910 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -71,8 +71,6 @@ class SpecialRecentChanges extends IncludableSpecialPage { * @return FormOptions */ public function setup( $parameters ) { - global $wgRequest; - $opts = $this->getDefaultOptions(); $this->customFilters = array(); @@ -81,7 +79,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { $opts->add( $key, $params['default'] ); } - $opts->fetchValuesFromRequest( $wgRequest ); + $opts->fetchValuesFromRequest( $this->getRequest() ); // Give precedence to subpage syntax if( $parameters !== null ) { @@ -98,10 +96,10 @@ class SpecialRecentChanges extends IncludableSpecialPage { * @return FormOptions */ public function feedSetup() { - global $wgFeedLimit, $wgRequest; + global $wgFeedLimit; $opts = $this->getDefaultOptions(); # Feed is cached on limit,hideminor,namespace; other params would randomly not work - $opts->fetchValuesFromRequest( $wgRequest, array( 'limit', 'hideminor', 'namespace' ) ); + $opts->fetchValuesFromRequest( $this->getRequest(), array( 'limit', 'hideminor', 'namespace' ) ); $opts->validateIntBounds( 'limit', 0, $wgFeedLimit ); return $opts; } @@ -111,9 +109,12 @@ class SpecialRecentChanges extends IncludableSpecialPage { */ public function getOptions() { if ( $this->rcOptions === null ) { - global $wgRequest; - $feedFormat = $wgRequest->getVal( 'feed' ); - $this->rcOptions = $feedFormat ? $this->feedSetup() : $this->setup( $this->rcSubpage ); + if ( $this->including() ) { + $isFeed = false; + } else { + $isFeed = (bool)$this->getRequest()->getVal( 'feed' ); + } + $this->rcOptions = $isFeed ? $this->feedSetup() : $this->setup( $this->rcSubpage ); } return $this->rcOptions; } @@ -125,12 +126,11 @@ class SpecialRecentChanges extends IncludableSpecialPage { * @param $subpage String */ public function execute( $subpage ) { - global $wgRequest, $wgOut; $this->rcSubpage = $subpage; - $feedFormat = $wgRequest->getVal( 'feed' ); + $feedFormat = $this->including() ? null : $this->getRequest()->getVal( 'feed' ); # 10 seconds server-side caching max - $wgOut->setSquidMaxage( 10 ); + $this->getOutput()->setSquidMaxage( 10 ); # Check if the client has a cached version $lastmod = $this->checkLastModified( $feedFormat ); if( $lastmod === false ) { @@ -140,6 +140,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { $opts = $this->getOptions(); $this->setHeaders(); $this->outputHeader(); + $this->addRecentChangesJS(); // Fetch results, prepare a batch link existence check query $conds = $this->buildMainQueryConds( $opts ); @@ -231,6 +232,9 @@ class SpecialRecentChanges extends IncludableSpecialPage { if( preg_match( '/^days=(\d+)$/', $bit, $m ) ) { $opts['days'] = $m[1]; } + if( preg_match( '/^namespace=(\d+)$/', $bit, $m ) ) { + $opts['namespace'] = $m[1]; + } } } @@ -291,7 +295,6 @@ class SpecialRecentChanges extends IncludableSpecialPage { $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff ); - $hidePatrol = $this->getUser()->useRCPatrol() && $opts['hidepatrolled']; $hideLoggedInUsers = $opts['hideliu'] && !$forcebot; $hideAnonymousUsers = $opts['hideanons'] && !$forcebot; @@ -325,24 +328,25 @@ class SpecialRecentChanges extends IncludableSpecialPage { # Namespace filtering if( $opts['namespace'] !== '' ) { - $namespaces[] = $opts['namespace']; + $selectedNS = $dbr->addQuotes( $opts['namespace'] ); + $operator = $opts['invert'] ? '!=' : '='; + $boolean = $opts['invert'] ? 'AND' : 'OR'; - $inversionSuffix = $opts['invert'] ? '!' : ''; - - if( $opts['associated'] ) { - # namespace association (bug 2429) - $namespaces[] = MWNamespace::getAssociated( $opts['namespace'] ); + # namespace association (bug 2429) + if( !$opts['associated'] ) { + $condition = "rc_namespace $operator $selectedNS"; + } else { + # Also add the associated namespace + $associatedNS = $dbr->addQuotes( + MWNamespace::getAssociated( $opts['namespace'] ) + ); + $condition = "(rc_namespace $operator $selectedNS " + . $boolean + . " rc_namespace $operator $associatedNS)"; } - $condition = $dbr->makeList( - array( 'rc_namespace' . $inversionSuffix - => $namespaces ), - LIST_AND - ); - $conds[] = $condition; } - return $conds; } @@ -449,14 +453,13 @@ class SpecialRecentChanges extends IncludableSpecialPage { } /** - * Send output to $wgOut, only called if not used feeds + * Send output to the OutputPage object, only called if not used feeds * * @param $rows Array of database rows * @param $opts FormOptions */ public function webOutput( $rows, $opts ) { - global $wgOut, $wgRCShowWatchingUsers, $wgShowUpdatedMarker; - global $wgAllowCategorizedRecentChanges; + global $wgRCShowWatchingUsers, $wgShowUpdatedMarker, $wgAllowCategorizedRecentChanges; $limit = $opts['limit']; @@ -466,7 +469,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { } // And now for the content - $wgOut->setFeedAppendQuery( $this->getFeedQuery() ); + $this->getOutput()->setFeedAppendQuery( $this->getFeedQuery() ); if( $wgAllowCategorizedRecentChanges ) { $this->filterByCategories( $rows, $opts ); @@ -478,7 +481,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { $dbr = wfGetDB( DB_SLAVE ); $counter = 1; - $list = ChangesList::newFromUser( $this->getUser() ); + $list = ChangesList::newFromContext( $this->getContext() ); $s = $list->beginRecentChangesList(); foreach( $rows as $obj ) { @@ -514,7 +517,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { --$limit; } $s .= $list->endRecentChangesList(); - $wgOut->addHTML( $s ); + $this->getOutput()->addHTML( $s ); } /** @@ -532,9 +535,9 @@ class SpecialRecentChanges extends IncludableSpecialPage { * @return String: XHTML */ public function doHeader( $opts ) { - global $wgScript, $wgOut; + global $wgScript; - $this->setTopText( $wgOut, $opts ); + $this->setTopText( $opts ); $defaults = $opts->getAllValues(); $nondefaults = $opts->getChangedValues(); @@ -580,11 +583,11 @@ class SpecialRecentChanges extends IncludableSpecialPage { $panel[] = $form; $panelString = implode( "\n", $panel ); - $wgOut->addHTML( + $this->getOutput()->addHTML( Xml::fieldset( wfMsg( 'recentchanges-legend' ), $panelString, array( 'class' => 'rcoptions' ) ) ); - $this->setBottomText( $wgOut, $opts ); + $this->setBottomText( $opts ); } /** @@ -614,21 +617,24 @@ class SpecialRecentChanges extends IncludableSpecialPage { /** * Send the text to be displayed above the options * - * @param $out OutputPage * @param $opts FormOptions */ - function setTopText( OutputPage $out, FormOptions $opts ) { - $out->addWikiText( wfMsgForContentNoTrans( 'recentchangestext' ) ); + function setTopText( FormOptions $opts ) { + global $wgContLang; + $this->getOutput()->addWikiText( + Html::rawElement( 'p', + array( 'lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir() ), + wfMsgForContentNoTrans( 'recentchangestext' ) + ), false ); } /** * Send the text to be displayed after the options, for use in * Recentchangeslinked * - * @param $out OutputPage * @param $opts FormOptions */ - function setBottomText( OutputPage $out, FormOptions $opts ) {} + function setBottomText( FormOptions $opts ) {} /** * Creates the choose namespace selection @@ -743,16 +749,11 @@ class SpecialRecentChanges extends IncludableSpecialPage { */ function makeOptionsLink( $title, $override, $options, $active = false ) { $params = $override + $options; + $text = htmlspecialchars( $title ); if ( $active ) { - return $this->getSkin()->link( - $this->getTitle(), - '' . htmlspecialchars( $title ) . '', - array(), $params, array( 'known' ) ); - } else { - return $this->getSkin()->link( - $this->getTitle(), htmlspecialchars( $title ), array(), - $params, array( 'known' ) ); + $text = '' . $text . ''; } + return Linker::linkKnown( $this->getTitle(), $text, array(), $params ); } /** @@ -762,7 +763,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { * @param $nondefaults Array */ function optionsPanel( $defaults, $nondefaults ) { - global $wgLang, $wgRCLinkLimits, $wgRCLinkDays; + global $wgRCLinkLimits, $wgRCLinkDays; $options = $nondefaults + $defaults; @@ -773,10 +774,10 @@ class SpecialRecentChanges extends IncludableSpecialPage { } if( $options['from'] ) { $note .= wfMsgExt( 'rcnotefrom', array( 'parseinline' ), - $wgLang->formatNum( $options['limit'] ), - $wgLang->timeanddate( $options['from'], true ), - $wgLang->date( $options['from'], true ), - $wgLang->time( $options['from'], true ) ) . '
'; + $this->getLanguage()->formatNum( $options['limit'] ), + $this->getLanguage()->timeanddate( $options['from'], true ), + $this->getLanguage()->date( $options['from'], true ), + $this->getLanguage()->time( $options['from'], true ) ) . '
'; } # Sort data for display and make sure it's unique after we've added user data. @@ -789,17 +790,17 @@ class SpecialRecentChanges extends IncludableSpecialPage { // limit links foreach( $wgRCLinkLimits as $value ) { - $cl[] = $this->makeOptionsLink( $wgLang->formatNum( $value ), + $cl[] = $this->makeOptionsLink( $this->getLanguage()->formatNum( $value ), array( 'limit' => $value ), $nondefaults, $value == $options['limit'] ); } - $cl = $wgLang->pipeList( $cl ); + $cl = $this->getLanguage()->pipeList( $cl ); // day links, reset 'from' to none foreach( $wgRCLinkDays as $value ) { - $dl[] = $this->makeOptionsLink( $wgLang->formatNum( $value ), + $dl[] = $this->makeOptionsLink( $this->getLanguage()->formatNum( $value ), array( 'days' => $value, 'from' => '' ), $nondefaults, $value == $options['days'] ); } - $dl = $wgLang->pipeList( $dl ); + $dl = $this->getLanguage()->pipeList( $dl ); // show/hide links @@ -829,14 +830,23 @@ class SpecialRecentChanges extends IncludableSpecialPage { // show from this onward link $timestamp = wfTimestampNow(); - $now = $wgLang->timeanddate( $timestamp, true ); + $now = $this->getLanguage()->timeanddate( $timestamp, true ); $tl = $this->makeOptionsLink( $now, array( 'from' => $timestamp ), $nondefaults ); $rclinks = wfMsgExt( 'rclinks', array( 'parseinline', 'replaceafter' ), - $cl, $dl, $wgLang->pipeList( $links ) ); + $cl, $dl, $this->getLanguage()->pipeList( $links ) ); $rclistfrom = wfMsgExt( 'rclistfrom', array( 'parseinline', 'replaceafter' ), $tl ); return "{$note}$rclinks
$rclistfrom"; } + + /** + * add javascript specific to the [[Special:RecentChanges]] page + */ + function addRecentChangesJS() { + $this->getOutput()->addModules( array( + 'mediawiki.special.recentchanges', + ) ); + } }