* interfaces.
*
* EditPage cares about two distinct titles:
- * $wgTitle is the page that forms submit to, links point to,
+ * $this->mContextTitle is the page that forms submit to, links point to,
* 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.
const AS_IMAGE_REDIRECT_ANON = 233;
const AS_IMAGE_REDIRECT_LOGGED = 234;
+ /**
+ * @var Article
+ */
var $mArticle;
+
+ /**
+ * @var Title
+ */
var $mTitle;
+ private $mContextTitle = null;
var $action;
var $isConflict = false;
var $isCssJsSubpage = false;
var $mTokenOk = false;
var $mTokenOkExceptSuffix = false;
var $mTriedSave = false;
+ var $incompleteForm = false;
var $tooBig = false;
var $kblength = false;
var $missingComment = false;
return $this->mArticle;
}
+ /**
+ * Set the context Title object
+ *
+ * @param $title Title object or null
+ */
+ public function setContextTitle( $title ) {
+ $this->mContextTitle = $title;
+ }
+
+ /**
+ * Get the context title object.
+ * If not set, $wgTitle will be returned. This behavior might changed in
+ * the future to return $this->mTitle instead.
+ *
+ * @return Title object
+ */
+ public function getContextTitle() {
+ if ( is_null( $this->mContextTitle ) ) {
+ global $wgTitle;
+ return $wgTitle;
+ } else {
+ return $this->mContextTitle;
+ }
+ }
/**
* Fetch initial editing page content.
if ( $wgUser->getOption( 'uselivepreview', false ) ) {
$wgOut->addModules( 'mediawiki.legacy.preview' );
}
+ // Bug #19334: textarea jumps when editing articles in IE8
+ $wgOut->addStyle( 'common/IE80Fixes.css', 'screen', 'IE 8' );
$permErrors = $this->getEditPermissionErrors();
if ( $permErrors ) {
$this->scrolltop = $request->getIntOrNull( 'wpScrolltop' );
- if ( is_null( $this->edittime ) ) {
+ if ($this->textbox1 === '' && $request->getVal( 'wpTextbox1' ) === null) {
+ // wpTextbox1 field is missing, possibly due to being "too big"
+ // according to some filter rules such as Suhosin's setting for
+ // suhosin.request.max_value_length (d'oh)
+ $this->incompleteForm = true;
+ } else {
+ // edittime should be one of our last fields; if it's missing,
+ // the submission probably broke somewhere in the middle.
+ $this->incompleteForm = is_null( $this->edittime );
+ }
+ if ( $this->incompleteForm ) {
# If the form is incomplete, force to preview.
wfDebug( __METHOD__ . ": Form data appears to be incomplete\n" );
wfDebug( "POST DATA: " . var_export( $_POST, true ) . "\n" );
// Custom edit intro for new sections
$this->section === 'new' ? 'MediaWiki:addsection-editintro' : '' );
- wfProfileOut( __METHOD__ );
-
// Allow extensions to modify form data
wfRunHooks( 'EditPage::importFormData', array( $this, $request ) );
+
+ wfProfileOut( __METHOD__ );
}
/**
}
function setHeaders() {
- global $wgOut, $wgTitle;
+ global $wgOut;
$wgOut->setRobotPolicy( 'noindex,nofollow' );
if ( $this->formtype == 'preview' ) {
$wgOut->setPageTitleActionText( wfMsg( 'preview' ) );
}
if ( $this->isConflict ) {
- $wgOut->setPageTitle( wfMsg( 'editconflict', $wgTitle->getPrefixedText() ) );
+ $wgOut->setPageTitle( wfMsg( 'editconflict', $this->getContextTitle()->getPrefixedText() ) );
} elseif ( $this->section != '' ) {
$msg = $this->section == 'new' ? 'editingcomment' : 'editingsection';
- $wgOut->setPageTitle( wfMsg( $msg, $wgTitle->getPrefixedText() ) );
+ $wgOut->setPageTitle( wfMsg( $msg, $this->getContextTitle()->getPrefixedText() ) );
} else {
# Use the title defined by DISPLAYTITLE magic word when present
if ( isset( $this->mParserOutput )
&& ( $dt = $this->mParserOutput->getDisplayTitle() ) !== false ) {
$title = $dt;
} else {
- $title = $wgTitle->getPrefixedText();
+ $title = $this->getContextTitle()->getPrefixedText();
}
$wgOut->setPageTitle( wfMsg( 'editing', $title ) );
}
* near the top, for captchas and the like.
*/
function showEditForm( $formCallback = null ) {
- global $wgOut, $wgUser, $wgTitle;
-
- # If $wgTitle is null, that means we're in API mode.
- # Some hook probably called this function without checking
- # for is_null($wgTitle) first. Bail out right here so we don't
- # do lots of work just to discard it right after.
- if ( is_null( $wgTitle ) )
- return;
+ global $wgOut, $wgUser;
wfProfileIn( __METHOD__ );
return;
}
- $action = htmlspecialchars( $this->getActionURL( $wgTitle ) );
+ $action = htmlspecialchars( $this->getActionURL( $this->getContextTitle() ) );
if ( $wgUser->getOption( 'showtoolbar' ) and !$this->isCssJsSubpage ) {
# prepare toolbar for edit buttons
if ( $this->wasDeletedSinceLastEdit() && 'save' == $this->formtype ) {
$username = $this->lastDelete->user_name;
$comment = $this->lastDelete->log_comment;
-
+
// It is better to not parse the comment at all than to have templates expanded in the middle
// TODO: can the checkLabel be moved outside of the div so that wrapWikiMsg could be used?
+ $key = $comment === ''
+ ? 'confirmrecreate-noreason'
+ : 'confirmrecreate';
$wgOut->addHTML(
'<div class="mw-confirm-recreate">' .
- wfMsgExt( 'confirmrecreate', 'parseinline', $username, "<nowiki>$comment</nowiki>" ) .
+ wfMsgExt( $key, 'parseinline', $username, "<nowiki>$comment</nowiki>" ) .
Xml::checkLabel( wfMsg( 'recreate' ), 'wpRecreate', 'wpRecreate', false,
array( 'title' => $sk->titleAttrib( 'recreate' ), 'tabindex' => 1, 'id' => 'wpRecreate' )
) .
}
protected function showHeader() {
- global $wgOut, $wgUser, $wgTitle, $wgMaxArticleSize, $wgLang;
+ global $wgOut, $wgUser, $wgMaxArticleSize, $wgLang;
if ( $this->isConflict ) {
$wgOut->wrapWikiMsg( "<div class='mw-explainconflict'>\n$1\n</div>", 'explainconflict' );
$this->edittime = $this->mArticle->getTimestamp();
if ( $this->isCssJsSubpage ) {
# Check the skin exists
if ( $this->isWrongCaseCssJsPage ) {
- $wgOut->wrapWikiMsg( "<div class='error' id='mw-userinvalidcssjstitle'>\n$1\n</div>", array( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() ) );
+ $wgOut->wrapWikiMsg( "<div class='error' id='mw-userinvalidcssjstitle'>\n$1\n</div>", array( 'userinvalidcssjstitle', $this->getContextTitle()->getSkinFromCssJsSubpage() ) );
}
if ( $this->formtype !== 'preview' ) {
if ( $this->isCssSubpage )
// Allow for site and per-namespace customization of contribution/copyright notice.
wfRunHooks( 'EditPageCopyrightWarning', array( $this->mTitle, &$copywarnMsg ) );
- return "<div id=\"editpage-copywarn\">\n" . call_user_func_array("wfMsgNoTrans", $copywarnMsg) . "\n</div>";
+ return "<div id=\"editpage-copywarn\">\n" .
+ call_user_func_array("wfMsgNoTrans", $copywarnMsg) . "\n</div>";
}
protected function showStandardInputs( &$tabindex = 2 ) {
$data = $dbr->selectRow(
array( 'logging', 'user' ),
array( 'log_type',
- 'log_action',
- 'log_timestamp',
- 'log_user',
- 'log_namespace',
- 'log_title',
- 'log_comment',
- 'log_params',
- 'log_deleted',
- 'user_name' ),
+ 'log_action',
+ 'log_timestamp',
+ 'log_user',
+ 'log_namespace',
+ 'log_title',
+ 'log_comment',
+ 'log_params',
+ 'log_deleted',
+ 'user_name' ),
array( 'log_namespace' => $this->mTitle->getNamespace(),
- 'log_title' => $this->mTitle->getDBkey(),
- 'log_type' => 'delete',
- 'log_action' => 'delete',
- 'user_id=log_user' ),
+ 'log_title' => $this->mTitle->getDBkey(),
+ 'log_type' => 'delete',
+ 'log_action' => 'delete',
+ 'user_id=log_user' ),
__METHOD__,
array( 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' )
);
} else {
$note = wfMsg( 'session_fail_preview' );
}
+ } else if ( $this->incompleteForm ) {
+ $note = wfMsg( 'edit_form_incomplete' );
} else {
$note = wfMsg( 'previewnote' );
}
}
# don't parse user css/js, show message about preview
- # XXX: stupid php bug won't let us use $wgTitle->isCssJsSubpage() here -- This note has been there since r3530. Sure the bug was fixed time ago?
+ # XXX: stupid php bug won't let us use $this->getContextTitle()->isCssJsSubpage() here -- This note has been there since r3530. Sure the bug was fixed time ago?
if ( $this->isCssJsSubpage || $this->mTitle->isCssOrJsPage() ) {
$level = 'user';
* Produce the stock "please login to edit pages" page
*/
function userNotLoggedInPage() {
- global $wgUser, $wgOut, $wgTitle;
+ global $wgUser, $wgOut;
$skin = $wgUser->getSkin();
$loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
$loginTitle,
wfMsgHtml( 'loginreqlink' ),
array(),
- array( 'returnto' => $wgTitle->getPrefixedText() ),
+ array( 'returnto' => $this->getContextTitle()->getPrefixedText() ),
array( 'known', 'noclasses' )
);
$wgOut->setArticleRelated( false );
$wgOut->addWikiMsgArray( 'whitelistedittext', array( $loginLink ), array( 'replaceafter' ) );
- $wgOut->returnToMain( false, $wgTitle );
+ $wgOut->returnToMain( false, $this->getContextTitle() );
}
/**
* @param $match Text which triggered one or more filters
*/
public function spamPageWithContent( $match = false ) {
- global $wgOut, $wgTitle;
+ global $wgOut;
$this->textbox2 = $this->textbox1;
$wgOut->setPageTitle( wfMsg( 'spamprotectiontitle' ) );
$wgOut->wrapWikiMsg( '<h2>$1</h2>', "yourtext" );
$this->showTextbox2();
- $wgOut->addReturnTo( $wgTitle, array( 'action' => 'edit' ) );
+ $wgOut->addReturnTo( $this->getContextTitle(), array( 'action' => 'edit' ) );
}
$imagesAvailable = $wgEnableUploads || count( $wgForeignFileRepos );
/**
-
- * toolarray an array of arrays which each include the filename of
- * the button image (without path), the opening tag, the closing tag,
- * and optionally a sample text that is inserted between the two when no
- * selection is highlighted.
- * The tip text is shown when the user moves the mouse over the button.
+ * $toolarray is an array of arrays each of which includes the
+ * filename of the button image (without path), the opening
+ * tag, the closing tag, optionally a sample text that is
+ * inserted between the two when no selection is highlighted
+ * and an option to select which switches the automatic
+ * selection of inserted text (default is true, see
+ * mw-editbutton-image). The tip text is shown when the user
+ * moves the mouse over the button.
*
- * Already here are accesskeys (key), which are not used yet until someone
- * can figure out a way to make them work in IE. However, we should make
- * sure these keys are not defined on the edit page.
+ * Also here: accesskeys (key), which are not used yet until
+ * someone can figure out a way to make them work in
+ * IE. However, we should make sure these keys are not defined
+ * on the edit page.
*/
$toolarray = array(
array(
'close' => ']]',
'sample' => wfMsg( 'image_sample' ),
'tip' => wfMsg( 'image_tip' ),
- 'key' => 'D'
+ 'key' => 'D',
+ 'select' => true
) : false,
$imagesAvailable ? array(
'image' => $wgLang->getImageFile( 'button-media' ),
continue;
}
+ if( !isset( $tool['select'] ) ) {
+ $tool['select'] = true;
+ }
+
$params = array(
$image = $wgStylePath . '/common/images/' . $tool['image'],
// Note that we use the tip both for the ALT tag and the TITLE tag of the image.
array_map( array( 'Xml', 'encodeJsVar' ), $params ) );
$script .= "addButton($paramList);\n";
}
-
+
$wgOut->addScript( Html::inlineScript(
- "if ( window.mediaWiki ) { $script }"
+ "if ( window.mediaWiki ) { jQuery(function(){{$script}}); }"
) );
-
+
$toolbar .= "\n</div>";
wfRunHooks( 'EditPageBeforeEditToolbar', array( &$toolbar ) );
public function getCancelLink() {
- global $wgUser, $wgTitle;
+ global $wgUser;
$cancelParams = array();
if ( !$this->isConflict && $this->mArticle->getOldID() > 0 ) {
}
return $wgUser->getSkin()->link(
- $wgTitle,
+ $this->getContextTitle(),
wfMsgExt( 'cancel', array( 'parseinline' ) ),
array( 'id' => 'mw-editform-cancel' ),
$cancelParams,
* @return bool false if output is done, true if the rest of the form should be displayed
*/
function attemptSave() {
- global $wgUser, $wgOut, $wgTitle;
+ global $wgUser, $wgOut;
$resultDetails = false;
# Allow bots to exempt some edits from bot flagging
switch ( $value ) {
case self::AS_HOOK_ERROR_EXPECTED:
case self::AS_CONTENT_TOO_BIG:
- case self::AS_ARTICLE_WAS_DELETED:
+ case self::AS_ARTICLE_WAS_DELETED:
case self::AS_CONFLICT_DETECTED:
case self::AS_SUMMARY_NEEDED:
case self::AS_TEXTBOX_EMPTY:
$this->userNotLoggedInPage();
return false;
- case self::AS_READ_ONLY_PAGE_LOGGED:
- case self::AS_READ_ONLY_PAGE:
- $wgOut->readOnlyPage();
- return false;
+ case self::AS_READ_ONLY_PAGE_LOGGED:
+ case self::AS_READ_ONLY_PAGE:
+ $wgOut->readOnlyPage();
+ return false;
- case self::AS_RATE_LIMITED:
- $wgOut->rateLimited();
- return false;
+ case self::AS_RATE_LIMITED:
+ $wgOut->rateLimited();
+ return false;
- case self::AS_NO_CREATE_PERMISSION:
- $this->noCreatePermission();
- return;
+ case self::AS_NO_CREATE_PERMISSION:
+ $this->noCreatePermission();
+ return;
case self::AS_BLANK_ARTICLE:
- $wgOut->redirect( $wgTitle->getFullURL() );
- return false;
+ $wgOut->redirect( $this->getContextTitle()->getFullURL() );
+ return false;
case self::AS_IMAGE_REDIRECT_LOGGED:
$wgOut->permissionRequired( 'upload' );