Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 4c6136787b9b5b1b79224befab15203f75d402db 1 parent 5bfacfb
straup authored
46 www/flickr_photos_user_archives_day.php
@@ -48,42 +48,38 @@
48 48 $months = dates_utils_months();
49 49 $GLOBALS['smarty']->assign_by_ref("months", $months);
50 50
51   - if (count($photos)){
  51 + flickr_photos_utils_assign_can_view_geo($photos, $GLOBALS['cfg']['user']['id']);
52 52
53   - flickr_photos_utils_assign_can_view_geo($photos, $GLOBALS['cfg']['user']['id']);
  53 + $user_days = flickr_photos_archives_days_for_user($owner, $year, $month, $more);
54 54
55   - $user_days = flickr_photos_archives_days_for_user($owner, $year, $month, $more);
  55 + $count_days = count($user_days);
56 56
57   - $count_days = count($user_days);
  57 + for ($i=0; $i < $count_days; $i++){
58 58
59   - for ($i=0; $i < $count_days; $i++){
60   -
61   - if ($user_days[$i] != $day){
62   - continue;
63   - }
64   -
65   - $next_day = $user_days[$i+1];
66   - $previous_day = $user_days[$i-1];
67   - break;
  59 + if ($user_days[$i] != $day){
  60 + continue;
68 61 }
69 62
70   - $GLOBALS['smarty']->assign("next_day", $next_day);
71   - $GLOBALS['smarty']->assign("previous_day", $previous_day);
  63 + $next_day = $user_days[$i+1];
  64 + $previous_day = $user_days[$i-1];
  65 + break;
  66 + }
  67 +
  68 + $GLOBALS['smarty']->assign("next_day", $next_day);
  69 + $GLOBALS['smarty']->assign("previous_day", $previous_day);
72 70
73   - $ymd = implode("-", array($year, $month, $day));
  71 + $ymd = implode("-", array($year, $month, $day));
74 72
75   - if (! $previous_day){
76   - if ($previous_ymd = flickr_photos_archives_previous_date_for_user($owner, $ymd, $more)){
77   - $GLOBALS['smarty']->assign("previous", explode("-", $previous_ymd));
78   - }
  73 + if (! $previous_day){
  74 + if ($previous_ymd = flickr_photos_archives_previous_date_for_user($owner, $ymd, $more)){
  75 + $GLOBALS['smarty']->assign("previous", explode("-", $previous_ymd));
79 76 }
  77 + }
80 78
81   - if (! $next_day){
82   - if ($next_ymd = flickr_photos_archives_next_date_for_user($owner, $ymd, $more)){
83   - $GLOBALS['smarty']->assign("next", explode("-", $next_ymd));
84   - }
  79 + if (! $next_day){
  80 + if ($next_ymd = flickr_photos_archives_next_date_for_user($owner, $ymd, $more)){
  81 + $GLOBALS['smarty']->assign("next", explode("-", $next_ymd));
85 82 }
86   -
87 83 }
88 84
89 85 $GLOBALS['smarty']->assign_by_ref("photos", $photos);
58 www/flickr_photos_user_archives_month.php
@@ -47,53 +47,49 @@
47 47 $months = dates_utils_months();
48 48 $GLOBALS['smarty']->assign("months", $months);
49 49
50   - if (count($photos)){
  50 + flickr_photos_utils_assign_can_view_geo($photos, $GLOBALS['cfg']['user']['id']);
51 51
52   - flickr_photos_utils_assign_can_view_geo($photos, $GLOBALS['cfg']['user']['id']);
  52 + $days = dates_utils_days_for_month($year, $month);
53 53
54   - $days = dates_utils_days_for_month($year, $month);
  54 + $user_months = flickr_photos_archives_months_for_user($owner, $year, $more);
  55 + $user_days = flickr_photos_archives_days_for_user($owner, $year, $month, $more);
55 56
56   - $user_months = flickr_photos_archives_months_for_user($owner, $year, $more);
57   - $user_days = flickr_photos_archives_days_for_user($owner, $year, $month, $more);
  57 + $count_months = count($user_months);
58 58
59   - $count_months = count($user_months);
  59 + for ($i=0; $i < $count_months; $i++){
60 60
61   - for ($i=0; $i < $count_months; $i++){
62   -
63   - if ($user_months[$i] != $month){
64   - continue;
65   - }
66   -
67   - $next_month = $user_months[$i+1];
68   - $previous_month = $user_months[$i-1];
69   - break;
  61 + if ($user_months[$i] != $month){
  62 + continue;
70 63 }
71 64
72   - $GLOBALS['smarty']->assign("next_month", $next_month);
73   - $GLOBALS['smarty']->assign("previous_month", $previous_month);
  65 + $next_month = $user_months[$i+1];
  66 + $previous_month = $user_months[$i-1];
  67 + break;
  68 + }
  69 +
  70 + $GLOBALS['smarty']->assign("next_month", $next_month);
  71 + $GLOBALS['smarty']->assign("previous_month", $previous_month);
74 72
75   - $GLOBALS['smarty']->assign("days", $days);
76   - $GLOBALS['smarty']->assign("user_days", $user_days);
  73 + $GLOBALS['smarty']->assign("days", $days);
  74 + $GLOBALS['smarty']->assign("user_days", $user_days);
77 75
78   - if (! $previous_month){
  76 + if (! $previous_month){
79 77
80   - $ymd = implode("-", array($year, $month, 1));
  78 + $ymd = implode("-", array($year, $month, 1));
81 79
82   - if ($previous_ymd = flickr_photos_archives_previous_date_for_user($owner, $ymd, $more)){
83   - $GLOBALS['smarty']->assign("previous", explode("-", $previous_ymd));
84   - }
  80 + if ($previous_ymd = flickr_photos_archives_previous_date_for_user($owner, $ymd, $more)){
  81 + $GLOBALS['smarty']->assign("previous", explode("-", $previous_ymd));
85 82 }
  83 + }
86 84
87   - if (! $next_month){
  85 + if (! $next_month){
88 86
89   - $last_dom = dates_utils_last_dom($year, $month);
90   - $ymd = implode("-", array($year, $month, $last_dom));
  87 + $last_dom = dates_utils_last_dom($year, $month);
  88 + $ymd = implode("-", array($year, $month, $last_dom));
91 89
92   - if ($next_ymd = flickr_photos_archives_next_date_for_user($owner, $ymd, $more)){
93   - $GLOBALS['smarty']->assign("next", explode("-", $next_ymd));
94   - }
  90 + if ($next_ymd = flickr_photos_archives_next_date_for_user($owner, $ymd, $more)){
  91 + $GLOBALS['smarty']->assign("next", explode("-", $next_ymd));
95 92 }
96   -
97 93 }
98 94
99 95 $GLOBALS['smarty']->assign_by_ref("photos", $photos);
50 www/flickr_photos_user_archives_year.php
@@ -45,34 +45,50 @@
45 45 $rsp = flickr_photos_archives_for_user_and_year($owner, $year, $more);
46 46 $photos = $rsp['rows'];
47 47
48   - if (count($photos)){
  48 + flickr_photos_utils_assign_can_view_geo($photos, $GLOBALS['cfg']['user']['id']);
49 49
50   - flickr_photos_utils_assign_can_view_geo($photos, $GLOBALS['cfg']['user']['id']);
  50 + $years = flickr_photos_archives_years_for_user($owner, $more);
  51 + $count_years = count($years);
51 52
52   - $years = flickr_photos_archives_years_for_user($owner, $more);
53   - $count_years = count($years);
  53 + for ($i=0; $i < $count_years; $i++){
54 54
55   - for ($i=0; $i < $count_years; $i++){
  55 + if ($years[$i] != $year){
  56 + continue;
  57 + }
  58 +
  59 + $next_year = $years[$i+1];
  60 + $previous_year = $years[$i-1];
  61 + break;
  62 + }
  63 +
  64 + $months = dates_utils_months();
  65 +
  66 + $user_months = flickr_photos_archives_months_for_user($owner, $year, $more);
56 67
57   - if ($years[$i] != $year){
58   - continue;
59   - }
  68 + $GLOBALS['smarty']->assign("next_year", $next_year);
  69 + $GLOBALS['smarty']->assign("previous_year", $previous_year);
60 70
61   - $next_year = $years[$i+1];
62   - $previous_year = $years[$i-1];
63   - break;
  71 + if (! $previous_year){
  72 +
  73 + $ymd = "{$year}-01-01";
  74 +
  75 + if ($previous_ymd = flickr_photos_archives_previous_date_for_user($owner, $ymd, $more)){
  76 + $GLOBALS['smarty']->assign("previous", explode("-", $previous_ymd));
64 77 }
  78 + }
65 79
66   - $months = dates_utils_months();
  80 + if (! $next_year){
67 81
68   - $user_months = flickr_photos_archives_months_for_user($owner, $year, $more);
  82 + $ymd = "{$year}-12-31";
69 83
70   - $GLOBALS['smarty']->assign("next_year", $next_year);
71   - $GLOBALS['smarty']->assign("previous_year", $previous_year);
72   - $GLOBALS['smarty']->assign("months", $months);
73   - $GLOBALS['smarty']->assign("user_months", $user_months);
  84 + if ($next_ymd = flickr_photos_archives_next_date_for_user($owner, $ymd, $more)){
  85 + $GLOBALS['smarty']->assign("next", explode("-", $next_ymd));
  86 + }
74 87 }
75 88
  89 + $GLOBALS['smarty']->assign("months", $months);
  90 + $GLOBALS['smarty']->assign("user_months", $user_months);
  91 +
76 92 $GLOBALS['smarty']->assign_by_ref("photos", $photos);
77 93 $GLOBALS['smarty']->assign("year", $year);
78 94
6 www/templates/page_flickr_photos_user_archives_day.txt
@@ -29,6 +29,10 @@
29 29
30 30 </div>
31 31
  32 +{if ! $photos|@count}
  33 +<p>None!</p>
  34 +{else}
  35 +
32 36 {foreach from=$photos item="row"}
33 37
34 38 <div class="photos_user_photo">
@@ -52,4 +56,6 @@
52 56
53 57 {include file="inc_flickr_photo_map_load.txt"}
54 58
  59 +{/if}
  60 +
55 61 {include file="inc_foot.txt"}
6 www/templates/page_flickr_photos_user_archives_month.txt
@@ -36,6 +36,10 @@
36 36
37 37 </div>
38 38
  39 +{if ! $photos|@count}
  40 +<p>None!</p>
  41 +{else}
  42 +
39 43 {foreach from=$photos item="row"}
40 44
41 45 <div class="photos_user_photo">
@@ -59,4 +63,6 @@
59 63
60 64 {include file="inc_flickr_photo_map_load.txt"}
61 65
  66 +{/if}
  67 +
62 68 {include file="inc_foot.txt"}
18 www/templates/page_flickr_photos_user_archives_year.txt
@@ -11,7 +11,11 @@
11 11
12 12 <div id="archives_navi">
13 13 <ul id="archives_navi_years">
14   -{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}
  14 +{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>
  15 +{elseif $previous}
  16 +{assign var="previous_month" value=$previous.1}
  17 +<li><a href="{$owner|@flickr_urls_photos_user_archives}date-{$context|escape}/{$previous.0|escape}/">{$previous.0|escape}</a></li>
  18 +{else}{* this is a dirty little hack to trick the CSS hooks *}<li style="display:none;"></li>{/if}
15 19
16 20 <li>
17 21 {if 0}<strong>{$year|escape}</strong>{/if}
@@ -23,11 +27,19 @@
23 27
24 28 </li>
25 29
26   -{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}
  30 +{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>
  31 +{elseif $next}
  32 +{assign var="next_month" value=$next.1}
  33 +<li><a href="{$owner|@flickr_urls_photos_user_archives}date-{$context|escape}/{$next.0|escape}/">{$next.0|escape}</a></li>
  34 +{else}{* this is a dirty little hack to trick the CSS hooks *}<li style="display:none;"></li>{/if}
27 35 </ul>
28 36
29 37 </div>
30 38
  39 +{if ! $photos|@count}
  40 +<p>None!</p>
  41 +{else}
  42 +
31 43 {foreach from=$photos item="row"}
32 44
33 45 <div class="photos_user_photo">
@@ -51,4 +63,6 @@
51 63
52 64 {include file="inc_flickr_photo_map_load.txt"}
53 65
  66 +{/if}
  67 +
54 68 {include file="inc_foot.txt"}

0 comments on commit 4c61367

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