X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FEditPage.php;h=ecd4bbb0fe6f8ad36904f6978d912dc1453d2be0;hb=fd2900c8a45145a1ca9dc0e15d5033366c21b9d0;hp=e733ef12f0fe14fe999ad95bb87197982298898c;hpb=7c7951f78fac944934a18bf34b1e12cd8ec3c850;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/EditPage.php b/includes/EditPage.php
index e733ef12f0..ecd4bbb0fe 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -84,6 +84,7 @@ class EditPage {
/* $didSave should be set to true whenever an article was succesfully altered. */
public $didSave = false;
+ public $undidRev = 0;
public $suppressIntro = false;
@@ -102,7 +103,12 @@ class EditPage {
$this->editFormTextBeforeContent =
$this->editFormTextAfterWarn =
$this->editFormTextAfterTools =
- $this->editFormTextBottom = "";
+ $this->editFormTextBottom =
+ $this->mPreloadText = "";
+ }
+
+ function getArticle() {
+ return $this->mArticle;
}
/**
@@ -110,7 +116,7 @@ class EditPage {
* @private
*/
function getContent( $def_text = '' ) {
- global $wgOut, $wgRequest, $wgParser, $wgMessageCache;
+ global $wgOut, $wgRequest, $wgParser, $wgContLang, $wgMessageCache;
wfProfileIn( __METHOD__ );
# Get variables from query string :P
@@ -122,11 +128,14 @@ class EditPage {
$text = '';
// For message page not locally set, use the i18n message.
// For other non-existent articles, use preload text if any.
- if( !$this->mTitle->exists() ) {
- if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
- $wgMessageCache->loadAllMessages();
+ if ( !$this->mTitle->exists() ) {
+ if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
# If this is a system message, get the default text.
- $text = wfMsgWeirdKey( $this->mTitle->getText() ) ;
+ list( $message, $lang ) = $wgMessageCache->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) );
+ $wgMessageCache->loadAllMessages( $lang );
+ $text = wfMsgGetKey( $message, false, $lang, false );
+ if( wfEmptyMsg( $message, $text ) )
+ $text = '';
} else {
# If requested, preload some text.
$text = $this->getPreloadedText( $preload );
@@ -134,14 +143,14 @@ class EditPage {
// For existing pages, get text based on "undo" or section parameters.
} else {
$text = $this->mArticle->getContent();
- if( $undo > 0 && $undoafter > 0 && $undo < $undoafter ) {
+ if ( $undo > 0 && $undoafter > 0 && $undo < $undoafter ) {
# If they got undoafter and undo round the wrong way, switch them
list( $undo, $undoafter ) = array( $undoafter, $undo );
}
- if( $undo > 0 && $undo > $undoafter ) {
+ if ( $undo > 0 && $undo > $undoafter ) {
# Undoing a specific edit overrides section editing; section-editing
# doesn't work with undoing.
- if( $undoafter ) {
+ if ( $undoafter ) {
$undorev = Revision::newFromId($undo);
$oldrev = Revision::newFromId($undoafter);
} else {
@@ -152,43 +161,36 @@ class EditPage {
# Sanity check, make sure it's the right page,
# the revisions exist and they were not deleted.
# Otherwise, $text will be left as-is.
- if( !is_null( $undorev ) && !is_null( $oldrev ) &&
+ if ( !is_null( $undorev ) && !is_null( $oldrev ) &&
$undorev->getPage() == $oldrev->getPage() &&
$undorev->getPage() == $this->mArticle->getID() &&
!$undorev->isDeleted( Revision::DELETED_TEXT ) &&
!$oldrev->isDeleted( Revision::DELETED_TEXT ) ) {
- $undorev_text = $undorev->getText();
- $oldrev_text = $oldrev->getText();
- $currev_text = $text;
-
- if( $currev_text != $undorev_text ) {
- $result = wfMerge( $undorev_text, $oldrev_text, $currev_text, $text );
+
+ $undotext = $this->mArticle->getUndoText( $undorev, $oldrev );
+ if ( $undotext === false ) {
+ # Warn the user that something went wrong
+ $this->editFormPageTop .= $wgOut->parse( '
' . wfMsgNoTrans( 'undo-failure' ) . '
' );
} else {
- # No use doing a merge if it's just a straight revert.
- $text = $oldrev_text;
- $result = true;
- }
- if( $result ) {
+ $text = $undotext;
# Inform the user of our success and set an automatic edit summary
- $this->editFormPageTop .= $wgOut->parse( wfMsgNoTrans( 'undo-success' ) );
+ $this->editFormPageTop .= $wgOut->parse( '
' . wfMsgNoTrans( 'undo-success' ) . '
' );
$firstrev = $oldrev->getNext();
# If we just undid one rev, use an autosummary
- if( $firstrev->mId == $undo ) {
- $this->summary = wfMsgForContent('undo-summary', $undo, $undorev->getUserText());
+ if ( $firstrev->mId == $undo ) {
+ $this->summary = wfMsgForContent( 'undo-summary', $undo, $undorev->getUserText() );
+ $this->undidRev = $undo;
}
$this->formtype = 'diff';
- } else {
- # Warn the user that something went wrong
- $this->editFormPageTop .= $wgOut->parse( wfMsgNoTrans( 'undo-failure' ) );
}
} else {
// Failed basic sanity checks.
// Older revisions may have been removed since the link
// was created, or we may simply have got bogus input.
- $this->editFormPageTop .= $wgOut->parse( wfMsgNoTrans( 'undo-norev' ) );
+ $this->editFormPageTop .= $wgOut->parse( '
' . wfMsgNoTrans( 'undo-norev' ) . '
' );
}
- } else if( $section != '' ) {
- if( $section == 'new' ) {
+ } else if ( $section != '' ) {
+ if ( $section == 'new' ) {
$text = $this->getPreloadedText( $preload );
} else {
$text = $wgParser->getSection( $text, $section, $def_text );
@@ -199,6 +201,11 @@ class EditPage {
wfProfileOut( __METHOD__ );
return $text;
}
+
+ /** Use this method before edit() to preload some text into the edit box */
+ public function setPreloadedText( $text ) {
+ $this->mPreloadText = $text;
+ }
/**
* Get the contents of a page from its title and remove includeonly tags
@@ -207,13 +214,15 @@ class EditPage {
* @return string The contents of the page.
*/
protected function getPreloadedText( $preload ) {
- if( $preload === '' ) {
+ if ( !empty($this->mPreloadText) ) {
+ return $this->mPreloadText;
+ } elseif ( $preload === '' ) {
return '';
} else {
$preloadTitle = Title::newFromText( $preload );
- if( isset( $preloadTitle ) && $preloadTitle->userCanRead() ) {
+ if ( isset( $preloadTitle ) && $preloadTitle->userCanRead() ) {
$rev = Revision::newFromTitle($preloadTitle);
- if( is_object( $rev ) ) {
+ if ( is_object( $rev ) ) {
$text = $rev->getText();
// TODO FIXME: AAAAAAAAAAA, this shouldn't be implementing
// its own mini-parser! -ævar
@@ -231,93 +240,87 @@ class EditPage {
* and set $wgMetadataWhitelist to the *full* title of the template whitelist
*/
function extractMetaDataFromArticle () {
- global $wgUseMetadataEdit , $wgMetadataWhitelist , $wgLang ;
- $this->mMetaData = '' ;
- if( !$wgUseMetadataEdit ) return ;
- if( $wgMetadataWhitelist == '' ) return ;
- $s = '' ;
+ global $wgUseMetadataEdit, $wgMetadataWhitelist, $wgContLang;
+ $this->mMetaData = '';
+ if ( !$wgUseMetadataEdit ) return;
+ if ( $wgMetadataWhitelist == '' ) return;
+ $s = '';
$t = $this->getContent();
# MISSING : filtering
# Categories and language links
- $t = explode ( "\n" , $t ) ;
- $catlow = strtolower ( $wgLang->getNsText ( NS_CATEGORY ) ) ;
- $cat = $ll = array() ;
- foreach ( $t AS $key => $x )
- {
- $y = trim ( strtolower ( $x ) ) ;
- while ( substr ( $y , 0 , 2 ) == '[[' )
- {
- $y = explode ( ']]' , trim ( $x ) ) ;
- $first = array_shift ( $y ) ;
- $first = explode ( ':' , $first ) ;
- $ns = array_shift ( $first ) ;
- $ns = trim ( str_replace ( '[' , '' , $ns ) ) ;
- if( strlen ( $ns ) == 2 OR strtolower ( $ns ) == $catlow )
- {
- $add = '[[' . $ns . ':' . implode ( ':' , $first ) . ']]' ;
- if( strtolower ( $ns ) == $catlow ) $cat[] = $add ;
- else $ll[] = $add ;
- $x = implode ( ']]' , $y ) ;
- $t[$key] = $x ;
- $y = trim ( strtolower ( $x ) ) ;
+ $t = explode ( "\n" , $t );
+ $catlow = strtolower ( $wgContLang->getNsText( NS_CATEGORY ) );
+ $cat = $ll = array();
+ foreach ( $t AS $key => $x ) {
+ $y = trim ( strtolower ( $x ) );
+ while ( substr ( $y , 0 , 2 ) == '[[' ) {
+ $y = explode ( ']]' , trim ( $x ) );
+ $first = array_shift ( $y );
+ $first = explode ( ':' , $first );
+ $ns = array_shift ( $first );
+ $ns = trim ( str_replace ( '[' , '' , $ns ) );
+ if ( $wgContLang->getLanguageName( $ns ) || strtolower ( $ns ) == $catlow ) {
+ $add = '[[' . $ns . ':' . implode ( ':' , $first ) . ']]';
+ if ( strtolower ( $ns ) == $catlow ) $cat[] = $add;
+ else $ll[] = $add;
+ $x = implode ( ']]' , $y );
+ $t[$key] = $x;
+ $y = trim ( strtolower ( $x ) );
+ } else {
+ $x = implode ( ']]' , $y );
+ $y = trim ( strtolower ( $x ) );
}
}
}
- if( count ( $cat ) ) $s .= implode ( ' ' , $cat ) . "\n" ;
- if( count ( $ll ) ) $s .= implode ( ' ' , $ll ) . "\n" ;
- $t = implode ( "\n" , $t ) ;
+ if ( count ( $cat ) ) $s .= implode ( ' ' , $cat ) . "\n";
+ if ( count ( $ll ) ) $s .= implode ( ' ' , $ll ) . "\n";
+ $t = implode ( "\n" , $t );
# Load whitelist
$sat = array () ; # stand-alone-templates; must be lowercase
- $wl_title = Title::newFromText ( $wgMetadataWhitelist ) ;
- $wl_article = new Article ( $wl_title ) ;
- $wl = explode ( "\n" , $wl_article->getContent() ) ;
- foreach ( $wl AS $x )
- {
- $isentry = false ;
- $x = trim ( $x ) ;
- while ( substr ( $x , 0 , 1 ) == '*' )
- {
- $isentry = true ;
- $x = trim ( substr ( $x , 1 ) ) ;
+ $wl_title = Title::newFromText ( $wgMetadataWhitelist );
+ $wl_article = new Article ( $wl_title );
+ $wl = explode ( "\n" , $wl_article->getContent() );
+ foreach ( $wl AS $x ) {
+ $isentry = false;
+ $x = trim ( $x );
+ while ( substr ( $x , 0 , 1 ) == '*' ) {
+ $isentry = true;
+ $x = trim ( substr ( $x , 1 ) );
}
- if( $isentry )
- {
- $sat[] = strtolower ( $x ) ;
+ if ( $isentry ) {
+ $sat[] = strtolower ( $x );
}
}
# Templates, but only some
- $t = explode ( '{{' , $t ) ;
+ $t = explode ( '{{' , $t );
$tl = array () ;
- foreach ( $t AS $key => $x )
- {
- $y = explode ( '}}' , $x , 2 ) ;
- if( count ( $y ) == 2 )
- {
- $z = $y[0] ;
- $z = explode ( '|' , $z ) ;
- $tn = array_shift ( $z ) ;
- if( in_array ( strtolower ( $tn ) , $sat ) )
- {
- $tl[] = '{{' . $y[0] . '}}' ;
- $t[$key] = $y[1] ;
- $y = explode ( '}}' , $y[1] , 2 ) ;
+ foreach ( $t AS $key => $x ) {
+ $y = explode ( '}}' , $x , 2 );
+ if ( count ( $y ) == 2 ) {
+ $z = $y[0];
+ $z = explode ( '|' , $z );
+ $tn = array_shift ( $z );
+ if ( in_array ( strtolower ( $tn ) , $sat ) ) {
+ $tl[] = '{{' . $y[0] . '}}';
+ $t[$key] = $y[1];
+ $y = explode ( '}}' , $y[1] , 2 );
}
- else $t[$key] = '{{' . $x ;
+ else $t[$key] = '{{' . $x;
}
- else if( $key != 0 ) $t[$key] = '{{' . $x ;
- else $t[$key] = $x ;
+ else if ( $key != 0 ) $t[$key] = '{{' . $x;
+ else $t[$key] = $x;
}
- if( count ( $tl ) ) $s .= implode ( ' ' , $tl ) ;
- $t = implode ( '' , $t ) ;
+ if ( count ( $tl ) ) $s .= implode ( ' ' , $tl );
+ $t = implode ( '' , $t );
- $t = str_replace ( "\n\n\n" , "\n" , $t ) ;
- $this->mArticle->mContent = $t ;
- $this->mMetaData = $s ;
+ $t = str_replace ( "\n\n\n" , "\n" , $t );
+ $this->mArticle->mContent = $t;
+ $this->mMetaData = $s;
}
/*
@@ -327,13 +330,13 @@ class EditPage {
* deletes.
*/
protected function wasDeletedSinceLastEdit() {
- if( $this->deletedSinceEdit )
+ if ( $this->deletedSinceEdit )
return true;
- if( $this->mTitle->isDeleted() ) {
+ if ( $this->mTitle->isDeletedQuick() ) {
$this->lastDelete = $this->getLastDelete();
- if( !is_null($this->lastDelete) ) {
- $deletetime = $this->lastDelete->log_timestamp;
- if( ($deletetime - $this->starttime) > 0 ) {
+ if ( $this->lastDelete ) {
+ $deleteTime = wfTimestamp( TS_MW, $this->lastDelete->log_timestamp );
+ if ( $deleteTime > $this->starttime ) {
$this->deletedSinceEdit = true;
}
}
@@ -357,9 +360,9 @@ class EditPage {
* the newly-edited page.
*/
function edit() {
- global $wgOut, $wgUser, $wgRequest;
+ global $wgOut, $wgRequest;
// Allow extensions to modify/prevent this form or submission
- if( !wfRunHooks( 'AlternateEdit', array( &$this ) ) ) {
+ if ( !wfRunHooks( 'AlternateEdit', array( &$this ) ) ) {
return;
}
@@ -372,43 +375,35 @@ class EditPage {
$this->importFormData( $wgRequest );
$this->firsttime = false;
- if( $this->live ) {
+ if ( $this->live ) {
$this->livePreview();
wfProfileOut( __METHOD__ );
return;
}
- if( wfReadOnly() ) {
- if( $this->save ){
+ if ( wfReadOnly() && $this->save ) {
// Force preview
$this->save = false;
$this->preview = true;
- } elseif( $this->preview || $this->diff ) {
- // A warning will be displayed instead
- } else {
- $this->readOnlyPage( $this->getContent() );
- wfProfileOut( __METHOD__ );
- return;
- }
}
$wgOut->addScriptFile( 'edit.js' );
-
- if( $permErrors = $this->getEditPermissionErrors() ) {
+ $permErrors = $this->getEditPermissionErrors();
+ if ( $permErrors ) {
wfDebug( __METHOD__.": User can't edit\n" );
$this->readOnlyPage( $this->getContent(), true, $permErrors, 'edit' );
wfProfileOut( __METHOD__ );
return;
} else {
- if( $this->save ) {
+ if ( $this->save ) {
$this->formtype = 'save';
- } else if( $this->preview ) {
+ } else if ( $this->preview ) {
$this->formtype = 'preview';
- } else if( $this->diff ) {
+ } else if ( $this->diff ) {
$this->formtype = 'diff';
} else { # First time through
$this->firsttime = true;
- if( $this->previewOnOpen() ) {
+ if ( $this->previewOnOpen() ) {
$this->formtype = 'preview';
} else {
$this->extractMetaDataFromArticle () ;
@@ -416,6 +411,11 @@ class EditPage {
}
}
}
+
+ // If they used redlink=1 and the page exists, redirect to the main article
+ if ( $wgRequest->getBool( 'redlink' ) && $this->mTitle->exists() ) {
+ $wgOut->redirect( $this->mTitle->getFullURL() );
+ }
wfProfileIn( __METHOD__."-business-end" );
@@ -425,30 +425,27 @@ class EditPage {
$this->isValidCssJsSubpage = $this->mTitle->isValidCssJsSubpage();
# Show applicable editing introductions
- if( $this->formtype == 'initial' || $this->firsttime )
+ if ( $this->formtype == 'initial' || $this->firsttime )
$this->showIntro();
- if( $this->mTitle->isTalkPage() ) {
+ if ( $this->mTitle->isTalkPage() ) {
$wgOut->addWikiMsg( 'talkpagetext' );
}
# Optional notices on a per-namespace and per-page basis
$editnotice_ns = 'editnotice-'.$this->mTitle->getNamespace();
- $editnotice_page = $editnotice_ns.'-'.$this->mTitle->getDBkey();
- if( !wfEmptyMsg( $editnotice_ns, wfMsgForContent( $editnotice_ns ) ) ) {
+ if ( !wfEmptyMsg( $editnotice_ns, wfMsgForContent( $editnotice_ns ) ) ) {
$wgOut->addWikiText( wfMsgForContent( $editnotice_ns ) );
}
- if( MWNamespace::hasSubpages( $this->mTitle->getNamespace() ) ) {
+ if ( MWNamespace::hasSubpages( $this->mTitle->getNamespace() ) ) {
$parts = explode( '/', $this->mTitle->getDBkey() );
$editnotice_base = $editnotice_ns;
while ( count( $parts ) > 0 ) {
$editnotice_base .= '-'.array_shift( $parts );
- if( !wfEmptyMsg( $editnotice_base, wfMsgForContent( $editnotice_base ) ) ) {
+ if ( !wfEmptyMsg( $editnotice_base, wfMsgForContent( $editnotice_base ) ) ) {
$wgOut->addWikiText( wfMsgForContent( $editnotice_base ) );
}
}
- } else if( !wfEmptyMsg( $editnotice_page, wfMsgForContent( $editnotice_page ) ) ) {
- $wgOut->addWikiText( wfMsgForContent( $editnotice_page ) );
}
# Attempt submission here. This will check for edit conflicts,
@@ -456,8 +453,8 @@ class EditPage {
# that edit() already checked just in case someone tries to sneak
# in the back door with a hand-edited submission URL.
- if( 'save' == $this->formtype ) {
- if( !$this->attemptSave() ) {
+ if ( 'save' == $this->formtype ) {
+ if ( !$this->attemptSave() ) {
wfProfileOut( __METHOD__."-business-end" );
wfProfileOut( __METHOD__ );
return;
@@ -466,14 +463,14 @@ class EditPage {
# First time through: get contents, set time for conflict
# checking, etc.
- if( 'initial' == $this->formtype || $this->firsttime ) {
- if( $this->initialiseForm() === false) {
+ if ( 'initial' == $this->formtype || $this->firsttime ) {
+ if ( $this->initialiseForm() === false) {
$this->noSuchSectionPage();
wfProfileOut( __METHOD__."-business-end" );
wfProfileOut( __METHOD__ );
return;
}
- if( !$this->mTitle->getArticleId() )
+ if ( !$this->mTitle->getArticleId() )
wfRunHooks( 'EditFormPreloadText', array( &$this->textbox1, &$this->mTitle ) );
}
@@ -486,14 +483,14 @@ class EditPage {
global $wgUser;
$permErrors = $this->mTitle->getUserPermissionsErrors( 'edit', $wgUser );
# Can this title be created?
- if( !$this->mTitle->exists() ) {
+ if ( !$this->mTitle->exists() ) {
$permErrors = array_merge( $permErrors,
wfArrayDiff2( $this->mTitle->getUserPermissionsErrors( 'create', $wgUser ), $permErrors ) );
}
# Ignore some permissions errors when a user is just previewing/viewing diffs
$remove = array();
foreach( $permErrors as $error ) {
- if( ($this->preview || $this->diff) &&
+ if ( ($this->preview || $this->diff) &&
($error[0] == 'blockedtext' || $error[0] == 'autoblockedtext') )
{
$remove[] = $error;
@@ -510,7 +507,7 @@ class EditPage {
*/
function readOnlyPage( $source = null, $protected = false, $reasons = array(), $action = null ) {
global $wgRequest, $wgOut;
- if( $wgRequest->getBool( 'redlink' ) ) {
+ if ( $wgRequest->getBool( 'redlink' ) ) {
// The edit page was reached via a red link.
// Redirect to the article page and let them click the edit tab if
// they really want a permission error.
@@ -527,19 +524,19 @@ class EditPage {
*/
protected function previewOnOpen() {
global $wgRequest, $wgUser;
- if( $wgRequest->getVal( 'preview' ) == 'yes' ) {
+ if ( $wgRequest->getVal( 'preview' ) == 'yes' ) {
// Explicit override from request
return true;
- } elseif( $wgRequest->getVal( 'preview' ) == 'no' ) {
+ } elseif ( $wgRequest->getVal( 'preview' ) == 'no' ) {
// Explicit override from request
return false;
- } elseif( $this->section == 'new' ) {
+ } elseif ( $this->section == 'new' ) {
// Nothing *to* preview for new sections
return false;
- } elseif( ( $wgRequest->getVal( 'preload' ) !== '' || $this->mTitle->exists() ) && $wgUser->getOption( 'previewonfirst' ) ) {
+ } elseif ( ( $wgRequest->getVal( 'preload' ) !== null || $this->mTitle->exists() ) && $wgUser->getOption( 'previewonfirst' ) ) {
// Standard preference behaviour
return true;
- } elseif( !$this->mTitle->exists() && $this->mTitle->getNamespace() == NS_CATEGORY ) {
+ } elseif ( !$this->mTitle->exists() && $this->mTitle->getNamespace() == NS_CATEGORY ) {
// Categories are special
return true;
} else {
@@ -559,7 +556,7 @@ class EditPage {
# Section edit can come from either the form or a link
$this->section = $request->getVal( 'wpSection', $request->getVal( 'section' ) );
- if( $request->wasPosted() ) {
+ if ( $request->wasPosted() ) {
# These fields need to be checked for encoding.
# Also remove trailing whitespace, but don't remove _initial_
# whitespace from the text boxes. This may be significant formatting.
@@ -567,7 +564,7 @@ class EditPage {
$this->textbox2 = $this->safeUnicodeInput( $request, 'wpTextbox2' );
$this->mMetaData = rtrim( $request->getText( 'metadata' ) );
# Truncate for whole multibyte characters. +5 bytes for ellipsis
- $this->summary = $wgLang->truncate( $request->getText( 'wpSummary' ), 250 );
+ $this->summary = $wgLang->truncate( $request->getText( 'wpSummary' ), 250, '' );
# Remove extra headings from summaries and new sections.
$this->summary = preg_replace('/^\s*=+\s*(.*?)\s*=+\s*$/', '$1', $this->summary);
@@ -577,11 +574,11 @@ class EditPage {
$this->scrolltop = $request->getIntOrNull( 'wpScrolltop' );
- if( is_null( $this->edittime ) ) {
+ if ( is_null( $this->edittime ) ) {
# If the form is incomplete, force to preview.
wfDebug( "$fname: Form data appears to be incomplete\n" );
wfDebug( "POST DATA: " . var_export( $_POST, true ) . "\n" );
- $this->preview = true;
+ $this->preview = true;
} else {
/* Fallback for live preview */
$this->preview = $request->getCheck( 'wpPreview' ) || $request->getCheck( 'wpLivePreview' );
@@ -591,13 +588,13 @@ class EditPage {
// if we forced preview due to session failure.
$this->mTriedSave = !$this->preview;
- if( $this->tokenOk( $request ) ) {
+ if ( $this->tokenOk( $request ) ) {
# Some browsers will not report any submit button
# if the user hits enter in the comment box.
# The unmarked state will be assumed to be a save,
# if the form seems otherwise complete.
wfDebug( "$fname: Passed token check.\n" );
- } else if( $this->diff ) {
+ } else if ( $this->diff ) {
# Failed token check, but only requested "Show Changes".
wfDebug( "$fname: Failed token check; Show Changes requested.\n" );
} else {
@@ -608,11 +605,11 @@ class EditPage {
}
}
$this->save = !$this->preview && !$this->diff;
- if( !preg_match( '/^\d{14}$/', $this->edittime )) {
+ if ( !preg_match( '/^\d{14}$/', $this->edittime )) {
$this->edittime = null;
}
- if( !preg_match( '/^\d{14}$/', $this->starttime )) {
+ if ( !preg_match( '/^\d{14}$/', $this->starttime )) {
$this->starttime = null;
}
@@ -622,10 +619,12 @@ class EditPage {
$this->watchthis = $request->getCheck( 'wpWatchthis' );
# Don't force edit summaries when a user is editing their own user or talk page
- if( ( $this->mTitle->mNamespace == NS_USER || $this->mTitle->mNamespace == NS_USER_TALK ) && $this->mTitle->getText() == $wgUser->getName() ) {
+ if ( ( $this->mTitle->mNamespace == NS_USER || $this->mTitle->mNamespace == NS_USER_TALK ) &&
+ $this->mTitle->getText() == $wgUser->getName() )
+ {
$this->allowBlankSummary = true;
} else {
- $this->allowBlankSummary = $request->getBool( 'wpIgnoreBlankSummary' );
+ $this->allowBlankSummary = $request->getBool( 'wpIgnoreBlankSummary' ) || !$wgUser->getOption( 'forceeditsummary');
}
$this->autoSumm = $request->getText( 'wpAutoSummary' );
@@ -646,17 +645,28 @@ class EditPage {
$this->watchthis = false;
$this->recreate = false;
- if( $this->section == 'new' && $request->getVal( 'preloadtitle' ) ) {
+ if ( $this->section == 'new' && $request->getVal( 'preloadtitle' ) ) {
$this->summary = $request->getVal( 'preloadtitle' );
}
+ elseif ( $this->section != 'new' && $request->getVal( 'summary' ) ) {
+ $this->summary = $request->getText( 'summary' );
+ }
+
+ if ( $request->getVal( 'minor' ) ) {
+ $this->minoredit = true;
+ }
}
+ // FIXME: unused variable?
$this->oldid = $request->getInt( 'oldid' );
$this->live = $request->getCheck( 'live' );
$this->editintro = $request->getText( 'editintro' );
wfProfileOut( $fname );
+
+ // Allow extensions to modify form data
+ wfRunHooks( 'EditPage::importFormData', array( &$this ) );
}
/**
@@ -679,30 +689,40 @@ class EditPage {
*/
protected function showIntro() {
global $wgOut, $wgUser;
- if( $this->suppressIntro ) {
+ if ( $this->suppressIntro ) {
return;
}
+
+ $namespace = $this->mTitle->getNamespace();
+
+ if ( $namespace == NS_MEDIAWIKI ) {
+ # Show a warning if editing an interface message
+ $wgOut->wrapWikiMsg( "
\n$1
", 'editinginterface' );
+ }
+
# Show a warning message when someone creates/edits a user (talk) page but the user does not exists
- if( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) {
+ if ( $namespace == NS_USER || $namespace == NS_USER_TALK ) {
$parts = explode( '/', $this->mTitle->getText(), 2 );
$username = $parts[0];
$id = User::idFromName( $username );
$ip = User::isIP( $username );
- if( $id == 0 && !$ip ) {
+ if ( $id == 0 && !$ip ) {
$wgOut->wrapWikiMsg( '
$1
',
array( 'userpage-userdoesnotexist', $username ) );
}
}
# Try to add a custom edit intro, or use the standard one if this is not possible.
- if( !$this->showCustomIntro() && !$this->mTitle->exists() ) {
- if( $wgUser->isLoggedIn() ) {
+ if ( !$this->showCustomIntro() && !$this->mTitle->exists() ) {
+ if ( $wgUser->isLoggedIn() ) {
$wgOut->wrapWikiMsg( '
",
+ 'deletedwhileediting' );
} else {
- // Hide the toolbar and edit area, use can click preview to get it back
+ // Hide the toolbar and edit area, user can click preview to get it back
// Add an confirmation checkbox and explanation.
$toolbar = '';
- $recreate = $wgOut->parse( wfMsg( 'confirmrecreate', $this->lastDelete->user_name , $this->lastDelete->log_comment ));
- $recreate .=
- " ".
- "";
+ $recreate = '