1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
trait TraitPaging |
4
|
|
|
{ |
5
|
|
|
|
6
|
|
|
protected static function paging(&$vars) |
7
|
|
|
{ |
8
|
|
|
if (self::$t['pages'] > 1) { |
9
|
|
|
$vars['pages'] = self::$t['pages']; |
10
|
|
|
$vars['page'] = self::$t['page']; |
11
|
|
|
$vars['jumpL'] = self::jumps(); |
12
|
|
|
$vars['jumpR'] = self::jumps(); |
13
|
|
|
$vars['arrowL'] = self::config('UTF8_LEFT_SYMBOL'); |
14
|
|
|
$vars['arrowR'] = self::config('UTF8_RIGHT_SYMBOL'); |
15
|
|
|
|
16
|
|
|
$limit = 10; |
17
|
|
|
|
18
|
|
|
$vars['start'] = $vars['page'] > ($limit / 2) ? |
19
|
|
|
($vars['page'] - $limit / 2) : |
20
|
|
|
1; |
21
|
|
|
|
22
|
|
|
if ($vars['page'] > ($vars['pages'] - ($limit / 2))) { |
23
|
|
|
$vars['final'] = $vars['pages']; |
24
|
|
|
} elseif ($vars['page'] > ($limit / 2)) { |
25
|
|
|
$vars['final'] = $vars['start'] + $limit; |
26
|
|
|
} else { |
27
|
|
|
$vars['final'] = $limit; |
28
|
|
|
} |
29
|
|
|
} |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** Jump links -1M|-100K|-10K|-1K|100|{paging}|100|+1K|+10K|+100K|+1M |
33
|
|
|
* @param string $html Code to show |
34
|
|
|
* @param null|int $multiplier multiplier |
35
|
|
|
* @return string */ |
36
|
|
|
protected static function jumps($html = '', $multiplier = null) |
37
|
|
|
{ |
38
|
|
|
static $direction; |
39
|
|
|
|
40
|
|
|
if (is_null($multiplier)) { |
41
|
|
|
$direction = !isset($direction) ? '-' : '+'; |
42
|
|
|
$multiplier = 100; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
$jump = self::jump($multiplier, $direction); |
46
|
|
|
$add = '<li class="jump"><a>' . $jump . '</a></li>'; |
47
|
|
|
|
48
|
|
|
$jumpExists = $direction === '-' ? |
49
|
|
|
(self::$t['page'] - $multiplier) > 0 : |
50
|
|
|
(self::$t['page'] + $multiplier) <= self::$t['pages']; |
51
|
|
|
|
52
|
|
|
if ($jumpExists) { |
53
|
|
|
$html = $direction === '-' ? $add . $html : $html . $add; |
54
|
|
|
return self::jumps($html, ($multiplier * 10)); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
return $html; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
private static function jump($multiplier, $direction) |
61
|
|
|
{ |
62
|
|
|
if ($multiplier >= 1000000) { |
63
|
|
|
return ($direction . ($multiplier / 1000000) . "M"); |
64
|
|
|
} elseif ($multiplier >= 1000) { |
65
|
|
|
return ($direction . ($multiplier / 1000) . "K"); |
66
|
|
|
} else { |
67
|
|
|
return ($direction . $multiplier); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|