]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - includes/htmlform/fields/HTMLTagFilter.php
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / includes / htmlform / fields / HTMLTagFilter.php
diff --git a/includes/htmlform/fields/HTMLTagFilter.php b/includes/htmlform/fields/HTMLTagFilter.php
new file mode 100644 (file)
index 0000000..38f9a0a
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Wrapper for ChangeTags::buildTagFilterSelector to use in HTMLForm
+ */
+class HTMLTagFilter extends HTMLFormField {
+       protected $tagFilter;
+
+       public function getTableRow( $value ) {
+               $this->tagFilter = ChangeTags::buildTagFilterSelector(
+                       $value, false, $this->mParent->getContext() );
+               if ( $this->tagFilter ) {
+                       return parent::getTableRow( $value );
+               }
+               return '';
+       }
+
+       public function getDiv( $value ) {
+               $this->tagFilter = ChangeTags::buildTagFilterSelector(
+                       $value, false, $this->mParent->getContext() );
+               if ( $this->tagFilter ) {
+                       return parent::getDiv( $value );
+               }
+               return '';
+       }
+
+       public function getOOUI( $value ) {
+               $this->tagFilter = ChangeTags::buildTagFilterSelector(
+                       $value, true, $this->mParent->getContext() );
+               if ( $this->tagFilter ) {
+                       return parent::getOOUI( $value );
+               }
+               return new OOUI\FieldLayout( new OOUI\Widget() );
+       }
+
+       public function getInputHTML( $value ) {
+               if ( $this->tagFilter ) {
+                       // we only need the select field, HTMLForm should handle the label
+                       return $this->tagFilter[1];
+               }
+               return '';
+       }
+
+       public function getInputOOUI( $value ) {
+               if ( $this->tagFilter ) {
+                       // we only need the select field, HTMLForm should handle the label
+                       return $this->tagFilter[1];
+               }
+               return '';
+       }
+}