Capitalization fix in memcached setting
[lhc/web/wiklou.git] / includes / Skin.php
index a30d198..fe1e947 100644 (file)
@@ -3,6 +3,7 @@
 /**
  *
  * @package MediaWiki
+ * @subpackage Skins
  */
 
 /**
@@ -13,27 +14,6 @@ if( defined( "MEDIAWIKI" ) ) {
 # See skin.doc
 require_once( 'Image.php' );
 
-# These are the INTERNAL names, which get mapped directly to class names and
-# file names in ./skins/. For display purposes, the Language class has
-# internationalized names
-#
-/*
-$wgValidSkinNames = array(
-       'standard'      => 'Standard',
-       'nostalgia'     => 'Nostalgia',
-       'cologneblue'   => 'CologneBlue'
-);
-if( $wgUsePHPTal ) {
-       #$wgValidSkinNames[] = 'PHPTal';
-       #$wgValidSkinNames['davinci'] = 'DaVinci';
-       #$wgValidSkinNames['mono'] = 'Mono';
-       #$wgValidSkinNames['monobookminimal'] = 'MonoBookMinimal';
-       $wgValidSkinNames['monobook'] = 'MonoBook';
-       $wgValidSkinNames['myskin'] = 'MySkin';
-       $wgValidSkinNames['chick'] = 'Chick';
-}
-*/
-
 # Get a list of all skins available in /skins/
 # Build using the regular expression '^(.*).php$'
 # Array keys are all lower case, array value keep the case used by filename
