Permalink
Browse files

Added meaningful titles to atlas and snapshot collections pages

  • Loading branch information...
1 parent 00f2854 commit 351f96b8066ba1e4c92404adc41283a1d517efd6 Michal Migurski committed Mar 22, 2012
Showing with 72 additions and 0 deletions.
  1. +66 −0 site/lib/data.php
  2. +1 −0 site/templates/atlases.html.tpl
  3. +1 −0 site/templates/uploads.html.tpl
  4. +2 −0 site/www/atlases.php
  5. +2 −0 site/www/uploads.php
View
@@ -235,6 +235,38 @@ function get_pagination($input)
return array(max(0, $count), max(0, $offset), max(0, $perpage), max(1, $page));
}
+ function get_args_title(&$dbh, $args)
+ {
+ $parts = array();
+
+ if(isset($args['date']) && $time = strtotime($args['date']))
+ {
+ $date = date('M jS, Y', $time);
+ $parts[] = "on $date";
+ }
+
+ if(isset($args['month']) && $time = strtotime("{$args['month']}-01"))
+ {
+ $month = date('F Y', $time);
+ $parts[] = "during $month";
+ }
+
+ if(isset($args['place']))
+ {
+ $place_info = woeid_placeinfo($args['place']);
+ $place_name = nice_placename($place_info[4]);
+ $parts[] = "in $place_name";
+ }
+
+ if(isset($args['user']) && $user = get_user($dbh, $args['user']))
+ {
+ $user_name = empty($user['name']) ? 'someone' : $user['name'];
+ $parts[] = "by $user_name";
+ }
+
+ return join(' ', $parts);
+ }
+
if(!function_exists('json_encode'))
{
function json_encode($value)
@@ -651,6 +683,40 @@ function placename_latlon($name)
return null;
}
+ function woeid_placeinfo($woeid)
+ {
+ $req = new HTTP_Request('http://api.flickr.com/services/rest/');
+ $req->addQueryString('method', 'flickr.places.getInfo');
+ $req->addQueryString('woe_id', $woeid);
+ $req->addQueryString('format', 'php_serial');
+ $req->addQueryString('api_key', FLICKR_KEY);
+
+ $res = $req->sendRequest();
+
+ if(PEAR::isError($res))
+ return array(null, null, null, null, null, null);
+
+ $rsp = unserialize($req->getResponseBody());
+
+ if(is_array($rsp) && is_array($rsp['place']))
+ {
+ $place_type = $rsp['place']['place_type'];
+ $place = $rsp['place'][$place_type];
+
+ list($place_name, $place_woeid) = array($place['_content'], $place['woeid']);
+
+ list($country, $region) = array($rsp['place']['country'], $rsp['place']['region']);
+
+ if(is_array($country))
+ list($country_name, $country_woeid) = array($country['_content'], $country['woeid']);
+
+ if(is_array($region))
+ list($region_name, $region_woeid) = array($region['_content'], $region['woeid']);
+ }
+
+ return array($country_name, $country_woeid, $region_name, $region_woeid, $place_name, $place_woeid);
+ }
+
function latlon_placeinfo($lat, $lon, $zoom)
{
$req = new HTTP_Request('http://api.flickr.com/services/rest/');
@@ -8,6 +8,7 @@
<body>
{include file="navigation.htmlf.tpl"}
<div class="container">
+ <h1>Atlases {$title|escape}</h1>
<h2>Atlases | <a href="{$base_dir}/uploads.php">Uploads</a></h2>
{foreach from=$prints item="print" name="index"}
@@ -8,6 +8,7 @@
<body>
{include file="navigation.htmlf.tpl"}
<div class="container">
+ <h1>Snapshots {$title|escape}</h1>
<h2><a href="{$base_dir}/atlases.php">Atlases</a> | Uploads</h2>
{foreach from=$scans item="scan" name="index"}
View
@@ -15,6 +15,7 @@
'user' => preg_match('/^\w+$/', $_GET['user']) ? $_GET['user'] : null
);
+ $title = get_args_title($context->db, $print_args);
$prints = get_prints($context->db, $print_args, 50);
$users = array();
@@ -31,6 +32,7 @@
$prints[$i]['user'] = $users[$user_id];
}
+ $context->sm->assign('title', $title);
$context->sm->assign('prints', $prints);
if($context->type == 'text/html') {
View
@@ -15,6 +15,7 @@
'user' => preg_match('/^\w+$/', $_GET['user']) ? $_GET['user'] : null
);
+ $title = get_args_title($context->db, $scan_args);
$scans = get_scans($context->db, $scan_args, 50);
$users = array();
@@ -28,6 +29,7 @@
$scans[$i]['user'] = $users[$user_id];
}
+ $context->sm->assign('title', $title);
$context->sm->assign('scans', $scans);
if($context->type == 'text/html') {

0 comments on commit 351f96b

Please sign in to comment.