| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Skins\Vector; |
| 4 |
|
| 5 |
use MediaWiki\Auth\Hook\LocalUserCreatedHook; |
| 6 |
use MediaWiki\Config\Config; |
| 7 |
use MediaWiki\Context\RequestContext; |
| 8 |
use MediaWiki\MediaWikiServices; |
| 9 |
use MediaWiki\Preferences\Hook\GetPreferencesHook; |
| 10 |
use MediaWiki\ResourceLoader as RL; |
| 11 |
use MediaWiki\Skins\Hook\SkinPageReadyConfigHook; |
| 12 |
use MediaWiki\Skins\Vector\Hooks\HookRunner; |
| 13 |
use MediaWiki\User\Options\UserOptionsManager; |
| 14 |
use MediaWiki\User\User; |
| 15 |
use RuntimeException; |
| 16 |
use SkinTemplate; |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
class Hooks implements |
| 27 |
GetPreferencesHook, |
| 28 |
LocalUserCreatedHook, |
| 29 |
SkinPageReadyConfigHook |
| 30 |
{ |
| 31 |
private Config $config; |
| 32 |
private UserOptionsManager $userOptionsManager; |
| 33 |
|
| 34 |
public function __construct( |
| 35 |
Config $config, |
| 36 |
UserOptionsManager $userOptionsManager |
| 37 |
) { |
| 38 |
$this->config = $config; |
| 39 |
$this->userOptionsManager = $userOptionsManager; |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
private static function isVectorSkin( string $skinName ): bool { |
| 49 |
return ( |
| 50 |
$skinName === Constants::SKIN_NAME_LEGACY || |
| 51 |
$skinName === Constants::SKIN_NAME_MODERN |
| 52 |
); |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
public static function getActiveABTest( |
| 61 |
RL\Context $context, |
| 62 |
Config $config |
| 63 |
) { |
| 64 |
$ab = $config->get( |
| 65 |
Constants::CONFIG_WEB_AB_TEST_ENROLLMENT |
| 66 |
); |
| 67 |
if ( count( $ab ) === 0 ) { |
| 68 |
|
| 69 |
return $ab; |
| 70 |
} |
| 71 |
if ( !array_key_exists( 'buckets', $ab ) ) { |
| 72 |
throw new RuntimeException( 'Invalid VectorWebABTestEnrollment value: Must contain buckets key.' ); |
| 73 |
} |
| 74 |
if ( !array_key_exists( 'unsampled', $ab['buckets'] ) ) { |
| 75 |
throw new RuntimeException( 'Invalid VectorWebABTestEnrollment value: Must define an `unsampled` bucket.' ); |
| 76 |
} else { |
| 77 |
|
| 78 |
foreach ( $ab['buckets'] as $bucketName => $bucketDefinition ) { |
| 79 |
if ( !is_array( $bucketDefinition ) ) { |
| 80 |
throw new RuntimeException( 'Invalid VectorWebABTestEnrollment value: Buckets should be arrays' ); |
| 81 |
} |
| 82 |
$samplingRate = $bucketDefinition['samplingRate']; |
| 83 |
if ( is_string( $samplingRate ) ) { |
| 84 |
throw new RuntimeException( |
| 85 |
'Invalid VectorWebABTestEnrollment value: Sampling rate should be number between 0 and 1.' |
| 86 |
); |
| 87 |
} |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
return $ab; |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
public static function getVectorSearchResourceLoaderConfig( |
| 103 |
RL\Context $context, |
| 104 |
Config $config |
| 105 |
): array { |
| 106 |
$vectorSearchConfig = [ |
| 107 |
'highlightQuery' => |
| 108 |
VectorServices::getLanguageService()->canWordsBeSplitSafely( $context->getLanguage() ) |
| 109 |
]; |
| 110 |
|
| 111 |
$hookRunner = new HookRunner( MediaWikiServices::getInstance()->getHookContainer() ); |
| 112 |
$hookRunner->onVectorSearchResourceLoaderConfig( $vectorSearchConfig ); |
| 113 |
|
| 114 |
return array_merge( $config->get( 'VectorWvuiSearchOptions' ), $vectorSearchConfig ); |
| 115 |
} |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
public function onSkinPageReadyConfig( |
| 128 |
RL\Context $context, |
| 129 |
array &$config |
| 130 |
): void { |
| 131 |
|
| 132 |
if ( !self::isVectorSkin( $context->getSkin() ) ) { |
| 133 |
return; |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
$config['search'] = false; |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
private static function updateActionsMenu( &$content_navigation ) { |
| 152 |
$key = null; |
| 153 |
if ( isset( $content_navigation['actions']['watch'] ) ) { |
| 154 |
$key = 'watch'; |
| 155 |
} |
| 156 |
if ( isset( $content_navigation['actions']['unwatch'] ) ) { |
| 157 |
$key = 'unwatch'; |
| 158 |
} |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
if ( $key !== null && isset( $content_navigation['actions'][ $key ] ) ) { |
| 163 |
$content_navigation['views'][$key] = $content_navigation['actions'][$key]; |
| 164 |
unset( $content_navigation['actions'][$key] ); |
| 165 |
} |
| 166 |
} |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
private static function updateViewsMenuIcons( &$content_navigation, $isLegacy ) { |
| 176 |
|
| 177 |
foreach ( $content_navigation['views'] as &$item ) { |
| 178 |
$icon = $item['icon'] ?? null; |
| 179 |
if ( $icon ) { |
| 180 |
if ( $isLegacy ) { |
| 181 |
self::appendClassToItem( |
| 182 |
$item['class'], |
| 183 |
[ 'icon' ] |
| 184 |
); |
| 185 |
} else { |
| 186 |
|
| 187 |
$item['button'] = true; |
| 188 |
$item['text-hidden'] = true; |
| 189 |
$item = self::updateMenuItemData( $item, false ); |
| 190 |
} |
| 191 |
} elseif ( !$isLegacy ) { |
| 192 |
|
| 193 |
self::appendClassToItem( |
| 194 |
$item['class'], |
| 195 |
[ 'vector-tab-noicon' ] |
| 196 |
); |
| 197 |
} |
| 198 |
} |
| 199 |
} |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
private static function updateAssociatedPagesMenuIcons( &$content_navigation ) { |
| 208 |
foreach ( $content_navigation['associated-pages'] as &$item ) { |
| 209 |
self::appendClassToItem( |
| 210 |
$item['class'], |
| 211 |
[ 'vector-tab-noicon' ] |
| 212 |
); |
| 213 |
} |
| 214 |
} |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
private static function appendClassToItem( &$item, $classes ) { |
| 223 |
$existingClasses = $item; |
| 224 |
|
| 225 |
if ( is_array( $existingClasses ) ) { |
| 226 |
|
| 227 |
$newArrayClasses = is_array( $classes ) ? $classes : [ trim( $classes ) ]; |
| 228 |
$item = array_merge( $existingClasses, $newArrayClasses ); |
| 229 |
} elseif ( is_string( $existingClasses ) ) { |
| 230 |
|
| 231 |
$newStrClasses = is_string( $classes ) ? trim( $classes ) : implode( ' ', $classes ); |
| 232 |
$item .= ' ' . $newStrClasses; |
| 233 |
} else { |
| 234 |
|
| 235 |
$item = $classes; |
| 236 |
} |
| 237 |
|
| 238 |
if ( is_string( $item ) ) { |
| 239 |
$item = trim( $item ); |
| 240 |
} |
| 241 |
} |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
private static function updateUserLinksDropdownItems( $sk, &$content_navigation ) { |
| 254 |
|
| 255 |
$user = $sk->getUser(); |
| 256 |
if ( $user->isRegistered() ) { |
| 257 |
|
| 258 |
$content_navigation['user-menu']['userpage']['collapsible'] = true; |
| 259 |
|
| 260 |
|
| 261 |
if ( isset( $content_navigation['user-menu']['watchlist'] ) ) { |
| 262 |
$content_navigation['user-menu']['watchlist']['collapsible'] = true; |
| 263 |
} |
| 264 |
|
| 265 |
|
| 266 |
$logoutMenu = []; |
| 267 |
if ( isset( $content_navigation['user-menu']['logout'] ) ) { |
| 268 |
$logoutMenu['logout'] = $content_navigation['user-menu']['logout']; |
| 269 |
$logoutMenu['logout']['id'] = 'pt-logout'; |
| 270 |
unset( $content_navigation['user-menu']['logout'] ); |
| 271 |
} |
| 272 |
$content_navigation['user-menu-logout'] = $logoutMenu; |
| 273 |
|
| 274 |
self::updateMenuItems( $content_navigation, 'user-menu' ); |
| 275 |
self::updateMenuItems( $content_navigation, 'user-menu-logout' ); |
| 276 |
} else { |
| 277 |
|
| 278 |
unset( $content_navigation['user-menu']['anonuserpage'] ); |
| 279 |
|
| 280 |
|
| 281 |
if ( isset( $content_navigation['user-menu']['login'] ) ) { |
| 282 |
$content_navigation['user-menu']['login']['collapsible'] = true; |
| 283 |
} |
| 284 |
if ( isset( $content_navigation['user-menu']['login-private'] ) ) { |
| 285 |
$content_navigation['user-menu']['login-private']['collapsible'] = true; |
| 286 |
} |
| 287 |
if ( isset( $content_navigation['user-menu']['createaccount'] ) ) { |
| 288 |
$content_navigation['user-menu']['createaccount']['collapsible'] = true; |
| 289 |
} |
| 290 |
|
| 291 |
|
| 292 |
$anonEditorMenu = []; |
| 293 |
if ( isset( $content_navigation['user-menu']['anoncontribs'] ) ) { |
| 294 |
$anonEditorMenu['anoncontribs'] = $content_navigation['user-menu']['anoncontribs']; |
| 295 |
$anonEditorMenu['anoncontribs']['id'] = 'pt-anoncontribs'; |
| 296 |
unset( $content_navigation['user-menu']['anoncontribs'] ); |
| 297 |
} |
| 298 |
if ( isset( $content_navigation['user-menu']['anontalk'] ) ) { |
| 299 |
$anonEditorMenu['anontalk'] = $content_navigation['user-menu']['anontalk']; |
| 300 |
$anonEditorMenu['anontalk']['id'] = 'pt-anontalk'; |
| 301 |
unset( $content_navigation['user-menu']['anontalk'] ); |
| 302 |
} |
| 303 |
$content_navigation['user-menu-anon-editor'] = $anonEditorMenu; |
| 304 |
|
| 305 |
|
| 306 |
self::updateMenuItems( $content_navigation, 'user-menu' ); |
| 307 |
} |
| 308 |
} |
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
private static function fixEcho( $sk, &$content_navigation ) { |
| 318 |
if ( isset( $content_navigation['notifications'] ) ) { |
| 319 |
foreach ( $content_navigation['notifications'] as &$item ) { |
| 320 |
$icon = $item['icon'] ?? null; |
| 321 |
if ( $icon ) { |
| 322 |
$linkClass = $item['link-class'] ?? []; |
| 323 |
$newLinkClass = [ |
| 324 |
|
| 325 |
'mw-echo-notification-badge-nojs' |
| 326 |
]; |
| 327 |
if ( in_array( 'mw-echo-unseen-notifications', $linkClass ) ) { |
| 328 |
$newLinkClass[] = 'mw-echo-unseen-notifications'; |
| 329 |
} |
| 330 |
$item['link-class'] = $newLinkClass; |
| 331 |
} |
| 332 |
} |
| 333 |
} |
| 334 |
} |
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
private static function updateUserLinksItems( $sk, &$content_navigation ) { |
| 346 |
$skinName = $sk->getSkinName(); |
| 347 |
if ( self::isSkinVersionLegacy( $skinName ) ) { |
| 348 |
|
| 349 |
|
| 350 |
unset( $content_navigation['user-page'] ); |
| 351 |
} else { |
| 352 |
self::fixEcho( $sk, $content_navigation ); |
| 353 |
self::updateUserLinksDropdownItems( $sk, $content_navigation ); |
| 354 |
} |
| 355 |
} |
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
private static function makeMenuItemCollapsible( array &$item, string $prefix = 'user-links-' ) { |
| 365 |
$collapseMenuItemClass = $prefix . 'collapsible-item'; |
| 366 |
self::appendClassToItem( $item[ 'class' ], $collapseMenuItemClass ); |
| 367 |
} |
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
private static function makeIcon( $name ) { |
| 377 |
|
| 378 |
return '<span class="vector-icon mw-ui-icon-' . $name . ' mw-ui-icon-wikimedia-' . $name . '"></span>'; |
| 379 |
} |
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
private static function updateItemData( |
| 392 |
$item, $buttonClassProp, $iconHtmlProp, $unsetIcon = true |
| 393 |
) { |
| 394 |
$hasButton = $item['button'] ?? false; |
| 395 |
$hideText = $item['text-hidden'] ?? false; |
| 396 |
$isCollapsible = $item['collapsible'] ?? false; |
| 397 |
$icon = $item['icon'] ?? ''; |
| 398 |
if ( $unsetIcon ) { |
| 399 |
unset( $item['icon'] ); |
| 400 |
} |
| 401 |
unset( $item['button'] ); |
| 402 |
unset( $item['text-hidden'] ); |
| 403 |
unset( $item['collapsible'] ); |
| 404 |
|
| 405 |
if ( $isCollapsible ) { |
| 406 |
self::makeMenuItemCollapsible( $item ); |
| 407 |
} |
| 408 |
if ( $hasButton ) { |
| 409 |
|
| 410 |
self::appendClassToItem( $item[ $buttonClassProp ], [ |
| 411 |
'cdx-button', |
| 412 |
'cdx-button--fake-button', |
| 413 |
'cdx-button--fake-button--enabled', |
| 414 |
'cdx-button--weight-quiet' |
| 415 |
] ); |
| 416 |
} |
| 417 |
if ( $icon ) { |
| 418 |
if ( $hideText && $hasButton ) { |
| 419 |
self::appendClassToItem( $item[ $buttonClassProp ], [ 'cdx-button--icon-only' ] ); |
| 420 |
} |
| 421 |
|
| 422 |
$item[ $iconHtmlProp ] = self::makeIcon( $icon ); |
| 423 |
} |
| 424 |
return $item; |
| 425 |
} |
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
private static function updateMenuItemData( $item, $unsetIcon = true ) { |
| 436 |
$buttonClassProp = 'link-class'; |
| 437 |
$iconHtmlProp = 'link-html'; |
| 438 |
return self::updateItemData( $item, $buttonClassProp, $iconHtmlProp, $unsetIcon ); |
| 439 |
} |
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
private static function updateMenuItems( &$content_navigation, $menu ) { |
| 448 |
foreach ( $content_navigation[$menu] as &$item ) { |
| 449 |
$item = self::updateMenuItemData( $item ); |
| 450 |
} |
| 451 |
} |
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
private static function createMoreOverflowMenu( &$content_navigation ) { |
| 467 |
$clonedViews = []; |
| 468 |
foreach ( $content_navigation['views'] ?? [] as $key => $item ) { |
| 469 |
$newItem = $item; |
| 470 |
self::makeMenuItemCollapsible( |
| 471 |
$newItem, |
| 472 |
'vector-more-' |
| 473 |
); |
| 474 |
$clonedViews['more-' . $key] = $newItem; |
| 475 |
} |
| 476 |
|
| 477 |
$content_navigation['views-overflow'] = $clonedViews; |
| 478 |
} |
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
public static function onSkinTemplateNavigation( $sk, &$content_navigation ) { |
| 491 |
$skinName = $sk->getSkinName(); |
| 492 |
|
| 493 |
if ( !$skinName || !self::isVectorSkin( $skinName ) ) { |
| 494 |
return; |
| 495 |
} |
| 496 |
|
| 497 |
$title = $sk->getRelevantTitle(); |
| 498 |
if ( |
| 499 |
$sk->getConfig()->get( 'VectorUseIconWatch' ) && |
| 500 |
$title && $title->canExist() |
| 501 |
) { |
| 502 |
self::updateActionsMenu( $content_navigation ); |
| 503 |
} |
| 504 |
|
| 505 |
self::updateUserLinksItems( $sk, $content_navigation ); |
| 506 |
if ( $skinName === Constants::SKIN_NAME_MODERN ) { |
| 507 |
self::createMoreOverflowMenu( $content_navigation ); |
| 508 |
} |
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
self::updateViewsMenuIcons( $content_navigation, self::isSkinVersionLegacy( $skinName ) ); |
| 513 |
self::updateAssociatedPagesMenuIcons( $content_navigation ); |
| 514 |
} |
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
public function onGetPreferences( $user, &$prefs ): void { |
| 523 |
$services = MediaWikiServices::getInstance(); |
| 524 |
$featureManagerFactory = $services->getService( 'Vector.FeatureManagerFactory' ); |
| 525 |
$featureManager = $featureManagerFactory->createFeatureManager( RequestContext::getMain() ); |
| 526 |
$isNightModeEnabled = $featureManager->isFeatureEnabled( Constants::FEATURE_NIGHT_MODE ); |
| 527 |
|
| 528 |
$vectorPrefs = [ |
| 529 |
Constants::PREF_KEY_LIMITED_WIDTH => [ |
| 530 |
'type' => 'toggle', |
| 531 |
'label-message' => 'vector-prefs-limited-width', |
| 532 |
'section' => 'rendering/skin/skin-prefs', |
| 533 |
'help-message' => 'vector-prefs-limited-width-help', |
| 534 |
'hide-if' => [ '!==', 'skin', Constants::SKIN_NAME_MODERN ], |
| 535 |
], |
| 536 |
Constants::PREF_KEY_FONT_SIZE => [ |
| 537 |
'type' => 'select', |
| 538 |
'label-message' => 'vector-feature-custom-font-size-name', |
| 539 |
'section' => 'rendering/skin/skin-prefs', |
| 540 |
'options-messages' => [ |
| 541 |
'vector-feature-custom-font-size-0-label' => '0', |
| 542 |
'vector-feature-custom-font-size-1-label' => '1', |
| 543 |
'vector-feature-custom-font-size-2-label' => '2', |
| 544 |
], |
| 545 |
'hide-if' => [ '!==', 'skin', Constants::SKIN_NAME_MODERN ], |
| 546 |
], |
| 547 |
Constants::PREF_KEY_PAGE_TOOLS_PINNED => [ |
| 548 |
'type' => 'api' |
| 549 |
], |
| 550 |
Constants::PREF_KEY_MAIN_MENU_PINNED => [ |
| 551 |
'type' => 'api' |
| 552 |
], |
| 553 |
Constants::PREF_KEY_TOC_PINNED => [ |
| 554 |
'type' => 'api' |
| 555 |
], |
| 556 |
Constants::PREF_KEY_APPEARANCE_PINNED => [ |
| 557 |
'type' => 'api' |
| 558 |
], |
| 559 |
Constants::PREF_KEY_NIGHT_MODE => [ |
| 560 |
'type' => $isNightModeEnabled ? 'select' : 'api', |
| 561 |
'label-message' => 'skin-theme-name', |
| 562 |
'help-message' => 'skin-theme-description', |
| 563 |
'section' => 'rendering/skin/skin-prefs', |
| 564 |
'options-messages' => [ |
| 565 |
'skin-theme-day-label' => 'day', |
| 566 |
'skin-theme-night-label' => 'night', |
| 567 |
'skin-theme-os-label' => 'os', |
| 568 |
], |
| 569 |
'hide-if' => [ '!==', 'skin', Constants::SKIN_NAME_MODERN ], |
| 570 |
], |
| 571 |
]; |
| 572 |
$prefs += $vectorPrefs; |
| 573 |
} |
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
public function onLocalUserCreated( $user, $isAutoCreated ) { |
| 582 |
$default = $this->config->get( Constants::CONFIG_KEY_DEFAULT_SKIN_VERSION_FOR_NEW_ACCOUNTS ); |
| 583 |
if ( $default ) { |
| 584 |
$this->userOptionsManager->setOption( |
| 585 |
$user, |
| 586 |
Constants::PREF_KEY_SKIN, |
| 587 |
$default === Constants::SKIN_VERSION_LEGACY ? |
| 588 |
Constants::SKIN_NAME_LEGACY : Constants::SKIN_NAME_MODERN |
| 589 |
); |
| 590 |
} |
| 591 |
} |
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
private static function isSkinVersionLegacy( $skinName ): bool { |
| 600 |
return $skinName === Constants::SKIN_NAME_LEGACY; |
| 601 |
} |
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
public function onGetBetaFeaturePreferences( User $user, array &$betaFeatures ) { |
| 610 |
$skinName = RequestContext::getMain()->getSkinName(); |
| 611 |
|
| 612 |
if ( $skinName !== Constants::SKIN_NAME_MODERN ) { |
| 613 |
return; |
| 614 |
} |
| 615 |
|
| 616 |
$configHasBeta = false; |
| 617 |
foreach ( Constants::VECTOR_BETA_FEATURES as $featureName ) { |
| 618 |
if ( $this->config->has( $featureName ) && $this->config->get( $featureName )[ 'beta' ] === true ) { |
| 619 |
$configHasBeta = true; |
| 620 |
break; |
| 621 |
} |
| 622 |
} |
| 623 |
if ( !$configHasBeta ) { |
| 624 |
return; |
| 625 |
} |
| 626 |
$skinsAssetsPath = $this->config->get( 'StylePath' ); |
| 627 |
$imagesDir = "$skinsAssetsPath/Vector/resources/images"; |
| 628 |
$betaFeatures[ Constants::VECTOR_2022_BETA_KEY ] = [ |
| 629 |
'label-message' => 'vector-2022-beta-preview-label', |
| 630 |
'desc-message' => 'vector-2022-beta-preview-description', |
| 631 |
'screenshot' => [ |
| 632 |
|
| 633 |
'ltr' => "$imagesDir/vector-2022-beta-preview-ltr.svg", |
| 634 |
'rtl' => "$imagesDir/vector-2022-beta-preview-rtl.svg", |
| 635 |
], |
| 636 |
'info-link' => 'https://www.mediawiki.org/wiki/Special:MyLanguage/Reading/Web/Accessibility_for_reading', |
| 637 |
'discussion-link' => 'https://www.mediawiki.org/wiki/Talk:Reading/Web/Accessibility_for_reading', |
| 638 |
]; |
| 639 |
} |
| 640 |
} |