if( $hookResult = $this->runHooks( get_class( $this ) . "Raw" ) ) {
die( $hookResult );
}
- if ( defined( 'MEDIAWIKI_INSTALL' ) ) {
+ if ( defined( 'MEDIAWIKI_INSTALL' ) || $this->htmlBodyOnly() ) {
echo $this->getHTML();
} else {
echo $this->htmlHeader();
function htmlFooter() {
echo "</body></html>";
}
+
+ /**
+ * headers handled by subclass?
+ */
+ function htmlBodyOnly() {
+ return false;
+ }
static function isCommandLine() {
return !empty( $GLOBALS['wgCommandLineMode'] ) && !defined( 'MEDIAWIKI_INSTALL' );
$extra = $this->searchForm();
- if($wgUseFileCache) {
+ if( $wgUseFileCache ) {
$cache = $this->fileCachedPage();
- if ( $cache !== null ) $extra = $cache;
+ # Cached version on file system?
+ if( $cache !== null ) {
+ # Hack: extend the body for error messages
+ $cache = str_replace( array('</html>','</body>'), '', $cache );
+ # Add cache notice...
+ $cachederror = "This is a cached copy of the requested page, and may not be up to date. ";
+ # Localize it if possible...
+ if( $wgLang instanceof Language ) {
+ $cachederror = htmlspecialchars( $wgLang->getMessage( 'dberr-cachederror' ) );
+ }
+ $warning = "<div style='color:red;font-size:150%;font-weight:bold;'>$cachederror</div>";
+ # Output cached page with notices on bottom and re-close body
+ return "{$cache}{$warning}<hr />$text<hr />$extra</body></html>";
+ }
}
-
- return $text . '<hr />' . $extra;
+ # Headers needed here - output is just the error message
+ return $this->htmlHeader()."$text<hr />$extra".$this->htmlFooter();
}
function searchForm() {
function fileCachedPage() {
global $wgTitle, $title, $wgLang, $wgOut;
if( $wgOut->isDisabled() ) return; // Done already?
- $cachederror = "The following is a cached copy of the requested page, and may not be up to date. ";
$mainpage = 'Main Page';
if ( $wgLang instanceof Language ) {
- $cachederror = htmlspecialchars( $wgLang->getMessage( 'dberr-cachederror' ) );
$mainpage = htmlspecialchars( $wgLang->getMessage( 'mainpage' ) );
}
$cache = new HTMLFileCache( $t );
if( $cache->isFileCached() ) {
- $warning = "<div style='color:red;font-size:150%;font-weight:bold;'>$cachederror</div>";
- return $warning . $cache->fetchPageText();
+ return $cache->fetchPageText();
} else {
return '';
}
}
+
+ function htmlBodyOnly() {
+ return true;
+ }
}
'dberr-info' => '(Cannot contact the database server: $1)',
'dberr-usegoogle' => 'You can try searching via Google in the meantime.',
'dberr-outofdate' => 'Note that their indexes of our content may be out of date.',
-'dberr-cachederror' => 'The following is a cached copy of the requested page, and may not be up to date.',
+'dberr-cachederror' => 'This is a cached copy of the requested page, and may not be up to date.',
);