Fix NS_PROJECT_TALK (bug #7792)
[lhc/web/wiklou.git] / includes / Linker.php
index ad2f098..42ad07b 100644 (file)
@@ -631,7 +631,7 @@ class Linker {
                                $zoomicon =  '<div class="magnify" style="float:'.$magnifyalign.'">'.
                                        '<a href="'.$u.'" class="internal" title="'.$more.'">'.
                                        '<img src="'.$wgStylePath.'/common/images/magnify-clip.png" ' .
-                                       'width="15" height="11" alt="'.$more.'" /></a></div>';
+                                       'width="15" height="11" alt="" /></a></div>';
                        }
                }
                $s .= '  <div class="thumbcaption"'.$textalign.'>'.$zoomicon.$label."</div></div></div>";
@@ -1131,20 +1131,61 @@ class Linker {
 
                        # Construct the HTML
                        $outText = '<div class="mw-templatesUsedExplanation">';
-                       if ($preview)
+                       if ( $preview ) {
                                $outText .= wfMsgExt( 'templatesusedpreview', array( 'parse' ) );
-                       elseif ($section)
+                       } elseif ( $section ) {
                                $outText .= wfMsgExt( 'templatesusedsection', array( 'parse' ) );
-                       else
+                       } else {
                                $outText .= wfMsgExt( 'templatesused', array( 'parse' ) );
+                       }
                        $outText .= '</div><ul>';
+
                        foreach ( $templates as $titleObj ) {
-                               $outText .= '<li>' . $sk->makeLinkObj( $titleObj ) . '</li>';
+                               $r = $titleObj->getRestrictions( 'edit' );
+                               if ( in_array( 'sysop', $r ) ) { 
+                                       $protected = wfMsgExt( 'template-protected', array( 'parseinline' ) );
+                               } elseif ( in_array( 'autoconfirmed', $r ) ) {
+                                       $protected = wfMsgExt( 'template-semiprotected', array( 'parseinline' ) );
+                               } else {
+                                       $protected = '';
+                               }
+                               $outText .= '<li>' . $sk->makeLinkObj( $titleObj ) . ' ' . $protected . '</li>';
                        }
                        $outText .= '</ul>';
                }
                wfProfileOut( __METHOD__  );
                return $outText;
        }
+       
+       /**
+        * Format a size in bytes for output, using an appropriate
+        * unit (B, KB, MB or GB) according to the magnitude in question
+        *
+        * @param $size Size to format
+        * @return string
+        */
+       public function formatSize( $size ) {
+               global $wgLang;
+               if( $size > 1024 ) {
+                       $size = $size / 1024;
+                       if( $size > 1024 ) {
+                               $size = $size / 1024;
+                               if( $size > 1024 ) {
+                                       $size = $size / 1024;
+                                       $msg = 'size-gigabytes';
+                               } else {
+                                       $msg = 'size-megabytes';
+                               }
+                       } else {
+                               $msg = 'size-kilobytes';
+                       }
+               } else {
+                       $msg = 'size-bytes';
+               }
+               $size = round( $size, 0 );
+               return wfMsgHtml( $msg, $wgLang->formatNum( $size ) );
+       }
+       
 }
+
 ?>