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->isDisabled() ) {
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 ) ) {
124 $numStars = strspn( $str,
'*' );
125 return [ $numStars, ltrim( substr( $str, $numStars ),
' ' ) ];
136 foreach (
$path as $key ) {
137 $position =& $position[$key];
148 protected function makeHtml( $tagset, $depth = 0 ) {
151 foreach ( $tagset as $key => $val ) {
152 if ( is_array( $val ) ) {
156 'disabled' =>
'disabled',
157 'style' =>
'color: GrayText',
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";
219 $this->selected = $value;
222 $default = $this->
buildLine(
'|nolicense' );
223 array_unshift( $this->lines, $default );
231 if ( !empty( $this->mParams[
'disabled'] ) ) {
232 $attribs[
'disabled'] =
'disabled';
235 $html = Html::rawElement(
'select', $attribs,
$html );
238 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....