X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/includes/pager/AlphabeticPager.php diff --git a/includes/pager/AlphabeticPager.php b/includes/pager/AlphabeticPager.php new file mode 100644 index 00000000..54036eb8 --- /dev/null +++ b/includes/pager/AlphabeticPager.php @@ -0,0 +1,108 @@ +isNavigationBarShown() ) { + return ''; + } + + if ( isset( $this->mNavigationBar ) ) { + return $this->mNavigationBar; + } + + $linkTexts = [ + 'prev' => $this->msg( 'prevn' )->numParams( $this->mLimit )->escaped(), + 'next' => $this->msg( 'nextn' )->numParams( $this->mLimit )->escaped(), + 'first' => $this->msg( 'page_first' )->escaped(), + 'last' => $this->msg( 'page_last' )->escaped() + ]; + + $lang = $this->getLanguage(); + + $pagingLinks = $this->getPagingLinks( $linkTexts ); + $limitLinks = $this->getLimitLinks(); + $limits = $lang->pipeList( $limitLinks ); + + $this->mNavigationBar = $this->msg( 'parentheses' )->rawParams( + $lang->pipeList( [ $pagingLinks['first'], + $pagingLinks['last'] ] ) )->escaped() . " " . + $this->msg( 'viewprevnext' )->rawParams( $pagingLinks['prev'], + $pagingLinks['next'], $limits )->escaped(); + + 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 .= $this->msg( 'pipe-separator' )->escaped(); + } + + if ( $order == $this->mOrderType ) { + $extra .= $this->msg( $msgs[$order] )->escaped(); + } else { + $extra .= $this->makeLink( + $this->msg( $msgs[$order] )->escaped(), + [ 'order' => $order ] + ); + } + } + + if ( $extra !== '' ) { + $extra = ' ' . $this->msg( 'parentheses' )->rawParams( $extra )->escaped(); + $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 associative + * 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; + } +}