47 $this->mDir = $this->mParser->getTargetLanguage()->getDir();
50 $this->mParser->getOptions()->getUserLangObj();
51 $this->mParser->getOutput()->addModuleStyles( [
52 'ext.inputBox.styles',
54 'mediawiki.ui.checkbox',
60 switch ( $this->mType ) {
63 $this->mParser->getOutput()->addModules(
'ext.inputBox' );
78 [
'class' =>
'error' ],
79 strlen( $this->mType ) > 0
80 ?
wfMessage(
'inputbox-error-bad-type', $this->mType )->
text()
103 'name' =>
'veaction',
117 return strtolower( $this->mBR ) ===
'<br />' ?
'mw-inputbox-input ' :
'';
129 if ( !$this->mButtonLabel ) {
130 $this->mButtonLabel =
wfMessage(
'inputbox-tryexact' )->text();
132 if ( !$this->mSearchButtonLabel ) {
133 $this->mSearchButtonLabel =
wfMessage(
'inputbox-searchfulltext' )->text();
135 if ( $this->mID !==
'' ) {
136 $idArray = [
'id' => Sanitizer::escapeId( $this->mID ) ];
142 $idRandStr = Sanitizer::escapeId(
'-' . $this->mID .
wfRandom(),
'noninitial' );
147 'class' =>
'mw-inputbox-centered',
153 'name' =>
'searchbox',
154 'class' =>
'searchbox',
162 'type' => $this->mHidden ?
'hidden' :
'text',
163 'value' => $this->mDefaultText,
164 'placeholder' => $this->mPlaceholderText,
165 'size' => $this->mWidth,
166 'dir' => $this->mDir,
170 if ( $this->mPrefix !=
'' ) {
174 if ( $this->mSearchFilter !=
'' ) {
175 $htmlOut .=
Html::hidden(
'searchfilter', $this->mSearchFilter );
178 if ( $this->mTour !=
'' ) {
185 $namespacesArray = explode(
',', $this->mNamespaces );
186 if ( $this->mNamespaces ) {
189 $showNamespaces = [];
192 foreach ( $namespacesArray
as $userNS ) {
193 $userNS = trim( $userNS );
196 if ( strpos( $userNS,
'**' ) ) {
197 $userNS = str_replace(
'**',
'', $userNS );
198 $checkedNS[$userNS] =
true;
201 $mainMsg =
wfMessage(
'inputbox-ns-main' )->inContentLanguage()->text();
202 if ( $userNS ==
'Main' || $userNS == $mainMsg ) {
204 } elseif ( array_search( $userNS,
$namespaces ) ) {
206 } elseif ( isset( $nsAliases[$userNS] ) ) {
207 $i = $nsAliases[$userNS];
211 $showNamespaces[$i] = $userNS;
212 if ( isset( $checkedNS[$userNS] ) && $checkedNS[$userNS] ) {
213 $checkedNS[$i] =
true;
218 foreach ( $showNamespaces
as $i =>
$name ) {
221 if ( ( isset( $checkedNS[$i] ) && $checkedNS[$i] ) ||
count( $showNamespaces ) == 1 ) {
222 $checked = [
'checked' =>
'checked' ];
225 if (
count( $showNamespaces ) == 1 ) {
232 'id' =>
'mw-inputbox-ns' . $i . $idRandStr
237 $htmlOut .=
' <div class="mw-inputbox-element mw-ui-checkbox">';
240 'type' =>
'checkbox',
243 'id' =>
'mw-inputbox-ns' . $i . $idRandStr
248 $htmlOut .=
'</div> ';
254 } elseif (
$type ==
'search' ) {
260 'class' =>
'mw-ui-button',
261 'value' => $this->mButtonLabel
264 $htmlOut .=
' ';
271 'name' =>
'fulltext',
272 'class' =>
'mw-ui-button',
273 'value' => $this->mSearchButtonLabel
278 if (
$type ==
'fulltext' ) {
294 if ( !$this->mButtonLabel ) {
295 $this->mButtonLabel =
wfMessage(
'inputbox-tryexact' )->text();
298 if ( $this->mID !==
'' ) {
306 $id = Sanitizer::escapeId( $unescapedID,
'noninitial' );
308 if ( isset( $this->mLabelText ) && strlen( trim( $this->mLabelText ) ) ) {
309 $this->mLabelText = $this->mParser->recursiveTagParse( $this->mLabelText );
310 $htmlLabel =
Xml::openElement(
'label', [
'for' =>
'bodySearchInput' . $id ] );
316 'name' =>
'bodySearch' . $id,
317 'id' =>
'bodySearch' . $id,
318 'class' =>
'bodySearch' . ( $this->mInline ?
' mw-inputbox-inline' :
'' ),
324 'class' =>
'bodySearchWrap' . ( $this->mInline ?
' mw-inputbox-inline' :
'' ),
328 $htmlOut .= $htmlLabel;
331 'type' => $this->mHidden ?
'hidden' :
'text',
333 'class' =>
'mw-ui-input mw-ui-input-inline',
334 'size' => $this->mWidth,
335 'id' =>
'bodySearchInput' . $id,
336 'dir' => $this->mDir,
343 'value' => $this->mButtonLabel,
344 'class' =>
'mw-ui-button',
349 if ( !empty( $this->mFullTextButton ) ) {
353 'name' =>
'fulltext',
354 'class' =>
'mw-ui-button',
355 'value' => $this->mSearchButtonLabel
373 if ( $this->mType ==
"comment" ) {
374 if ( !$this->mButtonLabel ) {
375 $this->mButtonLabel =
wfMessage(
'inputbox-postcomment' )->text();
378 if ( !$this->mButtonLabel ) {
379 $this->mButtonLabel =
wfMessage(
'inputbox-createarticle' )->text();
385 'class' =>
'mw-inputbox-centered',
390 'name' =>
'createbox',
391 'class' =>
'createbox',
395 if ( $this->mID !==
'' ) {
396 $createBoxParams[
'id'] = Sanitizer::escapeId( $this->mID );
400 $htmlOut .=
Html::hidden( $editArgs[
'name'], $editArgs[
'value'] );
401 if ( $this->mPreload !==
null ) {
404 if ( is_array( $this->mPreloadparams ) ) {
405 foreach ( $this->mPreloadparams
as $preloadparams ) {
406 $htmlOut .=
Html::hidden(
'preloadparams[]', $preloadparams );
409 if ( $this->mEditIntro !==
null ) {
410 $htmlOut .=
Html::hidden(
'editintro', $this->mEditIntro );
412 if ( $this->mSummary !==
null ) {
415 if ( $this->mNosummary !==
null ) {
416 $htmlOut .=
Html::hidden(
'nosummary', $this->mNosummary );
418 if ( $this->mPrefix !==
'' ) {
421 if ( $this->mMinor !==
null ) {
424 if ( $this->mType ==
'comment' ) {
429 'type' => $this->mHidden ?
'hidden' :
'text',
432 'mw-ui-input mw-ui-input-inline createboxInput',
433 'value' => $this->mDefaultText,
434 'placeholder' => $this->mPlaceholderText,
435 'size' => $this->mWidth,
436 'dir' => $this->mDir,
444 'class' =>
'mw-ui-button mw-ui-progressive createboxButton',
445 'value' => $this->mButtonLabel
461 if ( !$this->mButtonLabel ) {
462 $this->mButtonLabel =
wfMessage(
'inputbox-movearticle' )->text();
467 'class' =>
'mw-inputbox-centered',
473 'class' =>
'mw-movebox',
477 if ( $this->mID !==
'' ) {
478 $moveBoxParams[
'id'] = Sanitizer::escapeId( $this->mID );
483 $htmlOut .=
Html::hidden(
'wpReason', $this->mSummary );
487 'type' => $this->mHidden ?
'hidden' :
'text',
488 'name' =>
'wpNewTitle',
489 'class' => $this->
getLinebreakClasses() .
'mw-moveboxInput mw-ui-input mw-ui-input-inline',
490 'value' => $this->mDefaultText,
491 'placeholder' => $this->mPlaceholderText,
492 'size' => $this->mWidth,
493 'dir' => $this->mDir,
500 'class' =>
'mw-ui-button mw-ui-progressive',
501 'value' => $this->mButtonLabel
517 if ( !$this->mButtonLabel ) {
518 $this->mButtonLabel =
wfMessage(
'inputbox-postcommenttitle' )->text();
523 'class' =>
'mw-inputbox-centered',
527 $commentFormParams = [
528 'name' =>
'commentbox',
529 'class' =>
'commentbox',
533 if ( $this->mID !==
'' ) {
534 $commentFormParams[
'id'] = Sanitizer::escapeId( $this->mID );
538 $htmlOut .=
Html::hidden( $editArgs[
'name'], $editArgs[
'value'] );
539 if ( $this->mPreload !==
null ) {
542 if ( is_array( $this->mPreloadparams ) ) {
543 foreach ( $this->mPreloadparams
as $preloadparams ) {
544 $htmlOut .=
Html::hidden(
'preloadparams[]', $preloadparams );
547 if ( $this->mEditIntro !==
null ) {
548 $htmlOut .=
Html::hidden(
'editintro', $this->mEditIntro );
552 'type' => $this->mHidden ?
'hidden' :
'text',
553 'name' =>
'preloadtitle',
554 'class' => $this->
getLinebreakClasses() .
'commentboxInput mw-ui-input mw-ui-input-inline',
555 'value' => $this->mDefaultText,
556 'placeholder' => $this->mPlaceholderText,
557 'size' => $this->mWidth,
558 'dir' => $this->mDir,
568 'class' =>
'mw-ui-button mw-ui-progressive',
569 'value' => $this->mButtonLabel
587 foreach ( explode(
"\n", $text )
as $line ) {
588 if ( strpos(
$line,
'=' ) ===
false ) {
593 $value = Sanitizer::decodeCharReferences( trim(
$value ) );
594 if (
$name ==
'preloadparams[]' ) {
596 $this->mPreloadparams[] =
$value;
603 if ( isset( $values[
'dir'] ) && !in_array( $values[
'dir'], [
'ltr',
'rtl' ] ) ) {
604 unset( $values[
'dir'] );
611 'preload' =>
'mPreload',
613 'editintro' =>
'mEditIntro',
615 'summary' =>
'mSummary',
616 'nosummary' =>
'mNosummary',
619 'default' =>
'mDefaultText',
620 'placeholder' =>
'mPlaceholderText',
621 'bgcolor' =>
'mBGColor',
622 'buttonlabel' =>
'mButtonLabel',
623 'searchbuttonlabel' =>
'mSearchButtonLabel',
624 'fulltextbutton' =>
'mFullTextButton',
625 'namespaces' =>
'mNamespaces',
626 'labeltext' =>
'mLabelText',
627 'hidden' =>
'mHidden',
629 'inline' =>
'mInline',
630 'prefix' =>
'mPrefix',
632 'searchfilter' =>
'mSearchFilter',
638 'buttonlabel' =>
true,
639 'searchbuttonlabel' =>
true,
640 'placeholder' =>
true
643 if ( isset( $values[
$name] ) ) {
644 $this->$var = $values[
$name];
645 if ( isset( $convertOptions[
$name] ) ) {
652 $this->mBR = ( strtolower( $this->mBR ) ==
"no" ) ?
' ' :
'<br />';
655 $this->mWidth = intval( $this->mWidth <= 0 ? 50 : $this->mWidth );
659 $this->mBGColor =
'transparent';
670 \# [0-9
a-f]{3} | #
short hexadecimal
671 \# [0-9
a-f]{6} | #
long hexadecimal
673 \d+ \s* , \s* \d+ \s* , \s* \d+ | # rgb integer
674 [0-9.]+% \s* , \s* [0-9.]+% \s* , \s* [0-9.]+% # rgb percent
678 return (
bool)preg_match( $regex, $color );
682 if ( $this->mBGColor !=
'transparent' ) {
683 return 'background-color: ' . $this->mBGColor .
';';
713 $lang = $this->mParser->getConverterLanguage();
714 if (
$lang->hasVariants() && strpos( $text,
'-{' ) !==
false ) {
715 $text =
$lang->convert( $text );