45 $this->
msg = static::getMessageFromParams(
$params );
46 $this->selected =
null;
56 if ( !empty(
$params[
'licenses'] ) ) {
67 $defaultMsg =
wfMessage(
'licenses' )->inContentLanguage();
68 if ( $defaultMsg->isDisabled() ) {
69 $defaultMsg =
wfMessage(
'licenses' )->inLanguage(
70 MediaWikiServices::getInstance()->getContentLanguage() );
73 return $defaultMsg->plain();
91 foreach ( $lines as $line ) {
92 if ( !str_starts_with( $line,
'*' ) ) {
95 [ $level, $line ] = $this->
trimStars( $line );
97 if ( str_contains( $line,
'|' ) ) {
99 $this->
stackItem( $this->lines, $levels, $obj );
101 if ( $level < count( $levels ) ) {
102 $levels = array_slice( $levels, 0, $level );
104 if ( $level == count( $levels ) ) {
105 $levels[$level - 1] = $line;
106 } elseif ( $level > count( $levels ) ) {
118 $numStars = strspn( $str,
'*' );
119 return [ $numStars, ltrim( substr( $str, $numStars ),
' ' ) ];
130 foreach (
$path as $key ) {
131 $position =& $position[$key];
142 protected function makeHtml( $tagset, $depth = 0 ) {
145 foreach ( $tagset as $key => $val ) {
146 if ( is_array( $val ) ) {
150 'disabled' =>
'disabled'
157 $val->text, $val->template,
158 [
'title' =>
'{{' . $val->template .
'}}' ],
174 protected function outputOption( $message, $value, $attribs =
null, $depth = 0 ) {
175 $msgObj = $this->
msg( $message );
176 $text = $msgObj->exists() ? $msgObj->text() : $message;
177 $attribs[
'value'] = $value;
178 if ( $value === $this->selected && !isset( $attribs[
'disabled'] ) ) {
179 $attribs[
'selected'] =
'selected';
182 $val = str_repeat(
"\u{00A0}", $depth * 2 ) . $text;
183 return str_repeat(
"\t", $depth ) . Html::element(
'option', $attribs, $val ) .
"\n";
210 $this->selected = $value;
213 $default = $this->
buildLine(
'|nolicense' );
214 array_unshift( $this->lines, $default );
222 if ( !empty( $this->mParams[
'disabled'] ) ) {
223 $attribs[
'disabled'] =
'disabled';
226 $html = Html::rawElement(
'select', $attribs,
$html );
229 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....