33 parent::__construct( $params );
35 $this->
msg = static::getMessageFromParams( $params );
36 $this->selected =
null;
46 if ( !empty( $params[
'licenses'] ) ) {
47 return $params[
'licenses'];
57 $defaultMsg =
wfMessage(
'licenses' )->inContentLanguage();
58 if ( $defaultMsg->isDisabled() ) {
59 $defaultMsg =
wfMessage(
'licenses' )->inLanguage(
63 return $defaultMsg->plain();
81 foreach ( $lines as $line ) {
82 if ( !str_starts_with( $line,
'*' ) ) {
85 [ $level, $line ] = $this->
trimStars( $line );
87 if ( str_contains( $line,
'|' ) ) {
89 $this->
stackItem( $this->lines, $levels, $obj );
91 if ( $level < count( $levels ) ) {
92 $levels = array_slice( $levels, 0, $level );
94 if ( $level == count( $levels ) ) {
95 $levels[$level - 1] = $line;
96 } elseif ( $level > count( $levels ) ) {
108 $numStars = strspn( $str,
'*' );
109 return [ $numStars, ltrim( substr( $str, $numStars ),
' ' ) ];
120 foreach (
$path as $key ) {
121 $position =& $position[$key];
132 protected function makeHtml( $tagset, $depth = 0 ) {
135 foreach ( $tagset as $key => $val ) {
136 if ( is_array( $val ) ) {
140 'disabled' =>
'disabled'
147 $val->text, $val->template,
148 [
'title' =>
'{{' . $val->template .
'}}' ],
164 protected function outputOption( $message, $value, $attribs =
null, $depth = 0 ) {
165 $msgObj = $this->
msg( $message );
166 $text = $msgObj->exists() ? $msgObj->text() : $message;
167 $attribs[
'value'] = $value;
168 if ( $value === $this->selected && !isset( $attribs[
'disabled'] ) ) {
169 $attribs[
'selected'] =
'selected';
172 $val = str_repeat(
"\u{00A0}", $depth * 2 ) . $text;
173 return str_repeat(
"\t", $depth ) .
Html::element(
'option', $attribs, $val ) .
"\n";
200 $this->selected = $value;
203 $default = $this->
buildLine(
'|nolicense' );
204 array_unshift( $this->lines, $default );
212 if ( !empty( $this->mParams[
'disabled'] ) ) {
213 $attribs[
'disabled'] =
'disabled';
216 $html = Html::rawElement(
'select', $attribs,
$html );
219 array_shift( $this->lines );
227class_alias( Licenses::class,
'Licenses' );
wfMessage( $key,... $params)
This is the function for getting translated interface messages.