@@ -99,12 +79,10 @@ class Skin {
        var $rc_cache ; # Cache for Enhanced Recent Changes
        var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
        var $rcMoveIndex;
-       var $postParseLinkColour = true;
+       var $postParseLinkColour = false;
        /**#@-*/
 
        function Skin() {
-               global $wgUseOldExistenceCheck;
-               $postParseLinkColour = !$wgUseOldExistenceCheck;
                $this->linktrail = wfMsg('linktrail');
        }
 
@@ -296,14 +274,14 @@ class Skin {
                }
                else $a = array( 'bgcolor' => '#FFFFFF' );
                if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
-                 (!$wgTitle->isProtected() || $wgUser->isSysop()) ) {
+                 (!$wgTitle->isProtected() || $wgUser->isAllowed('protect')) ) {
                        $t = wfMsg( 'editthispage' );
                        $oid = $red = '';
-                       if ( !empty($redirect) ) {
+                       if ( !empty($redirect) && $redirect == 'no' ) {
                                $red = "&redirect={$redirect}";
                        }
                        if ( !empty($oldid) && ! isset( $diff ) ) {
-                               $oid = "&oldid={$oldid}";
+                               $oid = "&oldid=" . IntVal( $oldid );
                        }
                        $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
                        $s = 'document.location = "' .$s .'";';
@@ -451,6 +429,7 @@ class Skin {
                return $s;
        }
 
+       
        function getCategoryLinks () {
                global $wgOut, $wgTitle, $wgUser, $wgParser;
                global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
@@ -472,7 +451,7 @@ class Skin {
                        $s .= '<br/><hr/>';
 
                        # get a big array of the parents tree
-                       $parenttree = $wgTitle->getCategorieBrowser();
+                       $parenttree = $wgTitle->getParentCategoryTree();
 
                        # Render the array as a serie of links
                        function walkThrough ($tree) {
@@ -490,7 +469,7 @@ class Skin {
                                        # add our current element to the list
                                        $eltitle = Title::NewFromText($element);
                                        # FIXME : should be makeLink() [AV]
-                                       $return .= $sk->makeKnownLink($element, $eltitle->getText()).' &gt; ';
+                                       $return .= $sk->makeLink($element, $eltitle->getText()).' &gt; ';
                                }
                                return $return;
                        }
@@ -544,10 +523,10 @@ class Skin {
                $action = $wgRequest->getText( 'action' );
 
                $s = $this->printableLink();
-               if ( wfMsgForContent ( 'disclaimers' ) != '-' )
-                       $s .= ' | ' . $this->makeKnownLink( 
-                               wfMsgForContent( 'disclaimerpage' ), 
-                               wfMsgForContent( 'disclaimers' ) ) ;
+               $disclaimer = $this->disclaimerLink(); # may be empty
+               if( $disclaimer ) {
+                       $s .= ' | ' . $disclaimer;
+               }
 
                if ( $wgOut->isArticleRelated() ) {
                        if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
@@ -585,6 +564,7 @@ class Skin {
                                $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
                                # disable caching
                                $wgOut->setSquidMaxage(0);
+                               $wgOut->enableClientCache(false);
                        }
                }
 
@@ -597,7 +577,7 @@ class Skin {
 
        function getUndeleteLink() {
                global $wgUser, $wgTitle, $wgContLang, $action;
-               if( $wgUser->isSysop() &&
+               if( $wgUser->isAllowed('rollback') &&
                        (($wgTitle->getArticleId() == 0) || ($action == "history")) &&
                        ($n = $wgTitle->isDeleted() ) ) {
                        return wfMsg( 'thisisdeleted',
@@ -634,7 +614,7 @@ class Skin {
                global $wgOut, $wgTitle, $wgUser;
 
                $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
-               if($wgUser->getOption( 'editsectiononrightclick' ) && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
+               if($wgUser->getOption( 'editsectiononrightclick' ) && $wgTitle->userCanEdit()) { $s=$this->editSectionScript($wgTitle, 0,$s);}
                return $s;
        }
 
@@ -800,10 +780,11 @@ class Skin {
                                        }
                                }
                        }
-                       if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
-                               $s .= "\n<br />" . $this->deleteThisPage() .
-                               $sep . $this->protectThisPage() .
-                               $sep . $this->moveThisPage();
+                       if ( $wgTitle->getArticleId() ) {
+                               $s .= "\n<br />";
+                               if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
+                               if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
+                               if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
                        }
                        $s .= "<br />\n" . $this->otherLanguages();
                }
@@ -918,6 +899,10 @@ class Skin {
                return $s;
        }
 
+       /**
+        * show a drop-down box of special pages
+        * @TODO crash bug913. Need to be rewrote completly.
+        */
        function specialPagesList() {
                global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript;
                require_once('SpecialPage.php');
@@ -979,9 +964,13 @@ class Skin {
 
 
        function disclaimerLink() {
-               $s = $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
-                 wfMsg( 'disclaimers' ) );
-               return $s;
+               $disclaimers = wfMsg( 'disclaimers' );
+               if ($disclaimers == '-') {
+                       return "";
+               } else {
+                       return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
+                                                    $disclaimers );
+               }
        }
 
        function editThisPage() {
@@ -1016,7 +1005,7 @@ class Skin {
                global $wgUser, $wgOut, $wgTitle, $wgRequest;
 
                $diff = $wgRequest->getVal( 'diff' );
-               if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
+               if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
                        $n = $wgTitle->getPrefixedText();
                        $t = wfMsg( 'deletethispage' );
 
@@ -1031,7 +1020,7 @@ class Skin {
                global $wgUser, $wgOut, $wgTitle, $wgRequest;
 
                $diff = $wgRequest->getVal( 'diff' );
-               if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
+               if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
                        $n = $wgTitle->getPrefixedText();
 
                        if ( $wgTitle->isProtected() ) {
@@ -1652,7 +1641,6 @@ class Skin {
 
        function makeImage( $url, $alt = '' ) {
                global $wgOut;
-
                if ( '' == $alt ) {
                        $alt = $this->fnamePart( $url );
                }
@@ -1673,118 +1661,112 @@ class Skin {
                $align = '';
                $prefix = $postfix = '';
 
-               if ( $wgUseImageResize ) {
-                       # Check if the alt text is of the form "options|alt text"
-                       # Options are:
-                       #  * thumbnail          make a thumbnail with enlarge-icon and caption, alignment depends on lang
-                       #  * left               no resizing, just left align. label is used for alt= only
-                       #  * right              same, but right aligned
-                       #  * none               same, but not aligned
-                       #  * ___px              scale to ___ pixels width, no aligning. e.g. use in taxobox
-                       #  * center             center the image
-                       #  * framed             Keep original image size, no magnify-button.
-
-                       $part = explode( '|', $alt);
-
-                       $mwThumb  =& MagicWord::get( MAG_IMG_THUMBNAIL );
-                       $mwLeft   =& MagicWord::get( MAG_IMG_LEFT );
-                       $mwRight  =& MagicWord::get( MAG_IMG_RIGHT );
-                       $mwNone   =& MagicWord::get( MAG_IMG_NONE );
-                       $mwWidth  =& MagicWord::get( MAG_IMG_WIDTH );
-                       $mwCenter =& MagicWord::get( MAG_IMG_CENTER );
-                       $mwFramed =& MagicWord::get( MAG_IMG_FRAMED );
-                       $alt = $part[count($part)-1];
-
-                       $height = $framed = $thumb = false;
-                       $manual_thumb = "" ;
-
-                       foreach( $part as $key => $val ) {
-                               $val_parts = explode ( "=" , $val , 2 ) ;
-                               $left_part = array_shift ( $val_parts ) ;
-                               if ( ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
-                                       $thumb=true;
-                               } elseif ( count ( $val_parts ) == 1 && ! is_null( $mwThumb->matchVariableStartToEnd($left_part) ) ) {
-                                       # use manually specified thumbnail
-                                       $thumb=true;
-                                       $manual_thumb = array_shift ( $val_parts ) ;
-                               } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
-                                       # remember to set an alignment, don't render immediately
-                                       $align = 'right';
-                               } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
-                                       # remember to set an alignment, don't render immediately
-                                       $align = 'left';
-                               } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
-                                       # remember to set an alignment, don't render immediately
-                                       $align = 'center';
-                               } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
-                                       # remember to set an alignment, don't render immediately
-                                       $align = 'none';
-                               } elseif ( ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
-                                       # $match is the image width in pixels
-                                       if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
-                                               $width = intval( $m[1] );
-                                               $height = intval( $m[2] );
-                                       } else {
-                                               $width = intval($match);
-                                       }
-                               } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
-                                       $framed=true;
+               # Check if the alt text is of the form "options|alt text"
+               # Options are:
+               #  * thumbnail          make a thumbnail with enlarge-icon and caption, alignment depends on lang
+               #  * left               no resizing, just left align. label is used for alt= only
+               #  * right              same, but right aligned
+               #  * none               same, but not aligned
+               #  * ___px              scale to ___ pixels width, no aligning. e.g. use in taxobox
+               #  * center             center the image
+               #  * framed             Keep original image size, no magnify-button.
+
+               $part = explode( '|', $alt);
+
+               $mwThumb  =& MagicWord::get( MAG_IMG_THUMBNAIL );
+               $mwLeft   =& MagicWord::get( MAG_IMG_LEFT );
+               $mwRight  =& MagicWord::get( MAG_IMG_RIGHT );
+               $mwNone   =& MagicWord::get( MAG_IMG_NONE );
+               $mwWidth  =& MagicWord::get( MAG_IMG_WIDTH );
+               $mwCenter =& MagicWord::get( MAG_IMG_CENTER );
+               $mwFramed =& MagicWord::get( MAG_IMG_FRAMED );
+               $alt = '';
+
+               $height = $framed = $thumb = false;
+               $manual_thumb = "" ;
+
+               foreach( $part as $key => $val ) {
+                       $val_parts = explode ( "=" , $val , 2 ) ;
+                       $left_part = array_shift ( $val_parts ) ;
+                       if ( $wgUseImageResize && ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
+                               $thumb=true;
+                       } elseif ( $wgUseImageResize && count ( $val_parts ) == 1 && ! is_null( $mwThumb->matchVariableStartToEnd($left_part) ) ) {
+                               # use manually specified thumbnail
+                               $thumb=true;
+                               $manual_thumb = array_shift ( $val_parts ) ;
+                       } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
+                               # remember to set an alignment, don't render immediately
+                               $align = 'right';
+                       } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
+                               # remember to set an alignment, don't render immediately
+                               $align = 'left';
+                       } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
+                               # remember to set an alignment, don't render immediately
+                               $align = 'center';
+                       } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
+                               # remember to set an alignment, don't render immediately
+                               $align = 'none';
+                       } elseif ( $wgUseImageResize && ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
+                               # $match is the image width in pixels
+                               if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
+                                       $width = intval( $m[1] );
+                                       $height = intval( $m[2] );
+                               } else {
+                                       $width = intval($match);
                                }
+                       } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
+                               $framed=true;
+                       } else {
+                               $alt = $val;
                        }
-                       if ( 'center' == $align )
-                       {
-                               $prefix  = '<span style="text-align: center">';
-                               $postfix = '</span>';
-                               $align   = 'none';
-                       }
-
-                       if ( $thumb || $framed ) {
-
-                               # Create a thumbnail. Alignment depends on language
-                               # writing direction, # right aligned for left-to-right-
-                               # languages ("Western languages"), left-aligned
-                               # for right-to-left-languages ("Semitic languages")
-                               #
-                               # If  thumbnail width has not been provided, it is set
-                               # here to 180 pixels
-                               if ( $align == '' ) {
-                                       $align = $wgContLang->isRTL() ? 'left' : 'right';
-                               }
-                               if ( ! isset($width) ) {
-                                       $width = 180;
-                               }
-                               return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix;
+               }
+               if ( 'center' == $align )
+               {
+                       $prefix  = '<div class="center">';
+                       $postfix = '</div>';
+                       $align   = 'none';
+               }
+
+               if ( $thumb || $framed ) {
+
+                       # Create a thumbnail. Alignment depends on language
+                       # writing direction, # right aligned for left-to-right-
+                       # languages ("Western languages"), left-aligned
+                       # for right-to-left-languages ("Semitic languages")
+                       #
+                       # If  thumbnail width has not been provided, it is set
+                       # here to 180 pixels
+                       if ( $align == '' ) {
+                               $align = $wgContLang->isRTL() ? 'left' : 'right';
+                       }
+                       if ( ! isset($width) ) {
+                               $width = 180;
+                       }
+                       return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix;
 
-                       } elseif ( isset($width) ) {
+               } elseif ( isset($width) ) {
 
-                               # Create a resized image, without the additional thumbnail
-                               # features
+                       # Create a resized image, without the additional thumbnail
+                       # features
 
-                               if (    ( ! $height === false )
-                                    && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
-                                       print "height=$height<br>\nimg->getHeight() = ".$img->getHeight()."<br>\n";
-                                       print 'rescaling by factor '. $height / $img->getHeight() . "<br>\n";
-                                       $width = $img->getWidth() * $height / $img->getHeight();
-                               }
-                               if ( '' == $manual_thumb ) $url = $img->createThumb( $width );
+                       if (    ( ! $height === false )
+                            && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
+                               $width = $img->getWidth() * $height / $img->getHeight();
                        }
-               } # endif $wgUseImageResize
-
-               if ( empty( $alt ) ) {
-                       $alt = preg_replace( '/\.(.+?)^/', '', $img->getName() );
+                       if ( '' == $manual_thumb ) $url = $img->createThumb( $width );
                }
+
                $alt = preg_replace( '/<[^>]*>/', '', $alt );
                $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&amp;', $alt);
                $alt = str_replace( array('<', '>', '"'), array('&lt;', '&gt;', '&quot;'), $alt );
 
                $u = $nt->escapeLocalURL();
-               if ( $url == '' )
-               {
+               if ( $url == '' ) {
                        $s = wfMsg( 'missingimage', $img->getName() );
                        $s .= "<br>{$alt}<br>{$url}<br>\n";
                } else {
                        $s = '<a href="'.$u.'" class="image" title="'.$alt.'">' .
-                                '<img src="'.$url.'" alt="'.$alt.'" /></a>';
+                                '<img src="'.$url.'" alt="'.$alt.'" longdesc="'.$u.'" /></a>';
                }
                if ( '' != $align ) {
                        $s = "<div class=\"float{$align}\"><span>{$s}</span></div>";
@@ -1867,7 +1849,8 @@ class Skin {
                } else {
                        $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
                                '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
-                               'width="'.$boxwidth.'" height="'.$boxheight.'" /></a>';
+                               'width="'.$boxwidth.'" height="'.$boxheight.'" ' .
+                               'longdesc="'.$u.'" /></a>';
                        if ( $framed ) {
                                $zoomicon="";
                        } else {
@@ -1882,24 +1865,29 @@ class Skin {
        }
 
        function makeMediaLink( $name, $url, $alt = '' ) {
-               $nt = Title::makeTitleSafe( Namespace::getMedia(), $name );
+               $nt = Title::makeTitleSafe( NS_IMAGE, $name );
                return $this->makeMediaLinkObj( $nt, $alt );
        }
 
-       function makeMediaLinkObj( $nt, $alt = '' ) {
+       function makeMediaLinkObj( $nt, $alt = '', $nourl=false ) {             
                if ( ! isset( $nt ) )
                {
                        ### HOTFIX. Instead of breaking, return empty string.
                        $s = $alt;
                } else {
-                       $name = $nt->getDBKey();
-                       $url = Image::wfImageUrl( $name );
+                       $name = $nt->getDBKey();        
+                       $img   = Image::newFromTitle( $nt );
+                       $url = $img->getURL();
+                       # $nourl can be set by the parser
+                       # this is a hack to mask absolute URLs, so the parser doesn't
+                       # linkify them (it is currently not context-aware)
+                       # 2004-10-25
+                       if ($nourl) { $url=str_replace("http://","http-noparse://",$url) ; }
                        if ( empty( $alt ) ) {
                                $alt = preg_replace( '/\.(.+?)^/', '', $name );
                        }
-
                        $u = htmlspecialchars( $url );
-                       $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
+                       $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";                   
                }
                return $s;
        }
@@ -1972,7 +1960,7 @@ class Skin {
                if ( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
                        $r .= '&nbsp;&nbsp;';
                } else {
-                       # M & N (minor & new)
+                       # M, N and !
                        $M = wfMsg( 'minoreditletter' );
                        $N = wfMsg( 'newpageletter' );
 
@@ -1986,6 +1974,11 @@ class Skin {
                        } else {
                                $r .= '&nbsp;' ;
                        }
+                       if ( $rcObj->unpatrolled ) {
+                               $r .= '!';
+                       } else {
+                               $r .= '&nbsp;';
+                       }
                }
 
                # Timestamp
@@ -2031,12 +2024,20 @@ class Skin {
 
                # Collate list of users
                $isnew = false ;
+               $unpatrolled = false;
                $userlinks = array () ;
                foreach ( $block AS $rcObj ) {
                        $oldid = $rcObj->mAttribs['rc_last_oldid'];
-                       if ( $rcObj->mAttribs['rc_new'] ) $isnew = true ;
+                       if ( $rcObj->mAttribs['rc_new'] ) {
+                               $isnew = true ;
+                       }
                        $u = $rcObj->userlink ;
-                       if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
+                       if ( !isset ( $userlinks[$u] ) ) {
+                               $userlinks[$u] = 0 ;
+                       }
+                       if ( $rcObj->unpatrolled ) {
+                               $unpatrolled = true;
+                       }
                        $userlinks[$u]++ ;
                }
 
@@ -2057,8 +2058,8 @@ class Skin {
                $rcm = 'RCM'.$this->rcCacheIndex ;
                $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
                $arrowdir = $wgContLang->isRTL() ? 'l' : 'r';
-               $tl  = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" /></a></span>' ;
-               $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_d.png" width="12" height="12" /></a></span>' ;
+               $tl  = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" alt="+" /></a></span>' ;
+               $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_d.png" width="12" height="12" alt="-" /></a></span>' ;
                $r .= $tl ;
 
                # Main line
@@ -2067,6 +2068,11 @@ class Skin {
                if ( $isnew ) $r .= $N ;
                else $r .= '&nbsp;' ;
                $r .= '&nbsp;' ; # Minor
+               if ( $unpatrolled ) {
+                       $r .= "!";
+               } else {
+                       $r .= "&nbsp;";
+               }
 
                # Timestamp
                $r .= ' '.$block[0]->timestamp.' ' ;
@@ -2102,11 +2108,25 @@ class Skin {
 
                        $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;' ;
-                       $r .= '</tt>' ;
+                       if ( $rc_new ) {
+                               $r .= $N ;
+                       } else {
+                               $r .= '&nbsp;' ;
+                       }
+
+                       if ( $rc_minor ) {
+                               $r .= $M ;
+                       } else {
+                               $r .= '&nbsp;' ;
+                       }
+
+                       if ( $rcObj->unpatrolled ) {
+                               $r .= "!";
+                       } else {
+                               $r .= "&nbsp;";
+                       }
+
+                       $r .= '&nbsp;</tt>' ;
 
                        $o = '' ;
                        if ( $rc_last_oldid != 0 ) {
@@ -2178,19 +2198,22 @@ class Skin {
                extract( $rc->mAttribs );
                $curIdEq = 'curid=' . $rc_cur_id;
 
+               # Should patrol-related stuff be shown?
+               $unpatrolled = $wgUseRCPatrol && $wgUser->getID() != 0 && 
+                 ( !$wgOnlySysopsCanPatrol || $wgUser->isAllowed('patrol') ) && $rc_patrolled == 0;
+               
                # Make date header if necessary
                $date = $wgContLang->date( $rc_timestamp, true);
                $uidate = $wgLang->date( $rc_timestamp, true);
                $s = '';
                if ( $date != $this->lastdate ) {
                        if ( '' != $this->lastdate ) { $s .= "</ul>\n"; }
-                       $s .= "<h4>{$uidate}</h4>\n<ul class='special'>";
+                       $s .= "<h4>{$uidate}</h4>\n<ul class=\"special\">";
                        $this->lastdate = $date;
                        $this->rclistOpen = true;
                }
 
-               # If this edit has not yet been patrolled, make it stick out
-               $s .= ( ! $wgUseRCPatrol || $rc_patrolled ) ? '<li> ' : '<li class="not_patrolled"> ';
+               $s .= '<li>';
 
                if ( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
                        # Diff
@@ -2213,8 +2236,7 @@ class Skin {
                        if ( $rc_type == RC_NEW || $rc_type == RC_LOG ) {
                                $diffLink = wfMsg( 'diff' );
                        } else {
-                               if ( $wgUseRCPatrol && $rc_patrolled == 0 && $wgUser->getID() != 0 &&
-                                    ( $wgUser->isSysop() || !$wgOnlySysopsCanPatrol ) )
+                               if ( $unpatrolled )
                                        $rcidparam = "&rcid={$rc_id}";
                                else
                                        $rcidparam = "";
@@ -2228,15 +2250,15 @@ class Skin {
                        $s .= $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
                        $s .= ') . . ';
 
-                       # M and N (minor and new)
+                       # M, N and ! (minor, new and unpatrolled)
                        if ( $rc_minor ) { $s .= ' <span class="minor">'.wfMsg( "minoreditletter" ).'</span>'; }
                        if ( $rc_type == RC_NEW ) { $s .= '<span class="newpage">'.wfMsg( "newpageletter" ).'</span>'; }
+                       if ( !$rc_patrolled ) { $s .= ' <span class="unpatrolled">!</span>'; }
 
                        # Article link
                        # If it's a new article, there is no diff link, but if it hasn't been
                        # patrolled yet, we need to give users a way to do so
-                       if ( $wgUseRCPatrol && $rc_type == RC_NEW && $rc_patrolled == 0 &&
-                            $wgUser->getID() != 0 && ( $wgUser->isSysop() || !$wgOnlySysopsCanPatrol ) )
+                       if ( $unpatrolled && $rc_type == RC_NEW )
                                $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
                        else
                                $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '' );
@@ -2271,7 +2293,7 @@ class Skin {
                }
                # Block link
                $blockLink='';
-               if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
+               if ( ( 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
                        $blockLink = $this->makeKnownLink( $wgContLang->specialPage(
                          'Blockip' ), wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
 
@@ -2294,7 +2316,8 @@ class Skin {
 
        function recentChangesLineNew( &$baseRC, $watched = false ) {
                global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds;
-
+               global $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
+               
                # Create a specialised object
                $rc = RCCacheEntry::newFromParent( $baseRC ) ;
 
@@ -2313,7 +2336,15 @@ class Skin {
                        $ret .= "<h4>{$uidate}</h4>\n";
                        $this->lastdate = $date;
                }
-
+               
+               # Should patrol-related stuff be shown?
+               if ( $wgUseRCPatrol && $wgUser->getID() != 0 && 
+                 ( !$wgOnlySysopsCanPatrol || $wgUser->isAllowed('patrol') )) {
+                       $rc->unpatrolled = !$rc_patrolled;
+               } else {
+                       $rc->unpatrolled = false;
+               }
+               
                # Make article link
                if ( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
                        $msg = ( $rc_type == RC_MOVE ) ? "1movedto2" : "1movedto2_redir";
@@ -2324,6 +2355,9 @@ class Skin {
                        $logtype = $matches[1];
                        $logname = LogPage::logName( $logtype );
                        $clink = '(' . $this->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
+               } elseif ( $rc->unpatrolled && $rc_type == RC_NEW ) {
+                       # Unpatrolled new page, give rc_id in query
+                       $clink = $this->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
                } else {
                        $clink = $this->makeKnownLinkObj( $rc->getTitle(), '' ) ;
                }
@@ -2346,11 +2380,16 @@ class Skin {
 
                # 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 = wfMsg( 'last' );
                } else {
                        $lastLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'last' ),
-                         $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid );
+                         $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
                }
 
                # Make user link (or user contributions for unregistered users)
@@ -2373,7 +2412,7 @@ class Skin {
                $userTalkLink= $this->makeLink($utns . ':'.$rc_user_text, $talkname );
 
                global $wgDisableAnonTalk;
-               if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
+               if ( ( 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
                        $blockLink = $this->makeKnownLink( $wgContLang->specialPage(
                          'Blockip' ), wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
                        if( $wgDisableAnonTalk )
@@ -2492,7 +2531,7 @@ class Skin {
                if ( $iscur ) {
                        $url = Image::wfImageUrl( $img );
                        $rlink = $cur;
-                       if ( $wgUser->isSysop() ) {
+                       if ( $wgUser->isAllowed('delete') ) {
                                $link = $wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() .
                                  '&action=delete' );
                                $style = $this->getInternalLinkAttributes( $link, $delall );
@@ -2564,7 +2603,7 @@ class Skin {
                $hideline = ' <script type="text/javascript">showTocToggle("' . addslashes( wfMsg('showtoc') ) . '","' . addslashes( wfMsg('hidetoc') ) . '")</script>';
                return
                '<table border="0" id="toc"><tr id="toctitle"><td align="center">'."\n".
-               '<b>'.wfMsg('toc').'</b>' .
+               '<b>'.wfMsgForContent('toc').'</b>' .
                $hideline .
                '</td></tr><tr id="tocinside"><td>'."\n".
                $toc."</td></tr></table>\n";
@@ -2580,18 +2619,18 @@ class Skin {
                return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
        }
 
-       function editSectionScript( $section, $head ) {
-               global $wgTitle, $wgRequest;
+       function editSectionScript( $nt, $section, $head ) {
+               global $wgRequest;
                if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
                        return $head;
                }
-               $url = $wgTitle->escapeLocalURL( 'action=edit&section='.$section );
+               $url = $nt->escapeLocalURL( 'action=edit&section='.$section );
                return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
        }
 
        function editSectionLinkForOther( $title, $section ) {
                global $wgRequest;
-               global $wgUser, $wgContLang;
+               global $wgContLang;
 
                $title = Title::newFromText($title);
                $editurl = '&section='.$section;
@@ -2608,9 +2647,9 @@ class Skin {
 
        }
 
-       function editSectionLink( $section ) {
+       function editSectionLink( $nt, $section ) {
                global $wgRequest;
-               global $wgTitle, $wgUser, $wgContLang;
+               global $wgContLang;
 
                if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
                        # Section edit links would be out of sync on an old page.
@@ -2620,7 +2659,7 @@ class Skin {
                }
 
                $editurl = '&section='.$section;
-               $url = $this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
+               $url = $this->makeKnownLink($nt->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
 
                if( $wgContLang->isRTL() ) {
                        $farside = 'left';