45 $this->mDir = $this->mParser->getTargetLanguage()->getDir();
48 $this->mParser->getOptions()->getUserLangObj();
49 $this->mParser->getOutput()->addModuleStyles(
array(
50 'ext.inputBox.styles',
52 'mediawiki.ui.checkbox',
58 switch ( $this->mType ) {
61 $this->mParser->getOutput()->addModules(
'ext.inputBox' );
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 =
array(
'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 !=
'' ) {
177 $namespacesArray = explode(
',', $this->mNamespaces );
178 if ( $this->mNamespaces ) {
181 $showNamespaces =
array();
182 $checkedNS =
array();
183 # Check for valid namespaces
184 foreach ( $namespacesArray
as $userNS ) {
185 $userNS = trim( $userNS ); # no whitespace
187 # Namespace needs to be checked if flagged with "**"
188 if ( strpos( $userNS,
'**' ) ) {
189 $userNS = str_replace(
'**',
'', $userNS );
190 $checkedNS[$userNS] =
true;
193 $mainMsg =
wfMessage(
'inputbox-ns-main' )->inContentLanguage()->text();
194 if ( $userNS ==
'Main' || $userNS == $mainMsg ) {
196 } elseif ( array_search( $userNS,
$namespaces ) ) {
198 } elseif ( isset( $nsAliases[$userNS] ) ) {
199 $i = $nsAliases[$userNS];
201 continue; # Namespace
not recognized, skip
203 $showNamespaces[$i] = $userNS;
204 if ( isset( $checkedNS[$userNS] ) && $checkedNS[$userNS] ) {
205 $checkedNS[$i] =
true;
209 # Show valid namespaces
210 foreach ( $showNamespaces
as $i =>
$name ) {
213 if ( ( isset( $checkedNS[$i] ) && $checkedNS[$i] ) ||
count( $showNamespaces ) == 1 ) {
214 $checked =
array(
'checked' =>
'checked' );
217 if (
count( $showNamespaces ) == 1 ) {
224 'id' =>
'mw-inputbox-ns' . $i . $idRandStr
229 $htmlOut .=
' <div class="mw-inputbox-element mw-ui-checkbox">';
232 'type' =>
'checkbox',
235 'id' =>
'mw-inputbox-ns' . $i . $idRandStr
240 $htmlOut .=
'</div> ';
246 } elseif (
$type ==
'search' ) {
252 'class' =>
'mw-ui-button',
253 'value' => $this->mButtonLabel
256 $htmlOut .=
' ';
263 'name' =>
'fulltext',
264 'class' =>
'mw-ui-button',
265 'value' => $this->mSearchButtonLabel
270 if (
$type ==
'fulltext' ) {
286 if ( !$this->mButtonLabel ) {
287 $this->mButtonLabel =
wfMessage(
'inputbox-tryexact' )->text();
290 if ( $this->mID !==
'' ) {
298 $id = Sanitizer::escapeId( $unescapedID,
'noninitial' );
300 if ( isset( $this->mLabelText ) && strlen( trim( $this->mLabelText ) ) ) {
301 $this->mLabelText = $this->mParser->recursiveTagParse( $this->mLabelText );
308 'name' =>
'bodySearch' . $id,
309 'id' =>
'bodySearch' . $id,
310 'class' =>
'bodySearch' . ( $this->mInline ?
' mw-inputbox-inline' :
'' ),
316 'class' =>
'bodySearchWrap' . ( $this->mInline ?
' mw-inputbox-inline' :
'' ),
320 $htmlOut .= $htmlLabel;
323 'type' => $this->mHidden ?
'hidden' :
'text',
325 'class' =>
'mw-ui-input mw-ui-input-inline',
326 'size' => $this->mWidth,
327 'id' =>
'bodySearchInput' . $id,
328 'dir' => $this->mDir,
335 'value' => $this->mButtonLabel,
336 'class' =>
'mw-ui-button',
341 if ( !empty( $this->mFullTextButton ) ) {
345 'name' =>
'fulltext',
346 'class' =>
'mw-ui-button',
347 'value' => $this->mSearchButtonLabel
365 if ( $this->mType ==
"comment" ) {
366 if ( !$this->mButtonLabel ) {
367 $this->mButtonLabel =
wfMessage(
'inputbox-postcomment' )->text();
370 if ( !$this->mButtonLabel ) {
371 $this->mButtonLabel =
wfMessage(
'inputbox-createarticle' )->text();
377 'class' =>
'mw-inputbox-centered',
381 $createBoxParams =
array(
382 'name' =>
'createbox',
383 'class' =>
'createbox',
387 if ( $this->mID !==
'' ) {
388 $createBoxParams[
'id'] = Sanitizer::escapeId( $this->mID );
392 $htmlOut .=
Html::hidden( $editArgs[
'name'], $editArgs[
'value'] );
394 foreach ( $this->mPreloadparams
as $preloadparams ) {
395 $htmlOut .=
Html::hidden(
'preloadparams[]', $preloadparams );
397 $htmlOut .=
Html::hidden(
'editintro', $this->mEditIntro );
399 $htmlOut .=
Html::hidden(
'nosummary', $this->mNosummary );
402 if ( $this->mType ==
'comment' ) {
407 'type' => $this->mHidden ?
'hidden' :
'text',
410 'mw-ui-input mw-ui-input-inline createboxInput',
411 'value' => $this->mDefaultText,
412 'placeholder' => $this->mPlaceholderText,
413 'size' => $this->mWidth,
414 'dir' => $this->mDir,
422 'class' =>
'mw-ui-button mw-ui-progressive createboxButton',
423 'value' => $this->mButtonLabel
439 if ( !$this->mButtonLabel ) {
440 $this->mButtonLabel =
wfMessage(
'inputbox-movearticle' )->text();
445 'class' =>
'mw-inputbox-centered',
449 $moveBoxParams =
array(
451 'class' =>
'mw-movebox',
455 if ( $this->mID !==
'' ) {
456 $moveBoxParams[
'id'] = Sanitizer::escapeId( $this->mID );
460 $htmlOut .=
Html::hidden(
'wpReason', $this->mSummary );
464 'type' => $this->mHidden ?
'hidden' :
'text',
465 'name' =>
'wpNewTitle',
466 'class' => $this->
getLinebreakClasses() .
'mw-moveboxInput mw-ui-input mw-ui-input-inline',
467 'value' => $this->mDefaultText,
468 'placeholder' => $this->mPlaceholderText,
469 'size' => $this->mWidth,
470 'dir' => $this->mDir,
477 'class' =>
'mw-ui-button mw-ui-progressive',
478 'value' => $this->mButtonLabel
494 if ( !$this->mButtonLabel ) {
495 $this->mButtonLabel =
wfMessage(
'inputbox-postcommenttitle' )->text();
500 'class' =>
'mw-inputbox-centered',
504 $commentFormParams =
array(
505 'name' =>
'commentbox',
506 'class' =>
'commentbox',
510 if ( $this->mID !==
'' ) {
511 $commentFormParams[
'id'] = Sanitizer::escapeId( $this->mID );
515 $htmlOut .=
Html::hidden( $editArgs[
'name'], $editArgs[
'value'] );
517 foreach ( $this->mPreloadparams
as $preloadparams ) {
518 $htmlOut .=
Html::hidden(
'preloadparams[]', $preloadparams );
520 $htmlOut .=
Html::hidden(
'editintro', $this->mEditIntro );
523 'type' => $this->mHidden ?
'hidden' :
'text',
524 'name' =>
'preloadtitle',
525 'class' => $this->
getLinebreakClasses() .
'commentboxInput mw-ui-input mw-ui-input-inline',
526 'value' => $this->mDefaultText,
527 'placeholder' => $this->mPlaceholderText,
528 'size' => $this->mWidth,
529 'dir' => $this->mDir,
539 'class' =>
'mw-ui-button mw-ui-progressive',
540 'value' => $this->mButtonLabel
558 foreach ( explode(
"\n", $text )
as $line ) {
559 if ( strpos(
$line,
'=' ) ===
false )
563 $value = Sanitizer::decodeCharReferences( trim(
$value ) );
564 if (
$name ==
'preloadparams[]' ) {
566 $this->mPreloadparams[] =
$value;
573 if ( isset( $values[
'dir'] ) && !in_array( $values[
'dir'],
array(
'ltr',
'rtl' ) ) ) {
574 unset( $values[
'dir'] );
581 'preload' =>
'mPreload',
583 'editintro' =>
'mEditIntro',
585 'summary' =>
'mSummary',
586 'nosummary' =>
'mNosummary',
589 'default' =>
'mDefaultText',
590 'placeholder' =>
'mPlaceholderText',
591 'bgcolor' =>
'mBGColor',
592 'buttonlabel' =>
'mButtonLabel',
593 'searchbuttonlabel' =>
'mSearchButtonLabel',
594 'fulltextbutton' =>
'mFullTextButton',
595 'namespaces' =>
'mNamespaces',
596 'labeltext' =>
'mLabelText',
597 'hidden' =>
'mHidden',
599 'inline' =>
'mInline',
600 'prefix' =>
'mPrefix',
604 if ( isset( $values[
$name] ) ) {
605 $this->$var = $values[
$name];
610 $this->mBR = ( strtolower( $this->mBR ) ==
"no" ) ?
' ' :
'<br />';
613 $this->mWidth = intval( $this->mWidth <= 0 ? 50 : $this->mWidth );
617 $this->mBGColor =
'transparent';
628 \# [0-9
a-f]{3} | #
short hexadecimal
629 \# [0-9
a-f]{6} | #
long hexadecimal
631 \d+ \s* , \s* \d+ \s* , \s* \d+ | # rgb integer
632 [0-9.]+% \s* , \s* [0-9.]+% \s* , \s* [0-9.]+% # rgb percent
636 return (
bool) preg_match( $regex, $color );
640 if ( $this->mBGColor !=
'transparent' ) {
641 return 'background-color: ' . $this->mBGColor .
';';