diff options
author | marijus <mario@mariovavti.com> | 2014-10-25 15:23:20 +0200 |
---|---|---|
committer | marijus <mario@mariovavti.com> | 2014-10-25 15:23:20 +0200 |
commit | 6497e78956825dc845eb8a998369154c4d823a95 (patch) | |
tree | 7969b4f1105661ee7d81ea3eb8447386e7e43514 | |
parent | 59e19a1f45a3502559dd1df33c453aa2f99cb995 (diff) | |
download | volse-hubzilla-6497e78956825dc845eb8a998369154c4d823a95.tar.gz volse-hubzilla-6497e78956825dc845eb8a998369154c4d823a95.tar.bz2 volse-hubzilla-6497e78956825dc845eb8a998369154c4d823a95.zip |
some work on photos like/dislike
-rwxr-xr-x | mod/like.php | 1 | ||||
-rw-r--r-- | mod/photos.php | 40 | ||||
-rwxr-xr-x | view/tpl/nav.tpl | 3 | ||||
-rwxr-xr-x | view/tpl/photo_view.tpl | 85 |
4 files changed, 114 insertions, 15 deletions
diff --git a/mod/like.php b/mod/like.php index 916faf230..d17a42129 100755 --- a/mod/like.php +++ b/mod/like.php @@ -213,7 +213,6 @@ function like_content(&$a) { logger('like: verb ' . $verb . ' item ' . $item_id, LOGGER_DEBUG); - $r = q("SELECT * FROM item WHERE id = %d and item_restrict = 0 LIMIT 1", dbesc($item_id) ); diff --git a/mod/photos.php b/mod/photos.php index 06c566f47..003f7239d 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1023,7 +1023,7 @@ function photos_content(&$a) { $like = ''; $dislike = ''; - // display comments + if($r) { foreach($r as $item) { @@ -1031,10 +1031,33 @@ function photos_content(&$a) { like_puller($a,$item,$dlike,'dislike'); } - $like = ((isset($alike[$link_item['id']])) ? format_like($alike[$link_item['id']],$alike[$link_item['id'] . '-l'],'like',$link_item['id']) : ''); - $dislike = ((isset($dlike[$link_item['id']])) ? format_like($dlike[$link_item['id']],$dlike[$link_item['id'] . '-l'],'dislike',$link_item['id']) : ''); + $like_count = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid']] : ''); + $like_list = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid'] . '-l'] : ''); + if (count($like_list) > MAX_LIKERS) { + $like_list_part = array_slice($like_list, 0, MAX_LIKERS); + array_push($like_list_part, '<a href="#" data-toggle="modal" data-target="#likeModal-' . $this->get_id() . '"><b>' . t('View all') . '</b></a>'); + } else { + $like_list_part = ''; + } + $like_button_label = tt('Like','Likes',$like_count,'noun'); + + //if (feature_enabled($conv->get_profile_owner(),'dislike')) { + $dislike_count = ((x($dlike,$link_item['mid'])) ? $dlike[$link_item['mid']] : ''); + $dislike_list = ((x($dlike,$link_item['mid'])) ? $dlike[$link_item['mid'] . '-l'] : ''); + $dislike_button_label = tt('Dislike','Dislikes',$dislike_count,'noun'); + if (count($dislike_list) > MAX_LIKERS) { + $dislike_list_part = array_slice($dislike_list, 0, MAX_LIKERS); + array_push($dislike_list_part, '<a href="#" data-toggle="modal" data-target="#dislikeModal-' . $this->get_id() . '"><b>' . t('View all') . '</b></a>'); + } else { + $dislike_list_part = ''; + } + //} + + $like = ((isset($alike[$link_item['mid']])) ? format_like($alike[$link_item['mid']],$alike[$link_item['mid'] . '-l'],'like',$link_item['mid']) : ''); + $dislike = ((isset($dlike[$link_item['mid']])) ? format_like($dlike[$link_item['mid']],$dlike[$link_item['mid'] . '-l'],'dislike',$link_item['mid']) : ''); + // display comments foreach($r as $item) { $comment = ''; @@ -1128,6 +1151,17 @@ function photos_content(&$a) { '$likebuttons' => $likebuttons, '$like' => $like_e, '$dislike' => $dislike_e, + '$like_count' => $like_count, + '$like_list' => $like_list, + '$like_list_part' => $like_list_part, + '$like_button_label' => $like_button_label, + '$like_modal_title' => t('Likes','noun'), + '$dislike_modal_title' => t('Dislikes','noun'), + '$dislike_count' => $dislike_count, //((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_count : ''), + '$dislike_list' => $dislike_list, //((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_list : ''), + '$dislike_list_part' => $dislike_list_part, //((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_list_part : ''), + '$dislike_button_label' => $dislike_button_label, //((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_button_label : ''), + '$modal_dismiss' => t('Close'), '$comments' => $comments, '$commentbox' => $commentbox, '$paginate' => $paginate, diff --git a/view/tpl/nav.tpl b/view/tpl/nav.tpl index a283b35a8..a8a7a7da7 100755 --- a/view/tpl/nav.tpl +++ b/view/tpl/nav.tpl @@ -50,7 +50,8 @@ {{if $nav.register}}<li class="{{$nav.register.2}}"><a href="{{$nav.register.0}}" title="{{$nav.register.3}}" >{{$nav.register.1}}</a><li>{{/if}} {{if !$userinfo}} {{if $nav.loginmenu}} - <li class="{{$nav.loginmenu.0.2}} hidden-xs"><a data-toggle="dropdown" data-target="#" href="{{$nav.loginmenu.0.0}}" title="{{$nav.loginmenu.0.3}}" >{{$nav.loginmenu.0.1}} <span class="caret" id="usermenu-caret"></span></a> + <li class="{{$nav.loginmenu.0.2}} hidden-xs"> + <a data-toggle="dropdown" data-target="#" href="{{$nav.loginmenu.0.0}}" title="{{$nav.loginmenu.0.3}}" >{{$nav.loginmenu.0.1}} <span class="caret" id="usermenu-caret"></span></a> <ul class="dropdown-menu" role="menu"> {{foreach $nav.loginmenu as $loginmenu}} <li role="presentation"><a class="{{$loginmenu.2}}" href="{{$loginmenu.0}}" title="{{$loginmenu.3}}" role="menuitem">{{$loginmenu.1}}</a></li> diff --git a/view/tpl/photo_view.tpl b/view/tpl/photo_view.tpl index ddbce5b0b..f6b709247 100755 --- a/view/tpl/photo_view.tpl +++ b/view/tpl/photo_view.tpl @@ -81,24 +81,89 @@ <div id="photo-photo"><a href="{{$photo.href}}" title="{{$photo.title}}" onclick="$.colorbox({href: '{{$photo.href}}'}); return false;"><img style="width: 100%;" src="{{$photo.src}}"></a></div> <div id="photo-photo-end"></div> + {{if $tags}} + <div class="photo-item-tools-left" id="in-this-photo"> + <span id="in-this-photo-text">{{$tag_hdr}}</span> + {{foreach $tags as $t}} + {{$t.0}}{{if $edit}}<span id="tag-remove"> <a href="{{$t.1}}"><i class="icon-remove"></i></a> </span>{{/if}} + {{/foreach}} + </div> + {{/if}} + <div class="photo-item-tools"> - {{if $tags}} + {{if $like_count || $dislike_count}} <div class="photo-item-tools-left pull-left"> - <div id="in-this-photo"> - <span id="in-this-photo-text">{{$tag_hdr}}</span> - {{foreach $tags as $t}} - {{$t.0}}{{if $edit}}<span id="tag-remove"> <a href="{{$t.1}}"><i class="icon-remove"></i></a> </span>{{/if}} - {{/foreach}} + <div class="{{if $like_count && $dislike_count}}btn-group{{/if}}"> + {{if $like_count}} + <div class="btn-group"> + <button type="button" class="btn btn-default btn-sm wall-item-like dropdown-toggle" data-toggle="dropdown" id="wall-item-like-{{$id}}">{{$like_count}} {{$like_button_label}}</button> + {{if $like_list_part}} + <ul class="dropdown-menu" role="menu" aria-labelledby="wall-item-like-{{$item.id}}">{{foreach $like_list_part as $liker}}<li role="presentation">{{$liker}}</li>{{/foreach}}</ul> + {{else}} + <ul class="dropdown-menu" role="menu" aria-labelledby="wall-item-like-{{$item.id}}">{{foreach $like_list as $liker}}<li role="presentation">{{$liker}}</li>{{/foreach}}</ul> + {{/if}} + </div> + {{/if}} + {{if $dislike_count}} + <div class="btn-group"> + <button type="button" class="btn btn-default btn-sm wall-item-dislike dropdown-toggle" data-toggle="dropdown" id="wall-item-dislike-{{$id}}">{{$dislike_count}} {{$dislike_button_label}}</button> + {{if $dislike_list_part}} + <ul class="dropdown-menu" role="menu" aria-labelledby="wall-item-dislike-{{$id}}">{{foreach $dislike_list_part as $disliker}}<li role="presentation">{{$disliker}}</li>{{/foreach}}</ul> + {{else}} + <ul class="dropdown-menu" role="menu" aria-labelledby="wall-item-dislike-{{$id}}">{{foreach $dislike_list as $disliker}}<li role="presentation">{{$disliker}}</li>{{/foreach}}</ul> + {{/if}} + </div> + {{/if}} + </div> + {{if $like_list_part}} + <div class="modal" id="likeModal-{{$id}}"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> + <h4 class="modal-title">{{$like_modal_title}}</h4> + </div> + <div class="modal-body"> + <ul>{{foreach $like_list as $liker}}<li role="presentation">{{$liker}}</li>{{/foreach}}</ul> + </div> + <div class="modal-footer clear"> + <button type="button" class="btn btn-default" data-dismiss="modal">{{$modal_dismiss}}</button> + </div> + </div><!-- /.modal-content --> + </div><!-- /.modal-dialog --> + </div><!-- /.modal --> + {{/if}} + {{if $dislike_list_part}} + <div class="modal" id="dislikeModal-{{$id}}"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> + <h4 class="modal-title">{{$dislike_modal_title}}</h4> + </div> + <div class="modal-body"> + <ul>{{foreach $dislike_list as $disliker}}<li role="presentation">{{$disliker}}</li>{{/foreach}}</ul> + </div> + <div class="modal-footer clear"> + <button type="button" class="btn btn-default" data-dismiss="modal">{{$modal_dismiss}}</button> + </div> + </div><!-- /.modal-content --> + </div><!-- /.modal-dialog --> + </div><!-- /.modal --> + {{/if}} </div> </div> {{/if}} + {{if $likebuttons}} <div class="photo-item-tools-right btn-group pull-right"> - <i class="icon-thumbs-up-alt item-tool btn btn-default btn-sm" title="{{$likethis}}" onclick="dolike({{$id}},'like'); return false"></i> - <i class="icon-thumbs-down-alt item-tool btn btn-default btn-sm" title="{{$nolike}}" onclick="dolike({{$id}},'dislike'); return false"></i> - {{$like}} - {{$dislike}} + <button type="button" class="btn btn-default btn-sm" onclick="dolike({{$id}},'like'); return false"> + <i class="icon-thumbs-up-alt" title="{{$likethis}}"></i> + </button> + <button type="button" class="btn btn-default btn-sm" onclick="dolike({{$id}},'dislike'); return false"> + <i class="icon-thumbs-down-alt" title="{{$nolike}}"></i> + </button> </div> <div id="like-rotator-{{$id}}" class="like-rotator pull-right"></div> {{/if}} |