40 parent::__construct( $params );
44 if ( $this->mParams[
'interwiki'] && $this->mParams[
'relative'] ) {
47 throw new InvalidArgumentException(
'relative and interwiki may not be used together' );
50 if ( $value ===
null ) {
54 if ( !$this->mParams[
'required'] && $value ===
'' ) {
56 return parent::validate( $value, $alldata );
59 $titleFactory = MediaWikiServices::getInstance()->getTitleFactory();
61 if ( !$this->mParams[
'relative'] ) {
62 $title = $titleFactory->newFromTextThrow( $value );
65 $title = $titleFactory->newFromTextThrow( Title::makeName( $this->mParams[
'namespace'], $value ) );
71 if ( $title->isExternal() ) {
72 if ( $this->mParams[
'interwiki'] ) {
74 return parent::validate( $value, $alldata );
76 return $this->
msg(
'htmlform-title-interwiki', $title->getPrefixedText() );
80 $text = $title->getPrefixedText();
81 if ( $this->mParams[
'namespace'] !==
false &&
82 !$title->inNamespace( $this->mParams[
'namespace'] )
84 return $this->
msg(
'htmlform-title-badnamespace', $text, $this->mParams[
'namespace'] );
87 if ( $this->mParams[
'creatable'] && !$title->canExist() ) {
88 return $this->
msg(
'htmlform-title-not-creatable', $text );
91 if ( $this->mParams[
'exists'] && !$title->exists() ) {
92 return $this->
msg(
'htmlform-title-not-exists', $text );
95 return parent::validate( $value, $alldata );
99 if ( $this->mParams[
'namespace'] !==
false ) {
100 $params[
'namespace'] = $this->mParams[
'namespace'];
102 $params[
'relative'] = $this->mParams[
'relative'];
112 return [
'mediawiki.widgets' ];
117 $this->mClass .=
'mw-searchInput';
120 return parent::getInputHTML( $value );
126 'wrapAsLink' =>
false,
Implements a text input field for page titles.
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...
getDataAttribs()
Returns an array of data-* attributes to add to the field.
validate( $value, $alldata)
Override this function to add specific validation checks on the field input.
shouldInfuseOOUI()
Whether the field should be automatically infused.