*/
function edit() {
global $wgOut, $wgUser, $wgRequest, $wgTitle;
-
+
+ if ( ! wfRunHooks( 'AlternateEdit', array( &$this ) ) )
+ return;
+
$fname = 'EditPage::edit';
wfProfileIn( $fname );
wfDebug( "$fname: enter\n" );
return;
}
}
+ if ( !$this->mTitle->userCan( 'create' ) && !$this->mTitle->exists() ) {
+ wfDebug( "$fname: no create permission\n" );
+ $this->noCreatePermission();
+ wfProfileOut( $fname );
+ return;
+ }
if ( wfReadOnly() ) {
wfDebug( "$fname: read-only mode is engaged\n" );
if( $this->save || $this->preview ) {
# If article is new, insert it.
$aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
if ( 0 == $aid ) {
+ // Late check for create permission, just in case *PARANOIA*
+ if ( !$this->mTitle->userCan( 'create' ) ) {
+ wfDebug( "$fname: no create permission\n" );
+ $this->noCreatePermission();
+ wfProfileOut( $fname );
+ return;
+ }
+
# Don't save a new article if it's blank.
if ( ( '' == $this->textbox1 ) ) {
$wgOut->redirect( $this->mTitle->getFullURL() );
}
$wgOut->setPageTitle( $s );
if ( !$this->checkUnicodeCompliantBrowser() ) {
- $this->mArticle->setOldSubtitle();
$wgOut->addWikiText( wfMsg( 'nonunicodebrowser') );
}
if ( isset( $this->mArticle )
&& isset( $this->mArticle->mRevision )
&& !$this->mArticle->mRevision->isCurrent() ) {
- $this->mArticle->setOldSubtitle();
+ $this->mArticle->setOldSubtitle( $this->mArticle->mRevision->getId() );
$wgOut->addWikiText( wfMsg( 'editingold' ) );
}
}
if( is_callable( $formCallback ) ) {
call_user_func_array( $formCallback, array( &$wgOut ) );
}
+
+ // Put these up at the top to ensure they aren't lost on early form submission
+ $wgOut->addHTML( "
+<input type='hidden' value=\"" . htmlspecialchars( $this->section ) . "\" name=\"wpSection\" />
+<input type='hidden' value=\"{$this->starttime}\" name=\"wpStarttime\" />\n
+<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n
+<input type='hidden' value=\"{$this->scrolltop}\" name=\"wpScrolltop\" id=\"wpScrolltop\" />\n" );
+
$wgOut->addHTML( <<<END
$recreate
{$commentsubject}
END
. htmlspecialchars( $this->safeUnicodeOutput( $this->textbox1 ) ) .
"
-</textarea><br />
+</textarea>
+
+ " );
+
+ $wgOut->addWikiText( $copywarn );
+
+ $wgOut->addHTML( "
{$metadata}
{$editsummary}
{$checkboxhtml}
{$safemodehtml}
+");
+
+ $wgOut->addHTML( "
<div class='editButtons'>
<input tabindex='5' id='wpSave' type='submit' value=\"{$save}\" name=\"wpSave\" accesskey=\"".wfMsg('accesskey-save')."\"".
" title=\"".wfMsg('tooltip-save')."\"/>
<input tabindex='7' id='wpDiff' type='submit' value=\"{$diff}\" name=\"wpDiff\" accesskey=\"".wfMsg('accesskey-diff')."\"".
" title=\"".wfMsg('tooltip-diff')."\"/> <span class='editHelp'>{$cancel} | {$edithelp}</span></div>
</div>
+" );
+
+ $wgOut->addWikiText( wfMsgForContent( 'edittools' ) );
+
+ $wgOut->addHTML( "
<div class='templatesUsed'>
{$templates}
</div>
" );
- $wgOut->addWikiText( $copywarn );
- $wgOut->addHTML( "
-<input type='hidden' value=\"" . htmlspecialchars( $this->section ) . "\" name=\"wpSection\" />
-<input type='hidden' value=\"{$this->starttime}\" name=\"wpStarttime\" />\n
-<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n
-<input type='hidden' value=\"{$this->scrolltop}\" name=\"wpScrolltop\" id=\"wpScrolltop\" />\n" );
if ( $wgUser->isLoggedIn() ) {
/**
if ( $this->isConflict ) {
require_once( "DifferenceEngine.php" );
$wgOut->addWikiText( '==' . wfMsg( "yourdiff" ) . '==' );
- DifferenceEngine::showDiff( $this->textbox2, $this->textbox1,
- wfMsg( "yourtext" ), wfMsg( "storedversion" ) );
+
+ $de = new DifferenceEngine( $this->mTitle );
+ $de->setText( $this->textbox2, $this->textbox1 );
+ $de->showDiff( wfMsg( "yourtext" ), wfMsg( "storedversion" ) );
$wgOut->addWikiText( '==' . wfMsg( "yourtext" ) . '==' );
$wgOut->addHTML( "<textarea tabindex=6 id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}' wrap='virtual'>"
* @todo document
*/
function getPreviewText() {
- global $wgOut, $wgUser, $wgTitle, $wgParser, $wgAllowDiffPreview, $wgEnableDiffPreviewPreference;
+ global $wgOut, $wgUser, $wgTitle, $wgParser;
$fname = 'EditPage::getPreviewText';
wfProfileIn( $fname );
* The necessary JavaScript code can be found in style/wikibits.js.
*/
function getEditToolbar() {
- global $wgStylePath, $wgLang, $wgMimeType, $wgJsMimeType;
+ global $wgStylePath, $wgLang, $wgJsMimeType;
/**
* toolarray an array of arrays which each include the filename of
$this->section, $this->textbox1, $this->summary, $this->edittime );
$oldtitle = wfMsg( 'currentrev' );
$newtitle = wfMsg( 'yourtext' );
- if ( $oldtext != wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' ) || $newtext != '' ) {
- $difftext = DifferenceEngine::getDiff( $oldtext, $newtext, $oldtitle, $newtitle );
+ if ( $oldtext !== false || $newtext != '' ) {
+ $de = new DifferenceEngine( $this->mTitle );
+ $de->setText( $oldtext, $newtext );
+ $difftext = $de->getDiff( $oldtitle, $newtitle );
+ } else {
+ $difftext = '';
}
return '<div id="wikiDiff">' . $difftext . '</div>';
return strtr( $result, array( "�" => "&#x" ) );
}
+ function noCreatePermission() {
+ global $wgOut;
+ $wgOut->setPageTitle( wfMsg( 'nocreatetitle' ) );
+ $wgOut->addWikiText( wfMsg( 'nocreatetext' ) );
+ }
}