// was created, or we may simply have got bogus input.
$this->editFormPageTop .= $wgOut->parse( '<div class="error mw-undo-norev">' . wfMsgNoTrans( 'undo-norev' ) . '</div>' );
}
- } else if ( $section != '' ) {
+ } elseif ( $section != '' ) {
if ( $section == 'new' ) {
$text = $this->getPreloadedText( $preload );
} else {
} else {
if ( $this->save ) {
$this->formtype = 'save';
- } else if ( $this->preview ) {
+ } elseif ( $this->preview ) {
$this->formtype = 'preview';
- } else if ( $this->diff ) {
+ } elseif ( $this->diff ) {
$this->formtype = 'diff';
} else { # First time through
$this->firsttime = true;
} 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' ) !== null || $this->mTitle->exists() ) && $wgUser->getOption( 'previewonfirst' ) ) {
# The unmarked state will be assumed to be a save,
# if the form seems otherwise complete.
wfDebug( __METHOD__ . ": Passed token check.\n" );
- } else if ( $this->diff ) {
+ } elseif ( $this->diff ) {
# Failed token check, but only requested "Show Changes".
wfDebug( __METHOD__ . ": Failed token check; Show Changes requested.\n" );
} else {
$ip = User::isIP( $username );
if ( !$user->isLoggedIn() && !$ip ) { # User does not exist
$wgOut->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>",
- array( 'userpage-userdoesnotexist', $username ) );
- } else if ( $user->isBlocked() ) { # Show log extract if the user is currently blocked
+ array( 'userpage-userdoesnotexist', wfEscapeWikiText( $username ) ) );
+ } elseif ( $user->isBlocked() ) { # Show log extract if the user is currently blocked
LogEventsList::showLogExtract(
$wgOut,
'block',
}
$text = $this->textbox1;
- if ( $this->section == 'new' && $this->summary != '' ) {
+ if ( $this->section == 'new' && $this->summary != '' ) {
$text = wfMsgForContent( 'newsectionheaderdefaultlevel', $this->summary ) . "\n\n" . $text;
}
wfDebug( __METHOD__ . ": activating conflict; section replace failed.\n" );
$this->isConflict = true;
$text = $this->textbox1; // do not try to merge here!
- } else if ( $this->isConflict ) {
+ } elseif ( $this->isConflict ) {
# Attempt merge
if ( $this->mergeChangesInto( $text ) ) {
// Successful merge! Maybe we should tell the user the good news?
}
# Handle the user preference to force summaries here, but not for null edits
- if ( $this->section != 'new' && !$this->allowBlankSummary && 0 != strcmp( $oldtext, $text )
+ 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 ) {
}
# And a similar thing for new sections
- if ( $this->section == 'new' && !$this->allowBlankSummary ) {
+ if ( $this->section == 'new' && !$this->allowBlankSummary ) {
if ( trim( $this->summary ) == '' ) {
$this->missingSummary = true;
wfProfileOut( __METHOD__ );
# All's well
wfProfileIn( __METHOD__ . '-sectionanchor' );
$sectionanchor = '';
- if ( $this->section == 'new' ) {
+ if ( $this->section == 'new' ) {
if ( $this->textbox1 == '' ) {
$this->missingComment = true;
wfProfileOut( __METHOD__ . '-sectionanchor' );
$previewOutput = $this->getPreviewText();
}
- wfRunHooks( 'EditPage::showEditForm:initial', array( &$this ) );
+ wfRunHooks( 'EditPage::showEditForm:initial', array( &$this, &$formCallback ) );
$this->setHeaders();
}
$wgOut->addHTML( $this->editFormTextBeforeContent );
-
+
$wgOut->addHTML( $toolbar );
if ( $this->isConflict ) {
if ( !$this->mArticle->mRevision->userCan( Revision::DELETED_TEXT ) ) {
$wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-permission' );
- } else if ( $this->mArticle->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
+ } elseif ( $this->mArticle->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
$wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-view' );
}
* @return array An array in the format array( $label, $input )
*/
function getSummaryInput($summary = "", $labelText = null, $inputAttrs = null, $spanLabelAttrs = null) {
- global $wgUser;
//Note: the maxlength is overriden in JS to 250 and to make it use UTF-8 bytes, not characters.
$inputAttrs = ( is_array($inputAttrs) ? $inputAttrs : array() ) + array(
'id' => 'wpSummary',
'tabindex' => '1',
'size' => 60,
'spellcheck' => 'true',
- ) + $wgUser->getSkin()->tooltipAndAccessKeyAttribs( 'summary' );
+ ) + Linker::tooltipAndAccesskeyAttribs( 'summary' );
$spanLabelAttrs = ( is_array($spanLabelAttrs) ? $spanLabelAttrs : array() ) + array(
'class' => $this->missingSummary ? 'mw-summarymissed' : 'mw-summary',
'style' => '' // avoid php notices when appending preferences (appending allows customAttribs['style'] to still work
);
+ $pageLang = $this->mTitle->getPageLanguage();
+ $attribs['lang'] = $pageLang->getCode();
+ $attribs['dir'] = $pageLang->getDir();
+
$wgOut->addHTML( Html::textarea( $name, $wikitext, $attribs ) );
}
$wgOut->addHTML( implode( $this->getEditButtons( $tabindex ), "\n" ) . "\n" );
$cancel = $this->getCancelLink();
- $separator = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
+ if ( $cancel !== '' ) {
+ $cancel .= wfMsgExt( 'pipe-separator' , 'escapenoentities' );
+ }
$edithelpurl = Skin::makeInternalOrExternalUrl( wfMsgForContent( 'edithelppage' ) );
$edithelp = '<a target="helpwindow" href="'.$edithelpurl.'">'.
htmlspecialchars( wfMsg( 'edithelp' ) ).'</a> '.
htmlspecialchars( wfMsg( 'newwindow' ) );
- $wgOut->addHTML( " <span class='editHelp'>{$cancel}{$separator}{$edithelp}</span>\n" );
+ $wgOut->addHTML( " <span class='editHelp'>{$cancel}{$edithelp}</span>\n" );
$wgOut->addHTML( "</div><!-- editButtons -->\n</div><!-- editOptions -->\n" );
}
} else {
$note = wfMsg( 'session_fail_preview' );
}
- } else if ( $this->incompleteForm ) {
+ } elseif ( $this->incompleteForm ) {
$note = wfMsg( 'edit_form_incomplete' );
} else {
$note = wfMsg( 'previewnote' );
if ( $wgRawHtml && !$this->mTokenOk ) {
// Could be an offsite preview attempt. This is very unsafe if
// HTML is enabled, as it could be an attack.
- $parsedNote = $wgOut->parse( "<div class='previewnote'>" .
- wfMsg( 'session_fail_preview_html' ) . "</div>" );
+ $parsedNote = '';
+ if ( $this->textbox1 !== '' ) {
+ // Do not put big scary notice, if previewing the empty
+ // string, which happens when you initially edit
+ // a category page, due to automatic preview-on-open.
+ $parsedNote = $wgOut->parse( "<div class='previewnote'>" .
+ wfMsg( 'session_fail_preview_html' ) . "</div>" );
+ }
wfProfileOut( __METHOD__ );
return $parsedNote;
}
wfRunHooks( 'EditPageGetPreviewText', array( $this, &$toparse ) );
- // Parse mediawiki messages with correct target language
- if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
- list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $this->mTitle->getText() );
- $obj = wfGetLangObj( $lang );
- $parserOptions->setTargetLanguage( $obj );
- }
-
$parserOptions->setTidy( true );
$parserOptions->enableLimitReport();
$parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $toparse ),
'<h2 id="mw-previewheader">' . htmlspecialchars( wfMsg( 'preview' ) ) . "</h2>" .
$wgOut->parse( $note ) . $conflict . "</div>\n";
+ $pageLang = $this->mTitle->getPageLanguage();
+ $attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(),
+ 'class' => 'mw-content-'.$pageLang->getDir() );
+ $previewHTML = Html::rawElement( 'div', $attribs, $previewHTML );
+
wfProfileOut( __METHOD__ );
return $previewhead . $previewHTML . $this->previewTextAfterContent;
}