(bug 14869) Allow access to QueryPage-based special pages via API
[lhc/web/wiklou.git] / includes / specials / SpecialContributions.php
index 19c895e..8956535 100644 (file)
@@ -96,30 +96,28 @@ class SpecialContributions extends SpecialPage {
                $pager = new ContribsPager( $target, $this->opts['namespace'], $this->opts['year'], $this->opts['month'] );
                if( !$pager->getNumRows() ) {
                        $wgOut->addWikiMsg( 'nocontribs', $target );
-                       return;
+               } else {
+                       # Show a message about slave lag, if applicable
+                       if( ( $lag = $pager->getDatabase()->getLag() ) > 0 )
+                               $wgOut->showLagWarning( $lag );
+
+                       $wgOut->addHTML(
+                               '<p>' . $pager->getNavigationBar() . '</p>' .
+                               $pager->getBody() .
+                               '<p>' . $pager->getNavigationBar() . '</p>'
+                       );
                }
 
-               # Show a message about slave lag, if applicable
-               if( ( $lag = $pager->getDatabase()->getLag() ) > 0 )
-                       $wgOut->showLagWarning( $lag );
-
-               $wgOut->addHTML(
-                       '<p>' . $pager->getNavigationBar() . '</p>' .
-                       $pager->getBody() .
-                       '<p>' . $pager->getNavigationBar() . '</p>'
-               );
 
-               # If there were contributions, and it was a valid user or IP, show
-               # the appropriate "footer" message - WHOIS tools, etc.
+               # 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( '<div class="mw-contributions-footer">' );
-                               $wgOut->addWikiText( $text );
-                               $wgOut->addHTML( '</div>' );
+                               $wgOut->wrapWikiMsg(
+                                       "<div class='mw-contributions-footer'>\n$1\n</div>", $message );
                        }
                }
        }
@@ -157,26 +155,41 @@ class SpecialContributions extends SpecialPage {
                        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' ) );
+                                       $tools[] = $sk->linkKnown(
+                                               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() );
+                               $tools[] = $sk->linkKnown(
+                                       SpecialPage::getTitleFor( 'Log' ),
+                                       wfMsgHtml( 'sp-contributions-blocklog' ),
+                                       array(),
+                                       array(
+                                               'type' => 'block',
+                                               'page' => $nt->getPrefixedText()
+                                       )
+                               );
                        }
                        # Other logs link
