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( array( 'ext.inputBox.styles', 'mediawiki.ui.input', 'mediawiki.ui.checkbox', ) ); } public function render() { // Handle various types switch ( $this->mType ) { case 'create': case 'comment': $this->mParser->getOutput()->addModules( 'ext.inputBox' ); 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: return Xml::tags( 'div', null, Xml::element( 'strong', array( 'class' => 'error' ), strlen( $this->mType ) > 0 ? wfMessage( 'inputbox-error-bad-type', $this->mType )->text() : wfMessage( 'inputbox-error-no-type' )->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 = array( 'name' => 'action', 'value' => 'edit', ); // check, if VE is installed and VE editor is requested if ( ExtensionRegistry::getInstance()->isLoaded( 'VisualEditor' ) && $this->mUseVE ) { $args = array( '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 $type * @return string HTML */ public function getSearchForm( $type ) { global $wgContLang, $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 = array( 'id' => Sanitizer::escapeId( $this->mID ) ); } else { $idArray = array(); } // We need a unqiue id to link