Merge "profileinfo: Suppress frivolous warning about usort callback"
[lhc/web/wiklou.git] / includes / specials / SpecialEditTags.php
index f41a1f1..6545541 100644 (file)
@@ -123,7 +123,7 @@ class SpecialEditTags extends UnlistedSpecialPage {
 
                // Either submit or create our form
                if ( $this->isAllowed && $this->submitClicked ) {
-                       $this->submit( $request );
+                       $this->submit();
                } else {
                        $this->showForm();
                }
@@ -275,6 +275,7 @@ class SpecialEditTags extends UnlistedSpecialPage {
        protected function buildCheckBoxes() {
                // If there is just one item, provide the user with a multi-select field
                $list = $this->getList();
+               $tags = array();
                if ( $list->length() == 1 ) {
                        $list->reset();
                        $tags = $list->current()->getTags();
@@ -295,14 +296,9 @@ class SpecialEditTags extends UnlistedSpecialPage {
                        $html .= '</td></tr>';
                        $tagSelect = $this->getTagSelect( $tags, $this->msg( 'tags-edit-new-tags' )->plain() );
                        $html .= '<tr><td>' . $tagSelect[0] . '</td><td>' . $tagSelect[1];
-                       // also output the tags currently applied as a hidden form field, so we
-                       // know what to remove from the revision/log entry when the form is submitted
-                       $html .= Html::hidden( 'wpExistingTags', implode( ',', $tags ) );
-                       $html .= '</td></tr></table>';
                } else {
                        // Otherwise, use a multi-select field for adding tags, and a list of
                        // checkboxes for removing them
-                       $tags = array();
 
                        // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
                        for ( $list->reset(); $list->current(); $list->next() ) {
@@ -328,9 +324,13 @@ class SpecialEditTags extends UnlistedSpecialPage {
                                                'class' => 'mw-edittags-remove-checkbox',
                                        ) );
                        }
-                       $html .= '</td></tr></table>';
                }
 
+               // also output the tags currently applied as a hidden form field, so we
+               // know what to remove from the revision/log entry when the form is submitted
+               $html .= Html::hidden( 'wpExistingTags', implode( ',', $tags ) );
+               $html .= '</td></tr></table>';
+
                return $html;
        }
 
@@ -349,20 +349,18 @@ class SpecialEditTags extends UnlistedSpecialPage {
        protected function getTagSelect( $selectedTags, $label ) {
                $result = array();
                $result[0] = Xml::label( $label, 'mw-edittags-tag-list' );
-               $result[1] = Xml::openElement( 'select', array(
-                       'name' => 'wpTagList[]',
-                       'id' => 'mw-edittags-tag-list',
-                       'multiple' => 'multiple',
-                       'size' => '8',
-               ) );
+
+               $select = new XmlSelect( 'wpTagList[]', 'mw-edittags-tag-list', $selectedTags );
+               $select->setAttribute( 'multiple', 'multiple' );
+               $select->setAttribute( 'size', '8' );
 
                $tags = ChangeTags::listExplicitlyDefinedTags();
                $tags = array_unique( array_merge( $tags, $selectedTags ) );
-               foreach ( $tags as $tag ) {
-                       $result[1] .= Xml::option( $tag, $tag, in_array( $tag, $selectedTags ) );
-               }
 
-               $result[1] .= Xml::closeElement( 'select' );
+               // Values of $tags are also used as <option> labels
+               $select->addOptions( array_combine( $tags, $tags ) );
+
+               $result[1] = $select->getHTML();
                return $result;
        }