50 parent::__construct( $params );
52 $this->
msg = static::getMessageFromParams( $params );
53 $this->selected =
null;
63 if ( !empty( $params[
'licenses'] ) ) {
64 return $params[
'licenses'];
74 $defaultMsg =
wfMessage(
'licenses' )->inContentLanguage();
75 if ( $defaultMsg->isDisabled() ) {
76 $defaultMsg =
wfMessage(
'licenses' )->inLanguage(
77 MediaWikiServices::getInstance()->getContentLanguage() );
80 return $defaultMsg->plain();
98 foreach (
$lines as $line ) {
99 if ( !str_starts_with( $line,
'*' ) ) {
102 [ $level, $line ] = $this->
trimStars( $line );
104 if ( str_contains( $line,
'|' ) ) {
106 $this->
stackItem( $this->lines, $levels, $obj );
108 if ( $level < count( $levels ) ) {
109 $levels = array_slice( $levels, 0, $level );
111 if ( $level == count( $levels ) ) {
112 $levels[$level - 1] = $line;
113 } elseif ( $level > count( $levels ) ) {
125 $numStars = strspn( $str,
'*' );
126 return [ $numStars, ltrim( substr( $str, $numStars ),
' ' ) ];
137 foreach (
$path as $key ) {
138 $position =& $position[$key];
149 protected function makeHtml( $tagset, $depth = 0 ) {
152 foreach ( $tagset as $key => $val ) {
153 if ( is_array( $val ) ) {
157 'disabled' =>
'disabled',
158 'style' =>
'color: GrayText',
165 $val->text, $val->template,
166 [
'title' =>
'{{' . $val->template .
'}}' ],
182 protected function outputOption( $message, $value, $attribs =
null, $depth = 0 ) {
183 $msgObj = $this->
msg( $message );
184 $text = $msgObj->exists() ? $msgObj->text() : $message;
185 $attribs[
'value'] = $value;
186 if ( $value === $this->selected && !isset( $attribs[
'disabled'] ) ) {
187 $attribs[
'selected'] =
'selected';
190 $val = str_repeat(
"\u{00A0}", $depth * 2 ) . $text;
191 return str_repeat(
"\t", $depth ) . Html::element(
'option', $attribs, $val ) .
"\n";
220 $this->selected = $value;
223 $default = $this->
buildLine(
'|nolicense' );
224 array_unshift( $this->lines, $default );
232 if ( !empty( $this->mParams[
'disabled'] ) ) {
233 $attribs[
'disabled'] =
'disabled';
236 $html = Html::rawElement(
'select', $attribs,
$html );
239 array_shift( $this->lines );
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
A License class for use on Special:Upload (represents a single type of license).
A License class for use on Special:Upload.
makeHtml( $tagset, $depth=0)
static getMessageFromParams( $params)
outputOption( $message, $value, $attribs=null, $depth=0)
getLicenses()
Accessor for $this->lines.
stackItem(&$list, $path, $item)
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....