setHeaders(); $this->outputHeader(); $this->opts = array(); if( $par == 'newbies' ) { $target = 'newbies'; $this->opts['contribs'] = 'newbie'; } elseif( isset( $par ) ) { $target = $par; } else { $target = $wgRequest->getVal( 'target' ); } // check for radiobox if( $wgRequest->getVal( 'contribs' ) == 'newbie' ) { $target = 'newbies'; $this->opts['contribs'] = 'newbie'; } if( !strlen( $target ) ) { $wgOut->addHTML( $this->getForm() ); return; } $this->opts['limit'] = $wgRequest->getInt( 'limit', 50 ); $this->opts['target'] = $target; $nt = Title::makeTitleSafe( NS_USER, $target ); if( !$nt ) { $wgOut->addHTML( $this->getForm() ); return; } $id = User::idFromName( $nt->getText() ); if( $target != 'newbies' ) { $target = $nt->getText(); $wgOut->setSubtitle( $this->contributionsSub( $nt, $id ) ); $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsgExt( 'contributions-title', array( 'parsemag' ),$target ) ) ); } else { $wgOut->setSubtitle( wfMsgHtml( 'sp-contributions-newbies-sub') ); $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'sp-contributions-newbies-title' ) ) ); } if( ( $ns = $wgRequest->getVal( 'namespace', null ) ) !== null && $ns !== '' ) { $this->opts['namespace'] = intval( $ns ); } else { $this->opts['namespace'] = ''; } $this->opts['tagfilter'] = (string) $wgRequest->getVal( 'tagfilter' ); // Allows reverts to have the bot flag in recent changes. It is just here to // be passed in the form at the top of the page if( $wgUser->isAllowed( 'markbotedits' ) && $wgRequest->getBool( 'bot' ) ) { $this->opts['bot'] = '1'; } $skip = $wgRequest->getText( 'offset' ) || $wgRequest->getText( 'dir' ) == 'prev'; # Offset overrides year/month selection if( $skip ) { $this->opts['year'] = ''; $this->opts['month'] = ''; } else { $this->opts['year'] = $wgRequest->getIntOrNull( 'year' ); $this->opts['month'] = $wgRequest->getIntOrNull( 'month' ); } // Add RSS/atom links $this->setSyndicated(); $feedType = $wgRequest->getVal( 'feed' ); if( $feedType ) { return $this->feed( $feedType ); } wfRunHooks( 'SpecialContributionsBeforeMainOutput', $id ); $wgOut->addHTML( $this->getForm() ); $pager = new ContribsPager( $target, $this->opts['namespace'], $this->opts['year'], $this->opts['month'] ); if( !$pager->getNumRows() ) { $wgOut->addWikiMsg( 'nocontribs', $target ); return; } # Show a message about slave lag, if applicable if( ( $lag = $pager->getDatabase()->getLag() ) > 0 ) $wgOut->showLagWarning( $lag ); $wgOut->addHTML( '
' . $pager->getNavigationBar() . '
' . $pager->getBody() . '' . $pager->getNavigationBar() . '
' ); # If there were contributions, and it was a valid user or IP, show # the appropriate "footer" message - WHOIS tools, etc. if( $target != 'newbies' ) { $message = IP::isIPAddress( $target ) ? 'sp-contributions-footer-anon' : 'sp-contributions-footer'; $text = wfMsgNoTrans( $message, $target ); if( !wfEmptyMsg( $message, $text ) && $text != '-' ) { $wgOut->addHTML( ' ' ); } } } protected function setSyndicated() { global $wgOut; $queryParams = array( 'namespace' => $this->opts['namespace'], 'target' => $this->opts['target'] ); $wgOut->setSyndicated( true ); $wgOut->setFeedAppendQuery( wfArrayToCGI( $queryParams ) ); } /** * Generates the subheading with links * @param Title $nt Title object for the target * @param integer $id User ID for the target * @return String: appropriately-escaped HTML to be output literally */ protected function contributionsSub( $nt, $id ) { global $wgSysopUserBans, $wgLang, $wgUser; $sk = $wgUser->getSkin(); if( 0 == $id ) { $user = $nt->getText(); } else { $user = $sk->makeLinkObj( $nt, htmlspecialchars( $nt->getText() ) ); } $talk = $nt->getTalkPage(); if( $talk ) { # Talk page link $tools[] = $sk->makeLinkObj( $talk, wfMsgHtml( 'talkpagelinktext' ) ); if( ( $id != 0 && $wgSysopUserBans ) || ( $id == 0 && IP::isIPAddress( $nt->getText() ) ) ) { # Block link if( $wgUser->isAllowed( 'block' ) ) $tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Blockip', $nt->getDBkey() ), wfMsgHtml( 'blocklink' ) ); # Block log link $tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), wfMsgHtml( 'sp-contributions-blocklog' ), 'type=block&page=' . $nt->getPrefixedUrl() ); } # Other logs link $tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), wfMsg( 'sp-contributions-logs' ), 'user=' . $nt->getPartialUrl() ); # Add link to deleted user contributions for priviledged users if( $wgUser->isAllowed( 'deletedhistory' ) ) { $tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'DeletedContributions', $nt->getDBkey() ), wfMsgHtml( 'deletedcontributions' ) ); } # Add a link to change user rights for privileged users $userrightsPage = new UserrightsPage(); if( 0 !== $id && $userrightsPage->userCanChangeRights( User::newFromId( $id ) ) ) { $tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Userrights', $nt->getDBkey() ), wfMsgHtml( 'userrights' ) ); } wfRunHooks( 'ContributionsToolLinks', array( $id, $nt, &$tools ) ); $links = $wgLang->pipeList( $tools ); } // Old message 'contribsub' had one parameter, but that doesn't work for // languages that want to put the "for" bit right after $user but before // $links. If 'contribsub' is around, use it for reverse compatibility, // otherwise use 'contribsub2'. if( wfEmptyMsg( 'contribsub', wfMsg( 'contribsub' ) ) ) { return wfMsgHtml( 'contribsub2', $user, $links ); } else { return wfMsgHtml( 'contribsub', "$user ($links)" ); } } /** * Generates the namespace selector form with hidden attributes. * @param $this->opts Array: the options to be included. */ protected function getForm() { global $wgScript, $wgTitle; $this->opts['title'] = $wgTitle->getPrefixedText(); if( !isset( $this->opts['target'] ) ) { $this->opts['target'] = ''; } else { $this->opts['target'] = str_replace( '_' , ' ' , $this->opts['target'] ); } if( !isset( $this->opts['namespace'] ) ) { $this->opts['namespace'] = ''; } if( !isset( $this->opts['contribs'] ) ) { $this->opts['contribs'] = 'user'; } if( !isset( $this->opts['year'] ) ) { $this->opts['year'] = ''; } if( !isset( $this->opts['month'] ) ) { $this->opts['month'] = ''; } if( $this->opts['contribs'] == 'newbie' ) { $this->opts['target'] = ''; } if( !isset( $this->opts['tagfilter'] ) ) { $this->opts['tagfilter'] = ''; } $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ); # Add hidden params for tracking foreach ( $this->opts as $name => $value ) { if( in_array( $name, array( 'namespace', 'target', 'contribs', 'year', 'month' ) ) ) { continue; } $f .= "\t" . Xml::hidden( $name, $value ) . "\n"; } $tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagfilter'] ); $f .= '' . Xml::closeElement( 'form' ); return $f; } /** * Output a subscription feed listing recent edits to this page. * @param string $type */ protected function feed( $type ) { global $wgRequest, $wgFeed, $wgFeedClasses, $wgFeedLimit; if( !$wgFeed ) { global $wgOut; $wgOut->addWikiMsg( 'feed-unavailable' ); return; } if( !isset( $wgFeedClasses[$type] ) ) { global $wgOut; $wgOut->addWikiMsg( 'feed-invalid' ); return; } $feed = new $wgFeedClasses[$type]( $this->feedTitle(), wfMsgExt( 'tagline', 'parsemag' ), $this->getTitle()->getFullUrl() . "/" . urlencode($this->opts['target']) ); // Already valid title $nt = Title::makeTitleSafe( NS_USER, $this->opts['target'] ); $target = $this->opts['target'] == 'newbies' ? 'newbies' : $nt->getText(); $pager = new ContribsPager( $target, $this->opts['namespace'], $this->opts['year'], $this->opts['month'], $this->opts['tagfilter'] ); $pager->mLimit = min( $this->opts['limit'], $wgFeedLimit ); $feed->outHeader(); if( $pager->getNumRows() > 0 ) { while( $row = $pager->mResult->fetchObject() ) { $feed->outItem( $this->feedItem( $row ) ); } } $feed->outFooter(); } protected function feedTitle() { global $wgContLanguageCode, $wgSitename; $page = SpecialPage::getPage( 'Contributions' ); $desc = $page->getDescription(); return "$wgSitename - $desc [$wgContLanguageCode]"; } protected function feedItem( $row ) { $title = Title::MakeTitle( intval( $row->page_namespace ), $row->page_title ); if( $title ) { $date = $row->rev_timestamp; $comments = $title->getTalkPage()->getFullURL(); $revision = Revision::newFromTitle( $title, $row->rev_id ); return new FeedItem( $title->getPrefixedText(), $this->feedItemDesc( $revision ), $title->getFullURL(), $date, $this->feedItemAuthor( $revision ), $comments ); } else { return NULL; } } protected function feedItemAuthor( $revision ) { return $revision->getUserText(); } protected function feedItemDesc( $revision ) { if( $revision ) { return '' . htmlspecialchars( $revision->getUserText() ) . wfMsgForContent( 'colon-separator' ) . htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) . "
\n