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' );
145 $htmlOut = Xml::openElement(
'div',
147 'class' =>
'mw-inputbox-centered',
151 $htmlOut .= Xml::openElement(
'form',
153 'name' =>
'searchbox',
154 'class' =>
'searchbox',
158 $htmlOut .= Xml::element(
'input',
162 'type' => $this->mHidden ?
'hidden' :
'text',
170 if ( $this->mPrefix !=
'' ) {
171 $htmlOut .= Html::hidden(
'prefix', $this->mPrefix );
174 if ( $this->mSearchFilter !=
'' ) {
175 $htmlOut .= Html::hidden(
'searchfilter', $this->mSearchFilter );
178 if ( $this->mTour !=
'' ) {
179 $htmlOut .= Html::hidden(
'tour', $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 ) {
227 $htmlOut .= Xml::element(
'input',
232 'id' =>
'mw-inputbox-ns' . $i . $idRandStr
237 $htmlOut .=
' <div class="mw-inputbox-element mw-ui-checkbox">';
238 $htmlOut .= Xml::element(
'input',
240 'type' =>
'checkbox',
243 'id' =>
'mw-inputbox-ns' . $i . $idRandStr
247 $htmlOut .= Xml::label( $name,
'mw-inputbox-ns' . $i . $idRandStr );
248 $htmlOut .=
'</div> ';
254 } elseif (
$type ==
'search' ) {
256 $htmlOut .= Xml::element(
'input',
260 'class' =>
'mw-ui-button',
261 'value' => $this->mButtonLabel
264 $htmlOut .=
' ';
268 $htmlOut .= Xml::element(
'input',
271 'name' =>
'fulltext',
272 'class' =>
'mw-ui-button',
273 'value' => $this->mSearchButtonLabel
278 if (
$type ==
'fulltext' ) {
279 $htmlOut .= Html::hidden(
'fulltext',
'Search' );
282 $htmlOut .= Xml::closeElement(
'form' );
283 $htmlOut .= Xml::closeElement(
'div' );
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 ] );
312 $htmlLabel .= Xml::closeElement(
'label' );
314 $htmlOut = Xml::openElement(
'form',
316 'name' =>
'bodySearch' . $id,
317 'id' =>
'bodySearch' . $id,
318 'class' =>
'bodySearch' . ( $this->mInline ?
' mw-inputbox-inline' :
'' ),
322 $htmlOut .= Xml::openElement(
'div',
324 'class' =>
'bodySearchWrap' . ( $this->mInline ?
' mw-inputbox-inline' :
'' ),
328 $htmlOut .= $htmlLabel;
329 $htmlOut .= Xml::element(
'input',
331 'type' => $this->mHidden ?
'hidden' :
'text',
333 'class' =>
'mw-ui-input mw-ui-input-inline',
335 'id' =>
'bodySearchInput' . $id,
339 $htmlOut .=
' ' . Xml::element(
'input',
343 'value' => $this->mButtonLabel,
344 'class' =>
'mw-ui-button',
349 if ( !empty( $this->mFullTextButton ) ) {
350 $htmlOut .= Xml::element(
'input',
353 'name' =>
'fulltext',
354 'class' =>
'mw-ui-button',
355 'value' => $this->mSearchButtonLabel
360 $htmlOut .= Xml::closeElement(
'div' );
361 $htmlOut .= Xml::closeElement(
'form' );
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();
383 $htmlOut = Xml::openElement(
'div',
385 'class' =>
'mw-inputbox-centered',
390 'name' =>
'createbox',
391 'class' =>
'createbox',
395 if ( $this->mID !==
'' ) {
396 $createBoxParams[
'id'] = Sanitizer::escapeId( $this->mID );
398 $htmlOut .= Xml::openElement(
'form', $createBoxParams );
400 $htmlOut .= Html::hidden( $editArgs[
'name'], $editArgs[
'value'] );
401 if ( $this->mPreload !==
null ) {
402 $htmlOut .= Html::hidden(
'preload', $this->mPreload );
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 ) {
413 $htmlOut .= Html::hidden(
'summary', $this->mSummary );
415 if ( $this->mNosummary !==
null ) {
416 $htmlOut .= Html::hidden(
'nosummary', $this->mNosummary );
418 if ( $this->mPrefix !==
'' ) {
419 $htmlOut .= Html::hidden(
'prefix', $this->mPrefix );
421 if ( $this->mMinor !==
null ) {
422 $htmlOut .= Html::hidden(
'minor', $this->mMinor );
424 if ( $this->mType ==
'comment' ) {
425 $htmlOut .= Html::hidden(
'section',
'new' );
427 $htmlOut .= Xml::openElement(
'input',
429 'type' => $this->mHidden ?
'hidden' :
'text',
432 'mw-ui-input mw-ui-input-inline createboxInput',
440 $htmlOut .= Xml::openElement(
'input',
444 'class' =>
'mw-ui-button mw-ui-progressive createboxButton',
445 'value' => $this->mButtonLabel
448 $htmlOut .= Xml::closeElement(
'form' );
449 $htmlOut .= Xml::closeElement(
'div' );
461 if ( !$this->mButtonLabel ) {
462 $this->mButtonLabel =
wfMessage(
'inputbox-movearticle' )->text();
465 $htmlOut = Xml::openElement(
'div',
467 'class' =>
'mw-inputbox-centered',
473 'class' =>
'mw-movebox',
477 if ( $this->mID !==
'' ) {
478 $moveBoxParams[
'id'] = Sanitizer::escapeId( $this->mID );
480 $htmlOut .= Xml::openElement(
'form', $moveBoxParams );
481 $htmlOut .= Html::hidden(
'title',
483 $htmlOut .= Html::hidden(
'wpReason', $this->mSummary );
484 $htmlOut .= Html::hidden(
'prefix', $this->mPrefix );
485 $htmlOut .= Xml::openElement(
'input',
487 'type' => $this->mHidden ?
'hidden' :
'text',
488 'name' =>
'wpNewTitle',
489 'class' => $this->
getLinebreakClasses() .
'mw-moveboxInput mw-ui-input mw-ui-input-inline',
497 $htmlOut .= Xml::openElement(
'input',
500 'class' =>
'mw-ui-button mw-ui-progressive',
501 'value' => $this->mButtonLabel
504 $htmlOut .= Xml::closeElement(
'form' );
505 $htmlOut .= Xml::closeElement(
'div' );
517 if ( !$this->mButtonLabel ) {
518 $this->mButtonLabel =
wfMessage(
'inputbox-postcommenttitle' )->text();
521 $htmlOut = Xml::openElement(
'div',
523 'class' =>
'mw-inputbox-centered',
527 $commentFormParams = [
528 'name' =>
'commentbox',
529 'class' =>
'commentbox',
533 if ( $this->mID !==
'' ) {
534 $commentFormParams[
'id'] = Sanitizer::escapeId( $this->mID );
536 $htmlOut .= Xml::openElement(
'form', $commentFormParams );
538 $htmlOut .= Html::hidden( $editArgs[
'name'], $editArgs[
'value'] );
539 if ( $this->mPreload !==
null ) {
540 $htmlOut .= Html::hidden(
'preload', $this->mPreload );
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 );
550 $htmlOut .= Xml::openElement(
'input',
552 'type' => $this->mHidden ?
'hidden' :
'text',
553 'name' =>
'preloadtitle',
554 'class' => $this->
getLinebreakClasses() .
'commentboxInput mw-ui-input mw-ui-input-inline',
561 $htmlOut .= Html::hidden(
'section',
'new' );
562 $htmlOut .= Html::hidden(
'title', $this->mPage );
564 $htmlOut .= Xml::openElement(
'input',
568 'class' =>
'mw-ui-button mw-ui-progressive',
569 'value' => $this->mButtonLabel
572 $htmlOut .= Xml::closeElement(
'form' );
573 $htmlOut .= Xml::closeElement(
'div' );
587 foreach ( explode(
"\n", $text ) as
$line ) {
588 if ( strpos(
$line,
'=' ) ===
false ) {
592 $name = strtolower( trim( $name ) );
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
642 foreach (
$options as $name => $var ) {
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';
669 [a-zA-Z]* | #
color names
670 \# [0-9a-f]{3} | #
short hexadecimal
671 \# [0-9a-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 );