var $mMetaData = '';
var $isConflict = false;
var $isCssJsSubpage = false;
+ var $isCssSubpage = false;
+ var $isJsSubpage = false;
var $deletedSinceEdit = false;
var $formtype;
var $firsttime;
$this->editFormTextBeforeContent =
$this->editFormTextAfterWarn =
$this->editFormTextAfterTools =
- $this->editFormTextBottom = "";
+ $this->editFormTextBottom =
+ $this->mPreloadText = "";
}
function getArticle() {
return $this->mArticle;
}
+
/**
* Fetch initial editing page content.
* @private
wfProfileOut( __METHOD__ );
return $text;
}
+
+ /** Use this method before edit() to preload some text into the edit box */
+ public function setPreloadedText( $text ) {
+ $this->mPreloadText = $text;
+ }
/**
* Get the contents of a page from its title and remove includeonly tags
* @return string The contents of the page.
*/
protected function getPreloadedText( $preload ) {
- if ( $preload === '' ) {
+ if ( !empty($this->mPreloadText) ) {
+ return $this->mPreloadText;
+ } elseif ( $preload === '' ) {
return '';
} else {
$preloadTitle = Title::newFromText( $preload );
* 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 ) ) ) {
return;
}
$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 ) );
}
/**
}
// Run post-section-merge edit filter
- if ( !wfRunHooks( 'EditFilterMerged', array( $this, $this->textbox1, &$this->hookError, $this->summary ) ) ) {
+ if ( !wfRunHooks( 'EditFilterMerged', array( &$this, $this->textbox1, &$this->hookError, $this->summary ) ) ) {
# Error messages etc. could be handled within the hook...
wfProfileOut( $fname );
return self::AS_HOOK_ERROR;
$oldtext = $this->mArticle->getContent();
// Run post-section-merge edit filter
- if ( !wfRunHooks( 'EditFilterMerged', array( $this, $text, &$this->hookError, $this->summary ) ) ) {
+ if ( !wfRunHooks( 'EditFilterMerged', array( &$this, $text, &$this->hookError, $this->summary ) ) ) {
# Error messages etc. could be handled within the hook...
wfProfileOut( $fname );
return self::AS_HOOK_ERROR;
}
return true;
}
-
+
/**
* Check given input text against $wgSpamRegex, and return the text of the first match.
* @return mixed -- matching string or false
$sk = $wgUser->getSkin();
- wfRunHooks( 'EditPage::showEditForm:initial', array( &$this ) ) ;
-
#need to parse the preview early so that we know which templates are used,
#otherwise users with "show preview after edit box" will get a blank list
#we parse this near the beginning so that setHeaders can do the title
if ( $this->formtype == 'preview' ) {
$previewOutput = $this->getPreviewText();
}
+
+ wfRunHooks( 'EditPage::showEditForm:initial', array( &$this ) ) ;
$this->setHeaders();
} 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' );
+ }
}
}
$wgOut->addHTML( "</div>\n" );
}
- $q = 'action='.$this->action;
- #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
- $action = $wgTitle->escapeLocalURL( $q );
+ $action = $wgTitle->escapeLocalURL( array( 'action' => $this->action ) );
$summary = wfMsgExt( 'summary', 'parseinline' );
$subject = wfMsgExt( 'subject', 'parseinline' );
- $cancel = $sk->makeKnownLink( $wgTitle->getPrefixedText(),
- wfMsgExt('cancel', array('parseinline')) );
+ $cancel = $sk->link(
+ $wgTitle,
+ wfMsgExt( 'cancel', array( 'parseinline' ) ),
+ array(),
+ array(),
+ array( 'known', 'noclasses' )
+ );
$separator = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
$edithelpurl = Skin::makeInternalOrExternalUrl( wfMsgForContent( 'edithelppage' ));
$edithelp = '<a target="helpwindow" href="'.$edithelpurl.'">'.
$copywarnMsg = array( 'copyrightwarning2',
'[[' . wfMsgForContent( 'copyrightpage' ) . ']]' );
}
+ // Allow for site and per-namespace customization of contribution/copyright notice.
+ wfRunHooks( 'EditPageCopyrightWarning', array( $this->mTitle, &$copywarnMsg ) );
if ( $wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage ) {
# prepare toolbar for edit buttons
$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;
$token = htmlspecialchars( $wgUser->editToken() );
$wgOut->addHTML( "\n<input type='hidden' value=\"$token\" name=\"wpEditToken\" />\n" );
+ $this->showTosSummary();
$this->showEditTools();
$wgOut->addHTML( <<<END
function doLivePreviewScript() {
global $wgOut, $wgTitle;
$wgOut->addScriptFile( 'preview.js' );
- $liveAction = $wgTitle->getLocalUrl( "action={$this->action}&wpPreview=true&live=true" );
+ $liveAction = $wgTitle->getLocalUrl( array(
+ 'action' => $this->action,
+ 'wpPreview' => 'true',
+ 'live' => 'true'
+ ) );
return "return !lpDoPreview(" .
"editform.wpTextbox1.value," .
'"' . $liveAction . '"' . ")";
}
+ protected function showTosSummary() {
+ $msg = 'editpage-tos-summary';
+ // Give a chance for site and per-namespace customizations of
+ // terms of service summary link that might exist separately
+ // from the copyright notice.
+ //
+ // This will display between the save button and the edit tools,
+ // so should remain short!
+ wfRunHooks( 'EditPageTosSummary', array( $this->mTitle, &$msg ) );
+ $text = wfMsg( $msg );
+ if( !wfEmptyMsg( $msg, $text ) && $text !== '-' ) {
+ global $wgOut;
+ $wgOut->addHTML( '<div class="mw-tos-summary">' );
+ $wgOut->addWikiMsgArray( $msg, array() );
+ $wgOut->addHTML( '</div>' );
+ }
+ }
+
protected function showEditTools() {
global $wgOut;
$wgOut->addHTML( '<div class="mw-editTools">' );
$skin = $wgUser->getSkin();
$loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
- $loginLink = $skin->makeKnownLinkObj( $loginTitle, wfMsgHtml( 'loginreqlink' ), 'returnto=' . $wgTitle->getPrefixedUrl() );
+ $loginLink = $skin->link(
+ $loginTitle,
+ wfMsgHtml( 'loginreqlink' ),
+ array(),
+ array( 'returnto' => $wgTitle->getPrefixedText() ),
+ array( 'known', 'noclasses' )
+ );
$wgOut->setPageTitle( wfMsg( 'whitelistedittitle' ) );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$toolbar.="/*]]>*/\n</script>";
$toolbar.="\n</div>";
-
+
wfRunHooks( 'EditPageBeforeEditToolbar', array( &$toolbar ) );
-
+
return $toolbar;
}
global $wgUser;
$loglist = new LogEventsList( $wgUser->getSkin(), $out );
$pager = new LogPager( $loglist, array('move', 'delete'), false,
- $this->mTitle->getPrefixedText(), '', array('log_action'=>'delete') );
+ $this->mTitle->getPrefixedText(), '', array( "log_action != 'revision'" ) );
+
$count = $pager->getNumRows();
if ( $count > 0 ) {
$pager->mLimit = 10;