52 $this->mDir = $this->mParser->getTargetLanguage()->getDir();
55 $this->mParser->getOptions()->getUserLangObj();
56 $this->mParser->getOutput()->addModuleStyles( [
57 'ext.inputBox.styles',
59 'mediawiki.ui.checkbox',
65 switch ( $this->mType ) {
68 $this->mParser->getOutput()->addModules(
'ext.inputBox' );
83 [
'class' =>
'error' ],
84 strlen( $this->mType ) > 0
85 ?
wfMessage(
'inputbox-error-bad-type', $this->mType )->
text()
108 'name' =>
'veaction',
122 return strtolower( $this->mBR ) ===
'<br />' ?
'mw-inputbox-input ' :
'';
134 if ( !$this->mButtonLabel ) {
135 $this->mButtonLabel =
wfMessage(
'inputbox-tryexact' )->text();
137 if ( !$this->mSearchButtonLabel ) {
138 $this->mSearchButtonLabel =
wfMessage(
'inputbox-searchfulltext' )->text();
140 if ( $this->mID !==
'' ) {
141 $idArray = [
'id' => Sanitizer::escapeIdForAttribute( $this->mID ) ];
147 $idRandStr = Sanitizer::escapeIdForAttribute(
'-' . $this->mID .
wfRandom() );
152 'class' =>
'mw-inputbox-centered',
158 'name' =>
'searchbox',
159 'class' =>
'searchbox',
167 'type' => $this->mHidden ?
'hidden' :
'text',
168 'value' => $this->mDefaultText,
169 'placeholder' => $this->mPlaceholderText,
170 'size' => $this->mWidth,
171 'dir' => $this->mDir,
175 if ( $this->mPrefix !=
'' ) {
179 if ( $this->mSearchFilter !=
'' ) {
180 $htmlOut .=
Html::hidden(
'searchfilter', $this->mSearchFilter );
183 if ( $this->mTour !=
'' ) {
190 $namespacesArray = explode(
',', $this->mNamespaces );
191 if ( $this->mNamespaces ) {
194 $showNamespaces = [];
197 foreach ( $namespacesArray
as $userNS ) {
198 $userNS = trim( $userNS );
201 if ( strpos( $userNS,
'**' ) ) {
202 $userNS = str_replace(
'**',
'', $userNS );
203 $checkedNS[$userNS] =
true;
206 $mainMsg =
wfMessage(
'inputbox-ns-main' )->inContentLanguage()->text();
207 if ( $userNS ==
'Main' || $userNS == $mainMsg ) {
209 } elseif ( array_search( $userNS,
$namespaces ) ) {
211 } elseif ( isset( $nsAliases[$userNS] ) ) {
212 $i = $nsAliases[$userNS];
216 $showNamespaces[$i] = $userNS;
217 if ( isset( $checkedNS[$userNS] ) && $checkedNS[$userNS] ) {
218 $checkedNS[$i] =
true;
223 foreach ( $showNamespaces
as $i =>
$name ) {
226 if ( ( isset( $checkedNS[$i] ) && $checkedNS[$i] ) ||
count( $showNamespaces ) == 1 ) {
227 $checked = [
'checked' =>
'checked' ];
230 if (
count( $showNamespaces ) == 1 ) {
237 'id' =>
'mw-inputbox-ns' . $i . $idRandStr
242 $htmlOut .=
' <div class="mw-inputbox-element mw-ui-checkbox">';
245 'type' =>
'checkbox',
248 'id' =>
'mw-inputbox-ns' . $i . $idRandStr
253 $htmlOut .=
'</div> ';
259 } elseif (
$type ==
'search' ) {
265 'class' =>
'mw-ui-button',
266 'value' => $this->mButtonLabel
269 $htmlOut .=
' ';
276 'name' =>
'fulltext',
277 'class' =>
'mw-ui-button',
278 'value' => $this->mSearchButtonLabel
283 if (
$type ==
'fulltext' ) {
300 if ( !$this->mButtonLabel ) {
301 $this->mButtonLabel =
wfMessage(
'inputbox-tryexact' )->text();
304 if ( $this->mID !==
'' ) {
312 $id = Sanitizer::escapeIdForAttribute( $unescapedID );
314 if ( isset( $this->mLabelText ) && strlen( trim( $this->mLabelText ) ) ) {
315 $htmlLabel =
Xml::openElement(
'label', [
'for' =>
'bodySearchInput' . $id ] );
316 $htmlLabel .= $this->mParser->recursiveTagParse( $this->mLabelText );
321 'name' =>
'bodySearch' . $id,
322 'id' =>
'bodySearch' . $id,
323 'class' =>
'bodySearch' . ( $this->mInline ?
' mw-inputbox-inline' :
'' ),
329 'class' =>
'bodySearchWrap' . ( $this->mInline ?
' mw-inputbox-inline' :
'' ),
333 $htmlOut .= $htmlLabel;
336 'type' => $this->mHidden ?
'hidden' :
'text',
338 'class' =>
'mw-ui-input mw-ui-input-inline',
339 'size' => $this->mWidth,
340 'id' =>
'bodySearchInput' . $id,
341 'dir' => $this->mDir,
348 'value' => $this->mButtonLabel,
349 'class' =>
'mw-ui-button',
354 if ( !empty( $this->mFullTextButton ) ) {
358 'name' =>
'fulltext',
359 'class' =>
'mw-ui-button',
360 'value' => $this->mSearchButtonLabel
379 if ( $this->mType ==
"comment" ) {
380 if ( !$this->mButtonLabel ) {
381 $this->mButtonLabel =
wfMessage(
'inputbox-postcomment' )->text();
384 if ( !$this->mButtonLabel ) {
385 $this->mButtonLabel =
wfMessage(
'inputbox-createarticle' )->text();
391 'class' =>
'mw-inputbox-centered',
396 'name' =>
'createbox',
397 'class' =>
'createbox',
401 if ( $this->mID !==
'' ) {
402 $createBoxParams[
'id'] = Sanitizer::escapeIdForAttribute( $this->mID );
406 $htmlOut .=
Html::hidden( $editArgs[
'name'], $editArgs[
'value'] );
407 if ( $this->mPreload !==
null ) {
410 if ( is_array( $this->mPreloadparams ) ) {
411 foreach ( $this->mPreloadparams
as $preloadparams ) {
412 $htmlOut .=
Html::hidden(
'preloadparams[]', $preloadparams );
415 if ( $this->mEditIntro !==
null ) {
416 $htmlOut .=
Html::hidden(
'editintro', $this->mEditIntro );
418 if ( $this->mSummary !==
null ) {
421 if ( $this->mNosummary !==
null ) {
422 $htmlOut .=
Html::hidden(
'nosummary', $this->mNosummary );
424 if ( $this->mPrefix !==
'' ) {
427 if ( $this->mMinor !==
null ) {
430 if ( $this->mType ==
'comment' ) {
435 'type' => $this->mHidden ?
'hidden' :
'text',
438 'mw-ui-input mw-ui-input-inline createboxInput',
439 'value' => $this->mDefaultText,
440 'placeholder' => $this->mPlaceholderText,
441 'size' => $this->mWidth,
442 'dir' => $this->mDir,
450 'class' =>
'mw-ui-button mw-ui-progressive createboxButton',
451 'value' => $this->mButtonLabel
468 if ( !$this->mButtonLabel ) {
469 $this->mButtonLabel =
wfMessage(
'inputbox-movearticle' )->text();
474 'class' =>
'mw-inputbox-centered',
480 'class' =>
'mw-movebox',
484 if ( $this->mID !==
'' ) {
485 $moveBoxParams[
'id'] = Sanitizer::escapeIdForAttribute( $this->mID );
490 $htmlOut .=
Html::hidden(
'wpReason', $this->mSummary );
494 'type' => $this->mHidden ?
'hidden' :
'text',
495 'name' =>
'wpNewTitle',
496 'class' => $this->
getLinebreakClasses() .
'mw-moveboxInput mw-ui-input mw-ui-input-inline',
497 'value' => $this->mDefaultText,
498 'placeholder' => $this->mPlaceholderText,
499 'size' => $this->mWidth,
500 'dir' => $this->mDir,
507 'class' =>
'mw-ui-button mw-ui-progressive',
508 'value' => $this->mButtonLabel
525 if ( !$this->mButtonLabel ) {
526 $this->mButtonLabel =
wfMessage(
'inputbox-postcommenttitle' )->text();
531 'class' =>
'mw-inputbox-centered',
535 $commentFormParams = [
536 'name' =>
'commentbox',
537 'class' =>
'commentbox',
541 if ( $this->mID !==
'' ) {
542 $commentFormParams[
'id'] = Sanitizer::escapeIdForAttribute( $this->mID );
546 $htmlOut .=
Html::hidden( $editArgs[
'name'], $editArgs[
'value'] );
547 if ( $this->mPreload !==
null ) {
550 if ( is_array( $this->mPreloadparams ) ) {
551 foreach ( $this->mPreloadparams
as $preloadparams ) {
552 $htmlOut .=
Html::hidden(
'preloadparams[]', $preloadparams );
555 if ( $this->mEditIntro !==
null ) {
556 $htmlOut .=
Html::hidden(
'editintro', $this->mEditIntro );
560 'type' => $this->mHidden ?
'hidden' :
'text',
561 'name' =>
'preloadtitle',
562 'class' => $this->
getLinebreakClasses() .
'commentboxInput mw-ui-input mw-ui-input-inline',
563 'value' => $this->mDefaultText,
564 'placeholder' => $this->mPlaceholderText,
565 'size' => $this->mWidth,
566 'dir' => $this->mDir,
576 'class' =>
'mw-ui-button mw-ui-progressive',
577 'value' => $this->mButtonLabel
595 foreach ( explode(
"\n", $text )
as $line ) {
596 if ( strpos(
$line,
'=' ) ===
false ) {
601 $value = Sanitizer::decodeCharReferences( trim(
$value ) );
602 if (
$name ==
'preloadparams[]' ) {
604 $this->mPreloadparams[] =
$value;
611 if ( isset( $values[
'dir'] ) && !in_array( $values[
'dir'], [
'ltr',
'rtl' ] ) ) {
612 unset( $values[
'dir'] );
619 'preload' =>
'mPreload',
621 'editintro' =>
'mEditIntro',
623 'summary' =>
'mSummary',
624 'nosummary' =>
'mNosummary',
627 'default' =>
'mDefaultText',
628 'placeholder' =>
'mPlaceholderText',
629 'bgcolor' =>
'mBGColor',
630 'buttonlabel' =>
'mButtonLabel',
631 'searchbuttonlabel' =>
'mSearchButtonLabel',
632 'fulltextbutton' =>
'mFullTextButton',
633 'namespaces' =>
'mNamespaces',
634 'labeltext' =>
'mLabelText',
635 'hidden' =>
'mHidden',
637 'inline' =>
'mInline',
638 'prefix' =>
'mPrefix',
640 'searchfilter' =>
'mSearchFilter',
646 'buttonlabel' =>
true,
647 'searchbuttonlabel' =>
true,
648 'placeholder' =>
true
651 if ( isset( $values[
$name] ) ) {
652 $this->$var = $values[
$name];
653 if ( isset( $convertOptions[
$name] ) ) {
660 $this->mBR = ( strtolower( $this->mBR ) ==
"no" ) ?
' ' :
'<br />';
663 $this->mWidth = intval( $this->mWidth <= 0 ? 50 : $this->mWidth );
667 $this->mBGColor =
'transparent';
680 \# [0-9
a-f]{3} | #
short hexadecimal
681 \# [0-9
a-f]{6} | #
long hexadecimal
683 \d+ \s* , \s* \d+ \s* , \s* \d+ | # rgb integer
684 [0-9.]+% \s* , \s* [0-9.]+% \s* , \s* [0-9.]+% # rgb percent
688 return (
bool)preg_match( $regex, $color );
692 if ( $this->mBGColor !=
'transparent' ) {
693 return 'background-color: ' . $this->mBGColor .
';';
723 $lang = $this->mParser->getConverterLanguage();
724 if (
$lang->hasVariants() && strpos( $text,
'-{' ) !==
false ) {
725 $text =
$lang->convert( $text );