mParser = $parser; // Default value for dir taken from the page language (bug 37018) $this->mDir = $this->mParser->getTargetLanguage()->getDir(); // Split caches by language, to make sure visitors do not see a cached // version in a random language (since labels are in the user language) $this->mParser->getOptions()->getUserLangObj(); $this->mParser->getOutput()->addModuleStyles( [ 'ext.inputBox.styles', 'mediawiki.ui.input', 'mediawiki.ui.checkbox', 'mediawiki.ui.button', ] ); } public function render() { // Handle various types switch ( $this->mType ) { case 'create': case 'comment': return $this->getCreateForm(); case 'move': return $this->getMoveForm(); case 'commenttitle': return $this->getCommentForm(); case 'search': return $this->getSearchForm( 'search' ); case 'fulltext': return $this->getSearchForm( 'fulltext' ); case 'search2': return $this->getSearchForm2(); default: $key = $this->mType === '' ? 'inputbox-error-no-type' : 'inputbox-error-bad-type'; return Xml::tags( 'div', null, Xml::element( 'strong', [ 'class' => 'error' ], wfMessage( $key, $this->mType )->text() ) ); } } /** * Returns the action name and value to use in inputboxes which redirects to edit pages. * Decides, if the link should redirect to VE edit page (veaction=edit) or to wikitext editor * (action=edit). * * @return array Array with name and value data */ private function getEditActionArgs() { // default is wikitext editor $args = [ 'name' => 'action', 'value' => 'edit', ]; // check, if VE is installed and VE editor is requested if ( $this->shouldUseVE() ) { $args = [ 'name' => 'veaction', 'value' => 'edit', ]; } return $args; } /** * Get common classes, that could be added and depend on, if * a line break between a button and an input field is added or not. * * @return string */ private function getLinebreakClasses() { return strtolower( $this->mBR ) === '
' ? 'mw-inputbox-input ' : ''; } /** * Generate search form * @param string $type * @return string HTML */ public function getSearchForm( $type ) { global $wgNamespaceAliases; // Use button label fallbacks if ( !$this->mButtonLabel ) { $this->mButtonLabel = wfMessage( 'inputbox-tryexact' )->text(); } if ( !$this->mSearchButtonLabel ) { $this->mSearchButtonLabel = wfMessage( 'inputbox-searchfulltext' )->text(); } if ( $this->mID !== '' ) { $idArray = [ 'id' => Sanitizer::escapeIdForAttribute( $this->mID ) ]; } else { $idArray = []; } // We need a unqiue id to link