52 $this->
msg = static::getMessageFromParams(
$params );
53 $this->selected =
null;
63 if ( !empty(
$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'
164 $val->text, $val->template,
165 [
'title' =>
'{{' . $val->template .
'}}' ],
181 protected function outputOption( $message, $value, $attribs =
null, $depth = 0 ) {
182 $msgObj = $this->
msg( $message );
183 $text = $msgObj->exists() ? $msgObj->text() : $message;
184 $attribs[
'value'] = $value;
185 if ( $value === $this->selected && !isset( $attribs[
'disabled'] ) ) {
186 $attribs[
'selected'] =
'selected';
189 $val = str_repeat(
"\u{00A0}", $depth * 2 ) . $text;
190 return str_repeat(
"\t", $depth ) . Html::element(
'option', $attribs, $val ) .
"\n";
217 $this->selected = $value;
220 $default = $this->
buildLine(
'|nolicense' );
221 array_unshift( $this->lines, $default );
229 if ( !empty( $this->mParams[
'disabled'] ) ) {
230 $attribs[
'disabled'] =
'disabled';
233 $html = Html::rawElement(
'select', $attribs,
$html );
236 array_shift( $this->lines );
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
array $params
The job parameters.
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.
getLines()
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....