From ee210718ccbef15432741665ce2b13379067804e Mon Sep 17 00:00:00 2001 From: Friendika Date: Fri, 11 Mar 2011 20:06:13 -0800 Subject: [PATCH] photo album prev/next links --- mod/photos.php | 37 +++++++++++++++++++++++++++++-- view/theme/duepuntozero/style.css | 13 +++++++++++ view/theme/loozah/style.css | 14 ++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/mod/photos.php b/mod/photos.php index 854c6ee14..929d1c971 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -909,6 +909,32 @@ function photos_content(&$a) { return; } + $prevlink = ''; + $nextlink = ''; + + $prvnxt = q("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0 + $sql_extra ORDER BY `created` DESC ", + dbesc($ph[0]['album']), + intval($owner_uid) + ); + + if(count($prvnxt)) { + for($z = 0; $z < count($prvnxt); $z++) { + if($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) { + $prv = $z - 1; + $nxt = $z + 1; + if($prv < 0) + $prv = count($prvnxt) - 1; + if($nxt >= count($prvnxt)) + $nxt = 0; + break; + } + } + $prevlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] ; + $nextlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] ; + } + + if(count($ph) == 1) $hires = $lores = $ph[0]; if(count($ph) > 1) { @@ -938,11 +964,18 @@ function photos_content(&$a) { $o .= ''; } + if($prevlink) + $o .= '' ; - $o .= ''; + . $lores['resource-id'] . '-' . $lores['scale'] . '.jpg' . '" />'; + + if($nextlink) + $o .= ''; + + $o .= '
'; // Do we have an item for this photo? diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index d4643b20a..c54b9835a 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -2094,3 +2094,16 @@ a.mail-list-link { margin-top: 20px; } +#photo-prev-link, #photo-next-link { + padding: 10px; + float: left; +} + +#photo-photo { + float: left; +} + +#photo-photo-end { + clear: both; +} + diff --git a/view/theme/loozah/style.css b/view/theme/loozah/style.css index ffd352c5a..4461907bb 100644 --- a/view/theme/loozah/style.css +++ b/view/theme/loozah/style.css @@ -2126,3 +2126,17 @@ a.mail-list-link { margin-top: 20px; } + +#photo-prev-link, #photo-next-link { + padding: 10px; + float: left; +} + +#photo-photo { + float: left; +} + +#photo-photo-end { + clear: both; +} +