$undoafter = $wgRequest->getVal( 'undoafter' );
$undo = $wgRequest->getVal( 'undo' );
- $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() ) {
return $this->deletedSinceEdit;
}
+ /**
+ * Checks whether the user entered a skin name in uppercase,
+ * e.g. "User:Example/Monobook.css" instead of "monobook.css"
+ */
+ protected function isWrongCaseCssJsPage() {
+ if( $this->mTitle->isCssJsSubpage() ) {
+ $name = $this->mTitle->getSkinFromCssJsSubpage();
+ $skins = array_merge(
+ array_keys( Skin::getSkinNames() ),
+ array( 'common' )
+ );
+ return !in_array( $name, $skins )
+ && in_array( strtolower( $name ), $skins );
+ } else {
+ return false;
+ }
+ }
+
function submit() {
$this->edit();
}
$wgOut->addModules( 'mediawiki.legacy.edit' );
if ( $wgUser->getOption( 'uselivepreview', false ) ) {
- $wgOut->includeJQuery();
$wgOut->addModules( 'mediawiki.legacy.preview' );
}
$this->isCssJsSubpage = $this->mTitle->isCssJsSubpage();
$this->isCssSubpage = $this->mTitle->isCssSubpage();
$this->isJsSubpage = $this->mTitle->isJsSubpage();
- $this->isValidCssJsSubpage = $this->mTitle->isValidCssJsSubpage();
+ $this->isWrongCaseCssJsPage = $this->isWrongCaseCssJsPage();
# Show applicable editing introductions
if ( $this->formtype == 'initial' || $this->firsttime )
),
__METHOD__,
array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 50 ) );
- while( $row = $res->fetchObject() ) {
+ foreach ( $res as $row ) {
if( $row->rev_user != $id ) {
return false;
}
# Already watched
$this->watchthis = true;
}
+ if ( $wgUser->getOption( 'minordefault' ) ) $this->minoredit = true;
if ( $this->textbox1 === false ) return false;
wfProxyCheck();
return true;
# automatic one and pass that in the hidden field wpAutoSummary.
if ( $this->missingSummary ||
( $this->section == 'new' && $this->nosummary ) )
- $wgOut->addHTML( Xml::hidden( 'wpIgnoreBlankSummary', true ) );
+ $wgOut->addHTML( Html::hidden( 'wpIgnoreBlankSummary', true ) );
$autosumm = $this->autoSumm ? $this->autoSumm : md5( $this->summary );
- $wgOut->addHTML( Xml::hidden( 'wpAutoSummary', $autosumm ) );
+ $wgOut->addHTML( Html::hidden( 'wpAutoSummary', $autosumm ) );
- $wgOut->addHTML( Xml::hidden( 'oldid', $this->mArticle->getOldID() ) );
+ $wgOut->addHTML( Html::hidden( 'oldid', $this->mArticle->getOldID() ) );
if ( $this->section == 'new' ) {
$this->showSummaryInput( true, $this->summary );
} else {
if ( $this->isCssJsSubpage ) {
# Check the skin exists
- if ( !$this->isValidCssJsSubpage ) {
+ if ( $this->isWrongCaseCssJsPage ) {
$wgOut->wrapWikiMsg( "<div class='error' id='mw-userinvalidcssjstitle'>\n$1\n</div>", array( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() ) );
}
if ( $this->formtype !== 'preview' ) {
}
if ( $this->tooBig || $this->kblength > $wgMaxArticleSize ) {
- $wgOut->addHTML( "<div class='error' id='mw-edit-longpageerror'>\n" );
- $wgOut->addWikiMsg( 'longpageerror', $wgLang->formatNum( $this->kblength ), $wgLang->formatNum( $wgMaxArticleSize ) );
- $wgOut->addHTML( "</div>\n" );
- } elseif ( $this->kblength > 29 ) {
- $wgOut->addHTML( "<div id='mw-edit-longpagewarning'>\n" );
- $wgOut->addWikiMsg( 'longpagewarning', $wgLang->formatNum( $this->kblength ) );
- $wgOut->addHTML( "</div>\n" );
+ $wgOut->wrapWikiMsg( "<div class='error' id='mw-edit-longpageerror'>\n$1\n</div>",
+ array( 'longpageerror', $wgLang->formatNum( $this->kblength ), $wgLang->formatNum( $wgMaxArticleSize ) ) );
+ } else {
+ $msg = 'longpage-hint';
+ $text = wfMsg( $msg );
+ if( !wfEmptyMsg( $msg, $text ) && $text !== '-' ) {
+ $wgOut->wrapWikiMsg( "<div id='mw-edit-longpage-hint'>\n$1\n</div>",
+ array( 'longpage-hint', $wgLang->formatSize( strlen( $this->textbox1 ) ), strlen( $this->textbox1 ) )
+ );
+ }
}
}
HTML
);
if ( !$this->checkUnicodeCompliantBrowser() )
- $wgOut->addHTML(Xml::hidden( 'safemode', '1' ));
+ $wgOut->addHTML(Html::hidden( 'safemode', '1' ));
}
protected function showFormAfterText() {
* include the constant suffix to prevent editing from
* broken text-mangling proxies.
*/
- $wgOut->addHTML( "\n" . Xml::hidden( "wpEditToken", $wgUser->editToken() ) . "\n" );
+ $wgOut->addHTML( "\n" . Html::hidden( "wpEditToken", $wgUser->editToken() ) . "\n" );
}
/**
$parserOptions->setTidy( true );
$parserOutput = $wgParser->parse( $previewtext, $this->mTitle, $parserOptions );
$previewHTML = $parserOutput->mText;
- } elseif ( $rt = Title::newFromRedirectArray( $this->textbox1 ) ) {
- $previewHTML = $this->mArticle->viewRedirect( $rt, false );
} else {
- $toparse = $this->textbox1;
-
- # If we're adding a comment, we need to show the
- # summary as the headline
- if ( $this->section == "new" && $this->summary != "" ) {
- $toparse = "== {$this->summary} ==\n\n" . $toparse;
- }
+ $rt = Title::newFromRedirectArray( $this->textbox1 );
+ if ( $rt ) {
+ $previewHTML = $this->mArticle->viewRedirect( $rt, false );
+ } else {
+ $toparse = $this->textbox1;
- wfRunHooks( 'EditPageGetPreviewText', array( $this, &$toparse ) );
+ # If we're adding a comment, we need to show the
+ # summary as the headline
+ if ( $this->section == "new" && $this->summary != "" ) {
+ $toparse = "== {$this->summary} ==\n\n" . $toparse;
+ }
- // Parse mediawiki messages with correct target language
- if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
- list( /* $unused */, $lang ) = $wgMessageCache->figureMessage( $this->mTitle->getText() );
- $obj = wfGetLangObj( $lang );
- $parserOptions->setTargetLanguage( $obj );
- }
+ wfRunHooks( 'EditPageGetPreviewText', array( $this, &$toparse ) );
+ // Parse mediawiki messages with correct target language
+ if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
+ list( /* $unused */, $lang ) = $wgMessageCache->figureMessage( $this->mTitle->getText() );
+ $obj = wfGetLangObj( $lang );
+ $parserOptions->setTargetLanguage( $obj );
+ }
- $parserOptions->setTidy( true );
- $parserOptions->enableLimitReport();
- $parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $toparse ),
+ $parserOptions->setTidy( true );
+ $parserOptions->enableLimitReport();
+ $parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $toparse ),
$this->mTitle, $parserOptions );
- $previewHTML = $parserOutput->getText();
- $this->mParserOutput = $parserOutput;
- $wgOut->addParserOutputNoText( $parserOutput );
+ $previewHTML = $parserOutput->getText();
+ $this->mParserOutput = $parserOutput;
+ $wgOut->addParserOutputNoText( $parserOutput );
- if ( count( $parserOutput->getWarnings() ) ) {
- $note .= "\n\n" . implode( "\n\n", $parserOutput->getWarnings() );
+ if ( count( $parserOutput->getWarnings() ) ) {
+ $note .= "\n\n" . implode( "\n\n", $parserOutput->getWarnings() );
+ }
}
}
* Produce the stock "your edit contains spam" page
*
* @param $match Text which triggered one or more filters
+ * @deprecated Use method spamPageWithContent() instead
*/
static function spamPage( $match = false ) {
global $wgOut, $wgTitle;
$wgOut->returnToMain( false, $wgTitle );
}
+ /**
+ * Show "your edit contains spam" page with your diff and text
+ *
+ * @param $match Text which triggered one or more filters
+ */
+ public function spamPageWithContent( $match = false ) {
+ global $wgOut, $wgTitle;
+ $this->textbox2 = $this->textbox1;
+
+ $wgOut->setPageTitle( wfMsg( 'spamprotectiontitle' ) );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
+ $wgOut->setArticleRelated( false );
+
+ $wgOut->addHTML( '<div id="spamprotected">' );
+ $wgOut->addWikiMsg( 'spamprotectiontext' );
+ if ( $match ) {
+ $wgOut->addWikiMsg( 'spamprotectionmatch', wfEscapeWikiText( $match ) );
+ }
+ $wgOut->addHTML( '</div>' );
+
+ $wgOut->wrapWikiMsg( '<h2>$1</h2>', "yourdiff" );
+ $de = new DifferenceEngine( $this->mTitle );
+ $de->setText( $this->getContent(), $this->textbox2 );
+ $de->showDiff( wfMsg( "storedversion" ), wfMsg( "yourtext" ) );
+
+ $wgOut->wrapWikiMsg( '<h2>$1</h2>', "yourtext" );
+ $this->showTextbox2();
+
+ $wgOut->addReturnTo( $wgTitle, array( 'action' => 'edit' ) );
+ }
+
+
/**
* @private
* @todo document
$script = '';
foreach ( $toolarray as $tool ) {
- if ( !$tool ) continue;
+ if ( !$tool ) {
+ continue;
+ }
$params = array(
$image = $wgStylePath . '/common/images/' . $tool['image'],
);
$checkboxes['minor'] =
Xml::check( 'wpMinoredit', $checked['minor'], $attribs ) .
- " <label for='wpMinoredit' id='mw-editpage-minoredit'" . $skin->tooltip( 'minoredit', 'withaccess' ) . ">{$minorLabel}</label>";
+ " <label for='wpMinoredit' id='mw-editpage-minoredit'" . $skin->titleAttrib( 'minoredit', 'withaccess' ) . ">{$minorLabel}</label>";
}
$watchLabel = wfMsgExt( 'watchthis', array( 'parseinline' ) );
);
$checkboxes['watch'] =
Xml::check( 'wpWatchthis', $checked['watch'], $attribs ) .
- " <label for='wpWatchthis' id='mw-editpage-watch'" . $skin->tooltip( 'watch', 'withaccess' ) . ">{$watchLabel}</label>";
+ " <label for='wpWatchthis' id='mw-editpage-watch'" . $skin->titleAttrib( 'watch', 'withaccess' ) . ">{$watchLabel}</label>";
}
wfRunHooks( 'EditPageBeforeEditChecks', array( &$this, &$checkboxes, &$tabindex ) );
return $checkboxes;
*
* @return array
*/
- public function getEditButtons(&$tabindex) {
+ public function getEditButtons( &$tabindex ) {
$buttons = array();
$temp = array(
return false;
case self::AS_SPAM_ERROR:
- self::spamPage( $resultDetails['spam'] );
+ $this->spamPageWithContent( $resultDetails['spam'] );
return false;
case self::AS_BLOCKED_PAGE_FOR_USER: