From: Bartosz Dziewoński Date: Sun, 25 May 2014 21:58:05 +0000 (+0200) Subject: Don't use autodiscovery for core skins, move them to separate directories X-Git-Tag: 1.31.0-rc.0~15424 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=9e6827d7b56e905521f0110727a46b2d14f31298;p=lhc%2Fweb%2Fwiklou.git Don't use autodiscovery for core skins, move them to separate directories Step one on the way to killing the autodiscovery mechanism and making the core skins less intertwined with core. This only moves the files and fixes hardcoded paths throughout core. Any further changes will be done in separate patch(es). Moved files: * skins/MonoBook.php → skins/monobook/MonoBook.php * skins/Vector.php → skins/vector/Vector.php Bug: 65748 Change-Id: Ib4bdda5ed3c133fce0113eb17fa39950aa812f87 --- diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 05d4c1fde9..e7411a42a3 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -1180,10 +1180,10 @@ $wgAutoloadLocalClasses = array( 'MyLocalSettingsGenerator' => 'mw-config/overrides.php', # skins - 'MonoBookTemplate' => 'skins/MonoBook.php', - 'SkinMonoBook' => 'skins/MonoBook.php', - 'SkinVector' => 'skins/Vector.php', - 'VectorTemplate' => 'skins/Vector.php', + 'MonoBookTemplate' => 'skins/monobook/MonoBook.php', + 'SkinMonoBook' => 'skins/monobook/MonoBook.php', + 'SkinVector' => 'skins/vector/Vector.php', + 'VectorTemplate' => 'skins/vector/Vector.php', ); class AutoLoader { diff --git a/includes/Setup.php b/includes/Setup.php index a1bca22b72..51368b1730 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -601,6 +601,13 @@ $wgTitle = null; $wgDeferredUpdateList = array(); +// Enable default skins. +// This is hacky and bad, but it will go away before 1.24 release (or so I hope). +// These lines should eventually be placed in skins' meta definition files, and loaded by a +// require_once for each skin file generated by the installer and placed in LocalSettings.php. +$wgValidSkinNames['monobook'] = 'MonoBook'; +$wgValidSkinNames['vector'] = 'Vector'; + wfProfileOut( $fname . '-globals' ); wfProfileIn( $fname . '-extensions' ); diff --git a/includes/Skin.php b/includes/Skin.php index 06f39b1fc3..84dd3de09f 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -63,6 +63,19 @@ abstract class Skin extends ContextSource { if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) { $aSkin = $matches[1]; + + // Explicitly disallow loading core skins via the autodiscovery mechanism. + // + // They should be loaded already (in a non-autodicovery way), but old files might still + // exist on the server because our MW version upgrade process is widely documented as + // requiring just copying over all files, without removing old ones. + // + // This is one of the reasons we should have never used autodiscovery in the first + // place. This hack can be safely removed when autodiscovery is gone. + if ( in_array( $aSkin, array( 'CologneBlue', 'Modern', 'MonoBook', 'Vector' ) ) ) { + continue; + } + $wgValidSkinNames[strtolower( $aSkin )] = $aSkin; } } @@ -184,7 +197,6 @@ abstract class Skin extends ContextSource { # is no longer valid. wfDebug( "Skin class does not exist: $className\n" ); $className = 'SkinVector'; - require_once "{$wgStyleDirectory}/Vector.php"; } } $skin = new $className( $key ); diff --git a/resources/Resources.php b/resources/Resources.php index d7df027c0c..6926d13730 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1227,7 +1227,7 @@ return array( 'scripts' => 'resources/src/mediawiki.special/mediawiki.special.js', 'styles' => 'resources/src/mediawiki.special/mediawiki.special.css', 'skinStyles' => array( - 'vector' => 'skins/vector/special.less', + 'vector' => 'skins/vector/special.less', // FIXME this should use $wgStyleDirectory ), ), 'mediawiki.special.block' => array( @@ -1276,7 +1276,7 @@ return array( 'styles' => 'resources/src/mediawiki.special/mediawiki.special.preferences.css', 'position' => 'top', 'skinStyles' => array( - 'vector' => 'skins/vector/special.preferences.less', + 'vector' => 'skins/vector/special.preferences.less', // FIXME this should use $wgStyleDirectory ), 'messages' => array( 'prefs-tabs-navigation-hint', diff --git a/skins/.gitignore b/skins/.gitignore index 3ab8af25b8..a35670e8d3 100644 --- a/skins/.gitignore +++ b/skins/.gitignore @@ -7,5 +7,3 @@ !vector/* *.php -!MonoBook.php -!Vector.php diff --git a/skins/MonoBook.php b/skins/MonoBook.php deleted file mode 100644 index 7385d0ea8f..0000000000 --- a/skins/MonoBook.php +++ /dev/null @@ -1,411 +0,0 @@ -addModuleStyles( array( 'mediawiki.skinning.interface', 'skins.monobook.styles' ) ); - - // TODO: Migrate all of these - $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' ); - $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' ); - } -} - -/** - * @todo document - * @ingroup Skins - */ -class MonoBookTemplate extends BaseTemplate { - - /** - * Template filter callback for MonoBook skin. - * Takes an associative array of data set from a SkinTemplate-based - * class, and a wrapper for MediaWiki's localization database, and - * outputs a formatted page. - * - * @access private - */ - function execute() { - // Suppress warnings to prevent notices about missing indexes in $this->data - wfSuppressWarnings(); - - $this->html( 'headelement' ); - ?>
-
-
- - data['sitenotice'] ) { - ?> -
html( 'sitenotice' ) - ?>
- -

html( 'title' ) ?>

- -
-
msg( 'tagline' ) ?>
-
html( 'userlangattributes' ) ?>>html( 'subtitle' ) - ?>
- data['undelete'] ) { ?> -
html( 'undelete' ) ?>
- data['newtalk'] ) { - ?> -
html( 'newtalk' ) ?>
- -
msg( 'jumpto' ) - ?> msg( 'jumptonavigation' ) - ?>msg( 'comma-separator' ) - ?>msg( 'jumptosearch' ) - ?>
- - - html( 'bodytext' ) ?> - data['catlinks'] ) { - $this->html( 'catlinks' ); - } - ?> - - data['dataAfterContent'] ) { - $this->html( 'dataAfterContent' - ); - } - ?> -
-
-
-
-
html( 'userlangattributes' ) ?>> -

