Skip to content
Browse files

always fetch next/previous; copy when there are no photos

  • Loading branch information...
1 parent 5bfacfb commit 4c6136787b9b5b1b79224befab15203f75d402db straup committed Jan 5, 2012
View
46 www/flickr_photos_user_archives_day.php
@@ -48,42 +48,38 @@
$months = dates_utils_months();
$GLOBALS['smarty']->assign_by_ref("months", $months);
- if (count($photos)){
+ flickr_photos_utils_assign_can_view_geo($photos, $GLOBALS['cfg']['user']['id']);
- flickr_photos_utils_assign_can_view_geo($photos, $GLOBALS['cfg']['user']['id']);
+ $user_days = flickr_photos_archives_days_for_user($owner, $year, $month, $more);
- $user_days = flickr_photos_archives_days_for_user($owner, $year, $month, $more);
+ $count_days = count($user_days);
- $count_days = count($user_days);
+ for ($i=0; $i < $count_days; $i++){
- for ($i=0; $i < $count_days; $i++){
-
- if ($user_days[$i] != $day){
- continue;
- }
-
- $next_day = $user_days[$i+1];
- $previous_day = $user_days[$i-1];
- break;
+ if ($user_days[$i] != $day){
+ continue;
}
- $GLOBALS['smarty']->assign("next_day", $next_day);
- $GLOBALS['smarty']->assign("previous_day", $previous_day);
+ $next_day = $user_days[$i+1];
+ $previous_day = $user_days[$i-1];
+ break;
+ }
+
+ $GLOBALS['smarty']->assign("next_day", $next_day);
+ $GLOBALS['smarty']->assign("previous_day", $previous_day);
- $ymd = implode("-", array($year, $month, $day));
+ $ymd = implode("-", array($year, $month, $day));
- if (! $previous_day){
- if ($previous_ymd = flickr_photos_archives_previous_date_for_user($owner, $ymd, $more)){
- $GLOBALS['smarty']->assign("previous", explode("-", $previous_ymd));
- }
+ if (! $previous_day){
+ if ($previous_ymd = flickr_photos_archives_previous_date_for_user($owner, $ymd, $more)){
+ $GLOBALS['smarty']->assign("previous", explode("-", $previous_ymd));
}
+ }
- if (! $next_day){
- if ($next_ymd = flickr_photos_archives_next_date_for_user($owner, $ymd, $more)){
- $GLOBALS['smarty']->assign("next", explode("-", $next_ymd));
- }
+ if (! $next_day){
+ if ($next_ymd = flickr_photos_archives_next_date_for_user($owner, $ymd, $more)){
+ $GLOBALS['smarty']->assign("next", explode("-", $next_ymd));
}
-
}
$GLOBALS['smarty']->assign_by_ref("photos", $photos);
View
58 www/flickr_photos_user_archives_month.php
@@ -47,53 +47,49 @@
$months = dates_utils_months();
$GLOBALS['smarty']->assign("months", $months);
- if (count($photos)){
+ flickr_photos_utils_assign_can_view_geo($photos, $GLOBALS['cfg']['user']['id']);
- flickr_photos_utils_assign_can_view_geo($photos, $GLOBALS['cfg']['user']['id']);
+ $days = dates_utils_days_for_month($year, $month);
- $days = dates_utils_days_for_month($year, $month);
+ $user_months = flickr_photos_archives_months_for_user($owner, $year, $more);
+ $user_days = flickr_photos_archives_days_for_user($owner, $year, $month, $more);
- $user_months = flickr_photos_archives_months_for_user($owner, $year, $more);
- $user_days = flickr_photos_archives_days_for_user($owner, $year, $month, $more);
+ $count_months = count($user_months);
- $count_months = count($user_months);
+ for ($i=0; $i < $count_months; $i++){
- for ($i=0; $i < $count_months; $i++){
-
- if ($user_months[$i] != $month){
- continue;
- }
-
- $next_month = $user_months[$i+1];
- $previous_month = $user_months[$i-1];
- break;
+ if ($user_months[$i] != $month){
+ continue;
}
- $GLOBALS['smarty']->assign("next_month", $next_month);
- $GLOBALS['smarty']->assign("previous_month", $previous_month);
+ $next_month = $user_months[$i+1];
+ $previous_month = $user_months[$i-1];
+ break;
+ }
+
+ $GLOBALS['smarty']->assign("next_month", $next_month);
+ $GLOBALS['smarty']->assign("previous_month", $previous_month);
- $GLOBALS['smarty']->assign("days", $days);
- $GLOBALS['smarty']->assign("user_days", $user_days);
+ $GLOBALS['smarty']->assign("days", $days);
+ $GLOBALS['smarty']->assign("user_days", $user_days);
- if (! $previous_month){
+ if (! $previous_month){
- $ymd = implode("-", array($year, $month, 1));
+ $ymd = implode("-", array($year, $month, 1));
- if ($previous_ymd = flickr_photos_archives_previous_date_for_user($owner, $ymd, $more)){
- $GLOBALS['smarty']->assign("previous", explode("-", $previous_ymd));
- }
+ if ($previous_ymd = flickr_photos_archives_previous_date_for_user($owner, $ymd, $more)){
+ $GLOBALS['smarty']->assign("previous", explode("-", $previous_ymd));
}
+ }
- if (! $next_month){
+ if (! $next_month){
- $last_dom = dates_utils_last_dom($year, $month);
- $ymd = implode("-", array($year, $month, $last_dom));
+ $last_dom = dates_utils_last_dom($year, $month);
+ $ymd = implode("-", array($year, $month, $last_dom));
- if ($next_ymd = flickr_photos_archives_next_date_for_user($owner, $ymd, $more)){
- $GLOBALS['smarty']->assign("next", explode("-", $next_ymd));
- }
+ if ($next_ymd = flickr_photos_archives_next_date_for_user($owner, $ymd, $more)){
+ $GLOBALS['smarty']->assign("next", explode("-", $next_ymd));
}
-
}
$GLOBALS['smarty']->assign_by_ref("photos", $photos);
View
50 www/flickr_photos_user_archives_year.php
@@ -45,34 +45,50 @@
$rsp = flickr_photos_archives_for_user_and_year($owner, $year, $more);
$photos = $rsp['rows'];
- if (count($photos)){
+ flickr_photos_utils_assign_can_view_geo($photos, $GLOBALS['cfg']['user']['id']);
- flickr_photos_utils_assign_can_view_geo($photos, $GLOBALS['cfg']['user']['id']);
+ $years = flickr_photos_archives_years_for_user($owner, $more);
+ $count_years = count($years);
- $years = flickr_photos_archives_years_for_user($owner, $more);
- $count_years = count($years);
+ for ($i=0; $i < $count_years; $i++){
- for ($i=0; $i < $count_years; $i++){
+ if ($years[$i] != $year){
+ continue;
+ }
+
+ $next_year = $years[$i+1];
+ $previous_year = $years[$i-1];
+ break;
+ }
+
+ $months = dates_utils_months();
+
+ $user_months = flickr_photos_archives_months_for_user($owner, $year, $more);
- if ($years[$i] != $year){
- continue;
- }
+ $GLOBALS['smarty']->assign("next_year", $next_year);
+ $GLOBALS['smarty']->assign("previous_year", $previous_year);
- $next_year = $years[$i+1];
- $previous_year = $years[$i-1];
- break;
+ if (! $previous_year){
+
+ $ymd = "{$year}-01-01";
+
+ if ($previous_ymd = flickr_photos_archives_previous_date_for_user($owner, $ymd, $more)){
+ $GLOBALS['smarty']->assign("previous", explode("-", $previous_ymd));
}
+ }
- $months = dates_utils_months();
+ if (! $next_year){
- $user_months = flickr_photos_archives_months_for_user($owner, $year, $more);
+ $ymd = "{$year}-12-31";
- $GLOBALS['smarty']->assign("next_year", $next_year);
- $GLOBALS['smarty']->assign("previous_year", $previous_year);
- $GLOBALS['smarty']->assign("months", $months);
- $GLOBALS['smarty']->assign("user_months", $user_months);
+ if ($next_ymd = flickr_photos_archives_next_date_for_user($owner, $ymd, $more)){
+ $GLOBALS['smarty']->assign("next", explode("-", $next_ymd));
+ }
}
+ $GLOBALS['smarty']->assign("months", $months);
+ $GLOBALS['smarty']->assign("user_months", $user_months);
+
$GLOBALS['smarty']->assign_by_ref("photos", $photos);
$GLOBALS['smarty']->assign("year", $year);
View
6 www/templates/page_flickr_photos_user_archives_day.txt
@@ -29,6 +29,10 @@
</div>
+{if ! $photos|@count}
+<p>None!</p>
+{else}
+
{foreach from=$photos item="row"}
<div class="photos_user_photo">
@@ -52,4 +56,6 @@
{include file="inc_flickr_photo_map_load.txt"}
+{/if}
+
{include file="inc_foot.txt"}
View
6 www/templates/page_flickr_photos_user_archives_month.txt
@@ -36,6 +36,10 @@
</div>
+{if ! $photos|@count}
+<p>None!</p>
+{else}
+
{foreach from=$photos item="row"}
<div class="photos_user_photo">
@@ -59,4 +63,6 @@
{include file="inc_flickr_photo_map_load.txt"}
+{/if}
+
{include file="inc_foot.txt"}
View
18 www/templates/page_flickr_photos_user_archives_year.txt
@@ -11,7 +11,11 @@
<div id="archives_navi">
<ul id="archives_navi_years">
-{if $previous_year}<li><a title="photos from {$previous_year|escape}" href="{$owner|@flickr_urls_photos_user_archives}date-{$context|escape}/{$previous_year|escape}/">{$previous_year}</a></li>{else}{* this is a dirty little hack to trick the CSS hooks *}<li style="display:none;"></li>{/if}
+{if $previous_year}<li><a title="photos from {$previous_year|escape}" href="{$owner|@flickr_urls_photos_user_archives}date-{$context|escape}/{$previous_year|escape}/">{$previous_year}</a></li>
+{elseif $previous}
+{assign var="previous_month" value=$previous.1}
+<li><a href="{$owner|@flickr_urls_photos_user_archives}date-{$context|escape}/{$previous.0|escape}/">{$previous.0|escape}</a></li>
+{else}{* this is a dirty little hack to trick the CSS hooks *}<li style="display:none;"></li>{/if}
<li>
{if 0}<strong>{$year|escape}</strong>{/if}
@@ -23,11 +27,19 @@
</li>
-{if $next_year}<li><a title="photos from {$next_year|escape}" href="{$owner|@flickr_urls_photos_user_archives}date-{$context|escape}/{$next_year|escape}/">{$next_year}</a></li>{else}{* this is a dirty little hack to trick the CSS hooks *}<li style="display:none;"></li>{/if}
+{if $next_year}<li><a title="photos from {$next_year|escape}" href="{$owner|@flickr_urls_photos_user_archives}date-{$context|escape}/{$next_year|escape}/">{$next_year}</a></li>
+{elseif $next}
+{assign var="next_month" value=$next.1}
+<li><a href="{$owner|@flickr_urls_photos_user_archives}date-{$context|escape}/{$next.0|escape}/">{$next.0|escape}</a></li>
+{else}{* this is a dirty little hack to trick the CSS hooks *}<li style="display:none;"></li>{/if}
</ul>
</div>
+{if ! $photos|@count}
+<p>None!</p>
+{else}
+
{foreach from=$photos item="row"}
<div class="photos_user_photo">
@@ -51,4 +63,6 @@
{include file="inc_flickr_photo_map_load.txt"}
+{/if}
+
{include file="inc_foot.txt"}

0 comments on commit 4c61367

Please sign in to comment.
Something went wrong with that request. Please try again.