/
person.php
175 lines (170 loc) · 5.51 KB
/
person.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
include_once('config.php');
if (isset($_GET['id'])) {
$id = $_GET['id'];
}
$likeMap;
function sortByCategory($likes){
global $likeMap;
$r = array();
foreach($likes as $like){
if(isset($r[$like['category']])){
$r[$like['category']][] = $like['id'];
} else {
$r[$like['category']] = array($like['id']);
}
$likeMap[$like['id']] = $like['name'];
}
return $r;
}
$isLoggedIn = $facebook->getUser() && isset($id);
if ($isLoggedIn) {
$me = $facebook->api("/me/likes", 'GET');
$me = sortByCategory($me['data']);
$them = $facebook->api("/$id/likes", 'GET');
$them = sortByCategory($them['data']);
$out = array();
foreach ($me as $key => $meCategory) {
if(isset($them[$key])){
$themCategory = $them[$key];
$out[$key] = array_intersect($meCategory, $themCategory);
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>
</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
<link rel="stylesheet" href="css/local.css" />
<style>
#interest-list-them {
display:none;
}
#interest-list-me {
display:none;
}
</style>
<script type="text/javascript">
//Fixes facebook/jquery bug
if (window.location.hash == '#_=_')window.location.hash = '';
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
</script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js">
</script>
</head>
<body>
<!-- Home -->
<div data-role="page" id="page1">
<div data-theme="a" data-role="header">
<h3>
Hacky Birthday!
</h3>
</div>
<div data-role="content" style="padding: 15px">
<?php if($isLoggedIn) { ?>
<div id="#display-likes-button" data-role="fieldcontain">
<fieldset data-role="controlgroup" data-type="horizontal">
<legend>
Whose likes do you want to show?
</legend>
<input name="radiobuttons1" id="radio2" value="radio2" type="radio" onclick="onThemClicked()" />
<label for="radio2">
Their's
</label>
<input name="radiobuttons1" id="radio1" value="radio1" type="radio" onclick="onCommonClicked()" checked />
<label for="radio1">
Common
</label>
<input name="radiobuttons1" id="radio3" value="radio3" type="radio" onclick="onMeClicked()" />
<label for="radio3">
Your's
</label>
</fieldset>
</div>
<ul id="interest-list-common" data-role="listview" data-divider-theme="a" data-inset="true">
<?php
foreach ($out as $interestName => $interest) {
if (!empty($interest)) {
?>
<li data-role="list-divider" role="heading">
<?php print ucfirst($interestName); ?>
</li>
<?php foreach ($interest as $item) { ?>
<li data-theme="c">
<a href="<?php print "message.php?id=".$id."&item=".$item; ?>" data-transition="slide">
<?php print $likeMap[$item]; ?>
</a>
</li>
<?php }
}
} ?>
</ul>
<ul id="interest-list-them" data-role="listview" data-divider-theme="a" data-inset="true">
<?php
foreach ($them as $interestName => $interest) {
if (!empty($interest)) {
?>
<li data-role="list-divider" role="heading">
<?php print ucfirst($interestName); ?>
</li>
<?php foreach ($interest as $item) { ?>
<li data-theme="c">
<a href="<?php print "message.php?id=".$id."&item=".$item; ?>" data-transition="slide">
<?php print $likeMap[$item]; ?>
</a>
</li>
<?php }
}
} ?>
</ul>
<ul id="interest-list-me" data-role="listview" data-divider-theme="a" data-inset="true">
<?php
foreach ($me as $interestName => $interest) {
if (!empty($interest)) {
?>
<li data-role="list-divider" role="heading">
<?php print ucfirst($interestName); ?>
</li>
<?php foreach ($interest as $item) { ?>
<li data-theme="c">
<a href="<?php print "message.php?id=".$id."&item=".$item; ?>" data-transition="slide">
<?php print $likeMap[$item]; ?>
</a>
</li>
<?php }
}
} ?>
</ul>
</div>
<?php } else { ?>
<a data-role="button" data-transition="fade" href="<?php print getLoginUrl(); ?>" data-icon="plus" data-iconpos="left">
Login with Facebook
</a>
<?php } ?>
</div>
</div>
<script>
function onThemClicked() {
$('#interest-list-me').hide();
$('#interest-list-common').hide();
$('#interest-list-them').show();
}
function onMeClicked() {
$('#interest-list-them').hide();
$('#interest-list-common').hide();
$('#interest-list-me').show();
}
function onCommonClicked() {
$('#interest-list-me').hide();
$('#interest-list-them').hide();
$('#interest-list-common').show();
}
</script>
</body>
</html>