'ResourceLoaderUserDefaultsModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserDefaultsModule.php',
'ResourceLoaderUserModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserModule.php',
'ResourceLoaderUserOptionsModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserOptionsModule.php',
+ 'ResourceLoaderUserStylesModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserStylesModule.php',
'ResourceLoaderUserTokensModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserTokensModule.php',
'ResourceLoaderWikiModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderWikiModule.php',
'RestbaseVirtualRESTService' => __DIR__ . '/includes/libs/virtualrest/RestbaseVirtualRESTService.php',
/**
* Kept for extension compatibility; see $wgParserCacheType
- * @deprecated 1.26
+ * @deprecated since 1.26
*/
$wgEnableParserCache = true;
* Supports base 2 through 36; digit values 10-36 are represented
* as lowercase letters a-z. Input is case-insensitive.
*
- * @deprecated 1.27 Use Wikimedia\base_convert() directly
+ * @deprecated since 1.27 Use Wikimedia\base_convert() directly
*
* @param string $input Input number
* @param int $sourceBase Base of the input number
* @param string|null $deprecatedVersion Optionally mark hook as deprecated with version number
*
* @return bool True if no handler aborted the hook
- * @deprecated 1.25 - use Hooks::run
+ * @deprecated since 1.25 - use Hooks::run
*/
function wfRunHooks( $event, array $args = [], $deprecatedVersion = null ) {
return Hooks::run( $event, $args, $deprecatedVersion );
) {
// We're on a preview of a CSS subpage
// Exclude this page from the user module in case it's in there (bug 26283)
- $link = $this->makeResourceLoaderLink( 'user', ResourceLoaderModule::TYPE_STYLES,
+ $link = $this->makeResourceLoaderLink( 'user.styles', ResourceLoaderModule::TYPE_STYLES,
[ 'excludepage' => $this->getTitle()->getPrefixedDBkey() ]
);
$otherTags = array_merge( $otherTags, $link['html'] );
$otherTags[] = Html::inlineStyle( $previewedCSS );
} else {
// Load the user styles normally
- $moduleStyles[] = 'user';
+ $moduleStyles[] = 'user.styles';
}
// Per-user preference styles
*
* @return array A list in which each entry is an array with a message key as its first element.
* The remaining array elements are the message parameters.
- * @deprecated 1.25
+ * @deprecated since 1.25
*/
public function getErrorsArray() {
return $this->getStatusArray( 'error' );
*
* @return array A list in which each entry is an array with a message key as its first element.
* The remaining array elements are the message parameters.
- * @deprecated 1.25
+ * @deprecated since 1.25
*/
public function getWarningsArray() {
return $this->getStatusArray( 'warning' );
/**
* @param Title $title
* @return CdnCacheUpdate
- * @deprecated 1.27
+ * @deprecated since 1.27
*/
public static function newSimplePurge( Title $title ) {
return new CdnCacheUpdate( $title->getCdnUrls() );
/**
* Generic operation result class for FileRepo-related operations
* @ingroup FileRepo
- * @deprecated 1.25
+ * @deprecated since 1.25
*/
class FileRepoStatus extends Status {
}
* @param array $params [optional] Array key 'fallback' for $fallback.
* @param int|string $fallback Fallback cache, e.g. (CACHE_NONE, "hash") (since 1.24)
* @return BagOStuff
- * @deprecated 1.27
+ * @deprecated since 1.27
*/
public static function newAccelerator( $params = [], $fallback = null ) {
if ( $fallback === null ) {
* Class for handling function-scope profiling
*
* @since 1.22
- * @deprecated 1.25 No-op now
+ * @deprecated since 1.25 No-op now
*/
class ProfileSection {
/**
/**
* Begin profiling of a function
* @param string $functionname Name of the function we will profile
- * @deprecated 1.25
+ * @deprecated since 1.25
*/
function wfProfileIn( $functionname ) {
}
/**
* Stop profiling of a function
* @param string $functionname Name of the function we have profiled
- * @deprecated 1.25
+ * @deprecated since 1.25
*/
function wfProfileOut( $functionname = 'missing' ) {
}
<?php
/**
- * ResourceLoader module for user customizations.
- *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
*/
/**
- * Module for user customizations
+ * Module for user customizations scripts
*/
class ResourceLoaderUserModule extends ResourceLoaderWikiModule {
protected $targets = [ 'desktop', 'mobile' ];
/**
- * Get list of pages used by this module
- *
* @param ResourceLoaderContext $context
* @return array List of pages
*/
$pages["$userPage/" . $context->getSkin() . '.js'] = [ 'type' => 'script' ];
}
- if ( $config->get( 'AllowUserCss' ) ) {
- $pages["$userPage/common.css"] = [ 'type' => 'style' ];
- $pages["$userPage/" . $context->getSkin() . '.css'] = [ 'type' => 'style' ];
- }
-
- $useSiteJs = $config->get( 'UseSiteJs' );
- $useSiteCss = $config->get( 'UseSiteCss' );
// User group pages are maintained site-wide and enabled with site JS/CSS.
- if ( $useSiteJs || $useSiteCss ) {
+ if ( $config->get( 'UseSiteJs' ) ) {
foreach ( $user->getEffectiveGroups() as $group ) {
if ( $group == '*' ) {
continue;
}
- if ( $useSiteJs ) {
- $pages["MediaWiki:Group-$group.js"] = [ 'type' => 'script' ];
- }
- if ( $useSiteCss ) {
- $pages["MediaWiki:Group-$group.css"] = [ 'type' => 'style' ];
- }
+ $pages["MediaWiki:Group-$group.js"] = [ 'type' => 'script' ];
}
}
- // Hack for bug 26283: if we're on a preview page for a CSS/JS page,
- // we need to exclude that page from this module. In that case, the excludepage
- // parameter will be set to the name of the page we need to exclude.
+ // Hack for T28283: Allow excluding pages for preview on a CSS/JS page.
+ // The excludepage parameter is set by OutputPage.
$excludepage = $context->getRequest()->getVal( 'excludepage' );
if ( isset( $pages[$excludepage] ) ) {
- // This works because $excludepage is generated with getPrefixedDBkey(),
- // just like the keys in $pages[] above
unset( $pages[$excludepage] );
}
public function getGroup() {
return 'user';
}
+
+ /**
+ * @return array
+ */
+ public function getDependencies( ResourceLoaderContext $context = null ) {
+ return [ 'user.styles' ];
+ }
}
--- /dev/null
+<?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @author Trevor Parscal
+ * @author Roan Kattouw
+ */
+
+/**
+ * Module for user customizations styles
+ */
+class ResourceLoaderUserStylesModule extends ResourceLoaderWikiModule {
+
+ protected $origin = self::ORIGIN_USER_INDIVIDUAL;
+ protected $targets = [ 'desktop', 'mobile' ];
+
+ /**
+ * @param ResourceLoaderContext $context
+ * @return array List of pages
+ */
+ protected function getPages( ResourceLoaderContext $context ) {
+ $config = $this->getConfig();
+ $user = $context->getUserObj();
+ if ( $user->isAnon() ) {
+ return [];
+ }
+
+ // Use localised/normalised variant to ensure $excludepage matches
+ $userPage = $user->getUserPage()->getPrefixedDBkey();
+ $pages = [];
+
+ if ( $config->get( 'AllowUserCss' ) ) {
+ $pages["$userPage/common.css"] = [ 'type' => 'style' ];
+ $pages["$userPage/" . $context->getSkin() . '.css'] = [ 'type' => 'style' ];
+ }
+
+ // User group pages are maintained site-wide and enabled with site JS/CSS.
+ if ( $config->get( 'UseSiteCss' ) ) {
+ foreach ( $user->getEffectiveGroups() as $group ) {
+ if ( $group == '*' ) {
+ continue;
+ }
+ $pages["MediaWiki:Group-$group.css"] = [ 'type' => 'style' ];
+ }
+ }
+
+ // Hack for T28283: Allow excluding pages for preview on a CSS/JS page.
+ // The excludepage parameter is set by OutputPage.
+ $excludepage = $context->getRequest()->getVal( 'excludepage' );
+ if ( isset( $pages[$excludepage] ) ) {
+ unset( $pages[$excludepage] );
+ }
+
+ return $pages;
+ }
+
+ /**
+ * @return string
+ */
+ public function getType() {
+ return self::LOAD_STYLES;
+ }
+
+ /**
+ * Get group name
+ *
+ * @return string
+ */
+ public function getGroup() {
+ return 'user';
+ }
+}
* @note This does not return an instance of SiteSQLStore!
*
* @since 1.21
- * @deprecated 1.27 use MediaWikiServices::getSiteStore() or MediaWikiServices::getSiteLookup()
- * instead.
+ * @deprecated since 1.27 use MediaWikiServices::getSiteStore()
+ * or MediaWikiServices::getSiteLookup() instead.
*
* @param null $sitesTable IGNORED
* @param null $cache IGNORED
* Let users reset tokens like the watchlist token.
*
* @ingroup SpecialPage
- * @deprecated 1.26
+ * @deprecated since 1.26
*/
class SpecialResetTokens extends FormSpecialPage {
private $tokensList;
* @return string|bool User's current value for the option, or false if this option is disabled.
* @see resetTokenFromOption()
* @see getOption()
- * @deprecated 1.26 Applications should use the OAuth extension
+ * @deprecated since 1.26 Applications should use the OAuth extension
*/
public function getTokenFromOption( $oname ) {
global $wgHiddenPrefs;
// Scripts managed by the current user (stored in their user space)
'user' => [ 'class' => 'ResourceLoaderUserModule' ],
+ 'user.styles' => [ 'class' => 'ResourceLoaderUserStylesModule' ],
// Scripts generated based on the current user's preferences
'user.cssprefs' => [ 'class' => 'ResourceLoaderUserCSSPrefsModule' ],
* getAccessKeyPrefix
*
* @method updateTooltipAccessKeys_getAccessKeyPrefix
- * @deprecated 1.27 Use #getAccessKeyModifiers
+ * @deprecated since 1.27 Use #getAccessKeyModifiers
*/
$.fn.updateTooltipAccessKeys.getAccessKeyPrefix = function ( ua ) {
return getAccessKeyModifiers( ua ).join( '-' ) + '-';