}
function importFormData( &$request ) {
+ global $wgIsMySQL, $wgIsPg;
# 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->summary = trim( $request->getText( "wpSummary" ) );
$this->edittime = $request->getVal( 'wpEdittime' );
- if( !preg_match( '/^\d{14}$/', $this->edittime ) ) $this->edittime = "";
+ if ($wgIsMySQL)
+ if( !preg_match( '/^\d{14}$/', $this->edittime )) $this->edittime = "";
+ if ($wgIsPg)
+ if ( !preg_match( '/^\d{4}-\d\d-\d\d \d\d:\d\d:\d\d$/',
+ $this->edittime ))
+ $this->edittime = "";
$this->preview = $request->getCheck( 'wpPreview' );
$this->save = $request->wasPosted() && !$this->preview;
if ( "save" == $formtype ) {
# Check for spam
if ( $wgSpamRegex && preg_match( $wgSpamRegex, $this->textbox1 ) ) {
- sleep(10);
- $wgOut->redirect( $this->mTitle->getFullURL() );
+ if ( $wgUser->isSysop() ) {
+ $this->spamPage();
+ } else {
+ sleep(10);
+ $wgOut->redirect( $this->mTitle->getFullURL() );
+ }
return;
}
if ( $wgUser->isBlocked() ) {
$hasmatch = preg_match( "/^ *([=]{1,6})(.*?)(\\1) *\\n/i", $this->textbox1, $matches );
# we can't deal with anchors, includes, html etc in the header for now,
# headline would need to be parsed to improve this
- if($hasmatch and strlen($matches[2]) > 0 and !preg_match( "/[\\['{<>]/", $matches[2])) {
+ #if($hasmatch and strlen($matches[2]) > 0 and !preg_match( "/[\\['{<>]/", $matches[2])) {
+ if($hasmatch and strlen($matches[2]) > 0) {
global $wgInputEncoding;
$headline = do_html_entity_decode( $matches[2], ENT_COMPAT, $wgInputEncoding );
- # strip out HTML, will be useful when
- # $headline = preg_replace( "/<.*?" . ">/","",$headline );
+ # strip out HTML
+ $headline = preg_replace( "/<.*?" . ">/","",$headline );
$headline = trim( $headline );
- $sectionanchor = '#'.preg_replace("/[ \\?&\\/<>\\(\\)\\[\\]=,+']+/", '_', urlencode( $headline ) );
+ $sectionanchor = '#'.urlencode( str_replace(' ', '_', $headline ) );
+ $replacearray = array(
+ '%3A' => ':',
+ '%' => '.'
+ );
+ $sectionanchor = str_replace(array_keys($replacearray),array_values($replacearray),$sectionanchor);
}
}
$save = wfMsg( "savearticle" );
$prev = wfMsg( "showpreview" );
- $cancel = $sk->makeKnownLink( $this->mTitle->getPrefixedURL(),
+ $cancel = $sk->makeKnownLink( $this->mTitle->getPrefixedText(),
wfMsg( "cancel" ) );
- $edithelpurl = $sk->makeUrl( wfMsg( "edithelppage" ));
- $edithelp = '<a onclick="window.open('.
- "'$edithelpurl', 'helpwindow', 'width=610,height=400,left=10,top=10'".'); return false;" href="'.$edithelpurl.'">'.
- wfMsg( "edithelp" ).'</a>';
+ $edithelpurl = $sk->makeUrl( wfMsg( 'edithelppage' ));
+ $edithelp = '<a target="helpwindow" href="'.$edithelpurl.'">'.
+ htmlspecialchars( wfMsg( 'edithelp' ) ).'</a> '.
+ htmlspecialchars( wfMsg( 'newwindow' ) );
$copywarn = wfMsg( "copyrightwarning", $sk->makeKnownLink(
wfMsg( "copyrightpage" ) ) );
$previewhead.="<h2>" . wfMsg( "previewconflict" ) .
"</h2>\n";
}
- $previewtext = wfUnescapeHTML( $this->textbox1 );
$parserOptions = ParserOptions::newFromUser( $wgUser );
$parserOptions->setUseCategoryMagic( false );
$parserOutput = $wgParser->parse( $previewtext , $wgTitle, $parserOptions );
$wgOut->addHTML( $parserOutput->mText );
} else {
- $parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $previewtext ) ."\n\n",
+ $parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $this->textbox1 ) ."\n\n",
$wgTitle, $parserOptions );
$previewHTML = $parserOutput->mText;
$wgOut->addHTML($previewhead);
$wgOut->addHTML($previewHTML);
}
+ $wgOut->addLanguageLinks($parserOutput->getLanguageLinks());
$wgOut->addHTML( "<br style=\"clear:both;\" />\n" );
}
}
</textarea>
<br />{$editsummary}
{$checkboxhtml}
-<input tabindex='5' type='submit' value=\"{$save}\" name=\"wpSave\" accesskey=\"".wfMsg('accesskey-save')."\"".
+<input tabindex='5' id='wpSave' type='submit' value=\"{$save}\" name=\"wpSave\" accesskey=\"".wfMsg('accesskey-save')."\"".
" title=\"".wfMsg('tooltip-save')."\"/>
-<input tabindex='6' type='submit' value=\"{$prev}\" name=\"wpPreview\" accesskey=\"".wfMsg('accesskey-preview')."\"".
+<input tabindex='6' id='wpSave' type='submit' value=\"{$prev}\" name=\"wpPreview\" accesskey=\"".wfMsg('accesskey-preview')."\"".
" title=\"".wfMsg('tooltip-preview')."\"/>
<em>{$cancel}</em> | <em>{$edithelp}</em>
<br /><br />{$copywarn}
wfMsg( "yourtext" ), wfMsg( "storedversion" ) );
$wgOut->addHTML( "<h2>" . wfMsg( "yourtext" ) . "</h2>
-<textarea tabindex=6 name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}' wrap='virtual'>"
+<textarea tabindex=6 id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}' wrap='virtual'>"
. htmlspecialchars( $wgLang->recodeForEdit( $this->textbox2 ) ) .
"
</textarea>" );
$wgOut->returnToMain( false );
}
+ function spamPage()
+ {
+ global $wgOut, $wgSpamRegex;
+ $wgOut->setPageTitle( wfMsg( "spamprotectiontitle" ) );
+ $wgOut->setRobotpolicy( "noindex,nofollow" );
+ $wgOut->setArticleRelated( false );
+
+ $wgOut->addWikiText( wfMsg( "spamprotectiontext" ) );
+ $wgOut->addWikiText( "<pre>".$wgSpamRegex."</pre>" );
+ $wgOut->returnToMain( false );
+ }
+
# 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()
}
/* private */ function mergeChangesInto( &$text ){
+ global $wgIsPg;
$oldDate = $this->edittime;
$res = wfQuery("SELECT cur_text FROM cur WHERE cur_id=" .
$this->mTitle->getArticleID() . " FOR UPDATE", DB_WRITE);
$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 ".
+ $oldtable=$wgIsPg?'"old"':'old';
+ $res = wfQuery("SELECT old_text,old_flags FROM $oldtable WHERE old_namespace = $ns AND ".
"old_title = '{$title}' AND old_timestamp = '{$oldDate}'", DB_WRITE);
$obj = wfFetchObject($res);
- if(wfMerge($obj->old_text, $text, $yourtext, $result)){
+ $oldText = Article::getRevisionText( $obj );
+
+ if(wfMerge($oldText, $text, $yourtext, $result)){
$text = $result;
return true;
} else {