X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FEditPage.php;h=6dbee6215393d5c4c69e6f0c6baa732305beb651;hb=a1961ff3e85298ba1de70fc9bbbfe09ea601e549;hp=4133c0fac23269871829cadb932b7c66b8b6b40d;hpb=02c8f58aa31b1dee6b02bb47482850a90b430012;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/EditPage.php b/includes/EditPage.php index 4133c0fac2..6dbee62153 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; @@ -104,6 +105,10 @@ class EditPage { $this->editFormTextAfterTools = $this->editFormTextBottom = ""; } + + function getArticle() { + return $this->mArticle; + } /** * Fetch initial editing page content. @@ -160,35 +165,28 @@ class EditPage { $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()); + $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' ) { @@ -326,7 +324,7 @@ class EditPage { protected function wasDeletedSinceLastEdit() { if ( $this->deletedSinceEdit ) return true; - if ( $this->mTitle->isDeleted() ) { + if ( $this->mTitle->isDeletedQuick() ) { $this->lastDelete = $this->getLastDelete(); if ( $this->lastDelete ) { $deleteTime = wfTimestamp( TS_MW, $this->lastDelete->log_timestamp ); @@ -375,18 +373,10 @@ class EditPage { 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' ); @@ -413,6 +403,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" ); @@ -431,7 +426,6 @@ class EditPage { # 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 ) ) ) { $wgOut->addWikiText( wfMsgForContent( $editnotice_ns ) ); } @@ -444,8 +438,6 @@ class EditPage { $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, @@ -533,7 +525,7 @@ class EditPage { } 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 ) { @@ -564,7 +556,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); @@ -578,7 +570,7 @@ class EditPage { # 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' ); @@ -648,6 +640,13 @@ class EditPage { 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; + } } $this->oldid = $request->getInt( 'oldid' ); @@ -681,8 +680,16 @@ class EditPage { 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 ); @@ -700,9 +707,9 @@ class EditPage { $wgOut->wrapWikiMsg( '
$1
', 'newarticletextanon' ); } } - # Give a notice if the user is editing a deleted page... + # Give a notice if the user is editing a deleted/moved page... if ( !$this->mTitle->exists() ) { - $this->showDeletionLog( $wgOut ); + $this->showLogs( $wgOut ); } } @@ -741,12 +748,12 @@ class EditPage { if ( !wfRunHooks( 'EditPage::attemptSave', array( &$this ) ) ) { - wfDebug( "Hook 'EditPage::attemptSave' aborted article saving" ); + wfDebug( "Hook 'EditPage::attemptSave' aborted article saving\n" ); return self::AS_HOOK_ERROR; } # Check image redirect - if ( $this->mTitle->getNamespace() == NS_IMAGE && + if ( $this->mTitle->getNamespace() == NS_FILE && Title::newFromRedirect( $this->textbox1 ) instanceof Title && !$wgUser->isAllowed( 'upload' ) ) { if ( $wgUser->isAnon() ) { @@ -761,7 +768,7 @@ class EditPage { $this->mMetaData = '' ; # Check for spam - $match = self::matchSpamRegex( $this->summary ); + $match = self::matchSummarySpamRegex( $this->summary ); if ( $match === false ) { $match = self::matchSpamRegex( $this->textbox1 ); } @@ -863,11 +870,20 @@ class EditPage { wfProfileOut( $fname ); return self::AS_HOOK_ERROR; } + + # Handle the user preference to force summaries here. Check if it's not a redirect. + if ( !$this->allowBlankSummary && !Title::newFromRedirect( $this->textbox1 ) ) { + if ( md5( $this->summary ) == $this->autoSumm ) { + $this->missingSummary = true; + wfProfileOut( $fname ); + return self::AS_SUMMARY_NEEDED; + } + } $isComment = ( $this->section == 'new' ); $this->mArticle->insertNewArticle( $this->textbox1, $this->summary, - $this->minoredit, $this->watchthis, false, $isComment, $bot); + $this->minoredit, $this->watchthis, false, $isComment, $bot ); wfProfileOut( $fname ); return self::AS_SUCCESS_NEW_ARTICLE; @@ -897,39 +913,35 @@ class EditPage { } } $userid = $wgUser->getId(); + + # Suppress edit conflict with self, except for section edits where merging is required. + if ( $this->isConflict && $this->section == '' && $this->userWasLastToEdit($userid,$this->edittime) ) { + wfDebug( "EditPage::editForm Suppressing edit conflict, same user.\n" ); + $this->isConflict = false; + } if ( $this->isConflict ) { wfDebug( "EditPage::editForm conflict! getting section '$this->section' for time '$this->edittime' (article time '" . $this->mArticle->getTimestamp() . "')\n" ); - $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary, $this->edittime); - } - else { + $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary, $this->edittime ); + } else { wfDebug( "EditPage::editForm getting section '$this->section'\n" ); - $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary); + $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary ); } if ( is_null( $text ) ) { wfDebug( "EditPage::editForm activating conflict; section replace failed.\n" ); $this->isConflict = true; - $text = $this->textbox1; - } - - # Suppress edit conflict with self, except for section edits where merging is required. - if ( ( $this->section == '' ) && ( 0 != $userid ) && ( $this->mArticle->getUser() == $userid ) ) { - wfDebug( "EditPage::editForm Suppressing edit conflict, same user.\n" ); - $this->isConflict = false; - } else { - # switch from section editing to normal editing in edit conflict - if ( $this->isConflict ) { - # Attempt merge - if ( $this->mergeChangesInto( $text ) ) { - // Successful merge! Maybe we should tell the user the good news? - $this->isConflict = false; - wfDebug( "EditPage::editForm Suppressing edit conflict, successful merge.\n" ); - } else { - $this->section = ''; - $this->textbox1 = $text; - wfDebug( "EditPage::editForm Keeping edit conflict, failed merge.\n" ); - } + $text = $this->textbox1; // do not try to merge here! + } else if ( $this->isConflict ) { + # Attempt merge + if ( $this->mergeChangesInto( $text ) ) { + // Successful merge! Maybe we should tell the user the good news? + $this->isConflict = false; + wfDebug( "EditPage::editForm Suppressing edit conflict, successful merge.\n" ); + } else { + $this->section = ''; + $this->textbox1 = $text; + wfDebug( "EditPage::editForm Keeping edit conflict, failed merge.\n" ); } } @@ -948,9 +960,9 @@ class EditPage { } # Handle the user preference to force summaries here, but not for null edits - if ( $this->section != 'new' && !$this->allowBlankSummary && 0 != strcmp($oldtext, $text) && - !is_object( Title::newFromRedirect( $text ) ) # check if it's not a redirect - ) { + if ( $this->section != 'new' && !$this->allowBlankSummary && 0 != strcmp($oldtext,$text) + && !Title::newFromRedirect( $text ) ) # check if it's not a redirect + { if ( md5( $this->summary ) == $this->autoSumm ) { $this->missingSummary = true; wfProfileOut( $fname ); @@ -1012,7 +1024,8 @@ class EditPage { # update the article here if ( $this->mArticle->updateArticle( $text, $this->summary, $this->minoredit, - $this->watchthis, $bot, $sectionanchor ) ) { + $this->watchthis, $bot, $sectionanchor ) ) + { wfProfileOut( $fname ); return self::AS_SUCCESS_UPDATE; } else { @@ -1022,20 +1035,56 @@ class EditPage { return self::AS_END; } + /** + * Check if no edits were made by other users since + * the time a user started editing the page. Limit to + * 50 revisions for the sake of performance. + */ + protected function userWasLastToEdit( $id, $edittime ) { + if( !$id ) return false; + $dbw = wfGetDB( DB_MASTER ); + $res = $dbw->select( 'revision', + 'rev_user', + array( + 'rev_page' => $this->mArticle->getId(), + 'rev_timestamp > '.$dbw->addQuotes( $dbw->timestamp($edittime) ) + ), + __METHOD__, + array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 50 ) ); + while( $row = $res->fetchObject() ) { + if( $row->rev_user != $id ) { + return false; + } + } + return true; + } + /** * Check given input text against $wgSpamRegex, and return the text of the first match. * @return mixed -- matching string or false */ public static function matchSpamRegex( $text ) { global $wgSpamRegex; - if ( $wgSpamRegex ) { - // For back compatibility, $wgSpamRegex may be a single string or an array of regexes. - $regexes = (array)$wgSpamRegex; - foreach( $regexes as $regex ) { - $matches = array(); - if ( preg_match( $regex, $text, $matches ) ) { - return $matches[0]; - } + // For back compatibility, $wgSpamRegex may be a single string or an array of regexes. + $regexes = (array)$wgSpamRegex; + return self::matchSpamRegexInternal( $text, $regexes ); + } + + /** + * Check given input text against $wgSpamRegex, and return the text of the first match. + * @return mixed -- matching string or false + */ + public static function matchSummarySpamRegex( $text ) { + global $wgSummarySpamRegex; + $regexes = (array)$wgSummarySpamRegex; + return self::matchSpamRegexInternal( $text, $regexes ); + } + + protected static function matchSpamRegexInternal( $text, $regexes ) { + foreach( $regexes as $regex ) { + $matches = array(); + if( preg_match( $regex, $text, $matches ) ) { + return $matches[0]; } } return false; @@ -1083,7 +1132,7 @@ class EditPage { * near the top, for captchas and the like. */ function showEditForm( $formCallback=null ) { - global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize, $wgTitle; + global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize, $wgTitle, $wgRequest; # If $wgTitle is null, that means we're in API mode. # Some hook probably called this function without checking @@ -1114,7 +1163,7 @@ class EditPage { $wgOut->setArticleRelated( true ); if ( $this->isConflict ) { - $wgOut->addWikiMsg( 'explainconflict' ); + $wgOut->wrapWikiMsg( "
\n$1
", 'explainconflict' ); $this->textbox2 = $this->textbox1; $this->textbox1 = $this->getContent(); @@ -1123,9 +1172,7 @@ class EditPage { if ( $this->section != '' && $this->section != 'new' ) { $matches = array(); if ( !$this->summary && !$this->preview && !$this->diff ) { - preg_match( "/^(=+)(.+)\\1/mi", - $this->textbox1, - $matches ); + preg_match( "/^(=+)(.+)\\1/mi", $this->textbox1, $matches ); if ( !empty( $matches[2] ) ) { global $wgParser; $this->summary = "/* " . @@ -1136,7 +1183,7 @@ class EditPage { } if ( $this->missingComment ) { - $wgOut->wrapWikiMsg( '
$1
', 'missingcommenttext' ); + $wgOut->wrapWikiMsg( '
$1
', 'missingcommenttext' ); } if ( $this->missingSummary && $this->section != 'new' ) { @@ -1158,9 +1205,9 @@ class EditPage { // Let sysop know that this will make private content public if saved if ( !$this->mArticle->mRevision->userCan( Revision::DELETED_TEXT ) ) { - $wgOut->addWikiMsg( 'rev-deleted-text-permission' ); + $wgOut->wrapWikiMsg( "\n", 'rev-deleted-text-permission' ); } else if ( $this->mArticle->mRevision->isDeleted( Revision::DELETED_TEXT ) ) { - $wgOut->addWikiMsg( 'rev-deleted-text-view' ); + $wgOut->wrapWikiMsg( "\n", 'rev-deleted-text-view' ); } if ( !$this->mArticle->mRevision->isCurrent() ) { @@ -1189,8 +1236,6 @@ class EditPage { $classes = array(); // Textarea CSS if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { - # Show a warning if editing an interface message - $wgOut->addWikiMsg( 'editinginterface' ); } elseif ( $this->mTitle->isProtected( 'edit' ) ) { # Is the title semi-protected? if ( $this->mTitle->isSemiProtected() ) { @@ -1209,24 +1254,26 @@ class EditPage { if ( $this->mTitle->isCascadeProtected() ) { # Is this page under cascading protection from some source pages? list($cascadeSources, /* $restrictions */) = $this->mTitle->getCascadeProtectionSources(); - $notice = "$1\n"; - if ( count($cascadeSources) > 0 ) { + $notice = "
$1\n"; + $cascadeSourcesCount = count( $cascadeSources ); + if ( $cascadeSourcesCount > 0 ) { # Explain, and list the titles responsible foreach( $cascadeSources as $page ) { $notice .= '* [[:' . $page->getPrefixedText() . "]]\n"; } } - $wgOut->wrapWikiMsg( $notice, array( 'cascadeprotectedwarning', count($cascadeSources) ) ); + $notice .= '
'; + $wgOut->wrapWikiMsg( $notice, array( 'cascadeprotectedwarning', $cascadeSourcesCount ) ); } if ( !$this->mTitle->exists() && $this->mTitle->getRestrictions( 'create' ) ) { - $wgOut->addWikiMsg( 'titleprotectedwarning' ); + $wgOut->wrapWikiMsg( '
$1
', 'titleprotectedwarning' ); } if ( $this->kblength === false ) { $this->kblength = (int)(strlen( $this->textbox1 ) / 1024); } if ( $this->tooBig || $this->kblength > $wgMaxArticleSize ) { - $wgOut->addHTML( "
\n" ); + $wgOut->addHTML( "
\n" ); $wgOut->addWikiMsg( 'longpageerror', $wgLang->formatNum( $this->kblength ), $wgLang->formatNum( $wgMaxArticleSize ) ); $wgOut->addHTML( "
\n" ); } elseif ( $this->kblength > 29 ) { @@ -1239,12 +1286,12 @@ class EditPage { #if ( "no" == $redirect ) { $q .= "&redirect=no"; } $action = $wgTitle->escapeLocalURL( $q ); - $colonSep = wfMsg( 'colon-separator' ); - $summary = wfMsg( 'summary' ) . $colonSep; - $subject = wfMsg( 'subject' ) . $colonSep; + $summary = wfMsg( 'summary' ); + $subject = wfMsg( 'subject' ); $cancel = $sk->makeKnownLink( $wgTitle->getPrefixedText(), wfMsgExt('cancel', array('parseinline')) ); + $separator = wfMsgExt( 'pipe-separator' , 'escapenoentities' ); $edithelpurl = Skin::makeInternalOrExternalUrl( wfMsgForContent( 'edithelppage' )); $edithelp = ''. htmlspecialchars( wfMsg( 'edithelp' ) ).' '. @@ -1280,6 +1327,11 @@ class EditPage { # Already watched $this->watchthis = true; } + + # May be overriden by request parameters + if( $wgRequest->getBool( 'watchthis' ) ) { + $this->watchthis = true; + } if ( $wgUser->getOption( 'minordefault' ) ) $this->minoredit = true; } @@ -1295,7 +1347,7 @@ class EditPage { # if this is a comment, show a subject line at the top, which is also the edit summary. # Otherwise, show a summary field at the bottom - $summarytext = htmlspecialchars( $wgContLang->recodeForEdit( $this->summary ) ); # FIXME + $summarytext = $wgContLang->recodeForEdit( $this->summary ); # If a blank edit summary was previously provided, and the appropriate # user preference is active, pass a hidden tag as wpIgnoreBlankSummary. This will stop the @@ -1309,18 +1361,66 @@ class EditPage { $autosumm = $this->autoSumm ? $this->autoSumm : md5( $this->summary ); $summaryhiddens .= Xml::hidden( 'wpAutoSummary', $autosumm ); if ( $this->section == 'new' ) { - $commentsubject="\n{$summaryhiddens}
"; + $commentsubject = ''; + if ( !$wgRequest->getBool( 'nosummary' ) ) { + # Add a class if 'missingsummary' is triggered to allow styling of the summary line + $summaryClass = $this->missingSummary ? 'mw-summarymissed' : 'mw-summary'; + + $commentsubject = + Xml::tags( 'label', array( 'for' => 'wpSummary' ), $subject ); + $commentsubject = + Xml::tags( 'span', array( 'class' => $summaryClass, 'id' => "wpSummaryLabel" ), + $commentsubject ); + $commentsubject .= ' '; + $commentsubject .= Xml::input( 'wpSummary', + 60, + $summarytext, + array( + 'id' => 'wpSummary', + 'maxlength' => '200', + 'tabindex' => '1' + ) ); + } $editsummary = "
\n"; global $wgParser; $formattedSummary = wfMsgForContent( 'newsectionsummary', $wgParser->stripSectionName( $this->summary ) ); - $subjectpreview = $summarytext && $this->preview ? "
".wfMsg('subject-preview').$colonSep.$sk->commentBlock( $formattedSummary, $this->mTitle, true )."
\n" : ''; + $subjectpreview = $summarytext && $this->preview ? "
". wfMsg('subject-preview') . $sk->commentBlock( $formattedSummary, $this->mTitle, true )."
\n" : ''; $summarypreview = ''; } else { $commentsubject = ''; - $editsummary="
\n\n{$summaryhiddens}
"; - $summarypreview = $summarytext && $this->preview ? "
".wfMsg('summary-preview').$colonSep.$sk->commentBlock( $this->summary, $this->mTitle )."
\n" : ''; + + # Add a class if 'missingsummary' is triggered to allow styling of the summary line + $summaryClass = $this->missingSummary ? 'mw-summarymissed' : 'mw-summary'; + + $editsummary = Xml::tags( 'label', array( 'for' => 'wpSummary' ), $summary ); + $editsummary = Xml::tags( 'span', array( 'class' => $summaryClass, 'id' => "wpSummaryLabel" ), + $editsummary ) . ' '; + + $editsummary .= Xml::input( 'wpSummary', + 60, + $summarytext, + array( + 'id' => 'wpSummary', + 'maxlength' => '200', + 'tabindex' => '1' + ) ); + + // No idea where this is closed. + $editsummary = Xml::openElement( 'div', array( 'class' => 'editOptions' ) ) + . $editsummary . '
'; + + $summarypreview = ''; + if ( $summarytext && $this->preview ) { + $summarypreview = + Xml::tags( 'div', + array( 'class' => 'mw-summary-preview' ), + wfMsg( 'summary-preview' ) . + $sk->commentBlock( $this->summary, $this->mTitle ) + ); + } $subjectpreview = ''; } + $commentsubject .= $summaryhiddens; # Set focus to the edit box on load, except on preview or diff, where it would interfere with the display if ( !$this->preview && !$this->diff ) { @@ -1350,21 +1450,24 @@ class EditPage { $recreate = ''; if ( $this->wasDeletedSinceLastEdit() ) { if ( 'save' != $this->formtype ) { - $wgOut->addWikiMsg('deletedwhileediting'); + $wgOut->wrapWikiMsg( + "
\n$1
", + '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 = '
' . + $wgOut->parse( wfMsg( 'confirmrecreate', $this->lastDelete->user_name , $this->lastDelete->log_comment ) ) . + Xml::checkLabel( wfMsg( 'recreate' ), 'wpRecreate', 'wpRecreate', false, + array( 'title' => $sk->titleAttrib( 'recreate' ), 'tabindex' => 1, 'id' => 'wpRecreate' ) + ) . '
'; } } $tabindex = 2; - $checkboxes = self::getCheckboxes( $tabindex, $sk, + $checkboxes = $this->getCheckboxes( $tabindex, $sk, array( 'minor' => $this->minoredit, 'watch' => $this->watchthis ) ); $checkboxhtml = implode( $checkboxes, "\n" ); @@ -1413,7 +1516,7 @@ END $wgOut->addHTML( "
{$buttonshtml} - {$cancel} | {$edithelp} + {$cancel}{$separator}{$edithelp}
"); @@ -1578,12 +1681,12 @@ END protected function showEditTools() { global $wgOut; - $wgOut->addHtml( '
' ); + $wgOut->addHTML( '
' ); $wgOut->addWikiMsgArray( 'edittools', array(), array( 'content' ) ); - $wgOut->addHtml( '
' ); + $wgOut->addHTML( '
' ); } - function getLastDelete() { + protected function getLastDelete() { $dbr = wfGetDB( DB_SLAVE ); $data = $dbr->selectRow( array( 'logging', 'user' ), @@ -1595,15 +1698,23 @@ END 'log_title', 'log_comment', 'log_params', - 'user_name', ), + 'log_deleted', + 'user_name' ), array( 'log_namespace' => $this->mTitle->getNamespace(), 'log_title' => $this->mTitle->getDBkey(), 'log_type' => 'delete', 'log_action' => 'delete', 'user_id=log_user' ), __METHOD__, - array( 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' ) ); - + array( 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' ) + ); + // Quick paranoid permission checks... + if( is_object($data) ) { + if( $data->log_deleted & LogPage::DELETED_USER ) + $data->user_name = wfMsgHtml('rev-deleted-user'); + if( $data->log_deleted & LogPage::DELETED_COMMENT ) + $data->log_comment = wfMsgHtml('rev-deleted-comment'); + } return $data; } @@ -1612,7 +1723,7 @@ END * @return string */ function getPreviewText() { - global $wgOut, $wgUser, $wgTitle, $wgParser, $wgLang, $wgContLang; + global $wgOut, $wgUser, $wgTitle, $wgParser, $wgLang, $wgContLang, $wgMessageCache; wfProfileIn( __METHOD__ ); @@ -1628,6 +1739,8 @@ END $parserOptions = ParserOptions::newFromUser( $wgUser ); $parserOptions->setEditSection( false ); + $parserOptions->setIsPreview( true ); + $parserOptions->setIsSectionPreview( !is_null($this->section) && $this->section !== '' ); global $wgRawHtml; if ( $wgRawHtml && !$this->mTokenOk ) { @@ -1649,7 +1762,7 @@ END $parserOptions->setTidy(true); $parserOutput = $wgParser->parse( $previewtext, $this->mTitle, $parserOptions ); $previewHTML = $parserOutput->mText; - } elseif ( $rt = Title::newFromRedirect( $this->textbox1 ) ) { + } elseif ( $rt = Title::newFromRedirectArray( $this->textbox1 ) ) { $previewHTML = $this->mArticle->viewRedirect( $rt, false ); } else { $toparse = $this->textbox1; @@ -1664,19 +1777,9 @@ END // Parse mediawiki messages with correct target language if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { - $pos = strrpos( $this->mTitle->getText(), '/' ); - if ( $pos !== false ) { - $code = substr( $this->mTitle->getText(), $pos+1 ); - switch ($code) { - case $wgLang->getCode(): - $obj = $wgLang; break; - case $wgContLang->getCode(): - $obj = $wgContLang; break; - default: - $obj = Language::factory( $code ); - } - $parserOptions->setTargetLanguage( $obj ); - } + list( /* $unused */, $lang ) = $wgMessageCache->figureMessage( $this->mTitle->getText() ); + $obj = wfGetLangObj( $lang ); + $parserOptions->setTargetLanguage( $obj ); } @@ -1740,11 +1843,11 @@ END $rows = $wgUser->getIntOption( 'rows' ); $cols = $wgUser->getIntOption( 'cols' ); $attribs = array( 'id' => 'wpTextbox1', 'name' => 'wpTextbox1', 'cols' => $cols, 'rows' => $rows, 'readonly' => 'readonly' ); - $wgOut->addHtml( '
' ); + $wgOut->addHTML( '
' ); $wgOut->addWikiMsg( $first ? 'blockedoriginalsource' : 'blockededitsource', $this->mTitle->getPrefixedText() ); # Why we don't use Xml::element here? # Is it because if $source is '', it returns