* @todo document
*/
function importFormData( &$request ) {
+ global $wgLang ;
$fname = 'EditPage::importFormData';
wfProfileIn( $fname );
$this->textbox1 = $this->safeUnicodeInput( $request, 'wpTextbox1' );
$this->textbox2 = $this->safeUnicodeInput( $request, 'wpTextbox2' );
$this->mMetaData = rtrim( $request->getText( 'metadata' ) );
- $this->summary = $request->getText( 'wpSummary' );
+ # Truncate for whole multibyte characters. +5 bytes for ellipsis
+ $this->summary = $wgLang->truncate( $request->getText( 'wpSummary' ), 250 );
$this->edittime = $request->getVal( 'wpEdittime' );
$this->starttime = $request->getVal( 'wpStarttime' );
}
function showIntro() {
- global $wgOut;
+ global $wgOut, $wgUser;
$addstandardintro=true;
if($this->editintro) {
$introtitle=Title::newFromText($this->editintro);
}
}
if($addstandardintro) {
- $wgOut->addWikiText( wfMsg( 'newarticletext' ) );
+ if ( $wgUser->isLoggedIn() )
+ $wgOut->addWikiText( wfMsg( 'newarticletext' ) );
+ else
+ $wgOut->addWikiText( wfMsg( 'newarticletextanon' ) );
}
}
wfProfileOut( "$fname-checks" );
return false;
}
+ if ( !wfRunHooks( 'EditFilter', array( &$this, $this->textbox1, $this->section ) ) ) {
+ # Error messages or other handling should be performed by the filter function
+ wfProfileOut( $fname );
+ wfProfileOut( "$fname-checks" );
+ return false;
+ }
if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) {
# Check block state against master, thus 'false'.
$this->blockedIPpage();
}
else {
$wgOut->readOnlyPage();
+ wfProfileOut( "$fname-checks" );
wfProfileOut( $fname );
return false;
}
$aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
if ( 0 == $aid ) {
# Don't save a new article if it's blank.
- if ( ( '' == $this->textbox1 ) ||
- ( wfMsg( 'newarticletext' ) == $this->textbox1 ) ) {
+ if ( ( '' == $this->textbox1 ) ) {
$wgOut->redirect( $this->mTitle->getFullURL() );
wfProfileOut( $fname );
return false;
- }
- if (wfRunHooks('ArticleSave', array(&$this->mArticle, &$wgUser, &$this->textbox1,
- &$this->summary, &$this->minoredit, &$this->watchthis, NULL)))
- {
-
- $isComment=($this->section=='new');
- $this->mArticle->insertNewArticle( $this->textbox1, $this->summary,
- $this->minoredit, $this->watchthis, false, $isComment);
- wfRunHooks('ArticleSaveComplete', array(&$this->mArticle, &$wgUser, $this->textbox1,
- $this->summary, $this->minoredit,
- $this->watchthis, NULL));
}
+
+ $isComment=($this->section=='new');
+ $this->mArticle->insertNewArticle( $this->textbox1, $this->summary,
+ $this->minoredit, $this->watchthis, false, $isComment);
+
wfProfileOut( $fname );
return false;
}
$text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary);
}
- # Suppress edit conflict with self
- if ( ( 0 != $userid ) && ( $this->mArticle->getUser() == $userid ) ) {
+ # Suppress edit conflict with self, except for section edits where merging is required.
+ if ( ( $this->section == '' ) && ( 0 != $userid ) && ( $this->mArticle->getUser() == $userid ) ) {
wfDebug( "Suppressing edit conflict, same user.\n" );
$this->isConflict = false;
} else {
$this->textbox1 = $text;
$this->section = '';
- if (wfRunHooks('ArticleSave', array(&$this->mArticle, &$wgUser, &$text,
- &$this->summary, &$this->minoredit,
- &$this->watchthis, &$sectionanchor)))
- {
- # update the article here
- if($this->mArticle->updateArticle( $text, $this->summary, $this->minoredit,
- $this->watchthis, '', $sectionanchor ))
- {
- wfRunHooks('ArticleSaveComplete',
- array(&$this->mArticle, &$wgUser, $text,
- $this->summary, $this->minoredit,
- $this->watchthis, $sectionanchor));
- wfProfileOut( $fname );
- return false;
- } else {
- $this->isConflict = true;
- }
+ # update the article here
+ if( $this->mArticle->updateArticle( $text, $this->summary, $this->minoredit,
+ $this->watchthis, '', $sectionanchor ) ) {
+ wfProfileOut( $fname );
+ return false;
+ } else {
+ $this->isConflict = true;
}
wfProfileOut( $fname );
return true;
$this->edittime = $this->mArticle->getTimestamp();
$this->textbox1 = $this->mArticle->getContent( true );
$this->summary = '';
- $this->proxyCheck();
+ wfProxyCheck();
}
/**
* Send the edit form and related headers to $wgOut
+ * @param $formCallback Optional callable that takes an OutputPage
+ * parameter; will be called during form output
+ * near the top, for captchas and the like.
*/
- function showEditForm() {
+ function showEditForm( $formCallback=null ) {
global $wgOut, $wgUser, $wgAllowAnonymousMinor, $wgLang, $wgContLang;
$fname = 'EditPage::showEditForm';
{$toolbar}
<form id="editform" name="editform" method="post" action="$action"
enctype="multipart/form-data">
+END
+);
+ if( is_callable( $formCallback ) ) {
+ call_user_func_array( $formCallback, array( &$wgOut ) );
+ }
+ $wgOut->addHTML( <<<END
$recreate
{$commentsubject}
<textarea tabindex='1' accesskey="," name="wpTextbox1" rows='{$rows}'
* @todo document
*/
function blockedIPpage() {
- global $wgOut, $wgUser, $wgContLang, $wgIP;
+ global $wgOut, $wgUser, $wgContLang;
$wgOut->setPageTitle( wfMsg( 'blockedtitle' ) );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
$id = $wgUser->blockedBy();
$reason = $wgUser->blockedFor();
- $ip = $wgIP;
+ $ip = wfGetIP();
if ( is_numeric( $id ) ) {
$name = User::whoIs( $id );
$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() {
- global $wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath;
- global $wgIP, $wgUseMemCached, $wgMemc, $wgDBname, $wgProxyMemcExpiry;
-
- if ( !$wgBlockOpenProxies ) {
- return;
- }
-
- # Get MemCached key
- $skip = false;
- if ( $wgUseMemCached ) {
- $mcKey = $wgDBname.':proxy:ip:'.$wgIP;
- $mcValue = $wgMemc->get( $mcKey );
- if ( $mcValue ) {
- $skip = true;
- }
- }
-
- # Fork the processes
- if ( !$skip ) {
- $title = Title::makeTitle( NS_SPECIAL, 'Blockme' );
- $iphash = md5( $wgIP . $wgProxyKey );
- $url = $title->getFullURL( 'ip='.$iphash );
-
- 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 );
- }
- }
- }
-
/**
* @access private
* @todo document
$toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
}
- $toolbar.="addInfobox('" . wfEscapeJsString( wfMsg( "infobox" ) ) .
- "','" . wfEscapeJsString( wfMsg( "infobox_alert" ) ) . "');\n";
$toolbar.="document.writeln(\"</div>\");\n";
-
$toolbar.="/*]]>*/\n</script>";
return $toolbar;
}
* @return string HTML
*/
function getDiff() {
+ global $wgUser;
+
require_once( 'DifferenceEngine.php' );
$oldtext = $this->mArticle->fetchContent();
$newtext = $this->mArticle->replaceSection(
$this->section, $this->textbox1, $this->summary, $this->edittime );
$oldtitle = wfMsg( 'currentrev' );
$newtitle = wfMsg( 'yourtext' );
- if ( $oldtext != wfMsg( 'noarticletext' ) || $newtext != '' ) {
+ if ( $oldtext != wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' ) || $newtext != '' ) {
$difftext = DifferenceEngine::getDiff( $oldtext, $newtext, $oldtitle, $newtitle );
}