49 parent::__construct( $params );
51 $this->
msg = static::getMessageFromParams( $params );
52 $this->selected =
null;
62 if ( !empty( $params[
'licenses'] ) ) {
63 return $params[
'licenses'];
73 $defaultMsg =
wfMessage(
'licenses' )->inContentLanguage();
74 if ( !$defaultMsg->exists() || $defaultMsg->plain() ===
'-' ) {
75 $defaultMsg =
wfMessage(
'licenses' )->inLanguage(
76 MediaWikiServices::getInstance()->getContentLanguage() );
79 return $defaultMsg->plain();
98 if ( strpos(
$line,
'*' ) !== 0 ) {
103 if ( strpos(
$line,
'|' ) !==
false ) {
105 $this->
stackItem( $this->lines, $levels, $obj );
107 if ( $level < count( $levels ) ) {
108 $levels = array_slice( $levels, 0, $level );
110 if ( $level == count( $levels ) ) {
111 $levels[$level - 1] =
$line;
112 } 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 ) {
187 $attribs[
'selected'] =
'selected';
190 $val = str_repeat(
"\u{00A0}", $depth * 2 ) . $text;
191 return str_repeat(
"\t", $depth ) . Xml::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....