Merge pull request #1622 from rabuzarus/albums_widget

move html to photo_albums.tpl
This commit is contained in:
fabrixxm 2015-05-31 10:07:43 +02:00
commit 1cf3e778e8
9 changed files with 74 additions and 32 deletions

View file

@ -42,42 +42,58 @@ 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'))
);
if(count($albums)) {
$a->data['albums'] = $albums;
$albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true);
if($albums_visible) {
$o .= '<div id="side-bar-photos-albums" class="widget">';
$o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>';
// add various encodings to the array so we can just loop through and pick them out in a template
$ret = array('success' => false);
$o .= '<ul>';
foreach($albums as $album) {
if($albums) {
$a->data['albums'] = $albums;
if ($albums_visible)
$ret['success'] = true;
// don't show contact photos. We once translated this name, but then you could still access it under
// a different language setting. Now we store the name in English and check in English (and translated for legacy albums).
if((! strlen($album['album'])) || ($album['album'] === 'Contact Photos') || ($album['album'] === t('Contact Photos')))
continue;
$o .= '<li>' . '<a href="photos/' . $a->argv[1] . '/album/' . bin2hex($album['album']) . '" >' . $album['album'] . '</a></li>';
$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']),
'urlencode' => urlencode($album['album']),
'bin2hex' => bin2hex($album['album'])
);
$ret['albums'][] = $entry;
}
$o .= '</ul>';
}
if(local_user() && $a->data['user']['uid'] == local_user()) {
$o .= '<div id="photo-albums-upload-link"><a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload" >' .t('Upload New Photos') . '</a></div>';
}
$o .= '</div>';
$albums = $ret;
if(local_user() && $a->data['user']['uid'] == local_user())
$can_post = true;
if($albums['success']) {
$photo_albums_widget = replace_macros(get_markup_template('photo_albums.tpl'),array(
'$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
));
}
if(! x($a->page,'aside'))
$a->page['aside'] = '';
$a->page['aside'] .= $vcard_widget;
$a->page['aside'] .= $o;
$a->page['aside'] .= $photo_albums_widget;
$tpl = get_markup_template("photos_head.tpl");

View file

@ -0,0 +1,17 @@
<div id="side-bar-photos-albums" class="widget">
<h3>{{$title}}</h3>
<ul>
<li><a href="{{$baseurl}}/photos/{{$nick}}" title="{{$title}}" >{{$recent}}</a></li>
{{if $albums}}
{{foreach $albums as $al}}
{{if $al.text}}
<li><a href="{{$baseurl}}/photos/{{$nick}}/album/{{$al.bin2hex}}"><span class="badge pull-right">{{$al.total}}</span>{{$al.text}}</a></li>
{{/if}}
{{/foreach}}
{{/if}}
</ul>
{{if $can_post}}
<div class="photos-upload-link" ><a href="{{$upload.1}}">{{$upload.0}}</a></div>
{{/if}}
</div>

View file

@ -83,6 +83,8 @@ blockquote {
margin-right: 5px;
}
.pull-right { float: right }
/* nav */
@ -3367,7 +3369,7 @@ ul.menu-popup {
#recip {
}
.autocomplete-w1 { background: #ffffff; no-repeat bottom right; position:absolute; top:0px; left:0px; margin:6px 0 0 6px; /* IE6 fix: */ _background:none; _margin:1px 0 0 0; }
.autocomplete-w1 { background: #ffffff no-repeat bottom right; position:absolute; top:0px; left:0px; margin:6px 0 0 6px; /* IE6 fix: */ _background:none; _margin:1px 0 0 0; }
.autocomplete { color:#000; border:1px solid #999; background:#FFF; cursor:default; text-align:left; max-height:350px; overflow:auto; margin:-6px 6px 6px -6px; /* IE6 specific: */ _height:350px; _margin:0; _overflow-x:hidden; }
.autocomplete .selected { background:#F0F0F0; }
.autocomplete div { padding:2px 5px; white-space:nowrap; overflow:hidden; }
@ -3443,7 +3445,7 @@ ul.menu-popup {
.nav-ajax-left {margin-left: -1em; margin-top: 0px; }
nav #site-location,
nav #banner { position: relative; clear:both; }
ul.menu-popup { left: 0px; top 20px; }
ul.menu-popup { left: 0px; top: 20px; }
}

View file

@ -21,7 +21,7 @@ body {
div.container {
display: block;
width: 785 px;
width: 785px;
margin-top: 0px;
margin-bottom: 0px;
margin-left: auto;
@ -111,6 +111,8 @@ blockquote {
margin-right: 5px;
}
.pull-right { float: right }
/* nav */
@ -4094,7 +4096,7 @@ ul.notifications-menu-popup {
#recip {
}
.autocomplete-w1 { background: #ffffff; no-repeat bottom right; position:absolute; top:0px; left:0px; margin:6px 0 0 6px; /* IE6 fix: */ _background:none; _margin:1px 0 0 0; }
.autocomplete-w1 { background: #ffffff no-repeat bottom right; position:absolute; top:0px; left:0px; margin:6px 0 0 6px; /* IE6 fix: */ _background:none; _margin:1px 0 0 0; }
.autocomplete { color:#000; border:1px solid #999; background:#FFF; cursor:default; text-align:left; max-height:350px; overflow:auto; margin:-6px 6px 6px -6px; /* IE6 specific: */ _height:350px; _margin:0; _overflow-x:hidden; }
.autocomplete .selected { background:#F0F0F0; }
.autocomplete div { padding:2px 5px; white-space:nowrap; overflow:hidden; }

View file

@ -414,7 +414,8 @@ a:hover {
.left {
float: left;
}
.right {
.right,
.pull-right {
float: right;
}
.hidden {

View file

@ -414,7 +414,8 @@ a:hover {
.left {
float: left;
}
.right {
.right,
.pull-right {
float: right;
}
.hidden {

View file

@ -414,7 +414,8 @@ a:hover {
.left {
float: left;
}
.right {
.right,
.pull-right {
float: right;
}
.hidden {

View file

@ -44,7 +44,7 @@ a:visited { color: @LinkVisited; text-decoration: none; }
a:hover {color: @LinkHover; text-decoration: underline; }
.left { float: left; }
.right { float: right; }
.right, .pull-right { float: right; }
.hidden { display: none; }
.clear { clear: both; }

View file

@ -104,6 +104,8 @@ input[type=submit]:active {
top: 1px;
}
.pull-right { float: right }
#search-text,
#search-submit,
#search-save {