Bugfis, making ?uselang=qqq an invalid language code, see
[lhc/web/wiklou.git] / includes / Pager.php
index 3125610..8faec53 100644 (file)
@@ -154,6 +154,26 @@ abstract class IndexPager implements Pager {
 
                wfProfileOut( $fname );
        }
+       
+       /**
+        * Return the result wrapper.
+        */
+       function getResult() {
+               return $this->mResult;
+       }
+       
+       /**
+        * Set the offset from an other source than $wgRequest
+        */
+       function setOffset( $offset ) {
+               $this->mOffset = $offset;
+       }
+       /**
+        * Set the limit from an other source than $wgRequest
+        */
+       function setLimit( $limit ) {
+               $this->mLimit = $limit;
+       }
 
        /**
         * Extract some useful data from the result object for use by
@@ -284,21 +304,18 @@ abstract class IndexPager implements Pager {
                if ( $query === null ) {
                        return $text;
                }
-               if( $type == 'prev' || $type == 'next' ) {
-                       $attrs = "rel=\"$type\"";
-               } elseif( $type == 'first' ) {
-                       $attrs = "rel=\"start\"";
-               } else {
-                       # HTML 4 has no rel="end" . . .
-                       $attrs = '';
+
+               $attrs = array();
+               if( in_array( $type, array( 'first', 'prev', 'next', 'last' ) ) ) {
+                       # HTML5 rel attributes
+                       $attrs['rel'] = $type;
                }
 
                if( $type ) {
-                       $attrs .= " class=\"mw-{$type}link\"" ;
+                       $attrs['class'] = "mw-{$type}link";
                }
-               return $this->getSkin()->makeKnownLinkObj( $this->getTitle(), $text,
-                               wfArrayToCGI( $query, $this->getDefaultQuery() ), '', '',
-                               $attrs );
+               return $this->getSkin()->link( $this->getTitle(), $text,
+                       $attrs, $query + $this->getDefaultQuery(), array('noclasses','known') );
        }
 
        /**
@@ -513,10 +530,10 @@ abstract class AlphabeticPager extends IndexPager {
 
                $pagingLinks = $this->getPagingLinks( $linkTexts );
                $limitLinks = $this->getLimitLinks();
-               $limits = implode( ' | ', $limitLinks );
+               $limits = $wgLang->pipeList( $limitLinks );
 
                $this->mNavigationBar =
-                       "({$pagingLinks['first']} | {$pagingLinks['last']}) " .
+                       "(" . $wgLang->pipeList( array( $pagingLinks['first'], $pagingLinks['last'] ) ) . ") " .
                        wfMsgHtml( 'viewprevnext', $pagingLinks['prev'],
                        $pagingLinks['next'], $limits );
 
@@ -532,7 +549,7 @@ abstract class AlphabeticPager extends IndexPager {
                        if( $first ) {
                                $first = false;
                        } else {
-                               $extra .= ' | ';
+                               $extra .= wfMsgExt( 'pipe-separator' , 'escapenoentities' );
                        }
 
                        if( $order == $this->mOrderType ) {
@@ -593,9 +610,9 @@ abstract class ReverseChronologicalPager extends IndexPager {
 
                $pagingLinks = $this->getPagingLinks( $linkTexts );
                $limitLinks = $this->getLimitLinks();
-               $limits = implode( ' | ', $limitLinks );
+               $limits = $wgLang->pipeList( $limitLinks );
 
-               $this->mNavigationBar = "({$pagingLinks['first']} | {$pagingLinks['last']}) " .
+               $this->mNavigationBar = "({$pagingLinks['first']}" . wfMsgExt( 'pipe-separator' , 'escapenoentities' ) . "{$pagingLinks['last']}) " .
                        wfMsgHtml("viewprevnext", $pagingLinks['prev'], $pagingLinks['next'], $limits);
                return $this->mNavigationBar;
        }
@@ -728,7 +745,8 @@ abstract class TablePager extends IndexPager {
        }
 
        function formatRow( $row ) {
-               $s = "<tr>\n";
+               $rowClass = $this->getRowClass( $row );
+               $s = "<tr class=\"$rowClass\">\n";
                $fieldNames = $this->getFieldNames();
                $this->mCurrentRow = $row;  # In case formatValue needs to know
                foreach ( $fieldNames as $field => $name ) {
@@ -744,6 +762,10 @@ abstract class TablePager extends IndexPager {
                return $s;
        }
 
+       function getRowClass($row) {
+               return '';
+       }
+
        function getIndexField() {
                return $this->mSort;
        }
@@ -850,7 +872,7 @@ abstract class TablePager extends IndexPager {
                        "<form method=\"get\" action=\"$url\">" .
                        wfMsgHtml( 'table_pager_limit', $this->getLimitSelect() ) .
                        "\n<input type=\"submit\" value=\"$msgSubmit\"/>\n" .
-                       $this->getHiddenFields( 'limit' ) .
+                       $this->getHiddenFields( array('limit','title') ) .
                        "</form>\n";
        }