Bug fixes: watchlist and recent changes linked were broken in the last commit
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 17 Jan 2004 09:49:43 +0000 (09:49 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 17 Jan 2004 09:49:43 +0000 (09:49 +0000)
includes/Article.php
includes/DifferenceEngine.php
includes/EditPage.php
includes/OutputPage.php
includes/PageHistory.php
includes/RecentChange.php
includes/Skin.php
includes/SpecialRecentchanges.php
includes/SpecialRecentchangeslinked.php
includes/SpecialWatchlist.php

index 807007f..4051a5c 100644 (file)
@@ -503,7 +503,7 @@ class Article {
                        $oldid = wfInsertID( $res );
 
                        $bot = (int)($wgUser->isBot() || $forceBot);
-                       RecentChange::notifyEdit( $now, $this->mTitle, $me2, $wgUser, $this->getComment()
+                       RecentChange::notifyEdit( $now, $this->mTitle, $me2, $wgUser, $summary
                                $oldid, $this->getTimestamp() );
                        Article::onArticleEdit( $this->mTitle );
                }
index c3188c7..3012fe3 100644 (file)
@@ -32,12 +32,26 @@ class DifferenceEngine {
                $wgOut->setRobotpolicy( "noindex,follow" );
                
                $sk = $wgUser->getSkin();
-               $oldUserTitle = Title::makeTitle( NS_USER, $this->mOldUser );
-               $newUserTitle = Title::makeTitle( NS_USER, $this->mNewUser );
-               $oldUserLink = $sk->makeLinkObj( $oldUserTitle, $this->mOldUser );
-               $newUserLink = $sk->makeLinkObj( $newUserTitle, $this->mNewUser );
-               $oldHeader = "<strong>{$this->mOldtitle}</strong><br>$oldUserLink";
-               $newHeader = "<strong>{$this->mNewtitle}</strong><br>$newUserLink";
+               $talk = $wgLang->getNsText( NS_TALK );
+               $contribs = wfMsg( "contribslink" );
+
+               $oldUserLink = $sk->makeLinkObj( Title::makeTitle( NS_USER, $this->mOldUser ), $this->mOldUser );
+               $newUserLink = $sk->makeLinkObj( Title::makeTitle( NS_USER, $this->mNewUser ), $this->mNewUser );
+               $oldUTLink = $sk->makeLinkObj( Title::makeTitle( NS_USER_TALK, $this->mOldUser ), $talk );
+               $newUTLink = $sk->makeLinkObj( Title::makeTitle( NS_USER_TALK, $this->mNewUser ), $talk );
+               $oldContribs = $sk->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, "Contributions" ), $contribs,
+                       "target=" . urlencode($this->mOldUser) );
+               $newContribs = $sk->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, "Contributions" ), $contribs,
+                       "target=" . urlencode($this->mNewUser) );
+               if ( !$this->mNewid && $wgUser->isSysop() ) {
+                       $rollback = "&nbsp;&nbsp;&nbsp;<strong>[" . $sk->makeKnownLinkObj( $wgTitle, wfMsg( "rollbacklink" ),
+                               "action=rollback&from=" . urlencode($this->mNewUser) ) . "]</strong>";
+               } else {
+                       $rollback = "";
+               }
+
+               $oldHeader = "<strong>{$this->mOldtitle}</strong><br>$oldUserLink ($oldUTLink | $oldContribs)";
+               $newHeader = "<strong>{$this->mNewtitle}</strong><br>$newUserLink ($newUTLink | $newContribs) $rollback";
 
                DifferenceEngine::showDiff( $this->mOldtext, $this->mNewtext,
                  $oldHeader, $newHeader );
index 72be476..86c3c5c 100644 (file)
@@ -167,7 +167,9 @@ class EditPage {
                        $wpSummary = "";
                }
                $wgOut->setRobotpolicy( "noindex,nofollow" );
