$undorev = Revision::newFromId($undo);
$oldrev = $undorev ? $undorev->getPrevious() : null;
}
-
+
#Sanity check, make sure it's the right page.
# Otherwise, $text will be left as-is.
if ( !is_null($undorev) && !is_null($oldrev) && $undorev->getPage()==$oldrev->getPage() && $undorev->getPage()==$this->mArticle->getID() ) {
$undorev_text = $undorev->getText();
- $oldrev_text = $oldrev->getText();
- $currev_text = $text;
+ $oldrev_text = $oldrev->getText();
+ $currev_text = $text;
#No use doing a merge if it's just a straight revert.
if ( $currev_text != $undorev_text ) {
global $wgOut, $wgUser, $wgRequest, $wgTitle;
global $wgEmailConfirmToEdit;
- if ( ! wfRunHooks( 'AlternateEdit', array( &$this ) ) )
+ if ( ! wfRunHooks( 'AlternateEdit', array( &$this ) ) )
return;
$fname = 'EditPage::edit';
$wgOut->addWikiText( wfMsg( 'newarticletext' ) );
else
$wgOut->addWikiText( wfMsg( 'newarticletextanon' ) );
+ # Let the user know about previous deletions if applicable
+ $this->showDeletionLog( $wgOut );
}
}
}
#And a similar thing for new sections
- if( $this->section == 'new' && !$this->allowBlankSummary && $wgUser->getOption( 'forceeditsummary' ) ) {
+ if( $this->section == 'new' && !$this->allowBlankSummary && $wgUser->getOption( 'forceeditsummary' ) ) {
if (trim($this->summary) == '') {
$this->missingSummary = true;
wfProfileOut( $fname );
$this->summary = '';
$this->textbox1 = $this->getContent(false);
if ($this->textbox1 === false) return false;
-
+
if ( !$this->mArticle->exists() && $this->mArticle->mTitle->getNamespace() == NS_MEDIAWIKI )
$this->textbox1 = wfMsgWeirdKey( $this->mArticle->mTitle->getText() );
wfProxyCheck();
$wgOut->addWikiText( wfMsg( 'missingsummary' ) );
}
- if( $this->missingSummary && $this->section == 'new' ) {
- $wgOut->addWikiText( wfMsg( 'missingcommentheader' ) );
- }
+ if( $this->missingSummary && $this->section == 'new' ) {
+ $wgOut->addWikiText( wfMsg( 'missingcommentheader' ) );
+ }
if( !$this->hookError == '' ) {
$wgOut->addWikiText( $this->hookError );
if( wfEmptyMsg( 'semiprotectedpagewarning', $notice ) || $notice == '-' )
$notice = '';
} else {
- # It's either cascading protection or regular protection; work out which
- list($cascadeSources, $restrictions) = $this->mTitle->getCascadeProtectionSources();
- if ( !$cascadeSources || count( $cascadeSources ) == 0 ) {
- # Regular protection
- $notice = wfMsg( 'protectedpagewarning' );
- } else {
- # Cascading protection; explain, and list the titles responsible
- $notice = wfMsg( 'cascadeprotectedwarning' ) . "\n";
- foreach( $cascadeSources as $source )
- $notice .= '* [[:' . $source->getPrefixedText() . "]]\n";
- }
+ # Then it must be protected based on static groups (regular)
+ $notice = wfMsg( 'protectedpagewarning' );
}
$wgOut->addWikiText( $notice );
}
+ if ( $this->mTitle->isCascadeProtected() ) {
+ # Is this page under cascading protection from some source pages?
+ list($cascadeSources, /* $restrictions */) = $this->mTitle->getCascadeProtectionSources();
+ if ( count($cascadeSources) > 0 ) {
+ # Explain, and list the titles responsible
+ $notice = wfMsgExt( 'cascadeprotectedwarning', array('parsemag'), count($cascadeSources) ) . "\n";
+ foreach( $cascadeSources as $id => $page )
+ $notice .= '* [[:' . $page->getPrefixedText() . "]]\n";
+ }
+ $wgOut->addWikiText( $notice );
+ }
if ( $this->kblength === false ) {
$this->kblength = (int)(strlen( $this->textbox1 ) / 1024);
}
if ( 'diff' == $this->formtype ) {
+ $wgOut->addStyle( 'common/diff.css' );
$wgOut->addHTML( $this->getDiff() );
}
}
if( !$this->preview && !$this->diff ) {
$wgOut->setOnloadHandler( 'document.editform.wpTextbox1.focus()' );
}
- $templates = ($this->preview || $this->section) ? $this->mPreviewTemplates : $this->mArticle->getUsedTemplates();
+ $templates = ($this->preview || $this->section != '') ? $this->mPreviewTemplates : $this->mArticle->getUsedTemplates();
$formattedtemplates = $sk->formatTemplates( $templates, $this->preview, $this->section != '');
global $wgUseMetadataEdit ;
}
if ( $this->formtype == 'diff') {
+ $wgOut->addStyle( 'common/diff.css' );
$wgOut->addHTML( $this->getDiff() );
}
$wgOut->setArticleRelated( false );
$wgOut->addWikiText( wfMsg( 'nosuchsectiontext', $this->section ) );
- $wgOut->returnToMain( false );
+ $wgOut->returnToMain( false, $this->mTitle->getPrefixedUrl() );
}
/**
$wgOut->setPageTitle( wfMsg( 'nocreatetitle' ) );
$wgOut->addWikiText( wfMsg( 'nocreatetext' ) );
}
+
+ /**
+ * If there are rows in the deletion log for this page, show them,
+ * along with a nice little note for the user
+ *
+ * @param OutputPage $out
+ */
+ private function showDeletionLog( $out ) {
+ $title = $this->mArticle->getTitle();
+ $reader = new LogReader(
+ new FauxRequest(
+ array(
+ 'page' => $title->getPrefixedText(),
+ 'type' => 'delete',
+ )
+ )
+ );
+ if( $reader->hasRows() ) {
+ $out->addHtml( '<div id="mw-recreate-deleted-warn">' );
+ $out->addHtml( $this->buildWarningDismisser() );
+ $out->addWikiText( wfMsg( 'recreate-deleted-warn' ) );
+ $viewer = new LogViewer( $reader );
+ $viewer->showList( $out );
+ $out->addHtml( '</div>' );
+ }
+ }
+
+ /**
+ * Builds a JavaScript fragment that injects a link to dismiss the
+ * "recreating deleted" warning
+ *
+ * @return string
+ */
+ private function buildWarningDismisser() {
+ return '<script type="text/javascript">'
+ . 'document.write( \'<div class="mw-recreate-deleted-control">'
+ . '<a href="javascript:dismissRecreateWarning();">'
+ . wfMsgHtml( 'recreate-deleted-dismiss' ) . '</a></div>\' );'
+ . '</script>';
+ }
}