Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
UIUtils
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
20
0.00% covered (danger)
0.00%
0 / 1
 generateInfoTable
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
20
1<?php
2
3namespace MediaWiki\Extension\OAuth\Frontend;
4
5use IContextSource;
6use Message;
7use OOUI\Tag;
8
9/**
10 * Static utility class for the special pages
11 */
12class UIUtils {
13    /**
14     * Generate an information table for a consumer. The result will be suitable for use as a
15     * HTMLForm field with no label.
16     * @param array $info fieldname-message => description; description will be escaped (use
17     *   HtmlSnippet to avoid); fields with null value will be ignored; messages will be interpreted
18     *   as plaintext
19     * @param IContextSource $context
20     * @return string
21     */
22    public static function generateInfoTable( $info, $context ) {
23        $dl = new Tag( 'dl' );
24        $dl->addClasses( [ 'mw-mwoauth-infotable' ] );
25        foreach ( $info as $fieldname => $description ) {
26            if ( $description === null ) {
27                continue;
28            } elseif ( $description instanceof Message ) {
29                $description = $description->plain();
30            }
31            $dt = new Tag( 'dt' );
32            $dd = new Tag( 'dd' );
33            $dt->appendContent( $context->msg( $fieldname )->text() );
34            $dd->appendContent( $description );
35            $dl->appendContent( $dt, $dd );
36        }
37        return $dl->toString();
38    }
39}