X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FEditPage.php;h=42c74c905d3d934f52132daf4c81dc79a37fd210;hb=2f86970bd3625f2cd9f130827b1c947214a5d8cc;hp=afc330627c9484d1f6f5f4f645bca6781f11684a;hpb=7f0d27b0885ff5bce21f263eb5b1af5687de71a9;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/EditPage.php b/includes/EditPage.php
index afc330627c..42c74c905d 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -48,6 +48,8 @@ class EditPage {
var $mMetaData = '';
var $isConflict = false;
var $isCssJsSubpage = false;
+ var $isCssSubpage = false;
+ var $isJsSubpage = false;
var $deletedSinceEdit = false;
var $formtype;
var $firsttime;
@@ -84,6 +86,7 @@ class EditPage {
/* $didSave should be set to true whenever an article was succesfully altered. */
public $didSave = false;
+ public $undidRev = 0;
public $suppressIntro = false;
@@ -102,9 +105,15 @@ class EditPage {
$this->editFormTextBeforeContent =
$this->editFormTextAfterWarn =
$this->editFormTextAfterTools =
- $this->editFormTextBottom = "";
+ $this->editFormTextBottom =
+ $this->mPreloadText = "";
+ }
+
+ function getArticle() {
+ return $this->mArticle;
}
+
/**
* Fetch initial editing page content.
* @private
@@ -160,35 +169,28 @@ class EditPage {
$undorev->getPage() == $this->mArticle->getID() &&
!$undorev->isDeleted( Revision::DELETED_TEXT ) &&
!$oldrev->isDeleted( Revision::DELETED_TEXT ) ) {
- $undorev_text = $undorev->getText();
- $oldrev_text = $oldrev->getText();
- $currev_text = $text;
-
- if ( $currev_text != $undorev_text ) {
- $result = wfMerge( $undorev_text, $oldrev_text, $currev_text, $text );
+
+ $undotext = $this->mArticle->getUndoText( $undorev, $oldrev );
+ if ( $undotext === false ) {
+ # Warn the user that something went wrong
+ $this->editFormPageTop .= $wgOut->parse( '
' . wfMsgNoTrans( 'undo-failure' ) . '
' );
} else {
- # No use doing a merge if it's just a straight revert.
- $text = $oldrev_text;
- $result = true;
- }
- if ( $result ) {
+ $text = $undotext;
# Inform the user of our success and set an automatic edit summary
- $this->editFormPageTop .= $wgOut->parse( wfMsgNoTrans( 'undo-success' ) );
+ $this->editFormPageTop .= $wgOut->parse( '
' . wfMsgNoTrans( 'undo-success' ) . '
' );
$firstrev = $oldrev->getNext();
# If we just undid one rev, use an autosummary
if ( $firstrev->mId == $undo ) {
- $this->summary = wfMsgForContent('undo-summary', $undo, $undorev->getUserText());
+ $this->summary = wfMsgForContent( 'undo-summary', $undo, $undorev->getUserText() );
+ $this->undidRev = $undo;
}
$this->formtype = 'diff';
- } else {
- # Warn the user that something went wrong
- $this->editFormPageTop .= $wgOut->parse( wfMsgNoTrans( 'undo-failure' ) );
}
} else {
// 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( wfMsgNoTrans( 'undo-norev' ) );
+ $this->editFormPageTop .= $wgOut->parse( '
' . wfMsgNoTrans( 'undo-norev' ) . '
' );
}
} else if ( $section != '' ) {
if ( $section == 'new' ) {
@@ -202,6 +204,11 @@ class EditPage {
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
@@ -210,7 +217,9 @@ class EditPage {
* @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 );
@@ -326,7 +335,7 @@ class EditPage {
protected function wasDeletedSinceLastEdit() {
if ( $this->deletedSinceEdit )
return true;
- if ( $this->mTitle->isDeleted() ) {
+ if ( $this->mTitle->isDeletedQuick() ) {
$this->lastDelete = $this->getLastDelete();
if ( $this->lastDelete ) {
$deleteTime = wfTimestamp( TS_MW, $this->lastDelete->log_timestamp );
@@ -354,9 +363,9 @@ class EditPage {
* the newly-edited page.
*/
function edit() {
- global $wgOut, $wgUser, $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;
}
@@ -375,21 +384,17 @@ class EditPage {
return;
}
- if ( wfReadOnly() ) {
- if ( $this->save ){
+ if ( wfReadOnly() && $this->save ) {
// Force preview
$this->save = false;
$this->preview = true;
- } elseif ( $this->preview || $this->diff ) {
- // A warning will be displayed instead
- } else {
- $this->readOnlyPage( $this->getContent() );
- wfProfileOut( __METHOD__ );
- return;
- }
}
$wgOut->addScriptFile( 'edit.js' );
+
+ if($wgEnableJS2system)
+ $wgOut->addScriptClass( 'editPage' );
+
$permErrors = $this->getEditPermissionErrors();
if ( $permErrors ) {
wfDebug( __METHOD__.": User can't edit\n" );
@@ -413,12 +418,19 @@ class EditPage {
}
}
}
+
+ // If they used redlink=1 and the page exists, redirect to the main article
+ if ( $wgRequest->getBool( 'redlink' ) && $this->mTitle->exists() ) {
+ $wgOut->redirect( $this->mTitle->getFullURL() );
+ }
wfProfileIn( __METHOD__."-business-end" );
$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
@@ -431,7 +443,6 @@ class EditPage {
# Optional notices on a per-namespace and per-page basis
$editnotice_ns = 'editnotice-'.$this->mTitle->getNamespace();
- $editnotice_page = $editnotice_ns.'-'.$this->mTitle->getDBkey();
if ( !wfEmptyMsg( $editnotice_ns, wfMsgForContent( $editnotice_ns ) ) ) {
$wgOut->addWikiText( wfMsgForContent( $editnotice_ns ) );
}
@@ -444,8 +455,6 @@ class EditPage {
$wgOut->addWikiText( wfMsgForContent( $editnotice_base ) );
}
}
- } else if ( !wfEmptyMsg( $editnotice_page, wfMsgForContent( $editnotice_page ) ) ) {
- $wgOut->addWikiText( wfMsgForContent( $editnotice_page ) );
}
# Attempt submission here. This will check for edit conflicts,
@@ -533,7 +542,7 @@ class EditPage {
} elseif ( $this->section == 'new' ) {
// Nothing *to* preview for new sections
return false;
- } elseif ( ( $wgRequest->getVal( 'preload' ) !== '' || $this->mTitle->exists() ) && $wgUser->getOption( 'previewonfirst' ) ) {
+ } elseif ( ( $wgRequest->getVal( 'preload' ) !== null || $this->mTitle->exists() ) && $wgUser->getOption( 'previewonfirst' ) ) {
// Standard preference behaviour
return true;
} elseif ( !$this->mTitle->exists() && $this->mTitle->getNamespace() == NS_CATEGORY ) {
@@ -564,7 +573,7 @@ class EditPage {
$this->textbox2 = $this->safeUnicodeInput( $request, 'wpTextbox2' );
$this->mMetaData = rtrim( $request->getText( 'metadata' ) );
# Truncate for whole multibyte characters. +5 bytes for ellipsis
- $this->summary = $wgLang->truncate( $request->getText( 'wpSummary' ), 250 );
+ $this->summary = $wgLang->truncate( $request->getText( 'wpSummary' ), 250, '' );
# Remove extra headings from summaries and new sections.
$this->summary = preg_replace('/^\s*=+\s*(.*?)\s*=+\s*$/', '$1', $this->summary);
@@ -574,11 +583,11 @@ class EditPage {
$this->scrolltop = $request->getIntOrNull( 'wpScrolltop' );
- if ( is_null($this->section) || !$this->edittime || !$this->starttime ) {
+ if ( is_null( $this->edittime ) ) {
# If the form is incomplete, force to preview.
wfDebug( "$fname: Form data appears to be incomplete\n" );
wfDebug( "POST DATA: " . var_export( $_POST, true ) . "\n" );
- $this->preview = true;
+ $this->preview = true;
} else {
/* Fallback for live preview */
$this->preview = $request->getCheck( 'wpPreview' ) || $request->getCheck( 'wpLivePreview' );
@@ -648,14 +657,25 @@ class EditPage {
if ( $this->section == 'new' && $request->getVal( 'preloadtitle' ) ) {
$this->summary = $request->getVal( 'preloadtitle' );
}
+ elseif ( $this->section != 'new' && $request->getVal( 'summary' ) ) {
+ $this->summary = $request->getText( 'summary' );
+ }
+
+ if ( $request->getVal( 'minor' ) ) {
+ $this->minoredit = true;
+ }
}
+ // 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 ) );
}
/**
@@ -681,8 +701,16 @@ class EditPage {
if ( $this->suppressIntro ) {
return;
}
+
+ $namespace = $this->mTitle->getNamespace();
+
+ if ( $namespace == NS_MEDIAWIKI ) {
+ # Show a warning if editing an interface message
+ $wgOut->wrapWikiMsg( "
\n$1
", 'editinginterface' );
+ }
+
# Show a warning message when someone creates/edits a user (talk) page but the user does not exists
- if ( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) {
+ if ( $namespace == NS_USER || $namespace == NS_USER_TALK ) {
$parts = explode( '/', $this->mTitle->getText(), 2 );
$username = $parts[0];
$id = User::idFromName( $username );
@@ -700,9 +728,9 @@ class EditPage {
$wgOut->wrapWikiMsg( '
$1
', 'newarticletextanon' );
}
}
- # Give a notice if the user is editing a deleted page...
+ # Give a notice if the user is editing a deleted/moved page...
if ( !$this->mTitle->exists() ) {
- $this->showDeletionLog( $wgOut );
+ $this->showLogs( $wgOut );
}
}
@@ -739,14 +767,14 @@ class EditPage {
wfProfileIn( $fname );
wfProfileIn( "$fname-checks" );
- if ( !wfRunHooks( 'EditPage::attemptSave', array( &$this ) ) )
+ if ( !wfRunHooks( 'EditPage::attemptSave', array( $this ) ) )
{
- wfDebug( "Hook 'EditPage::attemptSave' aborted article saving" );
+ wfDebug( "Hook 'EditPage::attemptSave' aborted article saving\n" );
return self::AS_HOOK_ERROR;
}
# Check image redirect
- if ( $this->mTitle->getNamespace() == NS_IMAGE &&
+ if ( $this->mTitle->getNamespace() == NS_FILE &&
Title::newFromRedirect( $this->textbox1 ) instanceof Title &&
!$wgUser->isAllowed( 'upload' ) ) {
if ( $wgUser->isAnon() ) {
@@ -761,7 +789,7 @@ class EditPage {
$this->mMetaData = '' ;
# Check for spam
- $match = self::matchSpamRegex( $this->summary );
+ $match = self::matchSummarySpamRegex( $this->summary );
if ( $match === false ) {
$match = self::matchSpamRegex( $this->textbox1 );
}
@@ -862,12 +890,25 @@ class EditPage {
# 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.
+ if ( !$this->allowBlankSummary && !Title::newFromRedirect( $this->textbox1 ) ) {
+ if ( md5( $this->summary ) == $this->autoSumm ) {
+ $this->missingSummary = true;
+ wfProfileOut( $fname );
+ return self::AS_SUMMARY_NEEDED;
+ }
}
$isComment = ( $this->section == 'new' );
$this->mArticle->insertNewArticle( $this->textbox1, $this->summary,
- $this->minoredit, $this->watchthis, false, $isComment, $bot);
+ $this->minoredit, $this->watchthis, false, $isComment, $bot );
wfProfileOut( $fname );
return self::AS_SUCCESS_NEW_ARTICLE;
@@ -897,39 +938,35 @@ class EditPage {
}
}
$userid = $wgUser->getId();
+
+ # Suppress edit conflict with self, except for section edits where merging is required.
+ if ( $this->isConflict && $this->section == '' && $this->userWasLastToEdit($userid,$this->edittime) ) {
+ wfDebug( "EditPage::editForm Suppressing edit conflict, same user.\n" );
+ $this->isConflict = false;
+ }
if ( $this->isConflict ) {
wfDebug( "EditPage::editForm conflict! getting section '$this->section' for time '$this->edittime' (article time '" .
$this->mArticle->getTimestamp() . "')\n" );
- $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary, $this->edittime);
- }
- else {
+ $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary, $this->edittime );
+ } else {
wfDebug( "EditPage::editForm getting section '$this->section'\n" );
- $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary);
+ $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary );
}
if ( is_null( $text ) ) {
wfDebug( "EditPage::editForm activating conflict; section replace failed.\n" );
$this->isConflict = true;
- $text = $this->textbox1;
- }
-
- # Suppress edit conflict with self, except for section edits where merging is required.
- if ( $this->section == '' && $userid && $this->userWasLastToEdit($userid,$this->edittime) ) {
- wfDebug( "EditPage::editForm Suppressing edit conflict, same user.\n" );
- $this->isConflict = false;
- } else {
- # switch from section editing to normal editing in edit conflict
- if ( $this->isConflict ) {
- # Attempt merge
- if ( $this->mergeChangesInto( $text ) ) {
- // Successful merge! Maybe we should tell the user the good news?
- $this->isConflict = false;
- wfDebug( "EditPage::editForm Suppressing edit conflict, successful merge.\n" );
- } else {
- $this->section = '';
- $this->textbox1 = $text;
- wfDebug( "EditPage::editForm Keeping edit conflict, failed merge.\n" );
- }
+ $text = $this->textbox1; // do not try to merge here!
+ } else if ( $this->isConflict ) {
+ # Attempt merge
+ if ( $this->mergeChangesInto( $text ) ) {
+ // Successful merge! Maybe we should tell the user the good news?
+ $this->isConflict = false;
+ wfDebug( "EditPage::editForm Suppressing edit conflict, successful merge.\n" );
+ } else {
+ $this->section = '';
+ $this->textbox1 = $text;
+ wfDebug( "EditPage::editForm Keeping edit conflict, failed merge.\n" );
}
}
@@ -945,12 +982,16 @@ class EditPage {
# 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
- if ( $this->section != 'new' && !$this->allowBlankSummary && 0 != strcmp($oldtext, $text) &&
- !is_object( Title::newFromRedirect( $text ) ) # check if it's not a redirect
- ) {
+ if ( $this->section != 'new' && !$this->allowBlankSummary && 0 != strcmp($oldtext,$text)
+ && !Title::newFromRedirect( $text ) ) # check if it's not a redirect
+ {
if ( md5( $this->summary ) == $this->autoSumm ) {
$this->missingSummary = true;
wfProfileOut( $fname );
@@ -1012,7 +1053,8 @@ class EditPage {
# update the article here
if ( $this->mArticle->updateArticle( $text, $this->summary, $this->minoredit,
- $this->watchthis, $bot, $sectionanchor ) ) {
+ $this->watchthis, $bot, $sectionanchor ) )
+ {
wfProfileOut( $fname );
return self::AS_SUCCESS_UPDATE;
} else {
@@ -1025,16 +1067,19 @@ class EditPage {
/**
* Check if no edits were made by other users since
* the time a user started editing the page. Limit to
- * 20 revisions for the sake of sanity.
+ * 50 revisions for the sake of performance.
*/
protected function userWasLastToEdit( $id, $edittime ) {
+ if( !$id ) return false;
$dbw = wfGetDB( DB_MASTER );
$res = $dbw->select( 'revision',
'rev_user',
- array( 'rev_page' => $this->mArticle->getId(),
- "rev_timestamp > '".$dbw->timestamp($edittime)."'" ),
+ array(
+ 'rev_page' => $this->mArticle->getId(),
+ 'rev_timestamp > '.$dbw->addQuotes( $dbw->timestamp($edittime) )
+ ),
__METHOD__,
- array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 20 ) );
+ array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 50 ) );
while( $row = $res->fetchObject() ) {
if( $row->rev_user != $id ) {
return false;
@@ -1042,21 +1087,33 @@ class EditPage {
}
return true;
}
-
+
/**
* Check given input text against $wgSpamRegex, and return the text of the first match.
* @return mixed -- matching string or false
*/
public static function matchSpamRegex( $text ) {
global $wgSpamRegex;
- if ( $wgSpamRegex ) {
- // For back compatibility, $wgSpamRegex may be a single string or an array of regexes.
- $regexes = (array)$wgSpamRegex;
- foreach( $regexes as $regex ) {
- $matches = array();
- if ( preg_match( $regex, $text, $matches ) ) {
- return $matches[0];
- }
+ // For back compatibility, $wgSpamRegex may be a single string or an array of regexes.
+ $regexes = (array)$wgSpamRegex;
+ return self::matchSpamRegexInternal( $text, $regexes );
+ }
+
+ /**
+ * Check given input text against $wgSpamRegex, and return the text of the first match.
+ * @return mixed -- matching string or false
+ */
+ public static function matchSummarySpamRegex( $text ) {
+ global $wgSummarySpamRegex;
+ $regexes = (array)$wgSummarySpamRegex;
+ return self::matchSpamRegexInternal( $text, $regexes );
+ }
+
+ protected static function matchSpamRegexInternal( $text, $regexes ) {
+ foreach( $regexes as $regex ) {
+ $matches = array();
+ if( preg_match( $regex, $text, $matches ) ) {
+ return $matches[0];
}
}
return false;
@@ -1104,7 +1161,7 @@ class EditPage {
* near the top, for captchas and the like.
*/
function showEditForm( $formCallback=null ) {
- global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize, $wgTitle;
+ global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize, $wgTitle, $wgRequest;
# If $wgTitle is null, that means we're in API mode.
# Some hook probably called this function without checking
@@ -1118,8 +1175,6 @@ class EditPage {
$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
@@ -1128,6 +1183,8 @@ class EditPage {
if ( $this->formtype == 'preview' ) {
$previewOutput = $this->getPreviewText();
}
+
+ wfRunHooks( 'EditPage::showEditForm:initial', array( &$this ) ) ;
$this->setHeaders();
@@ -1135,7 +1192,7 @@ class EditPage {
$wgOut->setArticleRelated( true );
if ( $this->isConflict ) {
- $wgOut->addWikiMsg( 'explainconflict' );
+ $wgOut->wrapWikiMsg( "
', 'missingcommenttext' );
}
if ( $this->missingSummary && $this->section != 'new' ) {
@@ -1179,9 +1234,9 @@ class EditPage {
// Let sysop know that this will make private content public if saved
if ( !$this->mArticle->mRevision->userCan( Revision::DELETED_TEXT ) ) {
- $wgOut->addWikiMsg( 'rev-deleted-text-permission' );
+ $wgOut->wrapWikiMsg( "
\n" : '';
+
+ # Add a class if 'missingsummary' is triggered to allow styling of the summary line
+ $summaryClass = $this->missingSummary ? 'mw-summarymissed' : 'mw-summary';
+
+ $editsummary = Xml::tags( 'label', array( 'for' => 'wpSummary' ), $summary );
+ $editsummary = Xml::tags( 'span', array( 'class' => $summaryClass, 'id' => "wpSummaryLabel" ),
+ $editsummary ) . ' ';
+
+ $editsummary .= Xml::input( 'wpSummary',
+ 60,
+ $summarytext,
+ array(
+ 'id' => 'wpSummary',
+ 'maxlength' => '200',
+ 'tabindex' => '1'
+ ) );
+
+ // No idea where this is closed.
+ $editsummary = Xml::openElement( 'div', array( 'class' => 'editOptions' ) )
+ . $editsummary . ' ';
+
+ $summarypreview = '';
+ if ( $summarytext && ( $this->preview || $this->diff ) ) {
+ $summarypreview =
+ Xml::tags( 'div',
+ array( 'class' => 'mw-summary-preview' ),
+ wfMsgExt( 'summary-preview', 'parseinline' ) .
+ $sk->commentBlock( $this->summary, $this->mTitle )
+ );
+ }
$subjectpreview = '';
}
+ $commentsubject .= $summaryhiddens;
# Set focus to the edit box on load, except on preview or diff, where it would interfere with the display
if ( !$this->preview && !$this->diff ) {
@@ -1371,21 +1490,24 @@ class EditPage {
$recreate = '';
if ( $this->wasDeletedSinceLastEdit() ) {
if ( 'save' != $this->formtype ) {
- $wgOut->addWikiMsg('deletedwhileediting');
+ $wgOut->wrapWikiMsg(
+ "
\n$1
",
+ 'deletedwhileediting' );
} else {
- // Hide the toolbar and edit area, use can click preview to get it back
+ // Hide the toolbar and edit area, user can click preview to get it back
// Add an confirmation checkbox and explanation.
$toolbar = '';
- $recreate = $wgOut->parse( wfMsg( 'confirmrecreate', $this->lastDelete->user_name , $this->lastDelete->log_comment ));
- $recreate .=
- " ".
- "";
+ $recreate = '
' );
$wgOut->returnToMain( false, $wgTitle );
}
@@ -1842,8 +1996,7 @@ END
$baseText = $baseRevision->getText();
// The current state, we want to merge updates into it
- $currentRevision = Revision::loadFromTitle(
- $db, $this->mTitle );
+ $currentRevision = Revision::loadFromTitle( $db, $this->mTitle );
if ( is_null( $currentRevision ) ) {
wfProfileOut( $fname );
return false;
@@ -1910,7 +2063,7 @@ END
* @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
@@ -1972,7 +2125,7 @@ END
array(
'image' => $wgLang->getImageFile('button-image'),
'id' => 'mw-editbutton-image',
- 'open' => '[['.$wgContLang->getNsText(NS_IMAGE).':',
+ 'open' => '[['.$wgContLang->getNsText(NS_FILE).':',
'close' => ']]',
'sample' => wfMsg('image_sample'),
'tip' => wfMsg('image_tip'),
@@ -2025,9 +2178,9 @@ END
)
);
$toolbar = "
\n";
- $toolbar.="";
- $toolbar.="\n
";
return $toolbar;
}
@@ -2062,7 +2218,7 @@ END
*
* @return array
*/
- public static function getCheckboxes( &$tabindex, $skin, $checked ) {
+ public function getCheckboxes( &$tabindex, $skin, $checked ) {
global $wgUser;
$checkboxes = array();
@@ -2092,6 +2248,7 @@ END
Xml::check( 'wpWatchthis', $checked['watch'], $attribs ) .
" ";
}
+ wfRunHooks( 'EditPageBeforeEditChecks', array( &$this, &$checkboxes, &$tabindex ) );
return $checkboxes;
}
@@ -2121,6 +2278,8 @@ END
++$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',
@@ -2141,8 +2300,8 @@ END
'value' => wfMsg('showlivepreview'),
'accesskey' => wfMsg('accesskey-preview'),
'title' => '',
- 'onclick' => $this->doLivePreviewScript(),
);
+
$buttons['live'] = Xml::element('input', $temp, '');
} else {
$temp = array(
@@ -2169,40 +2328,10 @@ END
);
$buttons['diff'] = Xml::element('input', $temp, '');
- wfRunHooks( 'EditPageBeforeEditButtons', array( &$this, &$buttons ) );
+ wfRunHooks( 'EditPageBeforeEditButtons', array( &$this, &$buttons, &$tabindex ) );
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, maybe wrap them in XML
- * or something... 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 =
- '' . "\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
@@ -2228,7 +2357,7 @@ END
}
global $wgOut;
- $wgOut->addHtml( '
' . $difftext . '
' );
+ $wgOut->addHTML( '
' . $difftext . '
' );
}
/**
@@ -2353,35 +2482,35 @@ END
}
/**
- * If there are rows in the deletion log for this page, show them,
+ * 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 showDeletionLog( $out ) {
+ protected function showLogs( $out ) {
global $wgUser;
$loglist = new LogEventsList( $wgUser->getSkin(), $out );
- $pager = new LogPager( $loglist, 'delete', false, $this->mTitle->getPrefixedText() );
+ $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( '