Project

General

Profile

1
<?php
2

    
3
defined('_JEXEC') or die('Access denied');
4

    
5
jimport('joomla.methods');
6

    
7
// This helper formats paging.
8
abstract class PagingHelper {
9
	
10
	// Format paging.	
11
	// $page the current page
12
	// $totalPages the total pages
13
	// $pagingStart the page to start paging from
14
	// $pagingEnd the page to end paging to
15
	// $baseUrl the base URL to use for links
16
	// $fragment the URL fragment to use for links
17
	// return a string containing the full HTML for paging or an empty string if any errors occur
18
	public static function formatPaging($page, $totalPages, $pagingStart, $pagingEnd, $baseUrl, $fragment) {
19
		// TODO JRoute :: _ keeps decoding urlencoded values, so this is just a hack to cope with this
20
		return '<div class="pages">' . (($page > 1) ? ('<a href="' . JRoute :: _($baseUrl . '1' . $fragment) . '">&lt;&lt;</a><a href="' . JRoute :: _($baseUrl . ($page - 1) . $fragment) . '">&lt;</a>') : '') . implode('', array_map(function ($p) use ($page, $baseUrl, $fragment) {return ($p == $page) ? ('<a class="current">' . $p . '</a>') : ('<a href="' . JRoute :: _($baseUrl . $p . $fragment) . '">' . $p . '</a>');}, range($pagingStart, $pagingEnd))) . (($page < $totalPages) ? ('<a href="' . JRoute :: _($baseUrl . ($page + 1) . $fragment) . '">&gt;</a>') : '') . '</div>';
21
	}
22
}
23

    
(9-9/15)