From: Domas Mituzas Date: Tue, 6 Jun 2006 10:54:23 +0000 (+0000) Subject: Move revision deletion constants into Revision:: X-Git-Tag: 1.31.0-rc.0~56881 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=d8c04540b782816218565eb246f0db484f091b9f;p=lhc%2Fweb%2Fwiklou.git Move revision deletion constants into Revision:: --- diff --git a/includes/Article.php b/includes/Article.php index 2b32885997..6bffff297c 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -445,7 +445,7 @@ class Article { // 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(); @@ -815,8 +815,8 @@ class Article { // 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; diff --git a/includes/Export.php b/includes/Export.php index d0253eb7ae..cc5b4010b3 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -396,7 +396,7 @@ class XmlDumpWriter { $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 .= " \n"; @@ -412,13 +412,13 @@ class XmlDumpWriter { if( $row->rev_minor_edit ) { $out .= " \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 diff --git a/includes/Linker.php b/includes/Linker.php index 44d179973e..12cd4bc17d 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -833,12 +833,12 @@ class Linker { * @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 '' . $link . ''; } return $link; @@ -850,14 +850,14 @@ class Linker { * @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 '' . $link . ''; } return $link; @@ -977,13 +977,13 @@ class Linker { * @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 = " " . wfMsgHtml( 'rev-deleted-comment' ) . ""; } - if( $rev->isDeleted( MW_REV_DELETED_COMMENT ) ) { + if( $rev->isDeleted( Revision::MW_REV_DELETED_COMMENT ) ) { return " $block"; } return $block; diff --git a/includes/PageHistory.php b/includes/PageHistory.php index 2e70e4d902..320d857a39 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -263,7 +263,7 @@ class PageHistory { if ($notificationtimestamp && ($row->rev_timestamp >= $notificationtimestamp)) { $s .= ' ' . wfMsgHtml( 'updatedmarker' ) . ''; } - if( $row->rev_deleted & MW_REV_DELETED_TEXT ) { + if( $row->rev_deleted & Revision::MW_REV_DELETED_TEXT ) { $s .= ' ' . wfMsgHtml( 'deletedrev' ); } $s .= "\n"; @@ -275,13 +275,13 @@ class PageHistory { 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 '' . $link . ''; } return $link; @@ -290,7 +290,7 @@ class PageHistory { /** @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( @@ -313,7 +313,7 @@ class PageHistory { $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( @@ -337,7 +337,7 @@ class PageHistory { # 'title' => wfMsgHtml( 'selectolderversionfordiff' ) ); - if( !$rev->userCan( MW_REV_DELETED_TEXT ) ) { + if( !$rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) { $radio['disabled'] = 'disabled'; } diff --git a/includes/Revision.php b/includes/Revision.php index e9083a7742..7a33612c9c 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -8,18 +8,16 @@ 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. @@ -343,7 +341,7 @@ class Revision { * @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; @@ -363,7 +361,7 @@ class Revision { * @return string */ function getUserText() { - if( $this->isDeleted( MW_REV_DELETED_USER ) ) { + if( $this->isDeleted( self::MW_REV_DELETED_USER ) ) { return ""; } else { return $this->mUserText; @@ -383,7 +381,7 @@ class Revision { * @return string */ function getComment() { - if( $this->isDeleted( MW_REV_DELETED_COMMENT ) ) { + if( $this->isDeleted( self::MW_REV_DELETED_COMMENT ) ) { return ""; } else { return $this->mComment; @@ -418,7 +416,7 @@ class Revision { * @return string */ function getText() { - if( $this->isDeleted( MW_REV_DELETED_TEXT ) ) { + if( $this->isDeleted( self::MW_REV_DELETED_TEXT ) ) { return ""; } else { return $this->getRawText(); @@ -729,15 +727,15 @@ class Revision { /** * 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" ); diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index 959af08783..f09667d178 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -391,7 +391,7 @@ function ucListEdit( $sk, $row ) { } } - 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'] . ')'; @@ -401,7 +401,7 @@ function ucListEdit( $sk, $row ) { $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 = '' . $d . ''; } @@ -412,7 +412,7 @@ function ucListEdit( $sk, $row ) { } $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 = "
  • $ret
  • \n"; diff --git a/includes/SpecialRevisiondelete.php b/includes/SpecialRevisiondelete.php index 7854c22e69..cf37647357 100644 --- a/includes/SpecialRevisiondelete.php +++ b/includes/SpecialRevisiondelete.php @@ -46,10 +46,10 @@ class RevisionDeleteForm { $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 ) ); } /** @@ -222,9 +222,9 @@ class RevisionDeleter { 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' );