*/
var $mContent, $mContentLoaded;
var $mUser, $mTimestamp, $mUserText;
- var $mCounter, $mComment, $mCountAdjustment;
+ var $mCounter, $mComment, $mGoodAdjustment, $mTotalAdjustment;
var $mMinorEdit, $mRedirectedFrom;
var $mTouched, $mFileCache, $mTitle;
var $mId, $mTable;
$this->mCurID = $this->mUser = $this->mCounter = -1; # Not loaded
$this->mRedirectedFrom = $this->mUserText =
$this->mTimestamp = $this->mComment = $this->mFileCache = '';
- $this->mCountAdjustment = 0;
+ $this->mGoodAdjustment = $this->mTotalAdjustment = 0;
$this->mTouched = '19700101000000';
$this->mForUpdate = false;
$this->mIsRedirect = false;
array( /* SET */
'page_latest' => $revision->getId(),
'page_touched' => $dbw->timestamp(),
- 'page_is_new' => ($lastRevision === 0) ? 0 : 1,
+ 'page_is_new' => ($lastRevision === 0) ? 1 : 0,
'page_is_redirect' => Article::isRedirect( $text ),
'page_len' => strlen( $text ),
),
$fname = 'Article::insertNewArticle';
- $this->mCountAdjustment = $this->isCountable( $text );
+ $this->mGoodAdjustment = $this->isCountable( $text );
+ $this->mTotalAdjustment = 1;
$ns = $this->mTitle->getNamespace();
$ttl = $this->mTitle->getDBkey();
$lastRevision = 0;
if ( 0 != strcmp( $text, $oldtext ) ) {
- $this->mCountAdjustment = $this->isCountable( $text )
+ $this->mGoodAdjustment = $this->isCountable( $text )
- $this->isCountable( $oldtext );
+ $this->mTotalAdjustment = 0;
$now = wfTimestampNow();
$lastRevision = $dbw->selectField(
*/
function showArticle( $text, $subtitle , $sectionanchor = '', $me2, $now, $summary, $oldid ) {
global $wgUseDumbLinkUpdate, $wgAntiLockFlags, $wgOut, $wgUser, $wgLinkCache, $wgEnotif;
+ global $wgUseEnotif;
$wgLinkCache = new LinkCache();
$r = '';
$wgOut->redirect( $this->mTitle->getFullURL( $r ).$sectionanchor );
- # this call would better fit into RecentChange::notifyEdit and RecentChange::notifyNew .
- # this will be improved later (to-do)
-
- include_once( "UserMailer.php" );
- $wgEnotif = new EmailNotification ();
- $wgEnotif->notifyOnPageChange( $this->mTitle, $now, $summary, $me2, $oldid );
+ if ( $wgUseEnotif ) {
+ # this would be better as an extension hook
+ include_once( "UserMailer.php" );
+ $wgEnotif = new EmailNotification ();
+ $wgEnotif->notifyOnPageChange( $this->mTitle, $now, $summary, $me2, $oldid );
+ }
}
/**
wfDebug( "Article::confirmProtect\n" );
- $sub = htmlspecialchars( $this->mTitle->getPrefixedText() );
+ $sub = $this->mTitle->getPrefixedText();
$wgOut->setRobotpolicy( 'noindex,nofollow' );
$check = '';
# This code desperately needs to be totally rewritten
# Check permissions
- if ( ( ! $wgUser->isAllowed('delete') ) ) {
+ if( ( !$wgUser->isAllowed( 'delete' ) ) ) {
$wgOut->sysopRequired();
return;
}
- if ( wfReadOnly() ) {
+ if( wfReadOnly() ) {
$wgOut->readOnlyPage();
return;
}
# Better double-check that it hasn't been deleted yet!
$wgOut->setPagetitle( wfMsg( 'confirmdelete' ) );
- if ( ( '' == trim( $this->mTitle->getText() ) )
- or ( $this->mTitle->getArticleId() == 0 ) ) {
+ if( !$this->mTitle->exists() ) {
$wgOut->fatalError( wfMsg( 'cannotdelete' ) );
return;
}
- if ( $confirm ) {
+ if( $confirm ) {
$this->doDelete( $reason );
return;
}
# Fetch name(s) of contributors
$rev_name = '';
$all_same_user = true;
- while ( $row = $dbr->fetchObject( $revisions ) ) {
- if ( $rev_name != '' && $rev_name != $row->rev_user_text ) {
+ while( $row = $dbr->fetchObject( $revisions ) ) {
+ if( $rev_name != '' && $rev_name != $row->rev_user_text ) {
$all_same_user = false;
} else {
$rev_name = $row->rev_user_text;
#if this is empty, an earlier revision may contain "useful" text
$blanked = false;
- if($text == '') {
- $prevId = $this->mTitle->getPreviousRevisionID( $rev->getId() );
- $rev = Revision::newFromId( $prevId );
- if ( $rev ) {
- $text = $rev->getText();
+ if( $text == '' ) {
+ $prev = $rev->getPrevious();
+ if( $prev ) {
+ $text = $prev->getText();
$blanked = true;
}
}
- $length=strlen($text);
+ $length = strlen( $text );
# this should not happen, since it is not possible to store an empty, new
# page. Let's insert a standard text in case it does, though
- if($length == 0 && $reason === '') {
- $reason = wfMsg('exblank');
+ if( $length == 0 && $reason === '' ) {
+ $reason = wfMsg( 'exblank' );
}
- if($length < 500 && $reason === '') {
-
+ if( $length < 500 && $reason === '' ) {
# comment field=255, let's grep the first 150 to have some user
# space left
- $text=substr($text,0,150);
- # let's strip out newlines and HTML tags
- $text=preg_replace('/\"/',"'",$text);
- $text=preg_replace('/\</','<',$text);
- $text=preg_replace('/\>/','>',$text);
- $text=preg_replace("/[\n\r]/",'',$text);
+ global $wgContLang;
+ $text = $wgContLang->truncate( $text, 150, '...' );
- if( $length > 150 ) { $text .= '...'; } # we've only pasted part of the text
+ # let's strip out newlines
+ $text = preg_replace( "/[\n\r]/", '', $text );
- if(!$blanked) {
- if(!$all_same_user) {
- $reason = wfMsg ( 'excontent', $text );
+ if( !$blanked ) {
+ if( !$all_same_user ) {
+ $reason = wfMsg( 'excontent', $text );
} else {
- $reason = wfMsg ( 'excontentauthor', $text, $rev_name );
+ $reason = wfMsg( 'excontentauthor', $text, $rev_name );
}
} else {
- $reason = wfMsg ( 'exbeforeblank', $text );
+ $reason = wfMsg( 'exbeforeblank', $text );
}
}
}
$wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
- $sk = $wgUser->getSkin();
- $loglink = $sk->makeKnownLink( $wgContLang->getNsText( NS_SPECIAL ) .
- ':Log/delete',
- wfMsg( 'deletionlog' ) );
-
+ $loglink = '[[Special:Log/delete|' . wfMsg( 'deletionlog' ) . ']]';
$text = wfMsg( 'deletedtext', $deleted, $loglink );
- $wgOut->addHTML( '<p>' . $text . "</p>\n" );
+ $wgOut->addWikiText( $text );
$wgOut->returnToMain( false );
wfRunHooks('ArticleDeleteComplete', array(&$this, &$wgUser, $reason));
} else {
return false;
}
- $u = new SiteStatsUpdate( 0, 1, -$this->isCountable( $this->getContent( true ) ) );
+ $u = new SiteStatsUpdate( 0, 1, -$this->isCountable( $this->getContent( true ) ), -1 );
array_push( $wgDeferredUpdateList, $u );
$linksTo = $this->mTitle->getLinksTo();
* @private
*/
function viewUpdates() {
- global $wgDeferredUpdateList;
+ global $wgDeferredUpdateList, $wgUseEnotif;
if ( 0 != $this->getID() ) {
global $wgDisableCounters;
if ($this->mTitle->getNamespace() == NS_USER_TALK &&
$this->mTitle->getText() == $wgUser->getName())
{
- require_once( 'UserTalkUpdate.php' );
- $u = new UserTalkUpdate( 0, $this->mTitle->getNamespace(), $this->mTitle->getDBkey(), false, false, false );
- } else {
+ if ( $wgUseEnotif ) {
+ require_once( 'UserTalkUpdate.php' );
+ $u = new UserTalkUpdate( 0, $this->mTitle->getNamespace(), $this->mTitle->getDBkey(), false, false, false );
+ } else {
+ $wgUser->setNewtalk(0);
+ $wgUser->saveNewtalk();
+ }
+ } elseif ( $wgUseEnotif ) {
$wgUser->clearNotification( $this->mTitle );
}
*/
function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange) {
global $wgDeferredUpdateList, $wgDBname, $wgMemc;
- global $wgMessageCache, $wgUser;
+ global $wgMessageCache, $wgUser, $wgUseEnotif;
wfSeedRandom();
if ( 0 == mt_rand( 0, 999 ) ) {
$title = $this->mTitle->getPrefixedDBkey();
$shortTitle = $this->mTitle->getDBkey();
- $adj = $this->mCountAdjustment;
if ( 0 != $id ) {
$u = new LinksUpdate( $id, $title );
array_push( $wgDeferredUpdateList, $u );
- $u = new SiteStatsUpdate( 0, 1, $adj );
+ $u = new SiteStatsUpdate( 0, 1, $this->mGoodAdjustment, $this->mTotalAdjustment );
array_push( $wgDeferredUpdateList, $u );
$u = new SearchUpdate( $id, $title, $text );
array_push( $wgDeferredUpdateList, $u );
- # If this is another user's talk page,
- # create a watchlist entry for this page
+ # If this is another user's talk page, update newtalk
- if ($this->mTitle->getNamespace() == NS_USER_TALK &&
- $shortTitle != $wgUser->getName()) {
- require_once( 'UserTalkUpdate.php' );
- $u = new UserTalkUpdate( 1, $this->mTitle->getNamespace(), $shortTitle, $summary, $minoredit, $timestamp_of_pagechange);
+ if ($this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $wgUser->getName()) {
+ if ( $wgUseEnotif ) {
+ require_once( 'UserTalkUpdate.php' );
+ $u = new UserTalkUpdate( 1, $this->mTitle->getNamespace(), $shortTitle, $summary,
+ $minoredit, $timestamp_of_pagechange);
+ } else {
+ $other = User::newFromName($shortTitle);
+ $other->setNewtalk(1);
+ $other->saveNewtalk();
+ }
}
if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
$u = new SquidUpdate( $urls );
array_push( $wgPostCommitUpdateList, $u );
}
-
- # Clear persistent link cache
- LinkCache::linksccClearLinksTo( $title_obj );
}
function onArticleDelete($title_obj) {
$title_obj->touchLinks();
- LinkCache::linksccClearLinksTo( $title_obj );
}
+
function onArticleEdit($title_obj) {
- LinkCache::linksccClearPage( $title_obj->getArticleID() );
+ // This would be an appropriate place to purge caches.
+ // Why's this not in here now?
}
+
/**#@-*/
/**