-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ranking.php
70 lines (63 loc) · 2.36 KB
/
Ranking.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
class Ranking extends RequestHandler {
public function get($url, $rankType, $type, $page = 1) {
$rankTypes = array('top', 'stijgend', 'dalend');
$types = array('vrienden' => 'friends', 'bekeken' => 'views');
if(!in_array($rankType, $rankTypes) or !isset($types[$type])) {
die('Invalid type');
}
if($page <= 0) {
$page = 1;
}
$perPage = 20;
$friendslink = '/'.$rankType.'/vrienden';
$viewslink = '/'.$rankType.'/bekeken';
$topUsers = array();
$h2 = '';
$total = 0;
if($rankType == 'top') {
$topUsers = HyvesUser::getTop($perPage, $types[$type], $page);
if($type == 'vrienden') {
$h2 = "Hyvers met de meeste vrienden";
} else if ($type == 'bekeken') {
$h2 = "Vaakst bekeken Hyvers";
}
$total = HyvesUser::getTotalRegistered();
} else if($rankType == 'stijgend') {
$topUsers = HyvesUser::getRising($perPage, $types[$type], $page);
$total = HyvesUser::getTotalRising($types[$type]);
if($type == 'vrienden') {
$h2 = "Meest bevriende Hyvers in de laatste 24 uur";
} else if ($type == 'bekeken') {
$h2 = "Vaakst bekeken Hyvers in de laatste 24 uur";
}
} else if($rankType == 'dalend') {
$topUsers = HyvesUser::getFalling($perPage, $page);
$total = HyvesUser::getTotalFalling();
$h2 = "Meest ontvriende Hyvers";
$friendslink = '';
$viewslink = '';
}
if($page > 1) {
$prevlink = '/'.$rankType.'/'.$type.'/'.($page-1);
} else {
$prevlink = '';
}
if($total > $page*$perPage) {
$nextlink = '/'.$rankType.'/'.$type.'/'.($page+1);
} else {
$nextlink = '';
}
$template = self::$Twig->loadTemplate('ranking.html');
$template->display(array(
'topUsers' => $topUsers,
'page' => $page,
'perPage' => $perPage,
'prevlink' => $prevlink,
'nextlink' => $nextlink,
'friendslink' => $friendslink,
'viewslink' => $viewslink,
'h2' => $h2,
'total' => $total));
}
}