From: Brion Vibber Date: Thu, 1 Dec 2005 09:47:44 +0000 (+0000) Subject: * (bug 1915) Fix edit links when 'direction' used with 'oldid'; X-Git-Tag: 1.6.0~1088 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dcompta/operations/modifier.php?a=commitdiff_plain;h=7e2201ad13b46852e8d033f4de507646e1c17a13;p=lhc%2Fweb%2Fwiklou.git * (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 --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 40e5509cd2..9045115c6c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/Skin.php b/includes/Skin.php index 5abb870ca1..7c850c3cdd 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -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; diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 5b80782995..4acc49b2d6 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -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();