You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My case is to use different css and fonts for admins, compared to anonymous users.
The first attempt was to conditionally load $egChameleonExternalStyleVariables and $egChameleonExternalStyleModules in LocalSettings.php, based on the cookie test, because the $user object cannot be loaded here, due to the premature access to service error
if (isset($_COOKIE[$wgDBname.'_session']) && isset($_COOKIE[$wgDBname.'UserName']) && $_COOKIE[$wgDBname.'UserName'] == "XXX" )
But the solution is not stable, because in some cases it enters the anonymous branch, even if there is a cookie set and it compromises the design.
Then, I thought of making one or more forks of the Chameleon theme, which admin users can switch from their preferences.
But the variables were overwritten and the styles messed up.
After x-debugging load.php
$resourceLoader->modules["zzz.ext.bootstrap.styles"]->variables
I realized they were overwriting each other here
$resourceLoader->modules["zzz.ext.bootstrap.styles"]->styles
Here the styles from both themes were added
I think that Chameleon's interconnection with Bootstrap was not designed for such a use case, because all variables, styles and scripts go in the 'zzz.ext.bootstrap.styles' module, for all forks
protected function registerSkinWithMW() {
MediaWikiServices::getInstance()->getSkinFactory()->register( 'chameleon1', 'Chameleon1',
function () {
$styles = [
'mediawiki.ui.button',
'skins.chameleon1',
'zzz.ext.bootstrap.styles',
];
Finally, I found the workaround ext.bootstrap1.styles + ext.bootstrap1.scripts + new class BootstrapManager1.php workaround, see relevant details in the commit eurodomenii/mw_chameleon_fork@bb699af
My case is to use different css and fonts for admins, compared to anonymous users.
The first attempt was to conditionally load $egChameleonExternalStyleVariables and $egChameleonExternalStyleModules in LocalSettings.php, based on the cookie test, because the $user object cannot be loaded here, due to the premature access to service error
if (isset($_COOKIE[$wgDBname.'_session']) && isset($_COOKIE[$wgDBname.'UserName']) && $_COOKIE[$wgDBname.'UserName'] == "XXX" )
But the solution is not stable, because in some cases it enters the anonymous branch, even if there is a cookie set and it compromises the design.
Then, I thought of making one or more forks of the Chameleon theme, which admin users can switch from their preferences.
A concept of the project is posted at https://github.com/eurodomenii/mw_chameleon_fork
After copying the files, I ran two scripts
And rename few files
But the variables were overwritten and the styles messed up.
After x-debugging load.php
$resourceLoader->modules["zzz.ext.bootstrap.styles"]->variables
I realized they were overwriting each other here
$resourceLoader->modules["zzz.ext.bootstrap.styles"]->styles
Here the styles from both themes were added
I think that Chameleon's interconnection with Bootstrap was not designed for such a use case, because all variables, styles and scripts go in the 'zzz.ext.bootstrap.styles' module, for all forks
Finally, I found the workaround ext.bootstrap1.styles + ext.bootstrap1.scripts + new class BootstrapManager1.php workaround, see relevant details in the commit eurodomenii/mw_chameleon_fork@bb699af
I'm not convinced it's the best solution, it seems hackish, but it works!
See also https://github.com/eurodomenii/mw_chameleon_fork/blob/master/CommonSettings.php usage of new Chameleon1/2 variables.
The code below duplicates the scripts, but in a hurry, I preferred to simply comment it out, as I didn't need it.
Thank you!
The text was updated successfully, but these errors were encountered: