* redirects go to, etc. $this->mTitle (as well as $mArticle) is the
* page in the database that is actually being edited. These are
* usually the same, but they are now allowed to be different.
+ *
+ * Surgeon General's Warning: prolonged exposure to this class is known to cause
+ * headaches, which may be fatal.
*/
class EditPage {
const AS_SUCCESS_UPDATE = 200;
$undotext = $this->mArticle->getUndoText( $undorev, $oldrev );
if ( $undotext === false ) {
# Warn the user that something went wrong
- $this->editFormPageTop .= $wgOut->parse( '<div class="error mw-undo-failure">' . wfMsgNoTrans( 'undo-failure' ) . '</div>' );
+ $this->editFormPageTop .= $wgOut->parse( '<div class="error mw-undo-failure">' .
+ wfMsgNoTrans( 'undo-failure' ) . '</div>', true, /* interface */true );
} else {
$text = $undotext;
# Inform the user of our success and set an automatic edit summary
- $this->editFormPageTop .= $wgOut->parse( '<div class="mw-undo-success">' . wfMsgNoTrans( 'undo-success' ) . '</div>' );
+ $this->editFormPageTop .= $wgOut->parse( '<div class="mw-undo-success">' .
+ wfMsgNoTrans( 'undo-success' ) . '</div>', true, /* interface */true );
$firstrev = $oldrev->getNext();
# If we just undid one rev, use an autosummary
if ( $firstrev->mId == $undo ) {
// 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( '<div class="error mw-undo-norev">' . wfMsgNoTrans( 'undo-norev' ) . '</div>' );
+ $this->editFormPageTop .= $wgOut->parse( '<div class="error mw-undo-norev">' .
+ wfMsgNoTrans( 'undo-norev' ) . '</div>', true, /* interface */true );
}
} elseif ( $section != '' ) {
if ( $section == 'new' ) {
$wgOut->addWikiText( $editnotice_base_msg->plain() );
}
}
+ } else {
+ # Even if there are no subpages in namespace, we still don't want / in MW ns.
+ $editnoticeText = $editnotice_ns . '-' . str_replace( '/', '-', $this->mTitle->getDBkey() );
+ $editnoticeMsg = wfMessage( $editnoticeText )->inContentLanguage();
+ if ( $editnoticeMsg->exists() ) {
+ $wgOut->addWikiText( $editnoticeMsg->plain() );
+ }
}
# Attempt submission here. This will check for edit conflicts,
LogEventsList::showLogExtract(
$wgOut,
'block',
- $user->getUserPage()->getPrefixedText(),
+ $user->getUserPage(),
'',
array(
'lim' => 1,
}
# Give a notice if the user is editing a deleted/moved page...
if ( !$this->mTitle->exists() ) {
- LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), $this->mTitle->getPrefixedText(),
+ LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), $this->mTitle,
'', array( 'lim' => 10,
'conds' => array( "log_action != 'revision'" ),
'showIfEmpty' => false,
function internalAttemptSave( &$result, $bot = false ) {
global $wgFilterCallback, $wgUser, $wgRequest, $wgParser;
global $wgMaxArticleSize;
-
+
$status = Status::newGood();
wfProfileIn( __METHOD__ );
$status->setResult( false, $code );
wfProfileOut( __METHOD__ . '-checks' );
-
wfProfileOut( __METHOD__ );
return $status;
wfProfileOut( __METHOD__ );
return $status;
}
+
if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) {
# Check block state against master, thus 'false'.
$status->setResult( false, self::AS_BLOCKED_PAGE_FOR_USER );
wfProfileOut( __METHOD__ );
return $status;
}
+
$this->kblength = (int)( strlen( $this->textbox1 ) / 1024 );
if ( $this->kblength > $wgMaxArticleSize ) {
// Error will be displayed by showEditForm()
{
if ( md5( $this->summary ) == $this->autoSumm ) {
$this->missingSummary = true;
+ $status->fatal( 'missingsummary' );
+ $status->value = self::AS_SUMMARY_NEEDED;
wfProfileOut( __METHOD__ );
- return self::AS_SUMMARY_NEEDED;
+ return $status;
}
}
* during form output near the top, for captchas and the like.
*/
function showEditForm( $formCallback = null ) {
- global $wgOut, $wgUser, $wgEnableInterwikiTranscluding, $wgEnableInterwikiTemplatesTracking;
+ global $wgOut, $wgUser;
wfProfileIn( __METHOD__ );
$toolbar = '';
}
+
$wgOut->addHTML( $this->editFormPageTop );
if ( $wgUser->getOption( 'previewontop' ) ) {
$templates = $this->getTemplates();
$formattedtemplates = Linker::formatTemplates( $templates, $this->preview, $this->section != '');
- $distantTemplates = $this->getDistantTemplates();
- $formattedDistantTemplates = Linker::formatDistantTemplates( $distantTemplates, $this->preview, $this->section != '' );
-
$hiddencats = $this->mArticle->getHiddenCategories();
$formattedhiddencats = Linker::formatHiddenCategories( $hiddencats );
<div class='templatesUsed'>
{$formattedtemplates}
</div>
-HTML
-);
-
- if ( $wgEnableInterwikiTranscluding && $wgEnableInterwikiTemplatesTracking ) {
- $wgOut->addHTML( <<<HTML
-{$this->editFormTextAfterTools}
-<div class='distantTemplatesUsed'>
-{$formattedDistantTemplates}
-</div>
-HTML
-);
- }
-
- $wgOut->addHTML( <<<HTML
-{$this->editFormTextAfterTools}
<div class='hiddencats'>
{$formattedhiddencats}
</div>
# Then it must be protected based on static groups (regular)
$noticeMsg = 'protectedpagewarning';
}
- LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle->getPrefixedText(), '',
+ LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle, '',
array( 'lim' => 1, 'msgKey' => array( $noticeMsg ) ) );
}
if ( $this->mTitle->isCascadeProtected() ) {
$wgOut->wrapWikiMsg( $notice, array( 'cascadeprotectedwarning', $cascadeSourcesCount ) );
}
if ( !$this->mTitle->exists() && $this->mTitle->getRestrictions( 'create' ) ) {
- LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle->getPrefixedText(), '',
+ LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle, '',
array( 'lim' => 1,
'showIfEmpty' => false,
'msgKey' => array( 'titleprotectedwarning' ),
// 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>" );
+ wfMsg( 'session_fail_preview_html' ) . "</div>", true, /* interface */true );
}
wfProfileOut( __METHOD__ );
return $parsedNote;
$previewhead = "<div class='previewnote'>\n" .
'<h2 id="mw-previewheader">' . htmlspecialchars( wfMsg( 'preview' ) ) . "</h2>" .
- $wgOut->parse( $note ) . $conflict . "</div>\n";
+ $wgOut->parse( $note, true, /* interface */true ) . $conflict . "</div>\n";
$pageLang = $this->mTitle->getPageLanguage();
$attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(),
}
}
- function getDistantTemplates() {
- global $wgEnableInterwikiTemplatesTracking;
- if ( !$wgEnableInterwikiTemplatesTracking ) {
- return array( );
- }
- if ( $this->preview || $this->section != '' ) {
- $templates = array();
- if ( !isset( $this->mParserOutput ) ) return $templates;
- $templatesList = $this->mParserOutput->getDistantTemplates();
- foreach( $templatesList as $prefix => $templatesbyns ) {
- foreach( $templatesbyns as $ns => $template ) {
- foreach( array_keys( $template ) as $dbk ) {
- $templates[] = Title::makeTitle( $ns, $dbk, null, $prefix );
- }
- }
- }
- return $templates;
- } else {
- return $this->mArticle->getUsedDistantTemplates();
- }
- }
-
/**
* Call the stock "user is blocked" page
*/
'key' => 'R'
)
);
- $toolbar = "<div id='toolbar'>\n";
$script = '';
foreach ( $toolarray as $tool ) {
$cssId = $tool['id'],
);
- $paramList = implode( ',',
- array_map( array( 'Xml', 'encodeJsVar' ), $params ) );
- $script .= "mw.toolbar.addButton($paramList);\n";
+ $script .= Xml::encodeJsCall( 'mw.toolbar.addButton', $params );
}
- $wgOut->addScript( Html::inlineScript(
- "if ( window.mediaWiki ) {{$script}}"
- ) );
+ $wgOut->addScript( Html::inlineScript( ResourceLoader::makeLoaderConditionalScript( $script ) ) );
- $toolbar .= "\n</div>";
+ $toolbar = '<div id="toolbar"></div>';
wfRunHooks( 'EditPageBeforeEditToolbar', array( &$toolbar ) );