MediaWiki master
SkinAuthenticationPopup.php
Go to the documentation of this file.
1<?php
2
22namespace MediaWiki\Skin;
23
25use Wikimedia\RemexHtml\Serializer\SerializerNode;
26
35
36 private static function openLinksInNewWindow( string &$html ): void {
37 $html = HtmlHelper::modifyElements(
38 $html,
39 static function ( SerializerNode $node ): bool {
40 return $node->name === 'a'
41 && isset( $node->attrs['href'] )
42 && !str_contains( $node->attrs['class'] ?? '', 'mw-authentication-popup-link' );
43 },
44 static function ( SerializerNode $node ): SerializerNode {
45 $node->attrs['target'] ??= '_blank';
46 return $node;
47 }
48 );
49 }
50
51 public function getTemplateData() {
52 $data = parent::getTemplateData();
53
54 // This skin is intended to be shown in small popups, therefore open all links in new windows,
55 // except those explicitly marked. The CSS class can also be added by extensions.
56 self::openLinksInNewWindow( $data['html-body-content'] );
57 foreach ( $data['data-footer'] as &$footerItems ) {
58 foreach ( $footerItems['array-items'] as &$item ) {
59 self::openLinksInNewWindow( $item['html'] );
60 }
61 }
62
63 return $data;
64 }
65
66}
67
69class_alias( SkinAuthenticationPopup::class, 'SkinAuthenticationPopup' );
Static utilities for manipulating HTML strings.
SkinAuthenticationPopup is a "micro-skin" that omits most of the usual interface elements,...
getTemplateData()
to extend. Subclasses may extend this method to add additional template data. this method should neve...
Generic template for use with Mustache templates.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...