* Use Linker::revComment() to format the comment
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 9 Mar 2008 21:08:42 +0000 (21:08 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 9 Mar 2008 21:08:42 +0000 (21:08 +0000)
* Don't allow users to see the lenght of the text if they can't see it
* $fname -> __METHOD__
* wfElement() -> Xml::element()
* some fixes in Article.php

includes/Article.php
includes/PageHistory.php

index f726184..aa87093 100644 (file)
@@ -2247,7 +2247,7 @@ class Article {
                                'ar_text_id'    => 'rev_text_id',
                                'ar_text'       => '\'\'', // Be explicit to appease
                                'ar_flags'      => '\'\'', // MySQL's "strict mode"...
-                               'ar_len'                => 'rev_len',
+                               'ar_len'        => 'rev_len',
                                'ar_page_id'    => 'page_id',
                                'ar_deleted'    => $bitfield
                        ), array(
@@ -2690,7 +2690,7 @@ class Article {
                $sk = $wgUser->getSkin();
                $lnk = $current
                        ? wfMsg( 'currentrevisionlink' )
-                       : $lnk = $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'currentrevisionlink' ) );
+                       : $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'currentrevisionlink' ) );
                $curdiff = $current
                        ? wfMsg( 'diff' )
                        : $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'diff' ), 'diff=cur&oldid='.$oldid );
index 9550da6..5a94621 100644 (file)
@@ -69,8 +69,7 @@ class PageHistory {
                        /* Client cache fresh and headers sent, nothing more to do. */
                        return;
 
-               $fname = 'PageHistory::history';
-               wfProfileIn( $fname );
+               wfProfileIn( __METHOD__ );
 
                /*
                 * Setup page variables.
@@ -89,7 +88,7 @@ class PageHistory {
 
                $feedType = $wgRequest->getVal( 'feed' );
                if( $feedType ) {
-                       wfProfileOut( $fname );
+                       wfProfileOut( __METHOD__ );
                        return $this->feed( $feedType );
                }
 
@@ -98,7 +97,7 @@ class PageHistory {
                 */
                if( !$this->mTitle->exists() ) {
                        $wgOut->addWikiMsg( 'nohistory' );
-                       wfProfileOut( $fname );
+                       wfProfileOut( __METHOD__ );
                        return;
                }
 
@@ -126,7 +125,7 @@ class PageHistory {
                        $this->endHistoryList() .
                        $pager->getNavigationBar()
                );
-               wfProfileOut( $fname );
+               wfProfileOut( __METHOD__ );
        }
 
        /**
@@ -240,12 +239,12 @@ class PageHistory {
                
                $s .= " $link";
                $s .= ' '.$this->mSkin->revUserTools( $rev, true );
-               
+
                if( $row->rev_minor_edit ) {
-                       $s .= ' ' . wfElement( 'span', array( 'class' => 'minor' ), wfMsg( 'minoreditletter') );
+                       $s .= ' ' . Xml::element( 'span', array( 'class' => 'minor' ), wfMsg( 'minoreditletter') );
                }
 
-               if ( !is_null( $size = $rev->getSize() ) ) {
+               if ( !is_null( $size = $rev->getSize() ) && $rev->userCan( Revision::DELETED_TEXT ) ) {
                        if ( $size == 0 )
                                $stxt = wfMsgHtml( 'historyempty' );
                        else
@@ -253,19 +252,13 @@ class PageHistory {
                        $s .= " <span class=\"history-size\">$stxt</span>";
                }
 
-               #getComment is safe, but this is better formatted
-               if( $rev->isDeleted( Revision::DELETED_COMMENT ) ) {
-                       $s .= " <span class=\"history-deleted\"><span class=\"comment\">" .
-                       wfMsgHtml( 'rev-deleted-comment' ) . "</span></span>";
-               } else {
-                       $s .= $this->mSkin->revComment( $rev );
-               }
+               $s .= $this->mSkin->revComment( $rev, false, true );
                
                if ($notificationtimestamp && ($row->rev_timestamp >= $notificationtimestamp)) {
                        $s .= ' <span class="updatedmarker">' .  wfMsgHtml( 'updatedmarker' ) . '</span>';
                }
                #add blurb about text having been deleted
-               if( $row->rev_deleted & Revision::DELETED_TEXT ) {
+               if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
                        $s .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
                }
                
@@ -409,11 +402,11 @@ class PageHistory {
        function getLatestId() {
                if( is_null( $this->mLatestId ) ) {
                        $id = $this->mTitle->getArticleID();
-                       $db = wfGetDB(DB_SLAVE);
+                       $db = wfGetDB( DB_SLAVE );
                        $this->mLatestId = $db->selectField( 'page',
                                "page_latest",
                                array( 'page_id' => $id ),
-                               'PageHistory::getLatestID' );
+                               __METHOD__ );
                }
                return $this->mLatestId;
        }
@@ -424,8 +417,6 @@ class PageHistory {
         * used by the main UI but that's now handled by the pager.
         */
        function fetchRevisions($limit, $offset, $direction) {
-               $fname = 'PageHistory::fetchRevisions';
-
                $dbr = wfGetDB( DB_SLAVE );
 
                if ($direction == PageHistory::DIR_PREV)
@@ -444,7 +435,7 @@ class PageHistory {
                        'revision',
                        Revision::selectFields(),
                        array_merge(array("rev_page=$page_id"), $offsets),
-                       $fname,
+                       __METHOD__,
                        array('ORDER BY' => "rev_timestamp $dirs",
                                'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit)
                        );
@@ -459,7 +450,6 @@ class PageHistory {
        /** @todo document */
        function getNotificationTimestamp() {
                global $wgUser, $wgShowUpdatedMarker;
-               $fname = 'PageHistory::getNotficationTimestamp';
 
                if ($this->mNotificationTimestamp !== NULL)
                        return $this->mNotificationTimestamp;
@@ -476,7 +466,7 @@ class PageHistory {
                                'wl_title' => $this->mTitle->getDBkey(),
                                'wl_user' => $wgUser->getID()
                        ),
-                       $fname);
+                       __METHOD__ );
                
                // Don't use the special value reserved for telling whether the field is filled
                if ( is_null( $this->mNotificationTimestamp ) ) {