-               $wgOut->setArticleFlag( false );
+               
+               # Enabled article-related sidebar, toplinks, etc.
+               $wgOut->setArticleRelated( true );
 
                if ( $isConflict ) {
                        $s = wfMsg( "editconflict", $this->mTitle->getPrefixedText() );
@@ -342,7 +344,7 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
 
                $wgOut->setPageTitle( wfMsg( "blockedtitle" ) );
                $wgOut->setRobotpolicy( "noindex,nofollow" );
-               $wgOut->setArticleFlag( false );
+               $wgOut->setArticleRelated( false );
 
                $id = $wgUser->blockedBy();
                $reason = $wgUser->blockedFor();
@@ -364,7 +366,7 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
 
                $wgOut->setPageTitle( wfMsg( "whitelistedittitle" ) );
                $wgOut->setRobotpolicy( "noindex,nofollow" );
-               $wgOut->setArticleFlag( false );
+               $wgOut->setArticleRelated( false );
 
                $wgOut->addWikiText( wfMsg( "whitelistedittext" ) );
                $wgOut->returnToMain( false );
index 2fb8e0f..672ade1 100644 (file)
@@ -15,6 +15,7 @@ class OutputPage {
        var $mOnloadHandler;
        var $mDoNothing;
        var $mContainsOldMagic, $mContainsNewMagic; 
+       var $mIsArticleRelated;
 
        function OutputPage()
        {
@@ -24,7 +25,7 @@ class OutputPage {
                $this->mLastSection = $this->mRedirect = $this->mLastModified =
                $this->mSubtitle = $this->mDebugtext = $this->mRobotpolicy = 
                $this->mOnloadHandler = "";
-               $this->mIsarticle = $this->mPrintable = true;
+               $this->mIsArticleRelated = $this->mIsarticle = $this->mPrintable = true;
                $this->mSupressQuickbar = $this->mDTopen = $this->mPrintable = false;
                $this->mLanguageLinks = array();
                 $this->mCategoryLinks = array() ;
@@ -100,7 +101,6 @@ class OutputPage {
        function getPageTitle() { return $this->mPagetitle; }
        function setSubtitle( $str ) { $this->mSubtitle = $str; }
        function getSubtitle() { return $this->mSubtitle; }
-       function setArticleFlag( $v ) { $this->mIsarticle = $v; }
        function isArticle() { return $this->mIsarticle; }
        function setPrintable() { $this->mPrintable = true; }
        function isPrintable() { return $this->mPrintable; }
@@ -108,6 +108,25 @@ class OutputPage {
        function getOnloadHandler() { return $this->mOnloadHandler; }
        function disable() { $this->mDoNothing = true; }
 
+       function setArticleRelated( $v )
+       {
+               $this->mIsArticleRelated = $v;
+               if ( !$v ) {
+                       $this->mIsarticle = false;
+               }
+       }
+       function setArticleFlag( $v ) { 
+               $this->mIsarticle = $v; 
+               if ( $v ) {
+                       $this->mIsArticleRelated = $v;
+               }
+       }
+
+       function isArticleRelated( $v )
+       {
+               return $this->mIsArticleRelated;
+       }
+       
        function getLanguageLinks() {
                global $wgTitle, $wgLanguageCode;
                global $wgDBconnection, $wgDBname;
@@ -375,7 +394,7 @@ class OutputPage {
                $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
                $this->setPageTitle( wfMsg( $title ) );
                $this->setRobotpolicy( "noindex,nofollow" );
-               $this->setArticleFlag( false );
+               $this->setArticleRelated( false );
 
                $this->mBodytext = "";
                $this->addHTML( "<p>" . wfMsg( $msg ) . "\n" );
@@ -392,7 +411,7 @@ class OutputPage {
                $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
                $this->setPageTitle( wfMsg( "sysoptitle" ) );
                $this->setRobotpolicy( "noindex,nofollow" );
-               $this->setArticleFlag( false );
+               $this->setArticleRelated( false );
                $this->mBodytext = "";
 
                $sk = $wgUser->getSkin();
@@ -408,7 +427,7 @@ class OutputPage {
                $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
                $this->setPageTitle( wfMsg( "developertitle" ) );
                $this->setRobotpolicy( "noindex,nofollow" );
-               $this->setArticleFlag( false );
+               $this->setArticleRelated( false );
                $this->mBodytext = "";
 
                $sk = $wgUser->getSkin();
@@ -423,7 +442,7 @@ class OutputPage {
                
                $this->setPageTitle( wfMsgNoDB( "databaseerror" ) );
                $this->setRobotpolicy( "noindex,nofollow" );
-               $this->setArticleFlag( false );
+               $this->setArticleRelated( false );
 
                if ( $wgCommandLineMode ) {
                        $msg = wfMsgNoDB( "dberrortextcl" );
@@ -455,7 +474,7 @@ class OutputPage {
                global $wgUser, $wgReadOnlyFile;
 
                $this->setRobotpolicy( "noindex,nofollow" );
-               $this->setArticleFlag( false );
+               $this->setArticleRelated( false );
 
                if( $protected ) {
                        $this->setPageTitle( wfMsg( "viewsource" ) );
@@ -481,7 +500,7 @@ class OutputPage {
        {
                $this->setPageTitle( wfMsg( "internalerror" ) );
                $this->setRobotpolicy( "noindex,nofollow" );
-               $this->setArticleFlag( false );
+               $this->setArticleRelated( false );
 
                $this->mBodytext = $message;
                $this->output();
index 1def0a1..cca1d66 100644 (file)
@@ -31,6 +31,7 @@ class PageHistory {
                $wgOut->setPageTitle( $this->mTitle->getPRefixedText() );
                $wgOut->setSubtitle( wfMsg( "revhistory" ) );
                $wgOut->setArticleFlag( false );
+               $wgOut->setArticleRelated( true );
                $wgOut->setRobotpolicy( "noindex,nofollow" );
 
                if( $this->mTitle->getArticleID() == 0 ) {
index d7e8a6d..f2138e1 100644 (file)
@@ -42,6 +42,13 @@ class RecentChange
                return $rc;
        }
        
+       /* static */ function newFromCurRow( $row )
+       {
+               $rc = new RecentChange;
+               $rc->loadFromCurRow( $row );
+               return $rc;
+       }
+
        # Accessors
        
        function setAttribs( $attribs ) 
@@ -242,6 +249,31 @@ class RecentChange
                $this->mExtra = array();
        }
        
+       # Makes a pseudo-RC entry from a cur row, for watchlists and things
+       function loadFromCurRow( $row )
+       {
+               $this->mAttribs = array(
+                       "rc_timestamp" => $row->cur_timestamp,
+                       "rc_cur_time" => $row->cur_timestamp,
+                       "rc_user" => $row->cur_user,
+                       "rc_user_text" => $row->cur_user_text,
+                       "rc_namespace" => $row->cur_namespace,
+                       "rc_title" => $row->cur_title,
+                       "rc_comment" => $row->cur_comment,
+                       "rc_minor" => !!$row->cur_minor_edit,
+                       "rc_type" => $row->cur_is_new ? RC_NEW : RC_EDIT,
+                       "rc_cur_id" => $row->cur_id,
+                       'rc_this_oldid' => 0,
+                       'rc_last_oldid' => 0,
+                       'rc_bot'        => 0,
+                       'rc_moved_to_ns'        => 0,
+                       'rc_moved_to_title'     => ''
+               );
+
+               $this->mExtra = array();
+       }
+
+
        # Gets the end part of the diff URL assoicated with this object
        # Blank if no diff link should be displayed
        function diffLinkTrail( $forceCur )
index d15272e..0f324d1 100644 (file)
@@ -33,6 +33,14 @@ class RCCacheEntry extends RecentChange
        var $secureName, $link;
        var $curlink , $lastlink , $usertalklink , $versionlink ;
        var $userlink, $timestamp, $watched;
+
+       function newFromParent( $rc )
+       {
+               $rc2 = new RCCacheEntry;
+               $rc2->mAttribs = $rc->mAttribs;
+               $rc2->mExtra = $rc->mExtra;
+               return $rc2;
+       }
 } ;
 
 class Skin {
@@ -408,7 +416,7 @@ class Skin {
                $s = $this->printableLink();
                if ( wfMsg ( "disclaimers" ) != "-" ) $s .= " | " . $this->makeKnownLink( wfMsg( "disclaimerpage" ), wfMsg( "disclaimers" ) ) ;
 
-               if ( $wgOut->isArticle() ) {
+               if ( $wgOut->isArticleRelated() ) {
                        if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
                                $name = $wgTitle->getDBkey();
                                $link = wfEscapeHTML( wfImageUrl( $name ) );
@@ -424,33 +432,34 @@ class Skin {
                                #wfEscapeHTML( wfImageUrl( $name ) );
                                $style = $this->getExternalLinkAttributes( $link, $name );
                                $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
-                       }               }
-                       if ( "history" == $action || isset( $diff ) || isset( $oldid ) ) {
-                               $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(),
-                                               wfMsg( "currentrev" ) );
-                       }
+                       }               
+               }
+               if ( "history" == $action || isset( $diff ) || isset( $oldid ) ) {
+                       $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(),
+                                       wfMsg( "currentrev" ) );
+               }
 
-                       if ( $wgUser->getNewtalk() ) {
-                       # do not show "You have new messages" text when we are viewing our 
-                       # own talk page 
-
-                               if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
-                                                       $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
-                                       $n =$wgUser->getName();
-                                       $tl = $this->makeKnownLink( $wgLang->getNsText(
-                                                               Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
-                                                       wfMsg("newmessageslink") );
-                                       $s.=" | <strong>". wfMsg( "newmessages", $tl ) . "</strong>";
-                               }
-                       }
-                       if( $wgUser->isSysop() &&
-                                       (($wgTitle->getArticleId() == 0) || ($action == "history")) &&
-                                       ($n = $wgTitle->isDeleted() ) ) {
-                               $s .= " | " . wfMsg( "thisisdeleted",
-                                               $this->makeKnownLink(
-                                                       $wgLang->SpecialPage( "Undelete/" . $wgTitle->getPrefixedDBkey() ),
-                                                       wfMsg( "restorelink", $n ) ) );
+               if ( $wgUser->getNewtalk() ) {
+               # do not show "You have new messages" text when we are viewing our 
+               # own talk page 
+
+                       if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
+                                               $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
+                               $n =$wgUser->getName();
+                               $tl = $this->makeKnownLink( $wgLang->getNsText(
+                                                       Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
+                                               wfMsg("newmessageslink") );
+                               $s.=" | <strong>". wfMsg( "newmessages", $tl ) . "</strong>";
                        }
+               }
+               if( $wgUser->isSysop() &&
+                               (($wgTitle->getArticleId() == 0) || ($action == "history")) &&
+                               ($n = $wgTitle->isDeleted() ) ) {
+                       $s .= " | " . wfMsg( "thisisdeleted",
+                                       $this->makeKnownLink(
+                                               $wgLang->SpecialPage( "Undelete/" . $wgTitle->getPrefixedDBkey() ),
+                                               wfMsg( "restorelink", $n ) ) );
+               }
                return $s;
        }
 
@@ -588,7 +597,7 @@ class Skin {
                $s = $this->mainPageLink() . $sep
                  . $this->specialLink( "recentchanges" );
 
-               if ( $wgOut->isArticle() ) {
+               if ( $wgOut->isArticleRelated() ) {
                        $s .=  $sep . $this->editThisPage()
                          . $sep . $this->historyLink();
                }
@@ -604,7 +613,7 @@ class Skin {
                $sep = " |\n";
 
                $s = "";
-               if ( $wgOut->isArticle() ) {
+               if ( $wgOut->isArticleRelated() ) {
                        $s .= "<strong>" . $this->editThisPage() . "</strong>";
                        if ( 0 != $wgUser->getID() ) {
                                $s .= $sep . $this->watchThisPage();
@@ -768,8 +777,7 @@ class Skin {
                        unwatched. Therefore we do not show the "Watch this page" link in edit mode
                        */                      
                        if ( 0 != $wgUser->getID() && $articleExists) {
-                               if($action!="edit" && $action!="history" && 
-                                       $action != "submit" ) 
+                               if($action!="edit" && $action != "submit" ) 
                                {
                                        $s .= $sep . $this->watchThisPage(); 
                                }
@@ -786,7 +794,7 @@ class Skin {
                        }
                        $s.=$sep . $this->whatLinksHere();
                        
-                       if($wgOut->isArticle()) {
+                       if($wgOut->isArticleRelated()) {
                                $s .= $sep . $this->watchPageLinksLink();
                        }
 
@@ -907,7 +915,7 @@ class Skin {
        {
                global $wgOut, $wgTitle, $oldid, $redirect, $diff;
 
-               if ( ! $wgOut->isArticle() || $diff ) {
+               if ( ! $wgOut->isArticleRelated() ) {
                        $s = wfMsg( "protectedpage" );
                } else {
                        $n = $wgTitle->getPrefixedText();
@@ -968,7 +976,7 @@ class Skin {
        {
                global $wgUser, $wgOut, $wgTitle, $diff;
 
-               if ( $wgOut->isArticle() && ( ! $diff ) ) {
+               if ( $wgOut->isArticleRelated() ) {
                        $n = $wgTitle->getPrefixedText();
 
                        if ( $wgTitle->userIsWatching() ) {
@@ -1036,7 +1044,7 @@ class Skin {
        {
                global $wgOut, $wgTitle, $wgLang;
 
-               if ( ! $wgOut->isArticle() ) {
+               if ( ! $wgOut->isArticleRelated() ) {
                        $s = "(" . wfMsg( "notanarticle" ) . ")";
                } else {
                        $s = $this->makeKnownLink( $wgLang->specialPage(
@@ -1871,24 +1879,23 @@ class Skin {
 
        # Called in a loop over all displayed RC entries
        # Either returns the line, or caches it for later use
-       function recentChangesLine( $row, $watched = false )
+       function recentChangesLine( &$rc, $watched = false )
        {
                global $wgUser ;
                $usenew = $wgUser->getOption( "usenewrc" );
                if ( $usenew )
-                       $line = $this->recentChangesLineNew ( $row, $watched ) ;
+                       $line = $this->recentChangesLineNew ( $rc, $watched ) ;
                else
-                       $line = $this->recentChangesLineOld ( $row, $watched ) ;
+                       $line = $this->recentChangesLineOld ( $rc, $watched ) ;
                return $line ;
        }
        
-       function recentChangesLineOld( $row, $watched = false )
+       function recentChangesLineOld( &$rc, $watched = false )
        {
                global $wgTitle, $wgLang, $wgUser;
                
                # Extract DB fields into local scope
-               extract( get_object_vars( $row ) );
-               $rc = RecentChange::newFromRow( $row );
+               extract( $rc->mAttribs );
                $curIdEq = "curid=" . $rc_cur_id;
                
                # Make date header if necessary
@@ -1986,13 +1993,12 @@ class Skin {
        }
        
 #      function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
-       function recentChangesLineNew( $row, $watched = false )
+       function recentChangesLineNew( &$baseRC, $watched = false )
        {
                global $wgTitle, $wgLang, $wgUser;
 
-               # Fill $rc with all the information from the row
-               $rc = new RCCacheEntry ;
-               $rc->loadFromRow( $row );
+               # Create a specialised object
+               $rc = RCCacheEntry::newFromParent( $baseRC ) ;
 
                # Extract fields from DB into the function scope (rc_xxxx variables)
                extract( $rc->mAttribs );
index f775355..c38bf63 100644 (file)
@@ -111,7 +111,8 @@ function wfSpecialRecentchanges( $par )
                        break; 
                }
                if ( ! ( $hideminor && $obj1->rc_minor ) ) {
-                       $s .= $sk->recentChangesLine( $obj1, $obj1->wl_user );
+                       $rc = RecentChange::newFromRow( $obj1 );
+                       $s .= $sk->recentChangesLine( $rc, $obj1->wl_user );
                        --$limit;
                }
                $obj1 = wfFetchObject( $res );
index b2c568e..59d2e36 100644 (file)
@@ -66,16 +66,8 @@ function wfSpecialRecentchangeslinked( $par = NULL )
                $obj = wfFetchObject( $res );
                --$count;
 
-               $ts = $obj->cur_timestamp;
-               $u = $obj->cur_user;
-               $ut = $obj->cur_user_text;
-               $ns = $obj->cur_namespace;
-               $ttl = $obj->cur_title;
-               $com = $obj->cur_comment;
-               $me = ( $obj->cur_minor_edit > 0 );
-               $new = ( $obj->cur_is_new > 0 );
-
-               $s .= $sk->recentChangesLine( $ts, $u, $ut, $ns, $ttl, $com, $me, $new );
+               $rc = RecentChange::newFromCurRow( $obj );
+               $s .= $sk->recentChangesLine( $rc );
                --$limit;
        }
        $s .= $sk->endRecentChangesList();
index d457348..136cb3f 100644 (file)
@@ -123,7 +123,7 @@ function wfSpecialWatchlist()
         
 
        $sql = "SELECT
-  cur_namespace,cur_title,cur_comment,
+  cur_namespace,cur_title,cur_comment, cur_id
   cur_user,cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new
   FROM watchlist,cur USE INDEX ($x)
   WHERE wl_user=$uid
@@ -154,17 +154,9 @@ function wfSpecialWatchlist()
        $s = $sk->beginRecentChangesList();
 
        while ( $obj = wfFetchObject( $res ) ) {
-               $ts = $obj->cur_timestamp;
-               $u = $obj->cur_user;
-               $ut = $obj->cur_user_text;
-               $ns = $obj->cur_namespace;
-               $ttl = $obj->cur_title;
-               $com = $obj->cur_comment;
-               $me = ( $obj->cur_minor_edit > 0 );
-               $new = ( $obj->cur_is_new  > 0 );
-               $watched = true;
-
-               $s .= $sk->recentChangesLine( $ts, $u, $ut, $ns, $ttl, $com, $me, $new, $watched );
+               # Make fake RC entry
+               $rc = RecentChange::newFromCurRow( $obj );
+               $s .= $sk->recentChangesLine( $rc, true );
        }
        $s .= $sk->endRecentChangesList();