bugfix: if the upload path is absolute, don't prepend the server URL
[lhc/web/wiklou.git] / includes / ChangesList.php
index 5f6425d..6524d08 100644 (file)
@@ -1,14 +1,36 @@
 <?php
+/**
+ * @package MediaWiki
+ */
 
+/**
+ * @package MediaWiki
+ */
 class ChangesList {
        # Called by history lists and recent changes
        #
 
+       /** @todo document */
        function ChangesList( &$skin ) {
                $this->skin =& $skin;
        }
        
-       # Returns text for the start of the tabular part of RC
+       /**
+        * Returns the appropiate flags for new page, minor change and patrolling
+        */
+       function recentChangesFlags( $new, $minor, $patrolled, $nothing = '&nbsp;' ) {
+               $f = $new ? '<span class="newpage">' . htmlspecialchars( wfMsg( 'newpageletter' ) ) . '</span>'
+                               : $nothing;
+               $f .= $minor ? '<span class="minor">' . htmlspecialchars( wfMsg( 'minoreditletter' ) ) . '</span>'
+                               : $nothing;
+               $f .= $patrolled ? '<span class="unpatrolled">!</span>' : $nothing;
+               return $f;
+
+       }
+
+       /** 
+        * Returns text for the start of the tabular part of RC
+        */
        function beginRecentChangesList() {
                $this->rc_cache = array() ;
                $this->rcMoveIndex = 0;
@@ -47,27 +69,9 @@ class ChangesList {
                $r .= '<tt>' ;
 
                if ( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
-                       $r .= '&nbsp;&nbsp;';
+                       $r .= '&nbsp;&nbsp;&nbsp;';
                } else {
-                       # M, N and !
-                       $M = wfMsg( 'minoreditletter' );
-                       $N = wfMsg( 'newpageletter' );
-
-                       if ( $rc_type == RC_NEW ) {
-                               $r .= $N ;
-                       } else {
-                               $r .= '&nbsp;' ;
-                       }
-                       if ( $rc_minor ) {
-                               $r .= $M ;
-                       } else {
-                               $r .= '&nbsp;' ;
-                       }
-                       if ( $rcObj->unpatrolled ) {
-                               $r .= '!';
-                       } else {
-                               $r .= '&nbsp;';
-                       }
+                       $r .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled );
                }
 
                # Timestamp
@@ -92,9 +96,12 @@ class ChangesList {
                $r .= $rcObj->usertalklink ;
 
                # Comment
-                if ( $rc_comment != '' && $rc_type != RC_MOVE && $rc_type != RC_MOVE_OVER_REDIRECT ) {
-                       $rc_comment=$this->skin->formatComment($rc_comment, $rcObj->getTitle());
-                       $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' );
+                if ( $rc_type != RC_MOVE && $rc_type != RC_MOVE_OVER_REDIRECT ) {
+                       $r .= $this->skin->commentBlock( $rc_comment, $rcObj->getTitle() );
+               }
+
+               if ($rcObj->numberofWatchingusers > 0) {
+                       $r .= wfMsg('number_of_watching_users_RCview',  $wgContLang->formatNum($rcObj->numberofWatchingusers));
                }
 
                $r .= "<br />\n" ;
@@ -107,9 +114,7 @@ class ChangesList {
        function recentChangesBlockGroup ( $block ) {
                global $wgStylePath, $wgContLang ;
 
-               $r = '' ;
-               $M = wfMsg( 'minoreditletter' );
-               $N = wfMsg( 'newpageletter' );
+               $r = '';
 
                # Collate list of users
                $isnew = false ;
@@ -139,7 +144,7 @@ class ChangesList {
                        if ( $count > 1 ) $text .= " ({$count}&times;)" ;
                        array_push ( $users , $text ) ;
                }
-               $users = ' <font size="-1">['.implode('; ',$users).']</font>' ;
+               $users = ' <span class="changedby">['.implode('; ',$users).']</span>';
 
                # Arrow
                $rci = 'RCI'.$this->rcCacheIndex ;
@@ -152,16 +157,9 @@ class ChangesList {
                $r .= $tl ;
 
                # Main line
-               # M/N
+
                $r .= '<tt>' ;
-               if ( $isnew ) $r .= $N ;
-               else $r .= '&nbsp;' ;
-               $r .= '&nbsp;' ; # Minor
-               if ( $unpatrolled ) {
-                       $r .= "!";
-               } else {
-                       $r .= "&nbsp;";
-               }
+               $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled );
 
                # Timestamp
                $r .= ' '.$block[0]->timestamp.' ' ;
@@ -187,6 +185,10 @@ class ChangesList {
                }
 
                $r .= $users ;
+
+               if ($block[0]->numberofWatchingusers > 0) {
+                       $r .= wfMsg('number_of_watching_users_RCview',  $wgContLang->formatNum($block[0]->numberofWatchingusers));
+               }
                $r .= "<br />\n" ;
 
                # Sub-entries
@@ -197,24 +199,7 @@ class ChangesList {
 
                        $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
                        $r .= '<tt>&nbsp; &nbsp; &nbsp; &nbsp;' ;
-                       if ( $rc_new ) {
-                               $r .= $N ;
-                       } else {
-                               $r .= '&nbsp;' ;
-                       }
-
-                       if ( $rc_minor ) {
-                               $r .= $M ;
-                       } else {
-                               $r .= '&nbsp;' ;
-                       }
-
-                       if ( $rcObj->unpatrolled ) {
-                               $r .= "!";
-                       } else {
-                               $r .= "&nbsp;";
-                       }
-
+                       $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled );
                        $r .= '&nbsp;</tt>' ;
 
                        $o = '' ;
@@ -235,10 +220,7 @@ class ChangesList {
                        $r .= $rcObj->lastlink ;
                        $r .= ') . . '.$rcObj->userlink ;
                        $r .= $rcObj->usertalklink ;
-                       if ( $rc_comment != '' ) {
-                               $rc_comment=$this->skin->formatComment($rc_comment, $rcObj->getTitle());
-                               $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' ) ;
-                       }
+                       $r .= $this->skin->commentBlock( $rc_comment, $rcObj->getTitle() );
                        $r .= "<br />\n" ;
                }
                $r .= "</div>\n" ;
@@ -271,7 +253,7 @@ class ChangesList {
         * Either returns the line, or caches it for later use
         */
        function recentChangesLine( &$rc, $watched = false ) {
-               global $wgUser ;
+               global $wgUser;
                $usenew = $wgUser->getOption( 'usenewrc' );
                if ( $usenew )
                        $line = $this->recentChangesLineNew ( $rc, $watched ) ;
@@ -280,11 +262,13 @@ class ChangesList {
                return $line ;
        }
 
+
        function recentChangesLineOld( &$rc, $watched = false ) {
+               global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgUseRCPatrol,
+                       $wgOnlySysopsCanPatrol, $wgSysopUserBans;
+
                $fname = 'Skin::recentChangesLineOld';
                wfProfileIn( $fname );
-               
-               global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds, $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
 
                static $message;
                if( !isset( $message ) ) {
@@ -298,11 +282,11 @@ class ChangesList {
                $curIdEq = 'curid=' . $rc_cur_id;
 
                # Should patrol-related stuff be shown?
-               $unpatrolled = $wgUseRCPatrol && $wgUser->getID() != 0 && 
+               $unpatrolled = $wgUseRCPatrol && $wgUser->isLoggedIn() && 
                  ( !$wgOnlySysopsCanPatrol || $wgUser->isAllowed('patrol') ) && $rc_patrolled == 0;
                
                # Make date header if necessary
-               $date = $wgLang->date( $rc_timestamp, true);
+               $date = $wgLang->date( $rc_timestamp, true, true );
                $s = '';
                if ( $date != $this->lastdate ) {
                        if ( '' != $this->lastdate ) { $s .= "</ul>\n"; }
@@ -350,9 +334,7 @@ class ChangesList {
                        $s .= ') . . ';
 
                        # M, N and ! (minor, new and unpatrolled)
-                       if ( $rc_minor ) { $s .= ' <span class="minor">'.$message["minoreditletter"].'</span>'; }
-                       if ( $rc_type == RC_NEW ) { $s .= '<span class="newpage">'.$message["newpageletter"].'</span>'; }
-                       if ( !$rc_patrolled ) { $s .= ' <span class="unpatrolled">!</span>'; }
+                       $s .= ' ' . $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $unpatrolled, '' );
 
                        # Article link
                        # If it's a new article, there is no diff link, but if it hasn't been
@@ -365,13 +347,14 @@ class ChangesList {
                        if ( $watched ) {
                                $articleLink = '<strong>'.$articleLink.'</strong>';
                        }
+
                        $s .= ' '.$articleLink;
                        wfProfileOut("$fname-page");
                }
 
                wfProfileIn( "$fname-rest" );
                # Timestamp
-               $s .= '; ' . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . ' . . ';
+               $s .= '; ' . $wgLang->time( $rc_timestamp, true, true ) . ' . . ';
 
                # User link (or contributions for unregistered users)
                if ( 0 == $rc_user ) {
@@ -395,9 +378,9 @@ class ChangesList {
                }
                # Block link
                $blockLink='';
-               if ( ( 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
+               if ( ( $wgSysopUserBans || 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
                        $blockLinkPage = Title::makeTitle( NS_SPECIAL, 'Blockip' );
-                       $blockLink = $this->skin->makeKnownLink( $blockLinkPage,
+                       $blockLink = $this->skin->makeKnownLinkObj( $blockLinkPage,
                                $message['blocklink'], 'ip='.$rc_user_text );
 
                }
@@ -408,10 +391,14 @@ class ChangesList {
                if($userTalkLink) $s.=' ('.$userTalkLink.')';
 
                # Add comment
-               if ( '' != $rc_comment && '*' != $rc_comment && $rc_type != RC_MOVE && $rc_type != RC_MOVE_OVER_REDIRECT ) {
-                       $rc_comment = $this->skin->formatComment($rc_comment,$rc->getTitle());
-                       $s .= $wgContLang->emphasize(' (' . $rc_comment . ')');
+               if ( $rc_type != RC_MOVE && $rc_type != RC_MOVE_OVER_REDIRECT ) {
+                       $s .= $this->skin->commentBlock( $rc_comment, $rc->getTitle() );
                }
+
+               if ($rc->numberofWatchingusers > 0) {
+                       $s .= ' ' . wfMsg('number_of_watching_users_RCview',  $wgContLang->formatNum($rc->numberofWatchingusers));
+               }
+
                $s .= "</li>\n";
 
                wfProfileOut( "$fname-rest" );
@@ -420,8 +407,8 @@ class ChangesList {
        }
 
        function recentChangesLineNew( &$baseRC, $watched = false ) {
-               global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds;
-               global $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
+               global $wgTitle, $wgLang, $wgContLang, $wgUser,
+                       $wgUseRCPatrol, $wgOnlySysopsCanPatrol, $wgSysopUserBans;
                
                static $message;
                if( !isset( $message ) ) {
@@ -449,7 +436,7 @@ class ChangesList {
                }
                
                # Should patrol-related stuff be shown?
-               if ( $wgUseRCPatrol && $wgUser->getID() != 0 && 
+               if ( $wgUseRCPatrol && $wgUser->isLoggedIn() && 
                  ( !$wgOnlySysopsCanPatrol || $wgUser->isAllowed('patrol') )) {
                        $rc->unpatrolled = !$rc_patrolled;
                } else {
@@ -473,12 +460,19 @@ class ChangesList {
                        $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '' ) ;
                }
 
-               $time = $wgContLang->time( $rc_timestamp, true, $wgRCSeconds );
+               $time = $wgContLang->time( $rc_timestamp, true, true );
                $rc->watched = $watched ;
                $rc->link = $clink ;
                $rc->timestamp = $time;
+               $rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
 
                # Make "cur" and "diff" links
+               $titleObj = $rc->getTitle();
+               if ( $rc->unpatrolled ) {
+                       $rcIdQuery = "&rcid={$rc_id}";
+               } else {
+                       $rcIdQuery = '';
+               }
                if ( ( $rc_type == RC_NEW && $rc_this_oldid == 0 ) || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
                        $curLink = $message['cur'];
                        $diffLink = $message['diff'];
@@ -486,16 +480,10 @@ class ChangesList {
                        $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
                        $aprops = ' tabindex="'.$baseRC->counter.'"';
                        $curLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $message['cur'], $query, '' ,'' , $aprops );
-                       $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $message['diff'], $query, '' ,'' , $aprops );
+                       $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $message['diff'], $query . $rcIdQuery, '' ,'' , $aprops );
                }
 
                # Make "last" link
-               $titleObj = $rc->getTitle();
-               if ( $rc->unpatrolled ) {
-                       $rcIdQuery = "&rcid={$rc_id}";
-               } else {
-                       $rcIdQuery = '';
-               }
                if ( $rc_last_oldid == 0 || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
                        $lastLink = $message['last'];
                } else {
@@ -524,7 +512,7 @@ class ChangesList {
                $userTalkLink = $this->skin->makeLinkObj( $userTalkPage, $talkname );
 
                global $wgDisableAnonTalk;
-               if ( ( 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
+               if ( ( $wgSysopUserBans || 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
                        $blockPage =& Title::makeTitle( NS_SPECIAL, 'Blockip' );
                        $blockLink = $this->skin->makeKnownLinkObj( $blockPage,
                                $message['blocklink'], 'ip='.$rc_user_text );
@@ -554,6 +542,4 @@ class ChangesList {
        }
 
 }
-
-
-?>
\ No newline at end of file
+?>