var $mMetaData = '';
var $isConflict = false;
var $isCssJsSubpage = false;
+ var $isCssSubpage = false;
+ var $isJsSubpage = false;
var $deletedSinceEdit = false;
var $formtype;
var $firsttime;
return $this->mArticle;
}
+
/**
* Fetch initial editing page content.
* @private
* the newly-edited page.
*/
function edit() {
- global $wgOut, $wgRequest;
+ global $wgOut, $wgRequest, $wgEnableJS2system;
// Allow extensions to modify/prevent this form or submission
- if ( !wfRunHooks( 'AlternateEdit', array( &$this ) ) ) {
+ if ( !wfRunHooks( 'AlternateEdit', array( $this ) ) ) {
return;
}
}
if ( wfReadOnly() && $this->save ) {
- // Force preview
- $this->save = false;
- $this->preview = true;
+ // Force preview
+ $this->save = false;
+ $this->preview = true;
}
$wgOut->addScriptFile( 'edit.js' );
+
+ if( $wgEnableJS2system )
+ $wgOut->addScriptClass( 'editPage' );
+
$permErrors = $this->getEditPermissionErrors();
if ( $permErrors ) {
wfDebug( __METHOD__.": User can't edit\n" );
$this->isConflict = false;
// css / js subpages of user pages get a special treatment
$this->isCssJsSubpage = $this->mTitle->isCssJsSubpage();
+ $this->isCssSubpage = $this->mTitle->isCssSubpage();
+ $this->isJsSubpage = $this->mTitle->isJsSubpage();
$this->isValidCssJsSubpage = $this->mTitle->isValidCssJsSubpage();
# Show applicable editing introductions
}
}
+ // FIXME: unused variable?
$this->oldid = $request->getInt( 'oldid' );
$this->live = $request->getCheck( 'live' );
$this->editintro = $request->getText( 'editintro' );
wfProfileOut( $fname );
+
+ // Allow extensions to modify form data
+ wfRunHooks( 'EditPage::importFormData', array( $this, $request ) );
}
/**
}
# Give a notice if the user is editing a deleted/moved page...
if ( !$this->mTitle->exists() ) {
- $this->showLogs( $wgOut );
+ LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), $this->mTitle->getPrefixedText(),
+ '', array( 'lim' => 10,
+ 'conds' => array( "log_action != 'revision'" ),
+ 'showIfEmpty' => false,
+ 'msgKey' => array( 'recreate-moveddeleted-warn') )
+ );
}
}
wfProfileIn( $fname );
wfProfileIn( "$fname-checks" );
- if ( !wfRunHooks( 'EditPage::attemptSave', array( &$this ) ) )
+ if ( !wfRunHooks( 'EditPage::attemptSave', array( $this ) ) )
{
wfDebug( "Hook 'EditPage::attemptSave' aborted article saving\n" );
return self::AS_HOOK_ERROR;
# Error messages etc. could be handled within the hook...
wfProfileOut( $fname );
return self::AS_HOOK_ERROR;
+ } elseif ( $this->hookError != '' ) {
+ # ...or the hook could be expecting us to produce an error
+ wfProfileOut( $fname );
+ return self::AS_HOOK_ERROR_EXPECTED;
}
# Handle the user preference to force summaries here. Check if it's not a redirect.
# Error messages etc. could be handled within the hook...
wfProfileOut( $fname );
return self::AS_HOOK_ERROR;
+ } elseif ( $this->hookError != '' ) {
+ # ...or the hook could be expecting us to produce an error
+ wfProfileOut( $fname );
+ return self::AS_HOOK_ERROR_EXPECTED;
}
# Handle the user preference to force summaries here, but not for null edits
}
return true;
}
-
+
/**
* Check given input text against $wgSpamRegex, and return the text of the first match.
* @return mixed -- matching string or false
} else {
if ( $this->isCssJsSubpage ) {
# Check the skin exists
- if ( $this->isValidCssJsSubpage ) {
- if ( $this->formtype !== 'preview' ) {
- $wgOut->addWikiMsg( 'usercssjsyoucanpreview' );
- }
- } else {
+ if ( !$this->isValidCssJsSubpage ) {
$wgOut->addWikiMsg( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() );
}
+ if ( $this->formtype !== 'preview' ) {
+ if ( $this->isCssSubpage )
+ $wgOut->addWikiMsg( 'usercssyoucanpreview' );
+ if ( $this->isJsSubpage )
+ $wgOut->addWikiMsg( 'userjsyoucanpreview' );
+ }
}
}
$noticeMsg = 'protectedpagewarning';
$classes[] = 'mw-textarea-protected';
}
- $wgOut->addHTML( "<div class='mw-warning-with-logexcerpt'>\n" );
- $wgOut->addWikiMsg( $noticeMsg );
- LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle->getPrefixedText(), '', 1 );
- $wgOut->addHTML( "</div>\n" );
+ LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle->getPrefixedText(), '',
+ array( 'lim' => 1, 'msgKey' => array( $noticeMsg ) ) );
}
if ( $this->mTitle->isCascadeProtected() ) {
# Is this page under cascading protection from some source pages?
$cancel = $sk->link(
$wgTitle,
wfMsgExt( 'cancel', array( 'parseinline' ) ),
- array(),
+ array( 'id' => 'mw-editform-cancel' ),
array(),
array( 'known', 'noclasses' )
);
$toolbar = '';
}
+
// activate checkboxes if user wants them to be always active
if ( !$this->preview && !$this->diff ) {
# Sort out the "watch" checkbox
# Already watched
$this->watchthis = true;
}
-
+
# May be overriden by request parameters
if( $wgRequest->getBool( 'watchthis' ) ) {
$this->watchthis = true;
'maxlength' => '200',
'tabindex' => '1'
) );
+ } else {
+ $summaryhiddens .= Xml::hidden( 'wpIgnoreBlankSummary', true ); # bug 18699
}
$editsummary = "<div class='editOptions'>\n";
global $wgParser;
$formattedSummary = wfMsgForContent( 'newsectionsummary', $wgParser->stripSectionName( $this->summary ) );
- $subjectpreview = $summarytext && $this->preview ?
+ $subjectpreview = $summarytext && ( $this->preview || $this->diff ) ?
"<div class=\"mw-summary-preview\">". wfMsgExt('subject-preview', 'parseinline') . $sk->commentBlock( $formattedSummary, $this->mTitle, true )."</div>\n" : '';
$summarypreview = '';
} else {
. $editsummary . '<br/>';
$summarypreview = '';
- if ( $summarytext && $this->preview ) {
+ if ( $summarytext && ( $this->preview || $this->diff ) ) {
$summarypreview =
Xml::tags( 'div',
array( 'class' => 'mw-summary-preview' ),
END
);
+ if (!$this->preview) {
+ $wgOut->addHTML( Xml::tags( 'div',
+ array( 'class' => 'catlinks catlinks-allhidden',
+ 'id' => 'catlinks' ), ' ' ) );
+ }
+
if ( $this->isConflict && wfRunHooks( 'EditPageBeforeConflictDiff', array( &$this, &$wgOut ) ) ) {
$wgOut->wrapWikiMsg( '==$1==', "yourdiff" );
function doLivePreviewScript() {
global $wgOut, $wgTitle;
$wgOut->addScriptFile( 'preview.js' );
- $liveAction = $wgTitle->getLocalUrl( array(
- 'action' => $this->action,
- 'wpPreview' => 'true',
- 'live' => 'true'
- ) );
- return "return !lpDoPreview(" .
- "editform.wpTextbox1.value," .
- '"' . $liveAction . '"' . ")";
+ return "";
}
protected function showTosSummary() {
// This will display between the save button and the edit tools,
// so should remain short!
wfRunHooks( 'EditPageTosSummary', array( $this->mTitle, &$msg ) );
- $text = wfMsgForContent( $msg );
- if( $text != '-' ) {
+ $text = wfMsg( $msg );
+ if( !wfEmptyMsg( $msg, $text ) && $text !== '-' ) {
global $wgOut;
$wgOut->addHTML( '<div class="mw-tos-summary">' );
- $wgOut->addWikiMsgArray( $msg, array(), array( 'content' ) );
+ $wgOut->addWikiMsgArray( $msg, array() );
$wgOut->addHTML( '</div>' );
}
}
-
+
protected function showEditTools() {
global $wgOut;
$wgOut->addHTML( '<div class="mw-editTools">' );
* @return string
*/
static function getEditToolbar() {
- global $wgStylePath, $wgContLang, $wgLang, $wgJsMimeType;
+ global $wgStylePath, $wgContLang, $wgLang;
/**
* toolarray an array of arrays which each include the filename of
)
);
$toolbar = "<div id='toolbar'>\n";
- $toolbar.="<script type='$wgJsMimeType'>\n/*<![CDATA[*/\n";
- foreach($toolarray as $tool) {
+ $script = '';
+ foreach ( $toolarray as $tool ) {
$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.
$paramList = implode( ',',
array_map( array( 'Xml', 'encodeJsVar' ), $params ) );
- $toolbar.="addButton($paramList);\n";
+ $script .= "addButton($paramList);\n";
}
+ $toolbar .= Html::inlineScript( "\n$script\n" );
+
+ $toolbar .= "\n</div>";
- $toolbar.="/*]]>*/\n</script>";
- $toolbar.="\n</div>";
-
wfRunHooks( 'EditPageBeforeEditToolbar', array( &$toolbar ) );
-
+
return $toolbar;
}
++$tabindex; // use the same for preview and live preview
if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
+ $this->doLivePreviewScript(); // Add to output
+
$temp = array(
'id' => 'wpPreview',
'name' => 'wpPreview',
'value' => wfMsg('showlivepreview'),
'accesskey' => wfMsg('accesskey-preview'),
'title' => '',
- 'onclick' => $this->doLivePreviewScript(),
);
+
$buttons['live'] = Xml::element('input', $temp, '');
} else {
$temp = array(
return $buttons;
}
- /**
- * Output preview text only. This can be sucked into the edit page
- * via JavaScript, and saves the server time rendering the skin as
- * well as theoretically being more robust on the client (doesn't
- * disturb the edit box's undo history, won't eat your text on
- * failure, etc).
- *
- * @todo This doesn't include category or interlanguage links.
- * Would need to enhance it a bit, <s>maybe wrap them in XML
- * or something...</s> that might also require more skin
- * initialization, so check whether that's a problem.
- */
- function livePreview() {
- global $wgOut;
- $wgOut->disable();
- header( 'Content-type: text/xml; charset=utf-8' );
- header( 'Cache-control: no-cache' );
-
- $previewText = $this->getPreviewText();
- #$categories = $skin->getCategoryLinks();
-
- $s =
- '<?xml version="1.0" encoding="UTF-8" ?>' . "\n" .
- Xml::tags( 'livepreview', null,
- Xml::element( 'preview', null, $previewText )
- #. Xml::element( 'category', null, $categories )
- );
- echo $s;
- }
-
/**
* Get a diff between the current contents of the edit box and the
$wgOut->addWikiMsg( 'nocreatetext' );
}
- /**
- * If there are rows in the deletion/move log for this page, show them,
- * along with a nice little note for the user
- *
- * @param OutputPage $out
- */
- protected function showLogs( $out ) {
- global $wgUser;
- $loglist = new LogEventsList( $wgUser->getSkin(), $out );
- $pager = new LogPager( $loglist, array('move', 'delete'), false,
- $this->mTitle->getPrefixedText(), '', array( "log_action != 'revision'" ) );
-
- $count = $pager->getNumRows();
- if ( $count > 0 ) {
- $pager->mLimit = 10;
- $out->addHTML( '<div class="mw-warning-with-logexcerpt">' );
- $out->addWikiMsg( 'recreate-moveddeleted-warn' );
- $out->addHTML(
- $loglist->beginLogEventsList() .
- $pager->getBody() .
- $loglist->endLogEventsList()
- );
- if($count > 10){
- $out->addHTML( $wgUser->getSkin()->link(
- SpecialPage::getTitleFor( 'Log' ),
- wfMsgHtml( 'log-fulllog' ),
- array(),
- array( 'page' => $this->mTitle->getPrefixedText() ) ) );
- }
- $out->addHTML( '</div>' );
- return true;
- }
-
- return false;
- }
-
/**
* Attempt submission
* @return bool false if output is done, true if the rest of the form should be displayed