Use OOUI HTMLForm for Special:Watchlist
[lhc/web/wiklou.git] / includes / htmlform / HTMLAdvancedSelectNamespace.php
1 <?php
2 /**
3 * Creates a Html::namespaceSelector input field with a button assigned to the input field.
4 * @since 1.26
5 */
6 class HTMLAdvancedSelectNamespace extends HTMLSelectNamespace {
7 function getInputHTML( $value ) {
8 $allValue = ( isset( $this->mParams['all'] ) ? $this->mParams['all'] : '' );
9
10 return parent::getInputHTML( $value ) . '&#160;' .
11 Xml::checkLabel(
12 $this->msg( 'invert' )->text(),
13 $this->mParams['invertname'],
14 $this->mParams['invertid'],
15 $this->mParams['invertdefault'],
16 array( 'title' => $this->msg( 'tooltip-invert' )->text() )
17 ) . '&#160;' .
18 Xml::checkLabel(
19 $this->msg( 'namespace_association' )->text(),
20 $this->mParams['associatedname'],
21 $this->mParams['associatedid'],
22 $this->mParams['associateddefault'],
23 array( 'title' => $this->msg( 'tooltip-namespace_association' )->text() )
24 );
25 }
26
27 /**
28 * Get the OOUI version of this field.
29 * @since 1.26
30 * @param string $value
31 * @return MediaWiki\\Widget\\NamespaceInputWidget A layout with all widget.
32 */
33 public function getInputOOUI( $value ) {
34 # There are more fields in this Widget as only one, so there are more values instead of only once.
35 # Filter the data from the request before creating the form to set the correct values to the
36 # Widget elements.
37 # Get WebRequest only, if there is an instance of HTMLForm, use default data instead
38 $invertdefault = false;
39 $associateddefault = false;
40 if ( $this->mParent instanceof HTMLForm ) {
41 $request = $this->mParent->getRequest();
42 if ( $request->getCheck( $this->mParams['associatedname'] ) ) {
43 $associateddefault = true;
44 }
45 if ( $request->getCheck( $this->mParams['invertname'] ) ) {
46 $invertdefault = true;
47 }
48 }
49
50 // Unsupported: invertid, associatedid
51 return new MediaWiki\Widget\NamespaceInputWidget( array(
52 'valueNamespace' => $value,
53 'nameNamespace' => $this->mName,
54 'id' => $this->mID,
55 'includeAllValue' => $this->mAllValue,
56 'nameInvert' => $this->mParams['invertname'],
57 'labelInvert' => $this->msg( 'invert' )->text(),
58 'valueInvert' => $invertdefault,
59 'nameAssociated' => $this->mParams['associatedname'],
60 'valueAssociated' => $associateddefault,
61 'labelAssociated' => $this->msg( 'namespace_association' )->text(),
62 ) );
63 }
64 }