array_push( $this->mKeywords, $text );
}
}
- function addScript( $script ) { $this->mScripts .= "\t\t" . $script . "\n"; }
+ function addScript( $script ) { $this->mScripts .= "\t" . $script . "\n"; }
function addExtensionStyle( $url ) {
$linkarr = array( 'rel' => 'stylesheet', 'href' => $url, 'type' => 'text/css' );
global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces;
global $wgContLang, $wgUseTrackbacks, $wgStyleVersion;
- $this->addMeta( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" );
- $this->addStyle( 'common/wikiprintable.css', 'print' );
+ $this->addMeta( "http:Content-Type", "$wgMimeType; charset={$wgOutputEncoding}" );
+ if ( $sk->commonPrintStylesheet() ) {
+ $this->addStyle( 'common/wikiprintable.css', 'print' );
+ }
$sk->setupUserCss( $this );
$ret = '';
$ret .= "<?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n";
}
- $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
+ $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\" \"$wgDTD\">\n";
if ( '' == $this->getHTMLTitle() ) {
$this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ));
}
- $rtl = $wgContLang->isRTL() ? " dir='RTL'" : '';
+ $dir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
$ret .= "<html xmlns=\"{$wgXhtmlDefaultNamespace}\" ";
foreach($wgXhtmlNamespaces as $tag => $ns) {
$ret .= "xmlns:{$tag}=\"{$ns}\" ";
}
- $ret .= "xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" $rtl>\n";
- $ret .= "<head>\n<title>" . htmlspecialchars( $this->getHTMLTitle() ) . "</title>\n\t\t";
- $ret .= implode( "\t\t", array(
+ $ret .= "xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" dir=\"$dir\">\n";
+ $ret .= "<head>\n\t<title>" . htmlspecialchars( $this->getHTMLTitle() ) . "</title>\n\t";
+ $ret .= implode( "\n", array(
$this->getHeadLinks(),
$this->buildCssLinks(),
- $sk->getHeadScripts( $this->mAllowUserJs ),
- $this->mScripts,
+ $sk->getHeadScripts( $this->mAllowUserJs, $this->mScripts ),
$this->getHeadItems(),
));
if( $sk->usercss ){
protected function addDefaultMeta() {
global $wgVersion;
+
+ static $called = false;
+ if ( $called ) {
+ # Don't run this twice
+ return;
+ }
+ $called = true;
+
$this->addMeta( 'http:Content-Style-Type', 'text/css' ); //bug 15835
$this->addMeta( 'generator', "MediaWiki $wgVersion" );
}
}
- return implode( "\n\t\t", $tags ) . "\n";
+ return implode( "\n\t", $tags ) . "\n";
}
/**
$links[] = $link;
}
- return implode( "\n\t\t", $links );
+ return "\t" . implode( "\n\t", $links );
}
protected function styleLink( $style, $options ) {
return self::makeVariablesScript( $vars );
}
- function getHeadScripts( $allowUserJs ) {
+ /**
+ * Return a random selection of the scripts we want in the header,
+ * according to no particular rhyme or reason. Various other scripts are
+ * returned from a haphazard assortment of other functions scattered over
+ * various files. This entire hackish system needs to be burned to the
+ * ground and rebuilt.
+ *
+ * @var $allowUserJs bool Should probably be identical to $wgAllowUserJs,
+ * but is passed as a local variable for some
+ * obscure reason.
+ * @var $extraHtml string A bunch of raw HTML to jam into some arbitrary
+ * place where MonoBook has historically wanted it.
+ * Old-style skins formerly put it in a different
+ * place, but if either of those is broken it's
+ * likely to be the old-style skins.
+ * @return string Raw HTML to output in some location in the <head> that's
+ * entirely arbitrary but which will probably break
+ * everything if you put it someplace else.
+ */
+ function getHeadScripts( $allowUserJs, $extraHtml = '' ) {
global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
$vars = self::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
- $r = array( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>" );
+ $r = array( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n$extraHtml" );
global $wgUseSiteJs;
if( $wgUseSiteJs ) {
$jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : '';
htmlspecialchars( self::makeUrl( '-',
"action=raw$jsCache&gen=js&useskin=" .
urlencode( $this->getSkinName() ) ) ) .
- "\"><!-- site js --></script>";
+ "\"></script>";
}
if( $allowUserJs && $wgUser->isLoggedIn() ) {
$userpage = $wgUser->getUserPage();
'action=raw&ctype='.$wgJsMimeType ) );
$r[] = '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>";
}
- return $vars . "\t\t" . implode ( "\n\t\t", $r );
+ return $vars . "\t" . implode ( "\n\t", $r );
}
/**
wfProfileOut( __METHOD__ );
return $bar;
}
+
+ /**
+ * Should we include common/wikiprintable.css? Skins that have their own
+ * print stylesheet should override this and return false. (This is an
+ * ugly hack to get Monobook to play nicely with
+ * OutputPage::headElement().)
+ *
+ * @return bool
+ */
+ public function commonPrintStylesheet() {
+ return true;
+ }
}
wfProfileOut( __METHOD__ );
return $out;
}
+
+ public function commonPrintStylesheet() {
+ return false;
+ }
}
/**
* @access private
*/
function execute() {
- global $wgRequest;
+ global $wgRequest, $wgOut, $wgStyleVersion, $wgJsMimeType, $wgStylePath;
$this->skin = $skin = $this->data['skin'];
$action = $wgRequest->getText( 'action' );
// Suppress warnings to prevent notices about missing indexes in $this->data
wfSuppressWarnings();
-?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="<?php $this->text('xhtmldefaultnamespace') ?>" <?php
- foreach($this->data['xhtmlnamespaces'] as $tag => $ns) {
- ?>xmlns:<?php echo "{$tag}=\"{$ns}\" ";
- } ?>xml:lang="<?php $this->text('lang') ?>" lang="<?php $this->text('lang') ?>" dir="<?php $this->text('dir') ?>">
- <head>
- <meta http-equiv="Content-Type" content="<?php $this->text('mimetype') ?>; charset=<?php $this->text('charset') ?>" />
- <?php $this->html('headlinks') ?>
- <title><?php $this->text('pagetitle') ?></title>
- <?php $this->html('csslinks') ?>
-
- <!--[if lt IE 7]><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath') ?>/common/IEFixes.js?<?php echo $GLOBALS['wgStyleVersion'] ?>"></script>
- <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
+ $path = htmlspecialchars( $wgStylePath );
+ $wgOut->addScript( <<<HTML
+<!--[if lt IE 7]><script type="$wgJsMimeType" src="$path/common/IEFixes.js?$wgStyleVersion"></script>
+ <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
+HTML
+ );
- <?php print Skin::makeGlobalVariablesScript( $this->data ); ?>
+ echo $wgOut->headElement( $this->skin );
- <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath' ) ?>/common/wikibits.js?<?php echo $GLOBALS['wgStyleVersion'] ?>"></script>
-<?php $this->html('headscripts') ?>
-<?php if($this->data['jsvarurl']) { ?>
- <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('jsvarurl') ?>"></script>
-<?php } ?>
-<?php if($this->data['pagecss']) { ?>
- <style type="text/css"><?php $this->html('pagecss') ?></style>
-<?php }
- if($this->data['usercss']) { ?>
- <style type="text/css"><?php $this->html('usercss') ?></style>
-<?php }
- if($this->data['userjs']) { ?>
- <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('userjs' ) ?>"></script>
-<?php }
- if($this->data['userjsprev']) { ?>
- <script type="<?php $this->text('jsmimetype') ?>"><?php $this->html('userjsprev') ?></script>
-<?php }
- if($this->data['trackbackhtml']) print $this->data['trackbackhtml']; ?>
- </head>
-<body<?php if($this->data['body_ondblclick']) { ?> ondblclick="<?php $this->text('body_ondblclick') ?>"<?php } ?>
+?><body<?php if($this->data['body_ondblclick']) { ?> ondblclick="<?php $this->text('body_ondblclick') ?>"<?php } ?>
<?php if($this->data['body_onload']) { ?> onload="<?php $this->text('body_onload') ?>"<?php } ?>
class="mediawiki <?php $this->text('dir'); $this->text('capitalizeallnouns') ?> <?php $this->text('pageclass') ?> <?php $this->text('skinnameclass') ?>">
<div id="globalWrapper">