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) . '"><<</a><a href="' . JRoute :: _($baseUrl . ($page - 1) . $fragment) . '"><</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) . '">></a>') : '') . '</div>';
|
21
|
}
|
22
|
|
23
|
public static function formatPagingForAjax($page, $totalPages, $pagingStart, $pagingEnd, $baseUrl, $fragment,$source) {
|
24
|
return '<div class="pages">' . (($page > 1) ? ('<a href="' . JRoute :: _($baseUrl . '1' . $fragment) . '"><<</a>
|
25
|
<a href="' . JRoute :: _($baseUrl . ($page - 1) . $fragment) . '"><</a>') : '')
|
26
|
. implode('',
|
27
|
array_map(function ($p) use ($page, $baseUrl, $fragment,$source)
|
28
|
{
|
29
|
return ($p == $page) ? ('<a class="current">' . $p . '</a>') :
|
30
|
('<a onclick="gotoPage(\''.$baseUrl .'\',\''. ($p).'\',\'' . ($source) .'\',\''. $fragment.'\');">' . $p . '</a>');
|
31
|
},
|
32
|
range($pagingStart, $pagingEnd))) . (($page < $totalPages) ?
|
33
|
('<a onclick="gotoPage(\''.$baseUrl .'\',\'' . ($page + 1) .'\',\'' . ($source) .'\',\''. $fragment.'\');" >></a>') : '') . '</div>';
|
34
|
// href="' . JRoute :: _($baseUrl . ($page + 1) . $fragment) . '"
|
35
|
}
|
36
|
}
|
37
|
|