- /**
- * returns css with user-specific options
- */
- public function getUserStylesheet() {
- wfProfileIn( __METHOD__ );
-
- $s = "/* generated user stylesheet */\n";
- $s .= $this->reallyDoGetUserStyles();
- wfProfileOut( __METHOD__ );
- return $s;
- }
-
- /**
- * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
- * nated together. For some bizarre reason, it does *not* return any
- * custom user JS from subpages. Huh?
- *
- * There's absolutely no reason to have separate Monobook/Common JSes.
- * Any JS that cares can just check the skin variable generated at the
- * top. For now Monobook.js will be maintained, but it should be consi-
- * dered deprecated.
- *
- * @return string
- */
- public function getUserJs() {
- wfProfileIn( __METHOD__ );
-
- $s = parent::getUserJs();
- $s .= "\n\n/* MediaWiki:".ucfirst($this->skinname).".js */\n";
-
- // avoid inclusion of non defined user JavaScript (with custom skins only)
- // by checking for default message content
- $msgKey = ucfirst($this->skinname).'.js';
- $userJS = wfMsgForContent($msgKey);
- if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
- $s .= $userJS;
- }
-
- wfProfileOut( __METHOD__ );
- return $s;
- }
-
- /**
- * Add a local or specified stylesheet, with the given media options.
- * Meant primarily for internal use...
- *
- * @param $media -- to specify a media type, 'screen', 'printable', 'handheld' or any.
- * @param $conditional -- for IE conditional comments, specifying an IE version
- * @param $dir -- set to 'rtl' or 'ltr' for direction-specific sheets
- */
- public function addStyle( $style, $media='', $condition='', $dir='' ) {
- $options = array();
- if( $media )
- $options['media'] = $media;
- if( $condition )
- $options['condition'] = $condition;
- if( $dir )
- $options['dir'] = $dir;
- $this->styles[$style] = $options;
- }
-
- /**
- * Build a set of <link>s for the stylesheets specified in the $this->styles array.
- * These will be applied to various media & IE conditionals.
- */
- protected function buildCssLinks() {
- $links = array();
- foreach( $this->styles as $file => $options ) {
- $link = $this->styleLink( $file, $options );
- if( $link )
- $links[] = $link;
- }
-
- return implode( "\n\t\t", $links );
- }
-
- protected function styleLink( $style, $options ) {
- global $wgRequest;
-
- if( isset( $options['dir'] ) ) {
- global $wgContLang;
- $siteDir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
- if( $siteDir != $options['dir'] )
- return '';
- }
-
- if( isset( $options['media'] ) ) {
- $media = $this->transformCssMedia( $options['media'] );
- if( is_null( $media ) ) {
- return '';
- }
- } else {
- $media = '';
- }
-
- if( substr( $style, 0, 1 ) == '/' ||
- substr( $style, 0, 5 ) == 'http:' ||
- substr( $style, 0, 6 ) == 'https:' ) {
- $url = $style;
- } else {
- global $wgStylePath, $wgStyleVersion;
- $url = $wgStylePath . '/' . $style . '?' . $wgStyleVersion;
- }
-
- $attribs = array(
- 'rel' => 'stylesheet',
- 'href' => $url,
- 'type' => 'text/css' );
- if( $media ) {
- $attribs['media'] = $media;
- }
-
- $link = Xml::element( 'link', $attribs );
-
- if( isset( $options['condition'] ) ) {
- $condition = htmlspecialchars( $options['condition'] );
- $link = "<!--[if $condition]>$link<![endif]-->";
- }
- return $link;