Merge "Mark constructors of IndexPager subclasses as public"
[lhc/web/wiklou.git] / includes / specials / pagers / AllMessagesTablePager.php
index cbcff5a..e3c0d6d 100644 (file)
@@ -276,7 +276,7 @@ class AllMessagesTablePager extends TablePager {
                return $result;
        }
 
-       function getStartBody() {
+       protected function getStartBody() {
                $tableClass = $this->getTableClass();
                return Xml::openElement( 'table', [
                        'class' => "mw-datatable $tableClass",
@@ -295,7 +295,11 @@ class AllMessagesTablePager extends TablePager {
                                <th>" .
                $this->msg( 'allmessagescurrent' )->escaped() .
                "</th>
-                       </tr></thead><tbody>\n";
+                       </tr></thead>\n";
+       }
+
+       function getEndBody() {
+               return Html::closeElement( 'table' );
        }
 
        function formatValue( $field, $value ) {
@@ -345,54 +349,49 @@ class AllMessagesTablePager extends TablePager {
                return '';
        }
 
+       /** @return string HTML */
        function formatRow( $row ) {
                // Do all the normal stuff
                $s = parent::formatRow( $row );
 
                // But if there's a customised message, add that too.
                if ( $row->am_customised ) {
-                       $s .= Xml::openElement( 'tr', $this->getRowAttrs( $row, true ) );
+                       $s .= Html::openElement( 'tr', $this->getRowAttrs( $row, true ) );
                        $formatted = strval( $this->formatValue( 'am_actual', $row->am_actual ) );
 
                        if ( $formatted === '' ) {
                                $formatted = "\u{00A0}";
                        }
 
-                       $s .= Xml::tags( 'td', $this->getCellAttrs( 'am_actual', $row->am_actual ), $formatted )
-                               . "</tr>\n";
+                       $s .= Html::element( 'td', $this->getCellAttrs( 'am_actual', $row->am_actual ), $formatted )
+                               . Html::closeElement( 'tr' );
                }
 
-               return $s;
+               return Html::rawElement( 'tbody', [], $s );
        }
 
-       function getRowAttrs( $row, $isSecond = false ) {
-               $arr = [];
-
-               if ( $row->am_customised ) {
-                       $arr['class'] = 'allmessages-customised';
-               }
-
-               if ( !$isSecond ) {
-                       $arr['id'] = Sanitizer::escapeIdForAttribute(
-                               'msg_' . $this->getLanguage()->lcfirst( $row->am_title )
-                       );
-               }
-
-               return $arr;
+       function getRowAttrs( $row ) {
+               return [];
        }
 
+       /** @return array HTML attributes */
        function getCellAttrs( $field, $value ) {
-               if ( $this->mCurrentRow->am_customised && $field === 'am_title' ) {
-                       return [ 'rowspan' => '2', 'class' => $field ];
-               } elseif ( $field === 'am_title' ) {
-                       return [ 'class' => $field ];
+               $attr = [];
+               if ( $field === 'am_title' ) {
+                       if ( $this->mCurrentRow->am_customised ) {
+                               $attr += [ 'rowspan' => '2' ];
+                       }
                } else {
-                       return [
+                       $attr += [
                                'lang' => $this->lang->getHtmlCode(),
                                'dir' => $this->lang->getDir(),
-                               'class' => $field
                        ];
+                       if ( $this->mCurrentRow->am_customised ) {
+                               // CSS class: am_default, am_actual
+                               $attr += [ 'class' => $field ];
+                       }
                }
+               return $attr;
        }
 
        // This is not actually used, as getStartBody is overridden above