Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| VectorComponentMainMenuActionOptOut | |
0.00% |
0 / 17 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getTemplateData | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace MediaWiki\Skins\Vector\Components; |
| 3 | |
| 4 | use MediaWiki\Skin\Skin; |
| 5 | use MediaWiki\SpecialPage\SpecialPage; |
| 6 | |
| 7 | /** |
| 8 | * VectorComponentMainMenuActionOptOut component |
| 9 | */ |
| 10 | class VectorComponentMainMenuActionOptOut implements VectorComponent { |
| 11 | /** @var Skin */ |
| 12 | private $skin; |
| 13 | |
| 14 | /** |
| 15 | * T243281: Code used to track clicks to opt-out link. |
| 16 | * |
| 17 | * The "vct" substring is used to describe the newest "Vector" (non-legacy) |
| 18 | * feature. The "w" describes the web platform. The "1" describes the version |
| 19 | * of the feature. |
| 20 | * |
| 21 | * @see https://wikitech.wikimedia.org/wiki/Provenance |
| 22 | * @var string |
| 23 | */ |
| 24 | private const OPT_OUT_LINK_TRACKING_CODE = 'vctw1'; |
| 25 | |
| 26 | public function __construct( Skin $skin ) { |
| 27 | $this->skin = $skin; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * @inheritDoc |
| 32 | */ |
| 33 | public function getTemplateData(): array { |
| 34 | $skin = $this->skin; |
| 35 | // Note: This data is also passed to legacy template where it is unused. |
| 36 | $optOutUrl = [ |
| 37 | 'text' => $skin->msg( 'vector-opt-out' )->text(), |
| 38 | 'href' => SpecialPage::getTitleFor( |
| 39 | 'Preferences', |
| 40 | false, |
| 41 | 'mw-prefsection-rendering-skin' |
| 42 | )->getLinkURL( 'useskin=vector&wprov=' . self::OPT_OUT_LINK_TRACKING_CODE ), |
| 43 | 'title' => $skin->msg( 'vector-opt-out-tooltip' )->text(), |
| 44 | 'active' => false, |
| 45 | ]; |
| 46 | $htmlData = [ |
| 47 | 'link' => $optOutUrl, |
| 48 | ]; |
| 49 | $component = new VectorComponentMainMenuAction( 'opt-out', $skin, $htmlData, [] ); |
| 50 | return $component->getTemplateData(); |
| 51 | } |
| 52 | } |