+
+ /**
+ * This function should be overridden to return the names of secondary columns
+ * to order by in addition to the column in getIndexField(). These fields will
+ * not be used in the pager offset or in any links for users.
+ *
+ * If getIndexField() returns an array of 'querykey' => 'indexfield' pairs then
+ * this must return a corresponding array of 'querykey' => array( fields...) pairs
+ * in order for a request with &count=querykey to use array( fields...) to sort.
+ *
+ * This is useful for pagers that GROUP BY a unique column (say page_id)
+ * and ORDER BY another (say page_len). Using GROUP BY and ORDER BY both on
+ * page_len,page_id avoids temp tables (given a page_len index). This would
+ * also work if page_id was non-unique but we had a page_len,page_id index.
+ *
+ * @return Array
+ */
+ protected function getExtraSortFields() { return array(); }
+
+ /**
+ * Return the default sorting direction: false for ascending, true for de-
+ * scending. You can also have an associative array of ordertype => dir,
+ * if multiple order types are supported. In this case getIndexField()
+ * must return an array, and the keys of that must exactly match the keys
+ * of this.
+ *
+ * For backward compatibility, this method's return value will be ignored
+ * if $this->mDefaultDirection is already set when the constructor is
+ * called, for instance if it's statically initialized. In that case the
+ * value of that variable (which must be a boolean) will be used.
+ *
+ * Note that despite its name, this does not return the value of the
+ * $this->mDefaultDirection member variable. That's the default for this
+ * particular instantiation, which is a single value. This is the set of
+ * all defaults for the class.
+ *
+ * @return Boolean
+ */
+ protected function getDefaultDirections() { return false; }
+}
+
+
+/**
+ * IndexPager with an alphabetic list and a formatted navigation bar
+ * @ingroup Pager
+ */
+abstract class AlphabeticPager extends IndexPager {
+ /**
+ * Shamelessly stolen bits from ReverseChronologicalPager,
+ * didn't want to do class magic as may be still revamped
+ */
+ function getNavigationBar() {
+ if ( !$this->isNavigationBarShown() ) return '';
+
+ if( isset( $this->mNavigationBar ) ) {
+ return $this->mNavigationBar;
+ }
+
+ $lang = $this->getLang();
+
+ $opts = array( 'parsemag', 'escapenoentities' );
+ $linkTexts = array(
+ 'prev' => wfMsgExt(
+ 'prevn',
+ $opts,
+ $lang->formatNum( $this->mLimit )
+ ),
+ 'next' => wfMsgExt(
+ 'nextn',
+ $opts,
+ $lang->formatNum($this->mLimit )
+ ),
+ 'first' => wfMsgExt( 'page_first', $opts ),
+ 'last' => wfMsgExt( 'page_last', $opts )
+ );
+
+ $pagingLinks = $this->getPagingLinks( $linkTexts );
+ $limitLinks = $this->getLimitLinks();
+ $limits = $lang->pipeList( $limitLinks );
+
+ $this->mNavigationBar =
+ "(" . $lang->pipeList(
+ array( $pagingLinks['first'],
+ $pagingLinks['last'] )
+ ) . ") " .
+ wfMsgHtml( 'viewprevnext', $pagingLinks['prev'],
+ $pagingLinks['next'], $limits );
+
+ if( !is_array( $this->getIndexField() ) ) {
+ # Early return to avoid undue nesting
+ return $this->mNavigationBar;
+ }
+
+ $extra = '';
+ $first = true;
+ $msgs = $this->getOrderTypeMessages();
+ foreach( array_keys( $msgs ) as $order ) {
+ if( $first ) {
+ $first = false;
+ } else {
+ $extra .= wfMsgExt( 'pipe-separator' , 'escapenoentities' );
+ }
+
+ if( $order == $this->mOrderType ) {
+ $extra .= wfMsgHTML( $msgs[$order] );
+ } else {
+ $extra .= $this->makeLink(
+ wfMsgHTML( $msgs[$order] ),
+ array( 'order' => $order )
+ );
+ }
+ }
+
+ if( $extra !== '' ) {
+ $this->mNavigationBar .= " ($extra)";
+ }
+
+ return $this->mNavigationBar;
+ }
+
+ /**
+ * If this supports multiple order type messages, give the message key for
+ * enabling each one in getNavigationBar. The return type is an associa-
+ * tive array whose keys must exactly match the keys of the array returned
+ * by getIndexField(), and whose values are message keys.
+ *
+ * @return Array
+ */
+ protected function getOrderTypeMessages() {
+ return null;
+ }