diff options
author | friendica <info@friendica.com> | 2015-02-09 21:18:50 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2015-02-09 21:18:50 -0800 |
commit | c69494524590b7ffa07fcab6780c603ded2cb720 (patch) | |
tree | ee1288ec9d159211649e9ecbd865bb5d849cab8c /include | |
parent | 55c3c54ef6fe3f3d80df01c94d334bdfbf395683 (diff) | |
download | volse-hubzilla-c69494524590b7ffa07fcab6780c603ded2cb720.tar.gz volse-hubzilla-c69494524590b7ffa07fcab6780c603ded2cb720.tar.bz2 volse-hubzilla-c69494524590b7ffa07fcab6780c603ded2cb720.zip |
like formatting for extended consensus items
Diffstat (limited to 'include')
-rw-r--r-- | include/ItemObject.php | 23 | ||||
-rw-r--r-- | include/conversation.php | 53 |
2 files changed, 76 insertions, 0 deletions
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; + } +} |