// FIXME: Horrible, horrible! This content-loading interface just plain sucks.
// We should instead work with the Revision object when we need it...
- $this->mContent = $revision->userCan( MW_REV_DELETED_TEXT ) ? $revision->getRawText() : "";
+ $this->mContent = $revision->userCan( Revision::MW_REV_DELETED_TEXT ) ? $revision->getRawText() : "";
//$this->mContent = $revision->getText();
$this->mUser = $revision->getUser();
// FIXME: This would be a nice place to load the 'no such page' text.
} else {
$this->setOldSubtitle( isset($this->mOldId) ? $this->mOldId : $oldid );
- if( $this->mRevision->isDeleted( MW_REV_DELETED_TEXT ) ) {
- if( !$this->mRevision->userCan( MW_REV_DELETED_TEXT ) ) {
+ if( $this->mRevision->isDeleted( Revision::MW_REV_DELETED_TEXT ) ) {
+ if( !$this->mRevision->userCan( Revision::MW_REV_DELETED_TEXT ) ) {
$wgOut->addWikiText( wfMsg( 'rev-deleted-text-permission' ) );
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
return;
$ts = wfTimestamp( TS_ISO_8601, $row->rev_timestamp );
$out .= " " . wfElement( 'timestamp', null, $ts ) . "\n";
- if( $row->rev_deleted & MW_REV_DELETED_USER ) {
+ if( $row->rev_deleted & Revision::MW_REV_DELETED_USER ) {
$out .= " " . wfElement( 'contributor', array( 'deleted' => 'deleted' ) ) . "\n";
} else {
$out .= " <contributor>\n";
if( $row->rev_minor_edit ) {
$out .= " <minor/>\n";
}
- if( $row->rev_deleted & MW_REV_DELETED_COMMENT ) {
+ if( $row->rev_deleted & Revision::MW_REV_DELETED_COMMENT ) {
$out .= " " . wfElement( 'comment', array( 'deleted' => 'deleted' ) ) . "\n";
} elseif( $row->rev_comment != '' ) {
$out .= " " . wfElementClean( 'comment', null, strval( $row->rev_comment ) ) . "\n";
}
- if( $row->rev_deleted & MW_REV_DELETED_TEXT ) {
+ if( $row->rev_deleted & Revision::MW_REV_DELETED_TEXT ) {
$out .= " " . wfElement( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
} elseif( isset( $row->old_text ) ) {
// Raw text from the database may have invalid chars
* @return string HTML
*/
function revUserLink( $rev ) {
- if( $rev->userCan( MW_REV_DELETED_USER ) ) {
+ if( $rev->userCan( Revision::MW_REV_DELETED_USER ) ) {
$link = $this->userLink( $rev->getRawUser(), $rev->getRawUserText() );
} else {
$link = wfMsgHtml( 'rev-deleted-user' );
}
- if( $rev->isDeleted( MW_REV_DELETED_USER ) ) {
+ if( $rev->isDeleted( Revision::MW_REV_DELETED_USER ) ) {
return '<span class="history-deleted">' . $link . '</span>';
}
return $link;
* @return string HTML
*/
function revUserTools( $rev ) {
- if( $rev->userCan( MW_REV_DELETED_USER ) ) {
+ if( $rev->userCan( Revision::MW_REV_DELETED_USER ) ) {
$link = $this->userLink( $rev->getRawUser(), $rev->getRawUserText() ) .
' ' .
$this->userToolLinks( $rev->getRawUser(), $rev->getRawUserText() );
} else {
$link = wfMsgHtml( 'rev-deleted-user' );
}
- if( $rev->isDeleted( MW_REV_DELETED_USER ) ) {
+ if( $rev->isDeleted( Revision::MW_REV_DELETED_USER ) ) {
return '<span class="history-deleted">' . $link . '</span>';
}
return $link;
* @return string HTML
*/
function revComment( $rev ) {
- if( $rev->userCan( MW_REV_DELETED_COMMENT ) ) {
+ if( $rev->userCan( Revision::MW_REV_DELETED_COMMENT ) ) {
$block = $this->commentBlock( $rev->getRawComment(), $rev->getTitle() );
} else {
$block = " <span class='comment'>" .
wfMsgHtml( 'rev-deleted-comment' ) . "</span>";
}
- if( $rev->isDeleted( MW_REV_DELETED_COMMENT ) ) {
+ if( $rev->isDeleted( Revision::MW_REV_DELETED_COMMENT ) ) {
return " <span class='history-deleted'>$block</span>";
}
return $block;
if ($notificationtimestamp && ($row->rev_timestamp >= $notificationtimestamp)) {
$s .= ' <span class="updatedmarker">' . wfMsgHtml( 'updatedmarker' ) . '</span>';
}
- if( $row->rev_deleted & MW_REV_DELETED_TEXT ) {
+ if( $row->rev_deleted & Revision::MW_REV_DELETED_TEXT ) {
$s .= ' ' . wfMsgHtml( 'deletedrev' );
}
$s .= "</li>\n";
function revLink( $rev ) {
global $wgLang;
$date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true );
- if( $rev->userCan( MW_REV_DELETED_TEXT ) ) {
+ if( $rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) {
$link = $this->mSkin->makeKnownLinkObj(
$this->mTitle, $date, "oldid=" . $rev->getId() );
} else {
$link = $date;
}
- if( $rev->isDeleted( MW_REV_DELETED_TEXT ) ) {
+ if( $rev->isDeleted( Revision::MW_REV_DELETED_TEXT ) ) {
return '<span class="history-deleted">' . $link . '</span>';
}
return $link;
/** @todo document */
function curLink( $rev, $latest ) {
$cur = wfMsgExt( 'cur', array( 'escape') );
- if( $latest || !$rev->userCan( MW_REV_DELETED_TEXT ) ) {
+ if( $latest || !$rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) {
return $cur;
} else {
return $this->mSkin->makeKnownLinkObj(
$last,
"diff=" . $rev->getId() . "&oldid=prev" );
}
- } elseif( !$rev->userCan( MW_REV_DELETED_TEXT ) ) {
+ } elseif( !$rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) {
return $last;
} else {
return $this->mSkin->makeKnownLinkObj(
# 'title' => wfMsgHtml( 'selectolderversionfordiff' )
);
- if( !$rev->userCan( MW_REV_DELETED_TEXT ) ) {
+ if( !$rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) {
$radio['disabled'] = 'disabled';
}
require_once( 'Database.php' );
require_once( 'Article.php' );
-/** @+ */
-define( 'MW_REV_DELETED_TEXT', 1 );
-define( 'MW_REV_DELETED_COMMENT', 2 );
-define( 'MW_REV_DELETED_USER', 4 );
-define( 'MW_REV_DELETED_RESTRICTED', 8 );
-/** @- */
-
/**
* @package MediaWiki
* @todo document
*/
class Revision {
+ const MW_REV_DELETED_TEXT = 1;
+ const MW_REV_DELETED_COMMENT = 2;
+ const MW_REV_DELETED_USER = 4;
+ const MW_REV_DELETED_RESTRICTED = 8;
+
/**
* Load a page revision from a given revision ID number.
* Returns null if no such revision can be found.
* @return int
*/
function getUser() {
- if( $this->isDeleted( MW_REV_DELETED_USER ) ) {
+ if( $this->isDeleted( self::MW_REV_DELETED_USER ) ) {
return 0;
} else {
return $this->mUser;
* @return string
*/
function getUserText() {
- if( $this->isDeleted( MW_REV_DELETED_USER ) ) {
+ if( $this->isDeleted( self::MW_REV_DELETED_USER ) ) {
return "";
} else {
return $this->mUserText;
* @return string
*/
function getComment() {
- if( $this->isDeleted( MW_REV_DELETED_COMMENT ) ) {
+ if( $this->isDeleted( self::MW_REV_DELETED_COMMENT ) ) {
return "";
} else {
return $this->mComment;
* @return string
*/
function getText() {
- if( $this->isDeleted( MW_REV_DELETED_TEXT ) ) {
+ if( $this->isDeleted( self::MW_REV_DELETED_TEXT ) ) {
return "";
} else {
return $this->getRawText();
/**
* Determine if the current user is allowed to view a particular
* field of this revision, if it's marked as deleted.
- * @param int $field one of MW_REV_DELETED_TEXT,
- * MW_REV_DELETED_COMMENT,
- * MW_REV_DELETED_USER
+ * @param int $field one of self::MW_REV_DELETED_TEXT,
+ * self::MW_REV_DELETED_COMMENT,
+ * self::MW_REV_DELETED_USER
* @return bool
*/
function userCan( $field ) {
if( ( $this->mDeleted & $field ) == $field ) {
global $wgUser;
- $permission = ( $this->mDeleted & MW_REV_DELETED_RESTRICTED ) == MW_REV_DELETED_RESTRICTED
+ $permission = ( $this->mDeleted & self::MW_REV_DELETED_RESTRICTED ) == self::MW_REV_DELETED_RESTRICTED
? 'hiderevision'
: 'deleterevision';
wfDebug( "Checking for $permission due to $field match on $this->mDeleted\n" );
}
}
- if( $rev->userCan( MW_REV_DELETED_TEXT ) ) {
+ if( $rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) {
$difftext = '(' . $sk->makeKnownLinkObj( $page, $messages['diff'], 'diff=prev&oldid='.$row->rev_id ) . ')';
} else {
$difftext = '(' . $messages['diff'] . ')';
$comment = $sk->revComment( $rev );
$d = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->rev_timestamp), true );
- if( $rev->isDeleted( MW_REV_DELETED_TEXT ) ) {
+ if( $rev->isDeleted( Revision::MW_REV_DELETED_TEXT ) ) {
$d = '<span class="history-deleted">' . $d . '</span>';
}
}
$ret = "{$d} {$histlink} {$difftext} {$mflag} {$link} {$comment} {$topmarktext}";
- if( $rev->isDeleted( MW_REV_DELETED_TEXT ) ) {
+ if( $rev->isDeleted( Revision::MW_REV_DELETED_TEXT ) ) {
$ret .= ' ' . wfMsgHtml( 'deletedrev' );
}
$ret = "<li>$ret</li>\n";
$this->skin = $wgUser->getSkin();
$this->checks = array(
- array( 'revdelete-hide-text', 'wpHideText', MW_REV_DELETED_TEXT ),
- array( 'revdelete-hide-comment', 'wpHideComment', MW_REV_DELETED_COMMENT ),
- array( 'revdelete-hide-user', 'wpHideUser', MW_REV_DELETED_USER ),
- array( 'revdelete-hide-restricted', 'wpHideRestricted', MW_REV_DELETED_RESTRICTED ) );
+ array( 'revdelete-hide-text', 'wpHideText', Revision::MW_REV_DELETED_TEXT ),
+ array( 'revdelete-hide-comment', 'wpHideComment', Revision::MW_REV_DELETED_COMMENT ),
+ array( 'revdelete-hide-user', 'wpHideUser', Revision::MW_REV_DELETED_USER ),
+ array( 'revdelete-hide-restricted', 'wpHideRestricted', Revision::MW_REV_DELETED_RESTRICTED ) );
}
/**
function updateRecentChanges( $rev, $bitfield ) {
$this->db->update( 'recentchanges',
array(
- 'rc_user' => ($bitfield & MW_REV_DELETED_USER) ? 0 : $rev->getUser(),
- 'rc_user_text' => ($bitfield & MW_REV_DELETED_USER) ? wfMsg( 'rev-deleted-user' ) : $rev->getUserText(),
- 'rc_comment' => ($bitfield & MW_REV_DELETED_COMMENT) ? wfMsg( 'rev-deleted-comment' ) : $rev->getComment() ),
+ 'rc_user' => ($bitfield & Revision::MW_REV_DELETED_USER) ? 0 : $rev->getUser(),
+ 'rc_user_text' => ($bitfield & Revision::MW_REV_DELETED_USER) ? wfMsg( 'rev-deleted-user' ) : $rev->getUserText(),
+ 'rc_comment' => ($bitfield & Revision::MW_REV_DELETED_COMMENT) ? wfMsg( 'rev-deleted-comment' ) : $rev->getComment() ),
array(
'rc_this_oldid' => $rev->getId() ),
'RevisionDeleter::updateRecentChanges' );