Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -2930,9 +2930,17 @@ |
2931 | 2931 | return false; |
2932 | 2932 | } |
2933 | 2933 | |
2934 | | - function useMessageCache() { |
2935 | | - // Not likely to work |
2936 | | - return false; |
| 2934 | + function msg( $key, $fallback /*[, params...] */ ) { |
| 2935 | + global $wgLang; |
| 2936 | + |
| 2937 | + $args = array_slice( func_get_args(), 2 ); |
| 2938 | + |
| 2939 | + if ( $this->useMessageCache() ) { |
| 2940 | + $message = $wgLang->getMessage( $key ); |
| 2941 | + } else { |
| 2942 | + $message = $fallback; |
| 2943 | + } |
| 2944 | + return wfMsgReplaceArgs( $message, $args ); |
2937 | 2945 | } |
2938 | 2946 | |
2939 | 2947 | function getLogMessage() { |
— | — | @@ -2941,30 +2949,17 @@ |
2942 | 2950 | } |
2943 | 2951 | |
2944 | 2952 | function getPageTitle() { |
2945 | | - global $wgSitename, $wgLang; |
2946 | | - |
2947 | | - $header = "$wgSitename has a problem"; |
2948 | | - |
2949 | | - if ( $wgLang instanceof Language ) { |
2950 | | - $header = htmlspecialchars( $wgLang->getMessage( 'dberr-header' ) ); |
2951 | | - } |
2952 | | - |
2953 | | - return $header; |
| 2953 | + global $wgSitename; |
| 2954 | + return htmlspecialchars( $this->msg( 'dberr-header', "$wgSitename has a problem" ) ); |
2954 | 2955 | } |
2955 | 2956 | |
2956 | 2957 | function getHTML() { |
2957 | | - global $wgLang, $wgUseFileCache, $wgShowDBErrorBacktrace; |
| 2958 | + global $wgUseFileCache, $wgShowDBErrorBacktrace; |
2958 | 2959 | |
2959 | | - $sorry = 'Sorry! This site is experiencing technical difficulties.'; |
2960 | | - $again = 'Try waiting a few minutes and reloading.'; |
2961 | | - $info = '(Can\'t contact the database server: $1)'; |
| 2960 | + $sorry = htmlspecialchars( $this->msg( 'dberr-problems', 'Sorry! This site is experiencing technical difficulties.' ) ); |
| 2961 | + $again = htmlspecialchars( $this->msg( 'dberr-again', 'Try waiting a few minutes and reloading.' ) ); |
| 2962 | + $info = htmlspecialchars( $this->msg( 'dberr-info', '(Can\'t contact the database server: $1)' ) ); |
2962 | 2963 | |
2963 | | - if ( $wgLang instanceof Language ) { |
2964 | | - $sorry = htmlspecialchars( $wgLang->getMessage( 'dberr-problems' ) ); |
2965 | | - $again = htmlspecialchars( $wgLang->getMessage( 'dberr-again' ) ); |
2966 | | - $info = htmlspecialchars( $wgLang->getMessage( 'dberr-info' ) ); |
2967 | | - } |
2968 | | - |
2969 | 2964 | # No database access |
2970 | 2965 | MessageCache::singleton()->disable(); |
2971 | 2966 | |
— | — | @@ -2991,17 +2986,13 @@ |
2992 | 2987 | # Hack: extend the body for error messages |
2993 | 2988 | $cache = str_replace( array( '</html>', '</body>' ), '', $cache ); |
2994 | 2989 | # Add cache notice... |
2995 | | - $cachederror = "This is a cached copy of the requested page, and may not be up to date. "; |
| 2990 | + $cache .= '<div style="color:red;font-size:150%;font-weight:bold;">'. |
| 2991 | + htmlspecialchars( $this->msg( 'dberr-cachederror', |
| 2992 | + 'This is a cached copy of the requested page, and may not be up to date. ' ) ) . |
| 2993 | + '</div>'; |
2996 | 2994 | |
2997 | | - # Localize it if possible... |
2998 | | - if ( $wgLang instanceof Language ) { |
2999 | | - $cachederror = htmlspecialchars( $wgLang->getMessage( 'dberr-cachederror' ) ); |
3000 | | - } |
3001 | | - |
3002 | | - $warning = "<div style='color:red;font-size:150%;font-weight:bold;'>$cachederror</div>"; |
3003 | | - |
3004 | 2995 | # Output cached page with notices on bottom and re-close body |
3005 | | - return "{$cache}{$warning}<hr />$text<hr />$extra</body></html>"; |
| 2996 | + return "{$cache}<hr />$text<hr />$extra</body></html>"; |
3006 | 2997 | } |
3007 | 2998 | } catch ( MWException $e ) { |
3008 | 2999 | // Do nothing, just use the default page |
— | — | @@ -3013,18 +3004,12 @@ |
3014 | 3005 | } |
3015 | 3006 | |
3016 | 3007 | function searchForm() { |
3017 | | - global $wgSitename, $wgServer, $wgLang; |
| 3008 | + global $wgSitename, $wgServer; |
3018 | 3009 | |
3019 | | - $usegoogle = "You can try searching via Google in the meantime."; |
3020 | | - $outofdate = "Note that their indexes of our content may be out of date."; |
3021 | | - $googlesearch = "Search"; |
| 3010 | + $usegoogle = htmlspecialchars( $this->msg( 'dberr-usegoogle', 'You can try searching via Google in the meantime.' ) ); |
| 3011 | + $outofdate = htmlspecialchars( $this->msg( 'dberr-outofdate', 'Note that their indexes of our content may be out of date.' ) ); |
| 3012 | + $googlesearch = htmlspecialchars( $this->msg( 'searchbutton', 'Search' ) ); |
3022 | 3013 | |
3023 | | - if ( $wgLang instanceof Language ) { |
3024 | | - $usegoogle = htmlspecialchars( $wgLang->getMessage( 'dberr-usegoogle' ) ); |
3025 | | - $outofdate = htmlspecialchars( $wgLang->getMessage( 'dberr-outofdate' ) ); |
3026 | | - $googlesearch = htmlspecialchars( $wgLang->getMessage( 'searchbutton' ) ); |
3027 | | - } |
3028 | | - |
3029 | 3014 | $search = htmlspecialchars( @$_REQUEST['search'] ); |
3030 | 3015 | |
3031 | 3016 | $server = htmlspecialchars( $wgServer ); |
— | — | @@ -3053,22 +3038,16 @@ |
3054 | 3039 | } |
3055 | 3040 | |
3056 | 3041 | private function fileCachedPage() { |
3057 | | - global $wgTitle, $wgLang, $wgOut; |
| 3042 | + global $wgTitle, $wgOut; |
3058 | 3043 | |
3059 | 3044 | if ( $wgOut->isDisabled() ) { |
3060 | 3045 | return; // Done already? |
3061 | 3046 | } |
3062 | 3047 | |
3063 | | - $mainpage = 'Main Page'; |
3064 | | - |
3065 | | - if ( $wgLang instanceof Language ) { |
3066 | | - $mainpage = htmlspecialchars( $wgLang->getMessage( 'mainpage' ) ); |
3067 | | - } |
3068 | | - |
3069 | 3048 | if ( $wgTitle ) { |
3070 | 3049 | $t =& $wgTitle; |
3071 | 3050 | } else { |
3072 | | - $t = Title::newFromText( $mainpage ); |
| 3051 | + $t = Title::newFromText( $this->msg( 'mainpage', 'Main Page' ) ); |
3073 | 3052 | } |
3074 | 3053 | |
3075 | 3054 | $cache = new HTMLFileCache( $t ); |