const AS_NO_CREATE_PERMISSION = 223;
/**
- * Status: user tried to create a blank page
+ * Status: user tried to create a blank page and wpIgnoreBlankArticle == false
*/
const AS_BLANK_ARTICLE = 224;
/** @var bool */
protected $allowBlankSummary = false;
+ /** @var bool */
+ protected $blankArticle = false;
+
+ /** @var bool */
+ protected $allowBlankArticle = false;
+
/** @var string */
protected $autoSumm = '';
}
}
- /**
- * Show a read-only error
- * Parameters are the same as OutputPage:readOnlyPage()
- * Redirect to the article page if redlink=1
- * @deprecated since 1.19; use displayPermissionsError() instead
- */
- function readOnlyPage( $source = null, $protected = false, $reasons = array(), $action = null ) {
- wfDeprecated( __METHOD__, '1.19' );
-
- global $wgRequest, $wgOut;
- if ( $wgRequest->getBool( 'redlink' ) ) {
- // The edit page was reached via a red link.
- // Redirect to the article page and let them click the edit tab if
- // they really want a permission error.
- $wgOut->redirect( $this->mTitle->getFullURL() );
- } else {
- $wgOut->readOnlyPage( $source, $protected, $reasons, $action );
- }
- }
-
/**
* Should we show a preview when the edit form is first shown?
*
}
$this->autoSumm = $request->getText( 'wpAutoSummary' );
+
+ $this->allowBlankArticle = $request->getBool( 'wpIgnoreBlankArticle' );
} else {
# Not a posted form? Start with nothing.
wfDebug( __METHOD__ . ": Not a posted form.\n" );
return true;
}
- /**
- * Fetch initial editing page content.
- *
- * @param string|bool $def_text
- * @return string|bool String on success, $def_text for invalid sections
- * @private
- * @deprecated since 1.21, get WikiPage::getContent() instead.
- */
- function getContent( $def_text = false ) {
- ContentHandler::deprecated( __METHOD__, '1.21' );
-
- if ( $def_text !== null && $def_text !== false && $def_text !== '' ) {
- $def_content = $this->toEditContent( $def_text );
- } else {
- $def_content = false;
- }
-
- $content = $this->getContentObject( $def_content );
-
- // Note: EditPage should only be used with text based content anyway.
- return $this->toEditText( $content );
- }
-
/**
* @param Content|null $def_content The default value to return
*
}
}
- /**
- * Use this method before edit() to preload some text into the edit box
- *
- * @param string $text
- * @deprecated since 1.21, use setPreloadedContent() instead.
- */
- public function setPreloadedText( $text ) {
- ContentHandler::deprecated( __METHOD__, "1.21" );
-
- $content = $this->toEditContent( $text );
-
- $this->setPreloadedContent( $content );
- }
-
/**
* Use this method before edit() to preload some content into the edit box
*
$this->mPreloadContent = $content;
}
- /**
- * Get the contents to be preloaded into the box, either set by
- * an earlier setPreloadText() or by loading the given page.
- *
- * @param string $preload Representing the title to preload from.
- *
- * @return string
- *
- * @deprecated since 1.21, use getPreloadedContent() instead
- */
- protected function getPreloadedText( $preload ) {
- ContentHandler::deprecated( __METHOD__, "1.21" );
-
- $content = $this->getPreloadedContent( $preload );
- $text = $this->toEditText( $content );
-
- return $text;
- }
-
/**
* Get the contents to be preloaded into the box, either set by
* an earlier setPreloadText() or by loading the given page.
case self::AS_TEXTBOX_EMPTY:
case self::AS_MAX_ARTICLE_SIZE_EXCEEDED:
case self::AS_END:
+ case self::AS_BLANK_ARTICLE:
return true;
case self::AS_HOOK_ERROR:
$wgOut->redirect( $this->mTitle->getFullURL( $extraQuery ) . $sectionanchor );
return false;
- case self::AS_BLANK_ARTICLE:
- $wgOut->redirect( $this->getContextTitle()->getFullURL() );
- return false;
-
case self::AS_SPAM_ERROR:
$this->spamPageWithContent( $resultDetails['spam'] );
return false;
$cleanSummary = $wgParser->stripSectionName( $this->summary );
return wfMessage( 'newsectionsummary' )
->rawParams( $cleanSummary )->inContentLanguage()->text();
- } else {
- return $this->summary;
}
+ return $this->summary;
}
/**
$defaultText = '';
}
- if ( $this->textbox1 === $defaultText ) {
+ if ( !$this->allowBlankArticle && $this->textbox1 === $defaultText ) {
+ $this->blankArticle = true;
+ $status->fatal( 'blankarticle' );
$status->setResult( false, self::AS_BLANK_ARTICLE );
wfProfileOut( __METHOD__ );
return $status;
}
}
- /**
- * Attempts to merge text content with base and current revisions
- *
- * @param string $editText
- *
- * @return bool
- * @deprecated since 1.21, use mergeChangesIntoContent() instead
- */
- function mergeChangesInto( &$editText ) {
- ContentHandler::deprecated( __METHOD__, "1.21" );
-
- $editContent = $this->toEditContent( $editText );
-
- $ok = $this->mergeChangesIntoContent( $editContent );
-
- if ( $ok ) {
- $editText = $this->toEditText( $editContent );
- return true;
- }
- return false;
- }
-
/**
* Attempts to do 3-way merge of edit content with a base revision
* and current content, in case of edit conflict, in whichever way appropriate
$wgOut->addHTML( $this->editFormTextBeforeContent );
- if ( !$this->isCssJsSubpage && $showToolbar && $wgUser->getOption( 'showtoolbar' ) ) {
+ if ( $this->contentModel === CONTENT_MODEL_WIKITEXT &&
+ $showToolbar && $wgUser->getOption( 'showtoolbar' ) )
+ {
$wgOut->addHTML( EditPage::getEditToolbar() );
}
+ if ( $this->blankArticle ) {
+ $wgOut->addHTML( Html::hidden( 'wpIgnoreBlankArticle', true ) );
+ }
+
if ( $this->isConflict ) {
// In an edit conflict bypass the overridable content form method
// and fallback to the raw wpTextbox1 since editconflicts can't be
$wgOut->wrapWikiMsg( "<div id='mw-missingcommentheader'>\n$1\n</div>", 'missingcommentheader' );
}
+ if ( $this->blankArticle ) {
+ $wgOut->wrapWikiMsg( "<div id='mw-blankarticle'>\n$1\n</div>", 'blankarticle' );
+ }
+
if ( $this->hookError !== '' ) {
$wgOut->addWikiText( $this->hookError );
}
}
protected function showStandardInputs( &$tabindex = 2 ) {
- global $wgOut;
+ global $wgOut, $wgUseMediaWikiUIEverywhere;
$wgOut->addHTML( "<div class='editOptions'>\n" );
if ( $this->section != 'new' ) {
$message = wfMessage( 'edithelppage' )->inContentLanguage()->text();
$edithelpurl = Skin::makeInternalOrExternalUrl( $message );
- $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' .
- wfMessage( 'edithelp' )->escaped() . '</a> ' .
+ $attrs = array(
+ 'target' => 'helpwindow',
+ 'href' => $edithelpurl,
+ );
+ if ( $wgUseMediaWikiUIEverywhere ) {
+ $attrs['class'] = 'mw-ui-button mw-ui-quiet';
+ }
+ $edithelp = Html::element( 'a', $attrs, wfMessage( 'edithelp' )->text() ) .
wfMessage( 'newwindow' )->parse();
$wgOut->addHTML( " <span class='cancelLink'>{$cancel}</span>\n" );
* @return string
*/
public function getCancelLink() {
+ global $wgUseMediaWikiUIEverywhere;
$cancelParams = array();
if ( !$this->isConflict && $this->oldid > 0 ) {
$cancelParams['oldid'] = $this->oldid;
}
+ $attrs = array( 'id' => 'mw-editform-cancel' );
+ if ( $wgUseMediaWikiUIEverywhere ) {
+ $attrs['class'] = 'mw-ui-button mw-ui-quiet';
+ }
return Linker::linkKnown(
$this->getContextTitle(),
wfMessage( 'cancel' )->parse(),
- array( 'id' => 'mw-editform-cancel' ),
+ $attrs,
$cancelParams
);
}
/**
* Shows a bulletin board style toolbar for common editing functions.
* It can be disabled in the user preferences.
- * The necessary JavaScript code can be found in skins/common/edit.js.
*
* @return string
*/
* @return array
*/
public function getCheckboxes( &$tabindex, $checked ) {
- global $wgUser;
+ global $wgUser, $wgUseMediaWikiUIEverywhere;
$checkboxes = array();
'accesskey' => wfMessage( 'accesskey-minoredit' )->text(),
'id' => 'wpMinoredit',
);
- $checkboxes['minor'] =
+ $minorEditHtml =
Xml::check( 'wpMinoredit', $checked['minor'], $attribs ) .
" <label for='wpMinoredit' id='mw-editpage-minoredit'" .
Xml::expandAttributes( array( 'title' => Linker::titleAttrib( 'minoredit', 'withaccess' ) ) ) .
">{$minorLabel}</label>";
+
+ if ( $wgUseMediaWikiUIEverywhere ) {
+ $checkboxes['minor'] = Html::openElement( 'div', array( 'class' => 'mw-ui-checkbox' ) ) .
+ $minorEditHtml .
+ Html::closeElement( 'div' );
+ } else {
+ $checkboxes['minor'] = $minorEditHtml;
+ }
}
}
'accesskey' => wfMessage( 'accesskey-watch' )->text(),
'id' => 'wpWatchthis',
);
- $checkboxes['watch'] =
+ $watchThisHtml =
Xml::check( 'wpWatchthis', $checked['watch'], $attribs ) .
" <label for='wpWatchthis' id='mw-editpage-watch'" .
Xml::expandAttributes( array( 'title' => Linker::titleAttrib( 'watch', 'withaccess' ) ) ) .
">{$watchLabel}</label>";
+ if ( $wgUseMediaWikiUIEverywhere ) {
+ $checkboxes['watch'] = Html::openElement( 'div', array( 'class' => 'mw-ui-checkbox' ) ) .
+ $watchThisHtml .
+ Html::closeElement( 'div' );
+ } else {
+ $checkboxes['watch'] = $watchThisHtml;
+ }
}
wfRunHooks( 'EditPageBeforeEditChecks', array( &$this, &$checkboxes, &$tabindex ) );
return $checkboxes;
* @return array
*/
public function getEditButtons( &$tabindex ) {
+ global $wgUseMediaWikiUIEverywhere;
+
$buttons = array();
$attribs = array(
'tabindex' => ++$tabindex,
'value' => wfMessage( 'savearticle' )->text(),
) + Linker::tooltipAndAccesskeyAttribs( 'save' );
+ if ( $wgUseMediaWikiUIEverywhere ) {
+ $attribs['class'] = 'mw-ui-button mw-ui-constructive';
+ }
$buttons['save'] = Xml::element( 'input', $attribs, '' );
++$tabindex; // use the same for preview and live preview
'tabindex' => $tabindex,
'value' => wfMessage( 'showpreview' )->text(),
) + Linker::tooltipAndAccesskeyAttribs( 'preview' );
+ if ( $wgUseMediaWikiUIEverywhere ) {
+ $attribs['class'] = 'mw-ui-button mw-ui-progressive';
+ }
$buttons['preview'] = Xml::element( 'input', $attribs, '' );
$buttons['live'] = '';
'tabindex' => ++$tabindex,
'value' => wfMessage( 'showdiff' )->text(),
) + Linker::tooltipAndAccesskeyAttribs( 'diff' );
+ if ( $wgUseMediaWikiUIEverywhere ) {
+ $attribs['class'] = 'mw-ui-button mw-ui-progressive';
+ }
$buttons['diff'] = Xml::element( 'input', $attribs, '' );
wfRunHooks( 'EditPageBeforeEditButtons', array( &$this, &$buttons, &$tabindex ) );
echo $s;
}
- /**
- * Call the stock "user is blocked" page
- *
- * @deprecated since 1.19; throw an exception directly instead
- */
- function blockedPage() {
- wfDeprecated( __METHOD__, '1.19' );
- global $wgUser;
-
- throw new UserBlockedError( $wgUser->getBlock() );
- }
-
- /**
- * Produce the stock "please login to edit pages" page
- *
- * @deprecated since 1.19; throw an exception directly instead
- */
- function userNotLoggedInPage() {
- wfDeprecated( __METHOD__, '1.19' );
- throw new PermissionsError( 'edit' );
- }
-
- /**
- * Show an error page saying to the user that he has insufficient permissions
- * to create a new page
- *
- * @deprecated since 1.19; throw an exception directly instead
- */
- function noCreatePermission() {
- wfDeprecated( __METHOD__, '1.19' );
- $permission = $this->mTitle->isTalkPage() ? 'createtalk' : 'createpage';
- throw new PermissionsError( $permission );
- }
-
/**
* Creates a basic error page which informs the user that
* they have attempted to edit a nonexistent section.