2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2003-08-02 20:43:11 +00:00
|
|
|
|
|
|
|
|
# Splitting edit page/HTML interface from Article...
|
|
|
|
|
# The actual database and text munging is still in Article,
|
|
|
|
|
# but it should get easier to call those from alternate
|
|
|
|
|
# interfaces.
|
|
|
|
|
|
|
|
|
|
class EditPage {
|
|
|
|
|
var $mArticle;
|
|
|
|
|
var $mTitle;
|
|
|
|
|
|
2004-03-08 09:09:35 +00:00
|
|
|
# Form values
|
|
|
|
|
var $save = false, $preview = false;
|
|
|
|
|
var $minoredit = false, $watchthis = false;
|
|
|
|
|
var $textbox1 = "", $textbox2 = "", $summary = "";
|
|
|
|
|
var $edittime = "", $section = "";
|
|
|
|
|
var $oldid = 0;
|
|
|
|
|
|
2003-08-02 20:43:11 +00:00
|
|
|
function EditPage( $article ) {
|
|
|
|
|
$this->mArticle =& $article;
|
|
|
|
|
global $wgTitle;
|
|
|
|
|
$this->mTitle =& $wgTitle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# This is the function that gets called for "action=edit".
|
|
|
|
|
|
|
|
|
|
function edit()
|
|
|
|
|
{
|
2004-03-08 09:09:35 +00:00
|
|
|
global $wgOut, $wgUser, $wgWhitelistEdit, $wgRequest;
|
2004-01-29 22:36:02 +00:00
|
|
|
// this is not an article
|
|
|
|
|
$wgOut->setArticleFlag(false);
|
2003-08-02 20:43:11 +00:00
|
|
|
|
2004-03-08 09:09:35 +00:00
|
|
|
$this->importFormData( $wgRequest );
|
2003-08-02 20:43:11 +00:00
|
|
|
|
|
|
|
|
if ( ! $this->mTitle->userCanEdit() ) {
|
2003-12-02 22:38:16 +00:00
|
|
|
$wgOut->readOnlyPage( $this->mArticle->getContent(), true );
|
2003-08-02 20:43:11 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ( $wgUser->isBlocked() ) {
|
|
|
|
|
$this->blockedIPpage();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-08-05 11:04:02 +00:00
|
|
|
if ( !$wgUser->getID() && $wgWhitelistEdit ) {
|
|
|
|
|
$this->userNotLoggedInPage();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-08-02 20:43:11 +00:00
|
|
|
if ( wfReadOnly() ) {
|
2004-03-08 09:09:35 +00:00
|
|
|
if( $this->save || $this->preview ) {
|
2003-08-02 20:43:11 +00:00
|
|
|
$this->editForm( "preview" );
|
|
|
|
|
} else {
|
2003-09-09 05:46:22 +00:00
|
|
|
$wgOut->readOnlyPage( $this->mArticle->getContent() );
|
2003-08-02 20:43:11 +00:00
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
2004-03-08 09:09:35 +00:00
|
|
|
if( !$wgRequest->wasPosted() ) $this->save = false;
|
|
|
|
|
if ( $this->save ) {
|
2003-08-02 20:43:11 +00:00
|
|
|
$this->editForm( "save" );
|
2004-03-08 09:09:35 +00:00
|
|
|
} else if ( $this->preview ) {
|
2003-08-02 20:43:11 +00:00
|
|
|
$this->editForm( "preview" );
|
|
|
|
|
} else { # First time through
|
|
|
|
|
$this->editForm( "initial" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-08 09:09:35 +00:00
|
|
|
function importFormData( &$request ) {
|
|
|
|
|
# These fields need to be checked for encoding.
|
|
|
|
|
# Also remove trailing whitespace, but don't remove _initial_
|
|
|
|
|
# whitespace from the text boxes. This may be significant formatting.
|
|
|
|
|
$this->textbox1 = rtrim( $request->getText( "wpTextbox1" ) );
|
|
|
|
|
$this->textbox2 = rtrim( $request->getText( "wpTextbox2" ) );
|
|
|
|
|
$this->summary = trim( $request->getText( "wpSummary" ) );
|
2004-03-18 06:56:14 +00:00
|
|
|
|
2004-03-08 09:09:35 +00:00
|
|
|
$this->edittime = $request->getVal( 'wpEdittime' );
|
|
|
|
|
if( !preg_match( '/^\d{14}$/', $this->edittime ) ) $this->edittime = "";
|
2004-03-18 06:56:14 +00:00
|
|
|
|
2004-03-08 09:09:35 +00:00
|
|
|
$this->save = $request->getCheck( 'wpSave' );
|
|
|
|
|
$this->preview = $request->getCheck( 'wpPreview' );
|
|
|
|
|
$this->minoredit = $request->getCheck( 'wpMinoredit' );
|
|
|
|
|
$this->watchthis = $request->getCheck( 'wpWatchthis' );
|
2004-03-18 06:56:14 +00:00
|
|
|
|
2004-03-08 09:09:35 +00:00
|
|
|
$this->oldid = $request->getInt( 'oldid' );
|
2004-03-18 06:56:14 +00:00
|
|
|
|
2004-03-08 09:09:35 +00:00
|
|
|
# Section edit can come from either the form or a link
|
|
|
|
|
$this->section = $request->getVal( 'wpSection', $request->getVal( 'section' ) );
|
|
|
|
|
}
|
2004-03-18 06:56:14 +00:00
|
|
|
|
2003-08-02 20:43:11 +00:00
|
|
|
# Since there is only one text field on the edit form,
|
|
|
|
|
# pressing <enter> will cause the form to be submitted, but
|
|
|
|
|
# the submit button value won't appear in the query, so we
|
|
|
|
|
# Fake it here before going back to edit(). This is kind of
|
|
|
|
|
# ugly, but it helps some old URLs to still work.
|
|
|
|
|
|
|
|
|
|
function submit()
|
|
|
|
|
{
|
2004-03-08 09:09:35 +00:00
|
|
|
if( !$this->preview ) $this->save = true;
|
2003-08-02 20:43:11 +00:00
|
|
|
|
|
|
|
|
$this->edit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# The edit form is self-submitting, so that when things like
|
|
|
|
|
# preview and edit conflicts occur, we get the same form back
|
|
|
|
|
# with the extra stuff added. Only when the final submission
|
|
|
|
|
# is made and all is well do we actually save and redirect to
|
|
|
|
|
# the newly-edited page.
|
|
|
|
|
|
|
|
|
|
function editForm( $formtype )
|
|
|
|
|
{
|
|
|
|
|
global $wgOut, $wgUser;
|
2004-02-29 08:43:29 +00:00
|
|
|
global $wgLang, $wgParser, $wgTitle;
|
|
|
|
|
global $wgAllowAnonymousMinor;
|
2004-03-20 08:41:33 +00:00
|
|
|
global $wgWhitelistEdit;
|
2003-08-02 20:43:11 +00:00
|
|
|
|
|
|
|
|
$sk = $wgUser->getSkin();
|
|
|
|
|
$isConflict = false;
|
|
|
|
|
|
|
|
|
|
if(!$this->mTitle->getArticleID()) { # new article
|
|
|
|
|
$wgOut->addWikiText(wfmsg("newarticletext"));
|
2004-03-05 21:44:38 +00:00
|
|
|
}
|
2003-08-02 20:43:11 +00:00
|
|
|
|
2004-03-08 09:39:01 +00:00
|
|
|
if( Namespace::isTalk( $this->mTitle->getNamespace() ) ) {
|
2004-03-05 21:44:38 +00:00
|
|
|
$wgOut->addWikiText(wfmsg("talkpagetext"));
|
2003-08-02 20:43:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Attempt submission here. This will check for edit conflicts,
|
|
|
|
|
# and redundantly check for locked database, blocked IPs, etc.
|
|
|
|
|
# that edit() already checked just in case someone tries to sneak
|
|
|
|
|
# in the back door with a hand-edited submission URL.
|
|
|
|
|
|
|
|
|
|
if ( "save" == $formtype ) {
|
|
|
|
|
if ( $wgUser->isBlocked() ) {
|
|
|
|
|
$this->blockedIPpage();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-08-05 11:04:02 +00:00
|
|
|
if ( !$wgUser->getID() && $wgWhitelistEdit ) {
|
|
|
|
|
$this->userNotLoggedInPage();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-08-02 20:43:11 +00:00
|
|
|
if ( wfReadOnly() ) {
|
|
|
|
|
$wgOut->readOnlyPage();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
# If article is new, insert it.
|
New edit toolbar for bold, italic, links, headlines, math, images, media,
sigs, horizontal lines (more can be added easily). Select text and click
to apply, or just click to see an example. Mouseover should show speedtips.
Also, access keys for the edit window (ALT+P=Preview, ALT+S=Save) -> Moz+IE
2004-01-11 04:11:43 +00:00
|
|
|
|
|
|
|
|
$aid = $this->mTitle->getArticleID();
|
2003-08-02 20:43:11 +00:00
|
|
|
if ( 0 == $aid ) {
|
2004-03-08 09:09:35 +00:00
|
|
|
# Don't save a new article if it's blank.
|
|
|
|
|
if ( ( "" == $this->textbox1 ) ||
|
|
|
|
|
( wfMsg( "newarticletext" ) == $this->textbox1 ) ) {
|
2004-03-07 07:26:56 +00:00
|
|
|
$wgOut->redirect( $this->mTitle->getFullURL() );
|
2003-08-02 20:43:11 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2004-03-08 09:09:35 +00:00
|
|
|
$this->mArticle->insertNewArticle( $this->textbox1, $this->summary, $this->minoredit, $this->watchthis );
|
2003-08-02 20:43:11 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2004-03-18 15:02:56 +00:00
|
|
|
|
2003-08-02 20:43:11 +00:00
|
|
|
# Article exists. Check for edit conflict.
|
|
|
|
|
|
|
|
|
|
$this->mArticle->clear(); # Force reload of dates, etc.
|
2004-03-14 22:28:52 +00:00
|
|
|
|
2004-03-18 06:56:14 +00:00
|
|
|
if( ( $this->section != "new" ) &&
|
2004-03-14 22:28:52 +00:00
|
|
|
($this->mArticle->getTimestamp() != $this->edittime ) ) {
|
New edit toolbar for bold, italic, links, headlines, math, images, media,
sigs, horizontal lines (more can be added easily). Select text and click
to apply, or just click to see an example. Mouseover should show speedtips.
Also, access keys for the edit window (ALT+P=Preview, ALT+S=Save) -> Moz+IE
2004-01-11 04:11:43 +00:00
|
|
|
$isConflict = true;
|
2003-08-02 20:43:11 +00:00
|
|
|
}
|
2004-03-08 09:09:35 +00:00
|
|
|
$userid = $wgUser->getID();
|
2003-08-02 20:43:11 +00:00
|
|
|
|
2004-03-18 06:56:14 +00:00
|
|
|
$text = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded(
|
2004-03-14 22:28:52 +00:00
|
|
|
$this->section, $this->textbox1, $this->summary);
|
2004-02-26 13:37:26 +00:00
|
|
|
# Suppress edit conflict with self
|
2003-08-02 20:43:11 +00:00
|
|
|
|
2004-03-08 09:09:35 +00:00
|
|
|
if ( ( 0 != $userid ) && ( $this->mArticle->getUser() == $userid ) ) {
|
2003-08-02 20:43:11 +00:00
|
|
|
$isConflict = false;
|
|
|
|
|
} else {
|
|
|
|
|
# switch from section editing to normal editing in edit conflict
|
2004-03-08 09:09:35 +00:00
|
|
|
# FIXME: This is confusing. In theory we should attempt to merge, finding
|
|
|
|
|
# the equivalent section if it's unchanged and avoid the conflict.
|
2003-08-02 20:43:11 +00:00
|
|
|
if($isConflict) {
|
2004-03-14 22:28:52 +00:00
|
|
|
if( $this->mergeChangesInto( $text ) ){
|
2004-03-14 15:05:52 +00:00
|
|
|
// Successful merge! Maybe we should tell the user the good news?
|
|
|
|
|
$isConflict = false;
|
|
|
|
|
} else {
|
|
|
|
|
$this->section = "";
|
2004-03-14 22:28:52 +00:00
|
|
|
$this->textbox1 = $text;
|
2004-03-14 15:05:52 +00:00
|
|
|
}
|
2003-08-02 20:43:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( ! $isConflict ) {
|
|
|
|
|
# All's well: update the article here
|
2004-03-14 22:28:52 +00:00
|
|
|
if($this->mArticle->updateArticle( $text, $this->summary, $this->minoredit, $this->watchthis ))
|
2003-08-17 11:58:33 +00:00
|
|
|
return;
|
|
|
|
|
else
|
|
|
|
|
$isConflict = true;
|
2003-08-02 20:43:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
# First time through: get contents, set time for conflict
|
|
|
|
|
# checking, etc.
|
|
|
|
|
|
|
|
|
|
if ( "initial" == $formtype ) {
|
2004-03-08 09:09:35 +00:00
|
|
|
$this->edittime = $this->mArticle->getTimestamp();
|
|
|
|
|
$this->textbox1 = $this->mArticle->getContent(true);
|
|
|
|
|
$this->summary = "";
|
2004-03-10 14:24:40 +00:00
|
|
|
$this->proxyCheck();
|
2003-08-02 20:43:11 +00:00
|
|
|
}
|
|
|
|
|
$wgOut->setRobotpolicy( "noindex,nofollow" );
|
2004-03-18 06:56:14 +00:00
|
|
|
|
2004-01-17 09:49:43 +00:00
|
|
|
# Enabled article-related sidebar, toplinks, etc.
|
|
|
|
|
$wgOut->setArticleRelated( true );
|
2003-08-02 20:43:11 +00:00
|
|
|
|
|
|
|
|
if ( $isConflict ) {
|
2003-11-15 14:21:29 +00:00
|
|
|
$s = wfMsg( "editconflict", $this->mTitle->getPrefixedText() );
|
2003-08-02 20:43:11 +00:00
|
|
|
$wgOut->setPageTitle( $s );
|
|
|
|
|
$wgOut->addHTML( wfMsg( "explainconflict" ) );
|
|
|
|
|
|
2004-03-08 09:09:35 +00:00
|
|
|
$this->textbox2 = $this->textbox1;
|
|
|
|
|
$this->textbox1 = $this->mArticle->getContent(true);
|
|
|
|
|
$this->edittime = $this->mArticle->getTimestamp();
|
2003-08-02 20:43:11 +00:00
|
|
|
} else {
|
2003-11-15 14:21:29 +00:00
|
|
|
$s = wfMsg( "editing", $this->mTitle->getPrefixedText() );
|
2003-08-02 20:43:11 +00:00
|
|
|
|
2004-03-08 09:09:35 +00:00
|
|
|
if( $this->section != "" ) {
|
|
|
|
|
if( $this->section == "new" ) {
|
2003-08-02 20:43:11 +00:00
|
|
|
$s.=wfMsg("commentedit");
|
|
|
|
|
} else {
|
|
|
|
|
$s.=wfMsg("sectionedit");
|
|
|
|
|
}
|
2004-03-20 01:18:19 +00:00
|
|
|
if(!$this->preview) {
|
|
|
|
|
$sectitle=preg_match("/^=+(.*?)=+/mi",
|
|
|
|
|
$this->textbox1,
|
|
|
|
|
$matches);
|
|
|
|
|
if($matches[1]) { $this->summary = "(".trim($matches[1]).")"; }
|
|
|
|
|
}
|
2003-08-02 20:43:11 +00:00
|
|
|
}
|
|
|
|
|
$wgOut->setPageTitle( $s );
|
2004-03-08 09:09:35 +00:00
|
|
|
if ( $this->oldid ) {
|
2003-08-02 20:43:11 +00:00
|
|
|
$this->mArticle->setOldSubtitle();
|
|
|
|
|
$wgOut->addHTML( wfMsg( "editingold" ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( wfReadOnly() ) {
|
|
|
|
|
$wgOut->addHTML( "<strong>" .
|
|
|
|
|
wfMsg( "readonlywarning" ) .
|
|
|
|
|
"</strong>" );
|
|
|
|
|
}
|
|
|
|
|
if( $this->mTitle->isProtected() ) {
|
|
|
|
|
$wgOut->addHTML( "<strong>" . wfMsg( "protectedpagewarning" ) .
|
|
|
|
|
"</strong><br />\n" );
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-08 09:09:35 +00:00
|
|
|
$kblength = (int)(strlen( $this->textbox1 ) / 1024);
|
2003-08-02 20:43:11 +00:00
|
|
|
if( $kblength > 29 ) {
|
New edit toolbar for bold, italic, links, headlines, math, images, media,
sigs, horizontal lines (more can be added easily). Select text and click
to apply, or just click to see an example. Mouseover should show speedtips.
Also, access keys for the edit window (ALT+P=Preview, ALT+S=Save) -> Moz+IE
2004-01-11 04:11:43 +00:00
|
|
|
$wgOut->addHTML( "<strong>" .
|
2003-11-15 14:21:29 +00:00
|
|
|
wfMsg( "longpagewarning", $kblength )
|
2003-08-02 20:43:11 +00:00
|
|
|
. "</strong>" );
|
|
|
|
|
}
|
New edit toolbar for bold, italic, links, headlines, math, images, media,
sigs, horizontal lines (more can be added easily). Select text and click
to apply, or just click to see an example. Mouseover should show speedtips.
Also, access keys for the edit window (ALT+P=Preview, ALT+S=Save) -> Moz+IE
2004-01-11 04:11:43 +00:00
|
|
|
|
2003-08-02 20:43:11 +00:00
|
|
|
$rows = $wgUser->getOption( "rows" );
|
|
|
|
|
$cols = $wgUser->getOption( "cols" );
|
|
|
|
|
|
|
|
|
|
$ew = $wgUser->getOption( "editwidth" );
|
|
|
|
|
if ( $ew ) $ew = " style=\"width:100%\"";
|
|
|
|
|
else $ew = "" ;
|
|
|
|
|
|
|
|
|
|
$q = "action=submit";
|
2004-03-08 09:09:35 +00:00
|
|
|
#if ( "no" == $redirect ) { $q .= "&redirect=no"; }
|
2004-03-07 07:26:56 +00:00
|
|
|
$action = $this->mTitle->escapeLocalURL( $q );
|
2003-08-02 20:43:11 +00:00
|
|
|
|
New edit toolbar for bold, italic, links, headlines, math, images, media,
sigs, horizontal lines (more can be added easily). Select text and click
to apply, or just click to see an example. Mouseover should show speedtips.
Also, access keys for the edit window (ALT+P=Preview, ALT+S=Save) -> Moz+IE
2004-01-11 04:11:43 +00:00
|
|
|
$summary = wfMsg( "summary" );
|
2003-08-02 20:43:11 +00:00
|
|
|
$subject = wfMsg("subject");
|
|
|
|
|
$minor = wfMsg( "minoredit" );
|
|
|
|
|
$watchthis = wfMsg ("watchthis");
|
|
|
|
|
$save = wfMsg( "savearticle" );
|
|
|
|
|
$prev = wfMsg( "showpreview" );
|
|
|
|
|
|
|
|
|
|
$cancel = $sk->makeKnownLink( $this->mTitle->getPrefixedURL(),
|
|
|
|
|
wfMsg( "cancel" ) );
|
|
|
|
|
$edithelp = $sk->makeKnownLink( wfMsg( "edithelppage" ),
|
|
|
|
|
wfMsg( "edithelp" ) );
|
2003-11-15 14:21:29 +00:00
|
|
|
$copywarn = wfMsg( "copyrightwarning", $sk->makeKnownLink(
|
|
|
|
|
wfMsg( "copyrightpage" ) ) );
|
2003-08-02 20:43:11 +00:00
|
|
|
|
2004-01-18 04:14:37 +00:00
|
|
|
if($wgUser->getOption("showtoolbar")) {
|
New edit toolbar for bold, italic, links, headlines, math, images, media,
sigs, horizontal lines (more can be added easily). Select text and click
to apply, or just click to see an example. Mouseover should show speedtips.
Also, access keys for the edit window (ALT+P=Preview, ALT+S=Save) -> Moz+IE
2004-01-11 04:11:43 +00:00
|
|
|
// prepare toolbar for edit buttons
|
|
|
|
|
$toolbar=$sk->getEditToolbar();
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-02 20:43:11 +00:00
|
|
|
// activate checkboxes if user wants them to be always active
|
2004-03-08 09:09:35 +00:00
|
|
|
if( !$this->preview ) {
|
|
|
|
|
if( $wgUser->getOption( "watchdefault" ) ) $this->watchthis = true;
|
|
|
|
|
if( $wgUser->getOption( "minordefault" ) ) $this->minoredit = true;
|
2004-03-18 06:56:14 +00:00
|
|
|
|
2004-03-08 09:09:35 +00:00
|
|
|
// activate checkbox also if user is already watching the page,
|
|
|
|
|
// require wpWatchthis to be unset so that second condition is not
|
|
|
|
|
// checked unnecessarily
|
|
|
|
|
if( !$this->watchthis && $this->mTitle->userIsWatching() ) $this->watchthis = true;
|
|
|
|
|
}
|
2004-03-18 06:56:14 +00:00
|
|
|
|
2004-03-08 09:09:35 +00:00
|
|
|
$minoredithtml = "";
|
New edit toolbar for bold, italic, links, headlines, math, images, media,
sigs, horizontal lines (more can be added easily). Select text and click
to apply, or just click to see an example. Mouseover should show speedtips.
Also, access keys for the edit window (ALT+P=Preview, ALT+S=Save) -> Moz+IE
2004-01-11 04:11:43 +00:00
|
|
|
|
2004-01-28 22:57:07 +00:00
|
|
|
if ( 0 != $wgUser->getID() || $wgAllowAnonymousMinor ) {
|
|
|
|
|
$minoredithtml =
|
2004-03-08 09:09:35 +00:00
|
|
|
"<input tabindex='3' type='checkbox' value='1' name='wpMinoredit'".($this->minoredit?" checked":"")." id='wpMinoredit'>".
|
2004-01-28 22:57:07 +00:00
|
|
|
"<label for='wpMinoredit'>{$minor}</label>";
|
2003-08-02 20:43:11 +00:00
|
|
|
}
|
2004-03-18 06:56:14 +00:00
|
|
|
|
2004-03-08 09:09:35 +00:00
|
|
|
$watchhtml = "";
|
2004-03-18 06:56:14 +00:00
|
|
|
|
2004-01-28 22:57:07 +00:00
|
|
|
if ( 0 != $wgUser->getID() ) {
|
2004-03-08 09:09:35 +00:00
|
|
|
$watchhtml = "<input tabindex='4' type='checkbox' name='wpWatchthis'".($this->watchthis?" checked":"")." id='wpWatchthis'>".
|
2004-01-28 22:57:07 +00:00
|
|
|
"<label for='wpWatchthis'>{$watchthis}</label>";
|
|
|
|
|
}
|
2004-03-18 06:56:14 +00:00
|
|
|
|
2004-03-08 09:09:35 +00:00
|
|
|
$checkboxhtml = $minoredithtml . $watchhtml . "<br>";
|
2003-08-02 20:43:11 +00:00
|
|
|
|
|
|
|
|
if ( "preview" == $formtype) {
|
New edit toolbar for bold, italic, links, headlines, math, images, media,
sigs, horizontal lines (more can be added easily). Select text and click
to apply, or just click to see an example. Mouseover should show speedtips.
Also, access keys for the edit window (ALT+P=Preview, ALT+S=Save) -> Moz+IE
2004-01-11 04:11:43 +00:00
|
|
|
$previewhead="<h2>" . wfMsg( "preview" ) . "</h2>\n<p><large><center><font color=\"#cc0000\">" .
|
2004-03-08 09:09:35 +00:00
|
|
|
wfMsg( "note" ) . wfMsg( "previewnote" ) . "</font></center></large><p>\n";
|
2003-08-02 20:43:11 +00:00
|
|
|
if ( $isConflict ) {
|
|
|
|
|
$previewhead.="<h2>" . wfMsg( "previewconflict" ) .
|
|
|
|
|
"</h2>\n";
|
|
|
|
|
}
|
2004-03-08 09:09:35 +00:00
|
|
|
$previewtext = wfUnescapeHTML( $this->textbox1 );
|
New edit toolbar for bold, italic, links, headlines, math, images, media,
sigs, horizontal lines (more can be added easily). Select text and click
to apply, or just click to see an example. Mouseover should show speedtips.
Also, access keys for the edit window (ALT+P=Preview, ALT+S=Save) -> Moz+IE
2004-01-11 04:11:43 +00:00
|
|
|
|
2004-02-29 08:43:29 +00:00
|
|
|
$parserOptions = ParserOptions::newFromUser( $wgUser );
|
|
|
|
|
$parserOptions->setUseCategoryMagic( false );
|
|
|
|
|
$parserOptions->setEditSection( false );
|
|
|
|
|
$parserOptions->setEditSectionOnRightClick( false );
|
|
|
|
|
$parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $previewtext ) ."\n\n",
|
|
|
|
|
$wgTitle, $parserOptions );
|
|
|
|
|
$previewHTML = $parserOutput->mText;
|
2004-03-18 06:56:14 +00:00
|
|
|
|
2003-08-02 20:43:11 +00:00
|
|
|
if($wgUser->getOption("previewontop")) {
|
|
|
|
|
$wgOut->addHTML($previewhead);
|
2004-02-29 08:43:29 +00:00
|
|
|
$wgOut->addHTML($previewHTML);
|
2003-08-02 20:43:11 +00:00
|
|
|
}
|
|
|
|
|
$wgOut->addHTML( "<br clear=\"all\" />\n" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# if this is a comment, show a subject line at the top, which is also the edit summary.
|
|
|
|
|
# Otherwise, show a summary field at the bottom
|
2004-03-08 09:09:35 +00:00
|
|
|
$summarytext = htmlspecialchars( $wgLang->recodeForEdit( $this->summary ) ); # FIXME
|
|
|
|
|
if( $this->section == "new" ) {
|
|
|
|
|
$commentsubject="{$subject}: <input tabindex='1' type='text' value=\"$summarytext\" name=\"wpSummary\" maxlength='200' size='60'><br>";
|
2004-03-08 01:51:32 +00:00
|
|
|
$editsummary = "";
|
2003-08-02 20:43:11 +00:00
|
|
|
} else {
|
2004-03-08 01:51:32 +00:00
|
|
|
$commentsubject = "";
|
2004-03-08 09:09:35 +00:00
|
|
|
$editsummary="{$summary}: <input tabindex='3' type='text' value=\"$summarytext\" name=\"wpSummary\" maxlength='200' size='60'><br>";
|
2003-08-02 20:43:11 +00:00
|
|
|
}
|
|
|
|
|
|
2004-03-08 09:09:35 +00:00
|
|
|
if( !$this->preview ) {
|
2003-12-11 05:52:15 +00:00
|
|
|
# Don't select the edit box on preview; this interferes with seeing what's going on.
|
|
|
|
|
$wgOut->setOnloadHandler( "document.editform.wpTextbox1.focus()" );
|
|
|
|
|
}
|
2003-08-02 20:43:11 +00:00
|
|
|
$wgOut->addHTML( "
|
New edit toolbar for bold, italic, links, headlines, math, images, media,
sigs, horizontal lines (more can be added easily). Select text and click
to apply, or just click to see an example. Mouseover should show speedtips.
Also, access keys for the edit window (ALT+P=Preview, ALT+S=Save) -> Moz+IE
2004-01-11 04:11:43 +00:00
|
|
|
{$toolbar}
|
2003-08-02 20:43:11 +00:00
|
|
|
<form id=\"editform\" name=\"editform\" method=\"post\" action=\"$action\"
|
|
|
|
|
enctype=\"application/x-www-form-urlencoded\">
|
|
|
|
|
{$commentsubject}
|
2004-03-08 09:09:35 +00:00
|
|
|
<textarea tabindex='2' name=\"wpTextbox1\" rows='{$rows}'
|
|
|
|
|
cols='{$cols}'{$ew} wrap=\"virtual\">" .
|
|
|
|
|
htmlspecialchars( $wgLang->recodeForEdit( $this->textbox1 ) ) .
|
2003-08-02 20:43:11 +00:00
|
|
|
"
|
|
|
|
|
</textarea>
|
|
|
|
|
<br>{$editsummary}
|
|
|
|
|
{$checkboxhtml}
|
2004-03-08 09:09:35 +00:00
|
|
|
<input tabindex='5' type='submit' value=\"{$save}\" name=\"wpSave\" accesskey=\"s\">
|
|
|
|
|
<input tabindex='6' type='submit' value=\"{$prev}\" name=\"wpPreview\" accesskey=\"p\">
|
2003-08-02 20:43:11 +00:00
|
|
|
<em>{$cancel}</em> | <em>{$edithelp}</em>
|
|
|
|
|
<br><br>{$copywarn}
|
2004-03-08 09:09:35 +00:00
|
|
|
<input type=hidden value=\"" . htmlspecialchars( $this->section ) . "\" name=\"wpSection\">
|
|
|
|
|
<input type=hidden value=\"{$this->edittime}\" name=\"wpEdittime\">\n" );
|
2003-08-02 20:43:11 +00:00
|
|
|
|
|
|
|
|
if ( $isConflict ) {
|
|
|
|
|
$wgOut->addHTML( "<h2>" . wfMsg( "yourdiff" ) . "</h2>\n" );
|
2004-03-14 13:42:16 +00:00
|
|
|
DifferenceEngine::showDiff( $this->textbox2, $this->textbox1,
|
2003-08-02 20:43:11 +00:00
|
|
|
wfMsg( "yourtext" ), wfMsg( "storedversion" ) );
|
|
|
|
|
|
|
|
|
|
$wgOut->addHTML( "<h2>" . wfMsg( "yourtext" ) . "</h2>
|
2004-03-08 09:09:35 +00:00
|
|
|
<textarea tabindex=6 name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}' wrap='virtual'>"
|
2004-03-14 13:42:16 +00:00
|
|
|
. htmlspecialchars( $wgLang->recodeForEdit( $this->textbox2 ) ) .
|
2003-08-02 20:43:11 +00:00
|
|
|
"
|
|
|
|
|
</textarea>" );
|
|
|
|
|
}
|
|
|
|
|
$wgOut->addHTML( "</form>\n" );
|
|
|
|
|
if($formtype =="preview" && !$wgUser->getOption("previewontop")) {
|
|
|
|
|
$wgOut->addHTML($previewhead);
|
2004-02-29 08:43:29 +00:00
|
|
|
$wgOut->addHTML($previewHTML);
|
2003-08-02 20:43:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function blockedIPpage()
|
|
|
|
|
{
|
2004-01-30 17:07:50 +00:00
|
|
|
global $wgOut, $wgUser, $wgLang, $wgIP;
|
2003-08-02 20:43:11 +00:00
|
|
|
|
|
|
|
|
$wgOut->setPageTitle( wfMsg( "blockedtitle" ) );
|
|
|
|
|
$wgOut->setRobotpolicy( "noindex,nofollow" );
|
2004-01-17 09:49:43 +00:00
|
|
|
$wgOut->setArticleRelated( false );
|
2003-08-02 20:43:11 +00:00
|
|
|
|
|
|
|
|
$id = $wgUser->blockedBy();
|
|
|
|
|
$reason = $wgUser->blockedFor();
|
2004-01-30 17:07:50 +00:00
|
|
|
$ip = $wgIP;
|
|
|
|
|
|
|
|
|
|
$name = User::whoIs( $id );
|
2003-08-02 20:43:11 +00:00
|
|
|
$link = "[[" . $wgLang->getNsText( Namespace::getUser() ) .
|
|
|
|
|
":{$name}|{$name}]]";
|
|
|
|
|
|
2003-12-12 00:25:29 +00:00
|
|
|
$wgOut->addWikiText( wfMsg( "blockedtext", $link, $reason, $ip ) );
|
2003-08-02 20:43:11 +00:00
|
|
|
$wgOut->returnToMain( false );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-05 11:04:02 +00:00
|
|
|
|
|
|
|
|
function userNotLoggedInPage()
|
|
|
|
|
{
|
|
|
|
|
global $wgOut, $wgUser, $wgLang;
|
|
|
|
|
|
|
|
|
|
$wgOut->setPageTitle( wfMsg( "whitelistedittitle" ) );
|
|
|
|
|
$wgOut->setRobotpolicy( "noindex,nofollow" );
|
2004-01-17 09:49:43 +00:00
|
|
|
$wgOut->setArticleRelated( false );
|
2003-08-05 11:04:02 +00:00
|
|
|
|
|
|
|
|
$wgOut->addWikiText( wfMsg( "whitelistedittext" ) );
|
|
|
|
|
$wgOut->returnToMain( false );
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-10 14:24:40 +00:00
|
|
|
# Forks processes to scan the originating IP for an open proxy server
|
|
|
|
|
# MemCached can be used to skip IPs that have already been scanned
|
|
|
|
|
function proxyCheck()
|
|
|
|
|
{
|
|
|
|
|
global $wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath;
|
|
|
|
|
global $wgIP, $wgUseMemCached, $wgMemc, $wgDBname, $wgProxyMemcExpiry;
|
|
|
|
|
|
|
|
|
|
if ( !$wgBlockOpenProxies ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Get MemCached key
|
|
|
|
|
$skip = false;
|
2004-03-13 02:20:35 +00:00
|
|
|
if ( $wgUseMemCached ) {
|
2004-03-10 14:24:40 +00:00
|
|
|
$mcKey = "$wgDBname:proxy:ip:$wgIP";
|
|
|
|
|
$mcValue = $wgMemc->get( $mcKey );
|
|
|
|
|
if ( $mcValue ) {
|
|
|
|
|
$skip = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-08-05 11:04:02 +00:00
|
|
|
|
2004-03-10 14:24:40 +00:00
|
|
|
# Fork the processes
|
|
|
|
|
if ( !$skip ) {
|
|
|
|
|
$title = Title::makeTitle( NS_SPECIAL, "Blockme" );
|
|
|
|
|
$url = $title->getFullURL();
|
|
|
|
|
foreach ( $wgProxyPorts as $port ) {
|
|
|
|
|
$params = implode( " ", array(
|
|
|
|
|
escapeshellarg( $wgProxyScriptPath ),
|
|
|
|
|
escapeshellarg( $wgIP ),
|
|
|
|
|
escapeshellarg( $port ),
|
|
|
|
|
escapeshellarg( $url )
|
|
|
|
|
));
|
|
|
|
|
exec( "php $params &>/dev/null &" );
|
|
|
|
|
}
|
|
|
|
|
# Set MemCached key
|
|
|
|
|
if ( $wgUseMemCached ) {
|
|
|
|
|
$wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-03-14 15:05:52 +00:00
|
|
|
|
2004-03-14 22:28:52 +00:00
|
|
|
/* private */ function mergeChangesInto( &$text ){
|
2004-03-14 15:05:52 +00:00
|
|
|
$oldDate = $this->edittime;
|
|
|
|
|
$res = wfQuery("SELECT cur_text FROM cur WHERE cur_id=" .
|
|
|
|
|
$this->mTitle->getArticleID() . " FOR UPDATE", DB_WRITE);
|
|
|
|
|
$obj = wfFetchObject($res);
|
|
|
|
|
|
|
|
|
|
$yourtext = $obj->cur_text;
|
|
|
|
|
$ns = $this->mTitle->getNamespace();
|
|
|
|
|
$title = wfStrencode( $this->mTitle->getDBkey() );
|
|
|
|
|
$res = wfQuery("SELECT old_text FROM old WHERE old_namespace = $ns AND ".
|
|
|
|
|
"old_title = '{$title}' AND old_timestamp = '{$oldDate}'", DB_WRITE);
|
|
|
|
|
$obj = wfFetchObject($res);
|
2004-03-14 22:28:52 +00:00
|
|
|
if(wfMerge($obj->old_text, $text, $yourtext, $result)){
|
|
|
|
|
$text = $result;
|
2004-03-14 15:05:52 +00:00
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-08-02 20:43:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|