/
flickr_photos_user_places.php
80 lines (53 loc) · 1.77 KB
/
flickr_photos_user_places.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
<?php
include("include/init.php");
loadlib("flickr_places");
loadlib("flickr_photos_places");
if ((! $GLOBALS['cfg']['enable_feature_solr']) || (! $GLOBALS['cfg']['enable_feature_places'])){
error_disabled();
}
if ($path = get_str("path")){
$flickr_user = flickr_users_get_by_path_alias($path);
}
else if ($nsid = get_str("nsid")){
$flickr_user = flickr_users_get_by_nsid($nsid);
}
if (! $flickr_user){
error_404();
}
$owner = users_get_by_id($flickr_user['user_id']);
$is_own = ($owner['id'] == $GLOBALS['cfg']['user']['id']) ? 1 : 0;
$GLOBALS['smarty']->assign_by_ref("owner", $owner);
$GLOBALS['smarty']->assign("is_own", $is_own);
# TO DO: check to see if facet is apssed in as a q uery param
$facet = get_str("facet");
$placetypes = flickr_places_valid_placetypes();
if ((! $facet) || (! flickr_places_is_valid_placetype($facet))){
$rand = rand(1, count($placetypes));
$facet = $placetypes[$rand - 1];
}
$mincount = 20;
$GLOBALS['smarty']->assign_by_ref("placetypes", $placetypes);
$GLOBALS['smarty']->assign("facet", $facet);
$GLOBALS['smarty']->assign("mincount", $mincount);
#
$viewer_id = $GLOBALS['cfg']['user']['id'];
$more = array(
'mincount' => $mincount,
);
$rsp = flickr_photos_places_for_user_facet($owner, $facet, $viewer_id, $more);
if ($rsp['ok']){
$locations = array();
foreach ($rsp['facets'] as $woeid => $ignore){
$loc = flickr_places_get_by_woeid($woeid);
$locations[$woeid] = $loc;
}
$GLOBALS['smarty']->assign_by_ref("facets", $rsp['facets']);
$GLOBALS['smarty']->assign_by_ref("locations", $locations);
}
else {
$GLOBALS['smarty']->assign("error", $rsp['error']);
}
# TO DO: pull in places without lots of photos
$GLOBALS['smarty']->display("page_flickr_photos_user_places.txt");
exit();
?>