* (bug 1915) Fix edit links when 'direction' used with 'oldid';
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 1 Dec 2005 09:47:44 +0000 (09:47 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 1 Dec 2005 09:47:44 +0000 (09:47 +0000)
  using revision ID reported via OutputPage; Skin::editUrlOptions()
* Remove obsolete 'redirect=no' on some edit links
* Include oldid for the second revision on edit link on diff view

RELEASE-NOTES
includes/Skin.php
includes/SkinTemplate.php

index 40e5509..9045115 100644 (file)
@@ -266,6 +266,10 @@ fully support the editing toolbar, but was found to be too confusing.
   versions of Safari and Konqueror
 * Don't die() when update.php reaches the end of the warning count
 * (bug 4071) Generate passwords long enough for $wgMinimalPasswordLength
+* (bug 1915) Fix edit links when 'direction' used with 'oldid';
+  using revision ID reported via OutputPage; Skin::editUrlOptions()
+* Remove obsolete 'redirect=no' on some edit links
+* Include oldid for the second revision on edit link on diff view
 
 
 === Caveats ===
index 5abb870..7c850c3 100644 (file)
@@ -102,6 +102,8 @@ class Skin extends Linker {
                $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
 
                $this->addMetadataLinks($out);
+               
+               $this->mRevisionId = $out->mRevisionId;
 
                wfProfileOut( $fname );
        }
@@ -318,15 +320,8 @@ END;
                if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
                  $wgTitle->userCanEdit() ) {
                        $t = wfMsg( 'editthispage' );
-                       $oid = $red = '';
-                       if ( !empty($redirect) && $redirect == 'no' ) {
-                               $red = "&redirect={$redirect}";
-                       }
-                       if ( !empty($oldid) && ! isset( $diff ) ) {
-                               $oid = "&oldid=" . intval( $oldid );
-                       }
-                       $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
-                       $s = 'document.location = "' .$s .'";';
+                       $s = $wgTitle->getFullURL( $this->editUrlOptions() );
+                       $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
                        $a += array ('ondblclick' => $s);
 
                }
@@ -1013,10 +1008,6 @@ END;
        function editThisPage() {
                global $wgOut, $wgTitle, $wgRequest;
 
-               $oldid = $wgRequest->getVal( 'oldid' );
-               $diff = $wgRequest->getVal( 'diff' );
-               $redirect = $wgRequest->getVal( 'redirect' );
-
                if ( ! $wgOut->isArticleRelated() ) {
                        $s = wfMsg( 'protectedpage' );
                } else {
@@ -1025,16 +1016,26 @@ END;
                        } else {
                                $t = wfMsg( 'viewsource' );
                        }
-                       $oid = $red = '';
 
-                       if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
-                       if ( $oldid && ! isset( $diff ) ) {
-                               $oid = '&oldid='.$oldid;
-                       }
-                       $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
+                       $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
                }
                return $s;
        }
+       
+       /**
+        * Return URL options for the 'edit page' link.
+        * This may include an 'oldid' specifier, if the current page view is such.
+        *
+        * @return string
+        * @access private
+        */
+       function editUrlOptions() {
+               if( $this->mRevisionId ) {
+                       return "action=edit&oldid=" . intval( $this->mRevisionId );
+               } else {
+                       return "action=edit";
+               }
+       }
 
        function deleteThisPage() {
                global $wgUser, $wgOut, $wgTitle, $wgRequest;
index 5b80782..4acc49b 100644 (file)
@@ -582,8 +582,6 @@ class SkinTemplate extends Skin {
                global $wgUser, $wgRequest;
                $action = $wgRequest->getText( 'action' );
                $section = $wgRequest->getText( 'section' );
-               $oldid = $wgRequest->getVal( 'oldid' );
-               $diff = $wgRequest->getVal( 'diff' );
                $content_actions = array();
 
                if( $this->iscontent ) {
@@ -606,13 +604,12 @@ class SkinTemplate extends Skin {
 
                        wfProfileIn( "$fname-edit" );
                        if ( $this->mTitle->userCanEdit() ) {
-                               $oid = ( $oldid && ! isset( $diff ) ) ? '&oldid='.intval( $oldid ) : false;
                                $istalk = $this->mTitle->isTalkPage();
                                $istalkclass = $istalk?' istalk':'';
                                $content_actions['edit'] = array(
                                        'class' => ((($action == 'edit' or $action == 'submit') and $section != 'new') ? 'selected' : '').$istalkclass,
                                        'text' => wfMsg('edit'),
-                                       'href' => $this->mTitle->getLocalUrl( 'action=edit'.$oid )
+                                       'href' => $this->mTitle->getLocalUrl( $this->editUrlOptions() )
                                );
 
                                if ( $istalk ) {
@@ -623,11 +620,10 @@ class SkinTemplate extends Skin {
                                        );
                                }
                        } else {
-                               $oid = ( $oldid && ! isset( $diff ) ) ? '&oldid='.intval( $oldid ) : '';
                                $content_actions['viewsource'] = array(
                                        'class' => ($action == 'edit') ? 'selected' : false,
                                        'text' => wfMsg('viewsource'),
-                                       'href' => $this->mTitle->getLocalUrl( 'action=edit'.$oid )
+                                       'href' => $this->mTitle->getLocalUrl( $this->editUrlOptions() )
                                );
                        }
                        wfProfileOut( "$fname-edit" );
@@ -704,7 +700,7 @@ class SkinTemplate extends Skin {
                        if( $this->loggedin || $wgValidationForAnons ) { # and $action != 'submit' ) {
                                # Validate tab. TODO: add validation to logged-in user rights
                                if($wgUseValidation && ( $action == "" || $action=='view' ) ){ # && $wgUser->isAllowed('validate')){
-                                       if ( $oldid ) $oid = intval( $oldid ) ; # Use the oldid
+                                       if ( $this->mRevisionId ) $oid = intval( $this->mRevisionId ) ; # Use the oldid
                                        else
                                                {# Trying to get the current article revision through this weird stunt
                                                $tid = $this->mTitle->getArticleID();