From 15499ff1aa7154aecddb4b801c4c0b96f6a2df76 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Wed, 27 May 2015 03:35:29 +0200 Subject: [PATCH 1/5] first step to get html code from photos.php removed --- mod/photos.php | 53 ++++++++++++++++++++++++++++++++- view/templates/photo_albums.tpl | 13 ++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 view/templates/photo_albums.tpl diff --git a/mod/photos.php b/mod/photos.php index f8bba01b0..3ae5bbf39 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -41,8 +41,57 @@ function photos_init(&$a) { $albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d $sql_extra order by created desc", intval($a->data['user']['uid']) ); + + $ret = array('success' => false); + $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true); + + foreach($albums as $k => $album) { + if( $album['album'] === 'Contact Photos') { + unset ($albums[$k]['album']); + } + } - if(count($albums)) { + if($albums) { + if ($albums_visible) { + $ret['success'] = true; + } + $ret['albums'] = array(); + foreach($albums as $k => $album) { + $entry = array( + 'text' => $album['album'], + 'total' => $album['total'], + 'url' => z_root() . '/photos/' . $channel['channel_address'] . '/album/' . bin2hex($album['album']), + 'urlencode' => urlencode($album['album']), + 'bin2hex' => bin2hex($album['album']) + ); + $ret['albums'][] = $entry; + } + } + + /*return $ret;*/ + + $o = ''; + + if(! $albums) { + if(array_key_exists('albums', get_app()->data)) + $albums = get_app()->data['albums']; + else + $albums = $ret; + } + + $albums = $ret; + + + if($albums['success']) { + $o = replace_macros(get_markup_template('photo_albums.tpl'),array( + '$nick' => $a->data['user']['nickname'], + '$title' => t('Photo Albums'), + '$albums' => $albums['albums'], + '$baseurl' => z_root() + )); + } + +/* if(count($albums)) { $a->data['albums'] = $albums; $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true); @@ -69,6 +118,8 @@ function photos_init(&$a) { $o .= ''; } + * + */ if(! x($a->page,'aside')) $a->page['aside'] = ''; diff --git a/view/templates/photo_albums.tpl b/view/templates/photo_albums.tpl new file mode 100644 index 000000000..bbbf5c4a9 --- /dev/null +++ b/view/templates/photo_albums.tpl @@ -0,0 +1,13 @@ +
From 415a606a59cd68d7a2c85abaf8bae14fe76dbeef Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Thu, 28 May 2015 15:54:53 +0200 Subject: [PATCH 2/5] better solution to exclude Contact Photos and include count of Photos --- mod/photos.php | 79 +++++++++------------------------ view/templates/photo_albums.tpl | 8 +++- 2 files changed, 28 insertions(+), 59 deletions(-) diff --git a/mod/photos.php b/mod/photos.php index 3ae5bbf39..1bb380696 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -38,29 +38,29 @@ function photos_init(&$a) { $sql_extra = permissions_sql($a->data['user']['uid']); - $albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d $sql_extra order by created desc", - intval($a->data['user']['uid']) + $albums = q("SELECT count(distinct `resource-id`) AS `total`, `album` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' + $sql_extra group by album order by created desc", + intval($a->data['user']['uid']), + dbesc('Contact Photos'), + dbesc( t('Contact Photos')) ); - - $ret = array('success' => false); + $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true); - foreach($albums as $k => $album) { - if( $album['album'] === 'Contact Photos') { - unset ($albums[$k]['album']); - } - } - + // add various encodings to the array so we can just loop through and pick them out in a template + $ret = array('success' => false); + if($albums) { - if ($albums_visible) { + $a->data['albums'] = $albums; + if ($albums_visible) $ret['success'] = true; - } + $ret['albums'] = array(); foreach($albums as $k => $album) { $entry = array( 'text' => $album['album'], 'total' => $album['total'], - 'url' => z_root() . '/photos/' . $channel['channel_address'] . '/album/' . bin2hex($album['album']), + 'url' => z_root() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album['album']), 'urlencode' => urlencode($album['album']), 'bin2hex' => bin2hex($album['album']) ); @@ -68,62 +68,27 @@ function photos_init(&$a) { } } - /*return $ret;*/ - - $o = ''; - - if(! $albums) { - if(array_key_exists('albums', get_app()->data)) - $albums = get_app()->data['albums']; - else - $albums = $ret; - } - - $albums = $ret; - + $albums = $ret; + + if(local_user() && $a->data['user']['uid'] == local_user()) + $can_post = true; if($albums['success']) { - $o = replace_macros(get_markup_template('photo_albums.tpl'),array( + $photo_albums_widget = replace_macros(get_markup_template('photo_albums.tpl'),array( '$nick' => $a->data['user']['nickname'], '$title' => t('Photo Albums'), '$albums' => $albums['albums'], - '$baseurl' => z_root() + '$baseurl' => z_root(), + '$upload' => array( t('Upload New Photos'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload/' . bin2hex($album)), + '$can_post' => $can_post )); } -/* if(count($albums)) { - $a->data['albums'] = $albums; - - $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true); - - if($albums_visible) { - $o .= ' '; - } - * - */ if(! x($a->page,'aside')) $a->page['aside'] = ''; $a->page['aside'] .= $o; + $a->page['aside'] .= $photo_albums_widget; $tpl = get_markup_template("photos_head.tpl"); diff --git a/view/templates/photo_albums.tpl b/view/templates/photo_albums.tpl index bbbf5c4a9..de8f2cd16 100644 --- a/view/templates/photo_albums.tpl +++ b/view/templates/photo_albums.tpl @@ -1,13 +1,17 @@ From 5cbb5b140c62c07a512861217ee61058580d6901 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 29 May 2015 16:08:17 +0200 Subject: [PATCH 3/5] css work --- mod/photos.php | 17 +++++++++-------- view/templates/photo_albums.tpl | 2 +- view/theme/duepuntozero/style.css | 6 ++++-- view/theme/frost/style.css | 6 ++++-- view/theme/quattro/dark/style.css | 3 ++- view/theme/quattro/green/style.css | 3 ++- view/theme/quattro/lilac/style.css | 3 ++- view/theme/quattro/quattro.less | 2 +- view/theme/smoothly/style.css | 2 ++ 9 files changed, 27 insertions(+), 17 deletions(-) diff --git a/mod/photos.php b/mod/photos.php index 1bb380696..8ec83b622 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -58,11 +58,11 @@ function photos_init(&$a) { $ret['albums'] = array(); foreach($albums as $k => $album) { $entry = array( - 'text' => $album['album'], - 'total' => $album['total'], - 'url' => z_root() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album['album']), + 'text' => $album['album'], + 'total' => $album['total'], + 'url' => z_root() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album['album']), 'urlencode' => urlencode($album['album']), - 'bin2hex' => bin2hex($album['album']) + 'bin2hex' => bin2hex($album['album']) ); $ret['albums'][] = $entry; } @@ -75,10 +75,11 @@ function photos_init(&$a) { if($albums['success']) { $photo_albums_widget = replace_macros(get_markup_template('photo_albums.tpl'),array( - '$nick' => $a->data['user']['nickname'], - '$title' => t('Photo Albums'), - '$albums' => $albums['albums'], - '$baseurl' => z_root(), + '$nick' => $a->data['user']['nickname'], + '$title' => t('Photo Albums'), + 'recent' => t('Recent Photos'), + '$albums' => $albums['albums'], + '$baseurl' => z_root(), '$upload' => array( t('Upload New Photos'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload/' . bin2hex($album)), '$can_post' => $can_post )); diff --git a/view/templates/photo_albums.tpl b/view/templates/photo_albums.tpl index de8f2cd16..02b439295 100644 --- a/view/templates/photo_albums.tpl +++ b/view/templates/photo_albums.tpl @@ -1,7 +1,7 @@