MediaWiki master
SkinAuthenticationPopup.php
Go to the documentation of this file.
1<?php
2
23use Wikimedia\RemexHtml\Serializer\SerializerNode;
24
33
34 private static function openLinksInNewWindow( string &$html ): void {
35 $html = HtmlHelper::modifyElements(
36 $html,
37 static function ( SerializerNode $node ): bool {
38 return $node->name === 'a'
39 && isset( $node->attrs['href'] )
40 && !str_contains( $node->attrs['class'] ?? '', 'mw-authentication-popup-link' );
41 },
42 static function ( SerializerNode $node ): SerializerNode {
43 $node->attrs['target'] ??= '_blank';
44 return $node;
45 }
46 );
47 }
48
49 public function getTemplateData() {
50 $data = parent::getTemplateData();
51
52 // This skin is intended to be shown in small popups, therefore open all links in new windows,
53 // except those explicitly marked. The CSS class can also be added by extensions.
54 self::openLinksInNewWindow( $data['html-body-content'] );
55 foreach ( $data['data-footer'] as &$footerItems ) {
56 foreach ( $footerItems['array-items'] as &$item ) {
57 self::openLinksInNewWindow( $item['html'] );
58 }
59 }
60
61 return $data;
62 }
63
64}
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.