false, 'creatable' => false, 'exists' => false, ); parent::__construct( $params ); } public function validate( $value, $alldata ) { try { $title = Title::newFromTextThrow( $value ); } catch ( MalformedTitleException $e ) { $msg = $this->msg( $e->getErrorMessage() ); $params = $e->getErrorMessageParameters(); if ( $params ) { $msg->params( $params ); } return $msg->parse(); } $text = $title->getPrefixedText(); if ( $this->mParams['namespace'] !== false && !$title->inNamespace( $this->mParams['namespace'] ) ) { return $this->msg( 'htmlform-title-badnamespace', $this->mParams['namespace'], $text )->parse(); } if ( $this->mParams['creatable'] && !$title->canExist() ) { return $this->msg( 'htmlform-title-not-creatable', $text )->escaped(); } if ( $this->mParams['exists'] && !$title->exists() ) { return $this->msg( 'htmlform-title-not-exists', $text )->parse(); } return parent::validate( $value, $alldata ); } protected function getInputWidget( $params ) { $this->mParent->getOutput()->addModules( 'mediawiki.widgets' ); if ( $this->mParams['namespace'] !== false ) { $params['namespace'] = $this->mParams['namespace']; } $params['relative'] = false; return new TitleInputWidget( $params ); } }