Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -2586,12 +2586,25 @@ |
2587 | 2587 | |
2588 | 2588 | $extra = $this->searchForm(); |
2589 | 2589 | |
2590 | | - if($wgUseFileCache) { |
| 2590 | + if( $wgUseFileCache ) { |
2591 | 2591 | $cache = $this->fileCachedPage(); |
2592 | | - if ( $cache !== null ) $extra = $cache; |
| 2592 | + # Cached version on file system? |
| 2593 | + if( $cache !== null ) { |
| 2594 | + # Hack: extend the body for error messages |
| 2595 | + $cache = str_replace( array('</html>','</body>'), '', $cache ); |
| 2596 | + # Add cache notice... |
| 2597 | + $cachederror = "This is a cached copy of the requested page, and may not be up to date. "; |
| 2598 | + # Localize it if possible... |
| 2599 | + if( $wgLang instanceof Language ) { |
| 2600 | + $cachederror = htmlspecialchars( $wgLang->getMessage( 'dberr-cachederror' ) ); |
| 2601 | + } |
| 2602 | + $warning = "<div style='color:red;font-size:150%;font-weight:bold;'>$cachederror</div>"; |
| 2603 | + # Output cached page with notices on bottom and re-close body |
| 2604 | + return "{$cache}{$warning}<hr />$text<hr />$extra</body></html>"; |
| 2605 | + } |
2593 | 2606 | } |
2594 | | - |
2595 | | - return $text . '<hr />' . $extra; |
| 2607 | + # Headers needed here - output is just the error message |
| 2608 | + return $this->htmlHeader()."$text<hr />$extra".$this->htmlFooter(); |
2596 | 2609 | } |
2597 | 2610 | |
2598 | 2611 | function searchForm() { |
— | — | @@ -2635,10 +2648,8 @@ |
2636 | 2649 | function fileCachedPage() { |
2637 | 2650 | global $wgTitle, $title, $wgLang, $wgOut; |
2638 | 2651 | if( $wgOut->isDisabled() ) return; // Done already? |
2639 | | - $cachederror = "The following is a cached copy of the requested page, and may not be up to date. "; |
2640 | 2652 | $mainpage = 'Main Page'; |
2641 | 2653 | if ( $wgLang instanceof Language ) { |
2642 | | - $cachederror = htmlspecialchars( $wgLang->getMessage( 'dberr-cachederror' ) ); |
2643 | 2654 | $mainpage = htmlspecialchars( $wgLang->getMessage( 'mainpage' ) ); |
2644 | 2655 | } |
2645 | 2656 | |
— | — | @@ -2652,12 +2663,15 @@ |
2653 | 2664 | |
2654 | 2665 | $cache = new HTMLFileCache( $t ); |
2655 | 2666 | if( $cache->isFileCached() ) { |
2656 | | - $warning = "<div style='color:red;font-size:150%;font-weight:bold;'>$cachederror</div>"; |
2657 | | - return $warning . $cache->fetchPageText(); |
| 2667 | + return $cache->fetchPageText(); |
2658 | 2668 | } else { |
2659 | 2669 | return ''; |
2660 | 2670 | } |
2661 | 2671 | } |
| 2672 | + |
| 2673 | + function htmlBodyOnly() { |
| 2674 | + return true; |
| 2675 | + } |
2662 | 2676 | |
2663 | 2677 | } |
2664 | 2678 | |
Index: trunk/phase3/includes/Exception.php |
— | — | @@ -161,7 +161,7 @@ |
162 | 162 | if( $hookResult = $this->runHooks( get_class( $this ) . "Raw" ) ) { |
163 | 163 | die( $hookResult ); |
164 | 164 | } |
165 | | - if ( defined( 'MEDIAWIKI_INSTALL' ) ) { |
| 165 | + if ( defined( 'MEDIAWIKI_INSTALL' ) || $this->htmlBodyOnly() ) { |
166 | 166 | echo $this->getHTML(); |
167 | 167 | } else { |
168 | 168 | echo $this->htmlHeader(); |
— | — | @@ -217,6 +217,13 @@ |
218 | 218 | function htmlFooter() { |
219 | 219 | echo "</body></html>"; |
220 | 220 | } |
| 221 | + |
| 222 | + /** |
| 223 | + * headers handled by subclass? |
| 224 | + */ |
| 225 | + function htmlBodyOnly() { |
| 226 | + return false; |
| 227 | + } |
221 | 228 | |
222 | 229 | static function isCommandLine() { |
223 | 230 | return !empty( $GLOBALS['wgCommandLineMode'] ) && !defined( 'MEDIAWIKI_INSTALL' ); |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -3871,6 +3871,6 @@ |
3872 | 3872 | 'dberr-info' => '(Cannot contact the database server: $1)', |
3873 | 3873 | 'dberr-usegoogle' => 'You can try searching via Google in the meantime.', |
3874 | 3874 | 'dberr-outofdate' => 'Note that their indexes of our content may be out of date.', |
3875 | | -'dberr-cachederror' => 'The following is a cached copy of the requested page, and may not be up to date.', |
| 3875 | +'dberr-cachederror' => 'This is a cached copy of the requested page, and may not be up to date.', |
3876 | 3876 | |
3877 | 3877 | ); |