32 parent::__construct( $params );
34 $this->
msg = static::getMessageFromParams( $params );
35 $this->selected =
null;
45 if ( !empty( $params[
'licenses'] ) ) {
46 return $params[
'licenses'];
56 $defaultMsg =
wfMessage(
'licenses' )->inContentLanguage();
57 if ( $defaultMsg->isDisabled() ) {
58 $defaultMsg =
wfMessage(
'licenses' )->inLanguage(
62 return $defaultMsg->plain();
80 foreach ( $lines as $line ) {
81 if ( !str_starts_with( $line,
'*' ) ) {
84 [ $level, $line ] = $this->
trimStars( $line );
86 if ( str_contains( $line,
'|' ) ) {
88 $this->
stackItem( $this->lines, $levels, $obj );
90 if ( $level < count( $levels ) ) {
91 $levels = array_slice( $levels, 0, $level );
93 if ( $level == count( $levels ) ) {
94 $levels[$level - 1] = $line;
95 } elseif ( $level > count( $levels ) ) {
107 $numStars = strspn( $str,
'*' );
108 return [ $numStars, ltrim( substr( $str, $numStars ),
' ' ) ];
119 foreach (
$path as $key ) {
120 $position =& $position[$key];
131 protected function makeHtml( $tagset, $depth = 0 ) {
134 foreach ( $tagset as $key => $val ) {
135 if ( is_array( $val ) ) {
139 'disabled' =>
'disabled'
146 $val->text, $val->template,
147 [
'title' =>
'{{' . $val->template .
'}}' ],
163 protected function outputOption( $message, $value, $attribs =
null, $depth = 0 ) {
164 $msgObj = $this->
msg( $message );
165 $text = $msgObj->exists() ? $msgObj->text() : $message;
166 $attribs[
'value'] = $value;
167 if ( $value === $this->selected && !isset( $attribs[
'disabled'] ) ) {
168 $attribs[
'selected'] =
'selected';
171 $val = str_repeat(
"\u{00A0}", $depth * 2 ) . $text;
172 return str_repeat(
"\t", $depth ) .
Html::element(
'option', $attribs, $val ) .
"\n";
199 $this->selected = $value;
202 $default = $this->
buildLine(
'|nolicense' );
203 array_unshift( $this->lines, $default );
211 if ( !empty( $this->mParams[
'disabled'] ) ) {
212 $attribs[
'disabled'] =
'disabled';
215 $html = Html::rawElement(
'select', $attribs,
$html );
218 array_shift( $this->lines );
225class_alias( Licenses::class,
'Licenses' );
wfMessage( $key,... $params)
This is the function for getting translated interface messages.