msg( 'navigation-heading' ) ?>

- cactions(); ?> - - - renderPortals( $this->data['sidebar'] ); - ?> -
-
- getFooterIcons( "icononly" ); - $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links - - if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) { - ?> - - printTrail(); - echo Html::closeElement( 'body' ); - echo Html::closeElement( 'html' ); - wfRestoreWarnings(); - } // end of execute() method - - /*************************************************************************************************/ - - /** - * @param array $sidebar - */ - protected function renderPortals( $sidebar ) { - if ( !isset( $sidebar['SEARCH'] ) ) { - $sidebar['SEARCH'] = true; - } - if ( !isset( $sidebar['TOOLBOX'] ) ) { - $sidebar['TOOLBOX'] = true; - } - if ( !isset( $sidebar['LANGUAGES'] ) ) { - $sidebar['LANGUAGES'] = true; - } - - foreach ( $sidebar as $boxName => $content ) { - if ( $content === false ) { - continue; - } - - if ( $boxName == 'SEARCH' ) { - $this->searchBox(); - } elseif ( $boxName == 'TOOLBOX' ) { - $this->toolbox(); - } elseif ( $boxName == 'LANGUAGES' ) { - $this->languageBox(); - } else { - $this->customBox( $boxName, $content ); - } - } - } - - function searchBox() { - global $wgUseTwoButtonsSearchForm; - ?> - - - - - - data['language_urls'] !== false ) { - ?> - - 'generated-sidebar portlet', - 'id' => Sanitizer::escapeId( "p-$bar" ), - 'role' => 'navigation' - ); - - $tooltip = Linker::titleAttrib( "p-$bar" ); - if ( $tooltip !== false ) { - $portletAttribs['title'] = $tooltip; - } - echo ' ' . Html::openElement( 'div', $portletAttribs ); - $msgObj = wfMessage( $bar ); - ?> - -

exists() ? $msgObj->text() : $bar ); ?>

