*/
function wfShowingResults( $offset, $limit ) {
global $wgLang;
- return wfMsgExt( 'showingresults', array( 'parseinline' ), $wgLang->formatNum( $limit ), $wgLang->formatNum( $offset+1 ) );
+ return wfMsgExt( 'showingresults', array( 'parseinline' ), $wgLang->formatNum( $limit ),
+ $wgLang->formatNum( $offset+1 ) );
}
/**
*/
function wfShowingResultsNum( $offset, $limit, $num ) {
global $wgLang;
- return wfMsgExt( 'showingresultsnum', array( 'parseinline' ), $wgLang->formatNum( $limit ), $wgLang->formatNum( $offset+1 ), $wgLang->formatNum( $num ) );
+ return wfMsgExt( 'showingresultsnum', array( 'parseinline' ), $wgLang->formatNum( $limit ),
+ $wgLang->formatNum( $offset+1 ), $wgLang->formatNum( $num ) );
}
/**
- * @todo document
+ * Generate (prev x| next x) (20|50|100...) type links for paging
+ * @param $offset string
+ * @param $limit int
+ * @param $link string
+ * @param $query string, optional URL query parameter string
+ * @param $atend bool, optional param for specified if this is the last page
*/
function wfViewPrevNext( $offset, $limit, $link, $query = '', $atend = false ) {
global $wgLang;
$fmtLimit = $wgLang->formatNum( $limit );
- $prev = wfMsg( 'prevn', $fmtLimit );
- $next = wfMsg( 'nextn', $fmtLimit );
-
+ # Get prev/next link display text
+ $prev = wfMsgHtml( 'prevn', $fmtLimit );
+ $next = wfMsgHtml( 'nextn', $fmtLimit );
+ # Get prev/next link title text
+ $pTitle = wfMsgExt( 'prevn-title', array('parsemag','escape'), $fmtLimit );
+ $nTitle = wfMsgExt( 'nextn-title', array('parsemag','escape'), $fmtLimit );
+ # Fetch the title object
if( is_object( $link ) ) {
$title =& $link;
} else {
return false;
}
}
-
- if ( 0 != $offset ) {
+ # Make 'previous' link
+ if( 0 != $offset ) {
$po = $offset - $limit;
- if ( $po < 0 ) { $po = 0; }
+ $po = max($po,0);
$q = "limit={$limit}&offset={$po}";
- if ( '' != $query ) { $q .= '&'.$query; }
- $plink = '<a href="' . $title->escapeLocalUrl( $q ) . "\" class=\"mw-prevlink\">{$prev}</a>";
- } else { $plink = $prev; }
-
+ if( $query != '' ) {
+ $q .= '&'.$query;
+ }
+ $plink = '<a href="' . $title->escapeLocalUrl( $q ) . "\" title=\"{$pTitle}\" class=\"mw-prevlink\">{$prev}</a>";
+ } else {
+ $plink = $prev;
+ }
+ # Make 'next' link
$no = $offset + $limit;
- $q = 'limit='.$limit.'&offset='.$no;
- if ( '' != $query ) { $q .= '&'.$query; }
-
- if ( $atend ) {
+ $q = "limit={$limit}&offset={$no}";
+ if( $query != '' ) {
+ $q .= '&'.$query;
+ }
+ if( $atend ) {
$nlink = $next;
} else {
- $nlink = '<a href="' . $title->escapeLocalUrl( $q ) . "\" class=\"mw-nextlink\">{$next}</a>";
- }
- $nums = $wgLang->pipeList( array( wfNumLink( $offset, 20, $title, $query ),
- wfNumLink( $offset, 50, $title, $query ),
- wfNumLink( $offset, 100, $title, $query ),
- wfNumLink( $offset, 250, $title, $query ),
- wfNumLink( $offset, 500, $title, $query ) ) );
-
+ $nlink = '<a href="' . $title->escapeLocalUrl( $q ) . "\" title=\"{$nTitle}\" class=\"mw-nextlink\">{$next}</a>";
+ }
+ # Make links to set number of items per page
+ $nums = $wgLang->pipeList( array(
+ wfNumLink( $offset, 20, $title, $query ),
+ wfNumLink( $offset, 50, $title, $query ),
+ wfNumLink( $offset, 100, $title, $query ),
+ wfNumLink( $offset, 250, $title, $query ),
+ wfNumLink( $offset, 500, $title, $query )
+ ) );
return wfMsg( 'viewprevnext', $plink, $nlink, $nums );
}
/**
- * @todo document
+ * Generate links for (20|50|100...) items-per-page links
+ * @param $offset string
+ * @param $limit int
+ * @param $title Title
+ * @param $query string, optional URL query parameter string
*/
-function wfNumLink( $offset, $limit, &$title, $query = '' ) {
+function wfNumLink( $offset, $limit, $title, $query = '' ) {
global $wgLang;
- if ( '' == $query ) { $q = ''; }
- else { $q = $query.'&'; }
- $q .= 'limit='.$limit.'&offset='.$offset;
-
+ if( $query == '' ) {
+ $q = '';
+ } else {
+ $q = $query.'&';
+ }
+ $q .= "limit={$limit}&offset={$offset}";
$fmtLimit = $wgLang->formatNum( $limit );
- $s = '<a href="' . $title->escapeLocalUrl( $q ) . "\" class=\"mw-numlink\">{$fmtLimit}</a>";
+ $lTitle = wfMsgExt('shown-title',array('parsemag','escape'),$limit);
+ $s = '<a href="' . $title->escapeLocalUrl( $q ) . "\" title=\"{$lTitle}\" class=\"mw-numlink\">{$fmtLimit}</a>";
return $s;
}