diff options
-rw-r--r-- | doc/roadmap.bb | 3 | ||||
-rw-r--r-- | include/ItemObject.php | 23 | ||||
-rw-r--r-- | include/conversation.php | 53 | ||||
-rwxr-xr-x | view/tpl/conv_item.tpl | 90 |
4 files changed, 108 insertions, 61 deletions
diff --git a/doc/roadmap.bb b/doc/roadmap.bb index fb4b83bb4..e38f5a981 100644 --- a/doc/roadmap.bb +++ b/doc/roadmap.bb @@ -21,9 +21,6 @@ Migration tools Friendica importer Diaspora importer -Poco reputation - Make it happen - Webpage design UI improvements If practical, separate "conversation" sub-themes from overall themes so one can choose different conversation and content layouts within a base theme. Make webpage building easy, with point-n-click selectors to build PDLs diff --git a/include/ItemObject.php b/include/ItemObject.php index 344664fd2..8f1112f6a 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -135,6 +135,28 @@ class Item extends BaseObject { $location = format_location($item); + + // process action responses - e.g. like/dislike/attend/agree/whatever + $response_verbs = array('like'); + if(feature_enabled($conv->get_profile_owner(),'dislike')) + $response_verbs[] = 'dislike'; + if($item['resource_type'] === 'event') { + $response_verbs[] = 'attendyes'; + $response_verbs[] = 'attendno'; + $response_verbs[] = 'attendmaybe'; + } + $consensus = (($item['item_flags'] & ITEM_CONSENSUS)? true : false); + if($consensus) { + $response_verbs[] = 'agree'; + $response_verbs[] = 'disagree'; + $response_verbs[] = 'abstain'; + } + + $responses = get_responses($conv_responses,$response_verbs,$this,$item); + + + $like_button_label = tt('Like','Likes',$like_count,'noun'); + $like_count = ((x($conv_responses['like'],$item['mid'])) ? $conv_responses['like'][$item['mid']] : ''); $like_list = ((x($conv_responses['like'],$item['mid'])) ? $conv_responses['like'][$item['mid'] . '-l'] : ''); if (count($like_list) > MAX_LIKERS) { @@ -307,6 +329,7 @@ class Item extends BaseObject { 'comment_count_txt' => $comment_count_txt, 'list_unseen_txt' => $list_unseen_txt, 'markseen' => t('Mark all seen'), + 'responses' => $responses, 'like_count' => $like_count, 'like_list' => $like_list, 'like_list_part' => $like_list_part, diff --git a/include/conversation.php b/include/conversation.php index 27b52ba6e..244c812ef 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1629,3 +1629,56 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ return replace_macros($tpl,array('$tabs' => $arr['tabs'])); } + + +function get_responses($conv_responses,$response_verbs,$ob,$item) { + $ret = array(); + foreach($response_verbs as $v) { + $ret[$v] = array(); + $ret[$v]['count'] = ((x($conv_responses[$v],$item['mid'])) ? $conv_responses[$v][$item['mid']] : ''); + $ret[$v]['list'] = ((x($conv_responses[$v],$item['mid'])) ? $conv_responses[$v][$item['mid'] . '-l'] : ''); + if(count($ret[$v]['list']) > MAX_LIKERS) { + $ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS); + array_push($ret[$v]['list_part'], '<a href="#" data-toggle="modal" data-target="#' . $v . 'Modal-' + . $ob->get_id() . '"><b>' . t('View all') . '</b></a>'); + } + else { + $ret[$v]['list_part'] = ''; + } + $ret[$v]['button'] = get_response_button_text($v,$ret[$v]['count']); + } + $ret['count'] = count($ret); + return $ret; +} + +function get_response_button_text($v,$count) { + switch($v) { + case 'like': + return tt('Like','Likes',$count,'noun'); + break; + case 'dislike': + return tt('Dislike','Dislikes',$count,'noun'); + break; + case 'attendyes': + return tt('Attending','Attending',$count,'noun'); + break; + case 'attendno': + return tt('Not Attending','Not Attending',$count,'noun'); + break; + case 'attendmaybe': + return tt('Undecided','Undecided',$count,'noun'); + break; + case 'agree': + return tt('Agree','Agrees',$count,'noun'); + break; + case 'agree': + return tt('Disagree','Disagrees',$count,'noun'); + break; + case 'abstain': + return tt('Abstain','Abstains',$count,'noun'); + break; + default: + return ''; + break; + } +} diff --git a/view/tpl/conv_item.tpl b/view/tpl/conv_item.tpl index f30ca7fc0..95f6bb2b6 100755 --- a/view/tpl/conv_item.tpl +++ b/view/tpl/conv_item.tpl @@ -104,72 +104,46 @@ </ul> </div> <div id="like-rotator-{{$item.id}}" class="like-rotator"></div> - <div class="wall-item-tools-left{{if $item.like_count && $item.dislike_count}} btn-group{{/if}}"> - {{if $item.like_count}} + + {{if $item.responses }} + <div class="wall-item-tools-left{{if $item.responses.count > 1}} btn-group{{/if}}"> + {{foreach $item.responses as $verb=>$response}} + {{if $response.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-{{$item.id}}">{{$item.like_count}} {{$item.like_button_label}}</button> - {{if $item.like_list_part}} - <ul class="dropdown-menu" role="menu" aria-labelledby="wall-item-like-{{$item.id}}">{{foreach $item.like_list_part as $liker}}<li role="presentation">{{$liker}}</li>{{/foreach}}</ul> + <button type="button" class="btn btn-default btn-sm wall-item-like dropdown-toggle" data-toggle="dropdown" id="wall-item-{{$verb}}-{{$item.id}}">{{$response.count}} {{$response.button}}</button> + {{if $response.list_part}} + <ul class="dropdown-menu" role="menu" aria-labelledby="wall-item-{{$verb}}-{{$item.id}}">{{foreach $response.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 $item.like_list as $liker}}<li role="presentation">{{$liker}}</li>{{/foreach}}</ul> + <ul class="dropdown-menu" role="menu" aria-labelledby="wall-item-{{$verb}}-{{$item.id}}">{{foreach $response.list as $liker}}<li role="presentation">{{$liker}}</li>{{/foreach}}</ul> {{/if}} </div> {{/if}} - {{if $item.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-{{$item.id}}">{{$item.dislike_count}} {{$item.dislike_button_label}}</button> - {{if $item.dislike_list_part}} - <ul class="dropdown-menu" role="menu" aria-labelledby="wall-item-dislike-{{$item.id}}">{{foreach $item.dislike_list_part as $disliker}}<li role="presentation">{{$disliker}}</li>{{/foreach}}</ul> - {{else}} - <ul class="dropdown-menu" role="menu" aria-labelledby="wall-item-dislike-{{$item.id}}">{{foreach $item.dislike_list as $disliker}}<li role="presentation">{{$disliker}}</li>{{/foreach}}</ul> - {{/if}} - </div> + + {{if $response.list_part}} + <div class="modal" id="{{$verb}}Modal-{{$item.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">{{$response.modal_title}}</h4> + </div> + <div class="modal-body"> + <ul>{{foreach $response.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">{{$item.modal_dismiss}}</button> + </div> + </div><!-- /.modal-content --> + </div><!-- /.modal-dialog --> + </div><!-- /.modal --> {{/if}} - </div> - {{if $item.like_list_part}} - <div class="modal" id="likeModal-{{$item.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">{{$item.like_modal_title}}</h4> - </div> - <div class="modal-body"> - <ul>{{foreach $item.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">{{$item.modal_dismiss}}</button> - </div> - </div><!-- /.modal-content --> - </div><!-- /.modal-dialog --> - </div><!-- /.modal --> - {{/if}} - {{if $item.dislike_list_part}} - <div class="modal" id="dislikeModal-{{$item.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">{{$item.dislike_modal_title}}</h4> - </div> - <div class="modal-body"> - <ul>{{foreach $item.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">{{$item.modal_dismiss}}</button> - </div> - </div><!-- /.modal-content --> - </div><!-- /.modal-dialog --> - </div><!-- /.modal --> + {{/foreach}} +</div> {{/if}} - </div> - {{* we dont' use this do we? - {{if $item.drop.pagedrop}} - <input type="checkbox" onclick="checkboxhighlight(this);" title="{{$item.drop.select}}" class="item-select" name="itemselected[]" value="{{$item.id}}" /> - {{/if}} - *}} + +</div> <div class="clear"></div> - </div> + <div class="wall-item-wrapper-end"></div> <div class="wall-item-outside-wrapper-end {{$item.indent}}" ></div> </div> |