-
- -
    - $val ) { - ?> - makeListItem( $key, $val ); ?> - - -
- renderAfterPortlet( $bar ); - ?> -
-
- getRequest()->getFuzzyBool( 'debug' ) ? '' : '.min'; - $out->addHeadItem( 'csshover', - '" - ); - - $out->addModules( array( 'skins.vector.js' ) ); - } - - /** - * Loads skin and user CSS files. - * @param OutputPage $out - */ - function setupSkinUserCss( OutputPage $out ) { - parent::setupSkinUserCss( $out ); - - $styles = array( 'mediawiki.skinning.interface', 'skins.vector.styles' ); - wfRunHooks( 'SkinVectorStyleModules', array( $this, &$styles ) ); - $out->addModuleStyles( $styles ); - } - - /** - * Adds classes to the body element. - * - * @param OutputPage $out - * @param array &$bodyAttrs Array of attributes that will be set on the body element - */ - function addToBodyAttributes( $out, &$bodyAttrs ) { - if ( isset( $bodyAttrs['class'] ) && strlen( $bodyAttrs['class'] ) > 0 ) { - $bodyAttrs['class'] .= ' ' . implode( ' ', static::$bodyClasses ); - } else { - $bodyAttrs['class'] = implode( ' ', static::$bodyClasses ); - } - } -} - -/** - * QuickTemplate class for Vector skin - * @ingroup Skins - */ -class VectorTemplate extends BaseTemplate { - /* Functions */ - - /** - * Outputs the entire contents of the (X)HTML page - */ - public function execute() { - global $wgVectorUseIconWatch; - - // Build additional attributes for navigation urls - $nav = $this->data['content_navigation']; - - if ( $wgVectorUseIconWatch ) { - $mode = $this->getSkin()->getUser()->isWatched( $this->getSkin()->getRelevantTitle() ) - ? 'unwatch' - : 'watch'; - - if ( isset( $nav['actions'][$mode] ) ) { - $nav['views'][$mode] = $nav['actions'][$mode]; - $nav['views'][$mode]['class'] = rtrim( 'icon ' . $nav['views'][$mode]['class'], ' ' ); - $nav['views'][$mode]['primary'] = true; - unset( $nav['actions'][$mode] ); - } - } - - $xmlID = ''; - foreach ( $nav as $section => $links ) { - foreach ( $links as $key => $link ) { - if ( $section == 'views' && !( isset( $link['primary'] ) && $link['primary'] ) ) { - $link['class'] = rtrim( 'collapsible ' . $link['class'], ' ' ); - } - - $xmlID = isset( $link['id'] ) ? $link['id'] : 'ca-' . $xmlID; - $nav[$section][$key]['attributes'] = - ' id="' . Sanitizer::escapeId( $xmlID ) . '"'; - if ( $link['class'] ) { - $nav[$section][$key]['attributes'] .= - ' class="' . htmlspecialchars( $link['class'] ) . '"'; - unset( $nav[$section][$key]['class'] ); - } - if ( isset( $link['tooltiponly'] ) && $link['tooltiponly'] ) { - $nav[$section][$key]['key'] = - Linker::tooltip( $xmlID ); - } else { - $nav[$section][$key]['key'] = - Xml::expandAttributes( Linker::tooltipAndAccesskeyAttribs( $xmlID ) ); - } - } - } - $this->data['namespace_urls'] = $nav['namespaces']; - $this->data['view_urls'] = $nav['views']; - $this->data['action_urls'] = $nav['actions']; - $this->data['variant_urls'] = $nav['variants']; - - // Reverse horizontally rendered navigation elements - if ( $this->data['rtl'] ) { - $this->data['view_urls'] = - array_reverse( $this->data['view_urls'] ); - $this->data['namespace_urls'] = - array_reverse( $this->data['namespace_urls'] ); - $this->data['personal_urls'] = - array_reverse( $this->data['personal_urls'] ); - } - // Output HTML Page - $this->html( 'headelement' ); - ?> -
-
-
- - - - data['sitenotice'] ) { - ?> -
html( 'sitenotice' ) ?>
- -

html( 'title' ) ?>

- html( 'prebodyhtml' ) ?> -
- data['isarticle'] ) { - ?> -
msg( 'tagline' ) ?>
- -
html( 'userlangattributes' ) - ?>>html( 'subtitle' ) ?>
- data['undelete'] ) { - ?> -
html( 'undelete' ) ?>
- - data['newtalk'] ) { - ?> -
html( 'newtalk' ) ?>
- -
- msg( 'jumpto' ) ?> - msg( 'jumptonavigation' ) - ?>msg( 'comma-separator' ) - ?> - msg( 'jumptosearch' ) ?> -
- html( 'bodycontent' ) ?> - data['printfooter'] ) { - ?> -
- html( 'printfooter' ); ?> -
- - data['catlinks'] ) { - ?> - html( 'catlinks' ); - ?> - - data['dataAfterContent'] ) { - ?> - html( 'dataAfterContent' ); - ?> - -
- html( 'debughtml' ); ?> -
-
-
-

msg( 'navigation-heading' ) ?>

- -
- renderNavigation( 'PERSONAL' ); ?> -
- renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?> -
-
- renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?> -
-
-
- - renderPortals( $this->data['sidebar'] ); ?> -
-
- - printTrail(); ?> - - - - $content ) { - if ( $content === false ) { - continue; - } - - switch ( $name ) { - case 'SEARCH': - break; - case 'TOOLBOX': - $this->renderPortal( 'tb', $this->getToolbox(), 'toolbox', 'SkinTemplateToolboxEnd' ); - break; - case 'LANGUAGES': - if ( $this->data['language_urls'] !== false ) { - $this->renderPortal( 'lang', $this->data['language_urls'], 'otherlanguages' ); - } - break; - default: - $this->renderPortal( $name, $content ); - break; - } - } - } - - /** - * @param string $name - * @param array $content - * @param null|string $msg - * @param null|string|array $hook - */ - protected function renderPortal( $name, $content, $msg = null, $hook = null ) { - if ( $msg === null ) { - $msg = $name; - } - $msgObj = wfMessage( $msg ); - ?> - - data['rtl'] ) { - $elements = array_reverse( $elements ); - } - // Render elements - foreach ( $elements as $name => $element ) { - switch ( $element ) { - case 'NAMESPACES': - ?> - - - - - - - - - - -