* modified the parameters order in Language::viewPrevNext() in comparaison of wfViewPrevNext() and changed it to require a Title object and extra parameter to be passed as array
* Use more modern methods to genrate i18n and HTML
* Removed wfNumLink(), not used anymore, only referenced in a comment in MetavidWiki extension
* Inlinised wfShowingResults(); I don't see any reason why only this message should get its own function
* Replaced all calls to wfViewPrevNext() and wfShowingResults() in core
* Simply use OutputPage::addWikiMsg() to display 'specialpage-empty' message
* Moved wfSpecialList() near wfViewPrevNext() in GlobalFunction.php
* @param $query String: optional URL query parameter string
* @param $atend Bool: optional param for specified if this is the last page
* @return String
+ * @deprecated in 1.19; use Language::viewPrevNext() instead
*/
function wfViewPrevNext( $offset, $limit, $link, $query = '', $atend = false ) {
global $wgLang;
- $fmtLimit = $wgLang->formatNum( $limit );
- // @todo FIXME: Why on earth this needs one message for the text and another one for tooltip?
- # Get prev/next link display text
- $prev = wfMsgExt( 'prevn', array( 'parsemag', 'escape' ), $fmtLimit );
- $next = wfMsgExt( 'nextn', array( 'parsemag', 'escape' ), $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
+
+ $query = wfCgiToArray( $query );
+
if( is_object( $link ) ) {
- $title =& $link;
+ $title = $link;
} else {
$title = Title::newFromText( $link );
if( is_null( $title ) ) {
return false;
}
}
- # Make 'previous' link
- if( 0 != $offset ) {
- $po = $offset - $limit;
- $po = max( $po, 0 );
- $q = "limit={$limit}&offset={$po}";
- 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 ) {
- $nlink = $next;
- } else {
- $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 wfMsgHtml( 'viewprevnext', $plink, $nlink, $nums );
+
+ return $wgLang->viewPrevNext( $title, $offset, $limit, $query, $atend );
}
/**
- * Generate links for (20|50|100...) items-per-page links
+ * Make a list item, used by various special pages
*
- * @param $offset String
- * @param $limit Integer
- * @param $title Title
- * @param $query String: optional URL query parameter string
+ * @param $page String Page link
+ * @param $details String Text between brackets
+ * @param $oppositedm Boolean Add the direction mark opposite to your
+ * language, to display text properly
+ * @return String
+ * @deprecated since 1.19; use Language::specialList() instead
*/
-function wfNumLink( $offset, $limit, $title, $query = '' ) {
+function wfSpecialList( $page, $details, $oppositedm = true ) {
global $wgLang;
- if( $query == '' ) {
- $q = '';
- } else {
- $q = $query.'&';
- }
- $q .= "limit={$limit}&offset={$offset}";
- $fmtLimit = $wgLang->formatNum( $limit );
- $lTitle = wfMsgExt( 'shown-title', array( 'parsemag', 'escape' ), $limit );
- $s = '<a href="' . $title->escapeLocalURL( $q ) . "\" title=\"{$lTitle}\" class=\"mw-numlink\">{$fmtLimit}</a>";
- return $s;
+ return $wgLang->specialList( $page, $details, $oppositedm );
}
/**
return $func( $str, $needle ) !== false;
}
-/**
- * Make a list item, used by various special pages
- *
- * @param $page String Page link
- * @param $details String Text between brackets
- * @param $oppositedm Boolean Add the direction mark opposite to your
- * language, to display text properly
- * @return String
- * @deprecated since 1.19; use Language::specialList() instead
- */
-function wfSpecialList( $page, $details, $oppositedm = true ) {
- global $wgLang;
- return $wgLang->specialList( $page, $details, $oppositedm );
-}
-
/**
* Safety wrapper around ini_get() for boolean settings.
* The values returned from ini_get() are pre-normalized for settings
if ( $this->shownavigation ) {
$out->addHTML( $this->getPageHeader() );
if ( $this->numRows > 0 ) {
- $out->addHTML( '<p>' . wfShowingResults( $this->offset, $this->numRows ) . '</p>' );
+ $out->addHTML( $this->msg( 'showingresults' )->numParams(
+ $this->numRows, $this->offset + 1 )->parseAsBlock() );
# Disable the "next" link when we reach the end
- $paging = wfViewPrevNext( $this->offset, $this->limit,
- $this->getTitle( $par ),
- wfArrayToCGI( $this->linkParameters() ), ( $this->numRows < $this->limit ) );
+ $paging = $this->getLang()->viewPrevNext( $this->getTitle( $par ), $this->offset,
+ $this->limit, $this->linkParameters(), ( $this->numRows < $this->limit ) );
$out->addHTML( '<p>' . $paging . '</p>' );
} else {
# No results to show, so don't bother with "showing X of Y" etc.
# -- just let the user know and give up now
- $out->addHTML( '<p>' . wfMsgHtml( 'specialpage-empty' ) . '</p>' );
+ $out->addWikiMsg( 'specialpage-empty' );
$out->addHTML( Xml::closeElement( 'div' ) );
return;
}
}
function feedDesc() {
- return wfMsgExt( 'tagline', 'parsemag' );
+ return $this->msg( 'tagline' )->text();
}
function feedUrl() {
if( $num || $this->offset ) {
// Show the create link ahead
$this->showCreateLink( $t );
- $prevnext = wfViewPrevNext( $this->offset, $this->limit,
- SpecialPage::getTitleFor( 'Search' ),
- wfArrayToCGI( $this->powerSearchOptions(), array( 'search' => $term ) ),
+ $prevnext = $this->getLang()->viewPrevNext( $this->getTitle(), $this->offset, $this->limit,
+ $this->powerSearchOptions() + array( 'search' => $term ),
max( $titleMatchesNum, $textMatchesNum ) < $this->limit
);
//$out->addHTML( "<p class='mw-search-pager-top'>{$prevnext}</p>\n" );
$lang->formatNum( $resultsShown )
);
} elseif ( $resultsShown >= $this->limit ) {
- $top = wfShowingResults( $this->offset, $this->limit );
+ $top = wfMsgExt( 'showingresults', array( 'parseinline' ),
+ $lang->formatNum( $this->limit ),
+ $lang->formatNum( $this->offset + 1 )
+ );
} else {
$top = wfMsgExt( 'showingresultsnum', array( 'parseinline' ),
$lang->formatNum( $this->limit ),
return $page . $details;
}
+ /**
+ * Generate (prev x| next x) (20|50|100...) type links for paging
+ *
+ * @param $title Title object to link
+ * @param $offset Integer offset parameter
+ * @param $limit Integer limit parameter
+ * @param $query String optional URL query parameter string
+ * @param $atend Bool optional param for specified if this is the last page
+ * @return String
+ */
+ public function viewPrevNext( Title $title, $offset, $limit, array $query = array(), $atend = false ) {
+ // @todo FIXME: Why on earth this needs one message for the text and another one for tooltip?
+
+ # Make 'previous' link
+ $prev = wfMessage( 'prevn' )->inLanguage( $this )->title( $title )->numParams( $limit )->text();
+ if( $offset > 0 ) {
+ $plink = $this->numLink( $title, max( $offset - $limit, 0 ), $limit,
+ $query, $prev, 'prevn-title', 'mw-prevlink' );
+ } else {
+ $plink = htmlspecialchars( $prev );
+ }
+
+ # Make 'next' link
+ $next = wfMessage( 'nextn' )->inLanguage( $this )->title( $title )->numParams( $limit )->text();
+ if( $atend ) {
+ $nlink = htmlspecialchars( $next );
+ } else {
+ $nlink = $this->numLink( $title, $offset + $limit, $limit,
+ $query, $next, 'prevn-title', 'mw-nextlink' );
+ }
+
+ # Make links to set number of items per page
+ $numLinks = array();
+ foreach( array( 20, 50, 100, 250, 500 ) as $num ) {
+ $numLinks[] = $this->numLink( $title, $offset, $num,
+ $query, $this->formatNum( $num ), 'shown-title', 'mw-numlink' );
+ }
+
+ return wfMessage( 'viewprevnext' )->inLanguage( $this )->title( $title
+ )->rawParams( $plink, $nlink, $this->pipeList( $numLinks ) )->escaped();
+ }
+
+ /**
+ * Helper function for viewPrevNext() that generates links
+ *
+ * @param $title Title object to link
+ * @param $offset Integer offset parameter
+ * @param $limit Integer limit parameter
+ * @param $query Array extra query parameters
+ * @param $link String text to use for the link; will be escaped
+ * @param $tooltipMsg String name of the message to use as tooltip
+ * @param $class String value of the "class" attribute of the link
+ * @return String HTML fragment
+ */
+ private function numLink( Title $title, $offset, $limit, array $query, $link, $tooltipMsg, $class ) {
+ $query = array( 'limit' => $limit, 'offset' => $offset ) + $query;
+ $tooltip = wfMessage( $tooltipMsg )->inLanguage( $this )->title( $title )->numParams( $limit )->text();
+ return Html::element( 'a', array( 'href' => $title->getLocalURL( $query ),
+ 'title' => $tooltip, 'class' => $class ), $link );
+ }
+
/**
* Get the conversion rule title, if any.
*