-                       $tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), wfMsg( 'sp-contributions-logs' ), 
-                               'user=' . $nt->getPartialUrl() );
+                       $tools[] = $sk->linkKnown(
+                               SpecialPage::getTitleFor( 'Log' ),
+                               wfMsgHtml( 'sp-contributions-logs' ),
+                               array(),
+                               array( 'user' => $nt->getText() )
+                       );
 
                        # Add link to deleted user contributions for priviledged users
                        if( $wgUser->isAllowed( 'deletedhistory' ) ) {
-                               $tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'DeletedContributions', 
-                                       $nt->getDBkey() ), wfMsgHtml( 'sp-contributions-deleted' ) );
+                               $tools[] = $sk->linkKnown(
+                                       SpecialPage::getTitleFor( 'DeletedContributions', $nt->getDBkey() ),
+                                       wfMsgHtml( 'sp-contributions-deleted' )
+                               );
                        }
 
                        # Add a link to change user rights for privileged users
                        $userrightsPage = new UserrightsPage();
                        if( 0 !== $id && $userrightsPage->userCanChangeRights( User::newFromId( $id ) ) ) {
-                               $tools[] = $sk->makeKnownLinkObj(
+                               $tools[] = $sk->linkKnown(
                                        SpecialPage::getTitleFor( 'Userrights', $nt->getDBkey() ),
                                        wfMsgHtml( 'sp-contributions-userrights' )
                                );
@@ -205,7 +218,7 @@ class SpecialContributions extends SpecialPage {
        protected function getForm() {
                global $wgScript;
        
-               $this->opts['title'] = SpecialPage::getTitleFor( 'Contributions' )->getPrefixedText();
+               $this->opts['title'] = $this->getTitle()->getPrefixedText();
                if( !isset( $this->opts['target'] ) ) {
                        $this->opts['target'] = '';
                } else {
@@ -249,7 +262,7 @@ class SpecialContributions extends SpecialPage {
        
                $f .= '<fieldset>' .
                        Xml::element( 'legend', array(), wfMsg( 'sp-contributions-search' ) ) .
-                       Xml::radioLabel( wfMsgExt( 'sp-contributions-newbies', array( 'parseinline' ) ), 
+                       Xml::radioLabel( wfMsgExt( 'sp-contributions-newbies', array( 'parsemag' ) ), 
                                'contribs', 'newbie' , 'newbie', $this->opts['contribs'] == 'newbie' ? true : false ) . '<br />' .
                        Xml::radioLabel( wfMsgExt( 'sp-contributions-username', array( 'parsemag' ) ), 
                                'contribs' , 'user', 'user', $this->opts['contribs'] == 'user' ? true : false ) . ' ' .
@@ -396,7 +409,7 @@ class ContribsPager extends ReverseChronologicalPager {
                $conds = array_merge( $userCond, $this->getNamespaceCond() );
                // Paranoia: avoid brute force searches (bug 17342)
                if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
-                       $conds[] = 'rev_deleted & ' . Revision::DELETED_USER . ' = 0';
+                       $conds[] = $this->mDb->bitAnd('rev_deleted', Revision::DELETED_USER) . ' = 0';
                }
                $join_cond['page'] = array( 'INNER JOIN', 'page_id=rev_page' );
                
@@ -484,7 +497,7 @@ class ContribsPager extends ReverseChronologicalPager {
                $page->resetArticleId( $row->rev_page ); // use process cache
                $link = $sk->link(
                        $page,
-                       $page->getPrefixedText(),
+                       htmlspecialchars( $page->getPrefixedText() ),
                        array(),
                        $page->isRedirect() ? array( 'redirect' => 'no' ) : array()
                );
@@ -493,7 +506,12 @@ class ContribsPager extends ReverseChronologicalPager {
                if( $row->rev_id == $row->page_latest ) {
                        $topmarktext .= '<span class="mw-uctop">' . $this->messages['uctop'] . '</span>';
                        if( !$row->page_is_new ) {
-                               $difftext .= '(' . $sk->makeKnownLinkObj( $page, $this->messages['diff'], 'diff=0' ) . ')';
+                               $difftext .= '(' . $sk->linkKnown(
+                                       $page,
+                                       $this->messages['diff'],
+                                       array(),
+                                       array( 'diff' => 0 )
+                               ) . ')';
                                # Add rollback link
                                if( $page->quickUserCan( 'rollback') && $page->quickUserCan( 'edit' ) ) {
                                        $topmarktext .= ' '.$sk->generateRollback( $rev );
@@ -503,17 +521,38 @@ class ContribsPager extends ReverseChronologicalPager {
                        }
                }
                # Is there a visible previous revision?
-               if( $rev->userCan(Revision::DELETED_TEXT) ) {
-                       $difftext = '(' . $sk->makeKnownLinkObj( $page, $this->messages['diff'],
-                               'diff=prev&oldid='.$row->rev_id ) . ')';
+               if( !$rev->isDeleted(Revision::DELETED_TEXT) ) {
+                       $difftext = '(' . $sk->linkKnown(
+                               $page,
+                               $this->messages['diff'],
+                               array(),
+                               array(
+                                       'diff' => 'prev',
+                                       'oldid' => $row->rev_id
+                               )
+                       ) . ')';
                } else {
                        $difftext = '(' . $this->messages['diff'] . ')';
                }
-               $histlink = '('.$sk->makeKnownLinkObj( $page, $this->messages['hist'], 'action=history' ) . ')';
+               $histlink = '('.$sk->linkKnown(
+                       $page,
+                       $this->messages['hist'],
+                       array(),
+                       array( 'action' => 'history' )
+               ) . ')';
 
                $comment = $wgContLang->getDirMark() . $sk->revComment( $rev, false, true );
                $date = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true );
-               $d = $sk->makeKnownLinkObj( $page, htmlspecialchars($date), 'oldid='.intval($row->rev_id) );
+               if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
+                       $d = '<span class="history-deleted">' . $date . '</span>';
+               } else {
+                       $d = $sk->linkKnown(
+                               $page,
+                               htmlspecialchars($date),
+                               array(),
+                               array( 'oldid' => intval( $row->rev_id ) )
+                       );
+               }
 
                if( $this->target == 'newbies' ) {
                        $userlink = ' . . ' . $sk->userLink( $row->rev_user, $row->rev_user_text );
@@ -522,10 +561,6 @@ class ContribsPager extends ReverseChronologicalPager {
                        $userlink = '';
                }
 
-               if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
-                       $d = '<span class="history-deleted">' . $d . '</span>';
-               }
-
                if( $rev->getParentId() === 0 ) {
                        $nflag = '<span class="newpage">' . $this->messages['newpageletter'] . '</span>';
                } else {