Fix for r85114, see code reviev
[lhc/web/wiklou.git] / includes / Pager.php
index 2d8be23..9028f0e 100644 (file)
@@ -51,7 +51,7 @@ interface Pager {
  *
  *  Subclassing the pager to implement concrete functionality should be fairly
  *  simple, please see the examples in HistoryPage.php and
- *  SpecialIpblocklist.php. You just need to override formatRow(),
+ *  SpecialBlockList.php. You just need to override formatRow(),
  *  getQueryInfo() and getIndexField(). Don't forget to call the parent
  *  constructor if you override it.
  *
@@ -164,7 +164,7 @@ abstract class IndexPager implements Pager {
        }
 
        /**
-        * Return the result wrapper.
+        * @return ResultWrapper The result wrapper.
         */
        function getResult() {
                return $this->mResult;
@@ -815,7 +815,7 @@ abstract class TablePager extends IndexPager {
                $tableClass = htmlspecialchars( $this->getTableClass() );
                $sortClass = htmlspecialchars( $this->getSortHeaderClass() );
 
-               $s = "<table border='1' class=\"$tableClass\"><thead><tr>\n";
+               $s = "<table style='border:1;' class=\"$tableClass\"><thead><tr>\n";
                $fields = $this->getFieldNames();
 
                # Make table header
@@ -899,7 +899,13 @@ abstract class TablePager extends IndexPager {
         * @return Associative array
         */
        function getRowAttrs( $row ) {
-               return array( 'class' => $this->getRowClass( $row ) );
+               $class = $this->getRowClass( $row );
+               if ( $class === '' ) {
+                       // Return an empty array to avoid clutter in HTML like class=""
+                       return array();
+               } else {
+                       return array( 'class' => $this->getRowClass( $row ) );
+               }
        }
 
        /**
@@ -937,7 +943,9 @@ abstract class TablePager extends IndexPager {
        function getNavigationBar() {
                global $wgStylePath, $wgContLang;
 
-               if ( !$this->isNavigationBarShown() ) return '';
+               if ( !$this->isNavigationBarShown() ) {
+                       return '';
+               }
 
                $path = "$wgStylePath/common/images";
                $labels = array(
@@ -974,10 +982,10 @@ abstract class TablePager extends IndexPager {
                $links = $this->getPagingLinks( $linkTexts, $disabledTexts );
 
                $navClass = htmlspecialchars( $this->getNavClass() );
-               $s = "<table class=\"$navClass\" align=\"center\" cellpadding=\"3\"><tr>\n";
-               $cellAttrs = 'valign="top" align="center" width="' . 100 / count( $links ) . '%"';
+               $s = "<table class=\"$navClass\"><tr>\n";
+               $width = 100 / count( $links ) . '%';
                foreach ( $labels as $type => $label ) {
-                       $s .= "<td $cellAttrs>{$links[$type]}</td>\n";
+                       $s .= "<td style='width:$width;'>{$links[$type]}</td>\n";
                }
                $s .= "</tr></table>\n";
                return $s;
@@ -1045,20 +1053,26 @@ abstract class TablePager extends IndexPager {
        function getLimitForm() {
                global $wgScript;
 
+               return Xml::openElement(
+                       'form',
+                       array(
+                               'method' => 'get',
+                               'action' => $wgScript
+                       ) ) . "\n" . $this->getLimitDropdown() . "</form>\n";
+       }
+
+       /**
+        * Gets a limit selection dropdown
+        *
+        * @return string
+        */
+       function getLimitDropdown() {
                # Make the select with some explanatory text
                $msgSubmit = wfMsgHtml( 'table_pager_limit_submit' );
-               return
-                       Xml::openElement(
-                               'form',
-                               array(
-                                       'method' => 'get',
-                                       'action' => $wgScript
-                               )
-                       ) . "\n" .
-                       wfMsgHtml( 'table_pager_limit', $this->getLimitSelect() ) .
+
+               return wfMsgHtml( 'table_pager_limit', $this->getLimitSelect() ) .
                        "\n<input type=\"submit\" value=\"$msgSubmit\"/>\n" .
-                       $this->getHiddenFields( array( 'limit' ) ) .
-                       "</form>\n";
+                       $this->getHiddenFields( array( 'limit' ) );
        }
 
        /**