136 if ( !$this->mButtonLabel ) {
137 $this->mButtonLabel =
wfMessage(
'inputbox-tryexact' )->text();
139 if ( !$this->mSearchButtonLabel ) {
140 $this->mSearchButtonLabel =
wfMessage(
'inputbox-searchfulltext' )->text();
142 if ( $this->mID !==
'' ) {
143 $idArray = [
'id' => Sanitizer::escapeIdForAttribute( $this->mID ) ];
149 $idRandStr = Sanitizer::escapeIdForAttribute(
'-' . $this->mID .
wfRandom() );
152 $htmlOut = Xml::openElement(
'div',
154 'class' =>
'mw-inputbox-centered',
158 $htmlOut .= Xml::openElement(
'form',
160 'name' =>
'searchbox',
161 'class' =>
'searchbox',
162 'action' => SpecialPage::getTitleFor(
'Search' )->getLocalUrl(),
165 $htmlOut .= Xml::element(
'input',
169 'type' => $this->mHidden ?
'hidden' :
'text',
177 if ( $this->mPrefix !=
'' ) {
178 $htmlOut .= Html::hidden(
'prefix', $this->mPrefix );
181 if ( $this->mSearchFilter !=
'' ) {
182 $htmlOut .= Html::hidden(
'searchfilter', $this->mSearchFilter );
185 if ( $this->mTour !=
'' ) {
186 $htmlOut .= Html::hidden(
'tour', $this->mTour );
192 $namespacesArray = explode(
',', $this->mNamespaces );
193 if ( $this->mNamespaces ) {
194 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
195 $namespaces = $contLang->getNamespaces();
197 $showNamespaces = [];
200 foreach ( $namespacesArray as $userNS ) {
201 $userNS = trim( $userNS );
204 if ( strpos( $userNS,
'**' ) ) {
205 $userNS = str_replace(
'**',
'', $userNS );
206 $checkedNS[$userNS] =
true;
209 $mainMsg =
wfMessage(
'inputbox-ns-main' )->inContentLanguage()->text();
210 if ( $userNS ==
'Main' || $userNS == $mainMsg ) {
212 } elseif ( array_search( $userNS, $namespaces ) ) {
213 $i = array_search( $userNS, $namespaces );
214 } elseif ( isset( $nsAliases[$userNS] ) ) {
215 $i = $nsAliases[$userNS];
219 $showNamespaces[$i] = $userNS;
220 if ( isset( $checkedNS[$userNS] ) && $checkedNS[$userNS] ) {
221 $checkedNS[$i] =
true;
226 foreach ( $showNamespaces as $i => $name ) {
229 if ( ( isset( $checkedNS[$i] ) && $checkedNS[$i] ) || count( $showNamespaces ) == 1 ) {
230 $checked = [
'checked' =>
'checked' ];
233 if ( count( $showNamespaces ) == 1 ) {
235 $htmlOut .= Xml::element(
'input',
240 'id' =>
'mw-inputbox-ns' . $i . $idRandStr
245 $htmlOut .=
' <div class="mw-inputbox-element mw-ui-checkbox">';
246 $htmlOut .= Xml::element(
'input',
248 'type' =>
'checkbox',
251 'id' =>
'mw-inputbox-ns' . $i . $idRandStr
255 $htmlOut .= Xml::label( $name,
'mw-inputbox-ns' . $i . $idRandStr );
256 $htmlOut .=
'</div> ';
262 } elseif (
$type ==
'search' ) {
264 $htmlOut .= Xml::element(
'input',
268 'class' =>
'mw-ui-button',
269 'value' => $this->mButtonLabel
272 $htmlOut .=
"\u{00A0}";
276 $htmlOut .= Xml::element(
'input',
279 'name' =>
'fulltext',
280 'class' =>
'mw-ui-button',
281 'value' => $this->mSearchButtonLabel
286 if (
$type ==
'fulltext' ) {
287 $htmlOut .= Html::hidden(
'fulltext',
'Search' );
290 $htmlOut .= Xml::closeElement(
'form' );
291 $htmlOut .= Xml::closeElement(
'div' );
303 if ( !$this->mButtonLabel ) {
304 $this->mButtonLabel =
wfMessage(
'inputbox-tryexact' )->text();
307 if ( $this->mID !==
'' ) {
315 $id = Sanitizer::escapeIdForAttribute( $unescapedID );
317 if ( isset( $this->mLabelText ) && strlen( trim( $this->mLabelText ) ) ) {
318 $htmlLabel = Xml::openElement(
'label', [
'for' =>
'bodySearchInput' . $id ] );
319 $htmlLabel .= $this->mParser->recursiveTagParse( $this->mLabelText );
320 $htmlLabel .= Xml::closeElement(
'label' );
322 $htmlOut = Xml::openElement(
'form',
324 'name' =>
'bodySearch' . $id,
325 'id' =>
'bodySearch' . $id,
326 'class' =>
'bodySearch' . ( $this->mInline ?
' mw-inputbox-inline' :
'' ),
327 'action' => SpecialPage::getTitleFor(
'Search' )->getLocalUrl(),
330 $htmlOut .= Xml::openElement(
'div',
332 'class' =>
'bodySearchWrap' . ( $this->mInline ?
' mw-inputbox-inline' :
'' ),
336 $htmlOut .= $htmlLabel;
337 $htmlOut .= Xml::element(
'input',
339 'type' => $this->mHidden ?
'hidden' :
'text',
341 'class' =>
'mw-ui-input mw-ui-input-inline',
343 'id' =>
'bodySearchInput' . $id,
347 $htmlOut .=
"\u{00A0}" . Xml::element(
'input',
351 'value' => $this->mButtonLabel,
352 'class' =>
'mw-ui-button',
357 if ( !empty( $this->mFullTextButton ) ) {
358 $htmlOut .= Xml::element(
'input',
361 'name' =>
'fulltext',
362 'class' =>
'mw-ui-button',
363 'value' => $this->mSearchButtonLabel
368 $htmlOut .= Xml::closeElement(
'div' );
369 $htmlOut .= Xml::closeElement(
'form' );
382 if ( $this->mType ==
"comment" ) {
383 if ( !$this->mButtonLabel ) {
384 $this->mButtonLabel =
wfMessage(
'inputbox-postcomment' )->text();
387 if ( !$this->mButtonLabel ) {
388 $this->mButtonLabel =
wfMessage(
'inputbox-createarticle' )->text();
392 $htmlOut = Xml::openElement(
'div',
394 'class' =>
'mw-inputbox-centered',
399 'name' =>
'createbox',
400 'class' =>
'createbox',
404 if ( $this->mID !==
'' ) {
405 $createBoxParams[
'id'] = Sanitizer::escapeIdForAttribute( $this->mID );
407 $htmlOut .= Xml::openElement(
'form', $createBoxParams );
409 $htmlOut .= Html::hidden( $editArgs[
'name'], $editArgs[
'value'] );
410 if ( $this->mPreload !==
null ) {
411 $htmlOut .= Html::hidden(
'preload', $this->mPreload );
413 if ( is_array( $this->mPreloadparams ) ) {
414 foreach ( $this->mPreloadparams as $preloadparams ) {
415 $htmlOut .= Html::hidden(
'preloadparams[]', $preloadparams );
418 if ( $this->mEditIntro !==
null ) {
419 $htmlOut .= Html::hidden(
'editintro', $this->mEditIntro );
421 if ( $this->mSummary !==
null ) {
422 $htmlOut .= Html::hidden(
'summary', $this->mSummary );
424 if ( $this->mNosummary !==
null ) {
425 $htmlOut .= Html::hidden(
'nosummary', $this->mNosummary );
427 if ( $this->mPrefix !==
'' ) {
428 $htmlOut .= Html::hidden(
'prefix', $this->mPrefix );
430 if ( $this->mMinor !==
null ) {
431 $htmlOut .= Html::hidden(
'minor', $this->mMinor );
433 if ( $this->mType ==
'comment' ) {
434 $htmlOut .= Html::hidden(
'section',
'new' );
436 $htmlOut .= Xml::openElement(
'input',
438 'type' => $this->mHidden ?
'hidden' :
'text',
441 'mw-ui-input mw-ui-input-inline createboxInput',
449 $htmlOut .= Xml::openElement(
'input',
453 'class' =>
'mw-ui-button mw-ui-progressive createboxButton',
454 'value' => $this->mButtonLabel
457 $htmlOut .= Xml::closeElement(
'form' );
458 $htmlOut .= Xml::closeElement(
'div' );
471 if ( !$this->mButtonLabel ) {
472 $this->mButtonLabel =
wfMessage(
'inputbox-movearticle' )->text();
475 $htmlOut = Xml::openElement(
'div',
477 'class' =>
'mw-inputbox-centered',
483 'class' =>
'mw-movebox',
487 if ( $this->mID !==
'' ) {
488 $moveBoxParams[
'id'] = Sanitizer::escapeIdForAttribute( $this->mID );
490 $htmlOut .= Xml::openElement(
'form', $moveBoxParams );
491 $htmlOut .= Html::hidden(
'title',
492 SpecialPage::getTitleFor(
'Movepage', $this->mPage )->getPrefixedText() );
493 $htmlOut .= Html::hidden(
'wpReason', $this->mSummary );
494 $htmlOut .= Html::hidden(
'prefix', $this->mPrefix );
495 $htmlOut .= Xml::openElement(
'input',
497 'type' => $this->mHidden ?
'hidden' :
'text',
498 'name' =>
'wpNewTitle',
499 'class' => $this->
getLinebreakClasses() .
'mw-moveboxInput mw-ui-input mw-ui-input-inline',
507 $htmlOut .= Xml::openElement(
'input',
510 'class' =>
'mw-ui-button mw-ui-progressive',
511 'value' => $this->mButtonLabel
514 $htmlOut .= Xml::closeElement(
'form' );
515 $htmlOut .= Xml::closeElement(
'div' );
528 if ( !$this->mButtonLabel ) {
529 $this->mButtonLabel =
wfMessage(
'inputbox-postcommenttitle' )->text();
532 $htmlOut = Xml::openElement(
'div',
534 'class' =>
'mw-inputbox-centered',
538 $commentFormParams = [
539 'name' =>
'commentbox',
540 'class' =>
'commentbox',
544 if ( $this->mID !==
'' ) {
545 $commentFormParams[
'id'] = Sanitizer::escapeIdForAttribute( $this->mID );
547 $htmlOut .= Xml::openElement(
'form', $commentFormParams );
549 $htmlOut .= Html::hidden( $editArgs[
'name'], $editArgs[
'value'] );
550 if ( $this->mPreload !==
null ) {
551 $htmlOut .= Html::hidden(
'preload', $this->mPreload );
553 if ( is_array( $this->mPreloadparams ) ) {
554 foreach ( $this->mPreloadparams as $preloadparams ) {
555 $htmlOut .= Html::hidden(
'preloadparams[]', $preloadparams );
558 if ( $this->mEditIntro !==
null ) {
559 $htmlOut .= Html::hidden(
'editintro', $this->mEditIntro );
561 $htmlOut .= Xml::openElement(
'input',
563 'type' => $this->mHidden ?
'hidden' :
'text',
564 'name' =>
'preloadtitle',
565 'class' => $this->
getLinebreakClasses() .
'commentboxInput mw-ui-input mw-ui-input-inline',
572 $htmlOut .= Html::hidden(
'section',
'new' );
573 $htmlOut .= Html::hidden(
'title', $this->mPage );
575 $htmlOut .= Xml::openElement(
'input',
579 'class' =>
'mw-ui-button mw-ui-progressive',
580 'value' => $this->mButtonLabel
583 $htmlOut .= Xml::closeElement(
'form' );
584 $htmlOut .= Xml::closeElement(
'div' );
598 foreach ( explode(
"\n", $text ) as
$line ) {
599 if ( strpos(
$line,
'=' ) ===
false ) {
602 list( $name, $value ) = explode(
'=',
$line, 2 );
603 $name = strtolower( trim( $name ) );
604 $value = Sanitizer::decodeCharReferences( trim( $value ) );
605 if ( $name ==
'preloadparams[]' ) {
607 $this->mPreloadparams[] = $value;
609 $values[ $name ] = $value;
614 if ( isset( $values[
'dir'] ) && !in_array( $values[
'dir'], [
'ltr',
'rtl' ] ) ) {
615 unset( $values[
'dir'] );
622 'preload' =>
'mPreload',
624 'editintro' =>
'mEditIntro',
626 'summary' =>
'mSummary',
627 'nosummary' =>
'mNosummary',
630 'default' =>
'mDefaultText',
631 'placeholder' =>
'mPlaceholderText',
632 'bgcolor' =>
'mBGColor',
633 'buttonlabel' =>
'mButtonLabel',
634 'searchbuttonlabel' =>
'mSearchButtonLabel',
635 'fulltextbutton' =>
'mFullTextButton',
636 'namespaces' =>
'mNamespaces',
637 'labeltext' =>
'mLabelText',
638 'hidden' =>
'mHidden',
640 'inline' =>
'mInline',
641 'prefix' =>
'mPrefix',
643 'searchfilter' =>
'mSearchFilter',
649 'buttonlabel' =>
true,
650 'searchbuttonlabel' =>
true,
651 'placeholder' =>
true
653 foreach ( $options as $name => $var ) {
654 if ( isset( $values[$name] ) ) {
655 $this->$var = $values[$name];
656 if ( isset( $convertOptions[$name] ) ) {
663 $this->mBR = ( strtolower( $this->mBR ) ==
"no" ) ?
' ' :
'<br />';
666 $this->mWidth = intval( $this->mWidth <= 0 ? 50 : $this->mWidth );
670 $this->mBGColor =
'transparent';
682 [a-zA-Z]* | # color names
683 \# [0-9a-f]{3} | #
short hexadecimal
684 \# [0-9a-f]{6} | #
long hexadecimal
686 \d+ \s* , \s* \d+ \s* , \s* \d+ | # rgb integer
687 [0-9.]+% \s* , \s* [0-9.]+% \s* , \s* [0-9.]+% # rgb percent
691 return (
bool)preg_match( $regex, $color );