aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/conversation.php142
-rwxr-xr-xview/tpl/conv_item.tpl12
-rwxr-xr-xview/tpl/conv_list.tpl4
3 files changed, 77 insertions, 81 deletions
diff --git a/include/conversation.php b/include/conversation.php
index b777e479b..4da6636fa 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -552,7 +552,12 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
$items = $cb['items'];
- $conv_responses = array(array('like'),array('dislike'),array('agree'),array('disagree'),array('abstain'),array('attendyes'),array('attendno'),array('attendmaybe'));
+ $conv_responses = array(
+ 'like' => array('title' => t('Likes','title')),'dislike' => array('title' => t('Dislikes','title')),
+ 'agree' => array('title' => t('Agree','title')),'disagree' => array('title' => t('Disagree','title')), 'abstain' => array('title' => t('Abstain','title')),
+ 'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title'))
+ );
+
// array with html for each thread (parent+comments)
$threads = array();
@@ -779,18 +784,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
}
}
- like_puller($a, $item, $conv_responses, 'like');
-
- if(feature_enabled($profile_owner, 'dislike'))
- like_puller($a, $item, $conv_responses, 'dislike');
-
- like_puller($a, $item, $conv_responses, 'attendyes');
- like_puller($a, $item, $conv_responses, 'attendno');
- like_puller($a, $item, $conv_responses, 'attendmaybe');
- like_puller($a, $item, $conv_responses, 'agree');
- like_puller($a, $item, $conv_responses, 'disagree');
- like_puller($a, $item, $conv_responses, 'abstain');
-
+ builtin_activity_puller($item, $conv_responses);
if(! visible_activity($item)) {
continue;
@@ -968,81 +962,82 @@ function item_photo_menu($item){
}
/**
- * @brief Returns a like/dislike entry.
- * It gives back a HTML link to the channel that liked/disliked.
+ * @brief Checks item to see if it is one of the builtin activities (like/dislike, event attendance, consensus items, etc.)
+ * Increments the count of each matching activity and adds a link to the author as needed.
*
* @param array $a (not used)
* @param array $item
- * @param array &$arr
- * @param string $mode like/dislike
+ * @param array &$conv_responses (already created with builtin activity structure)
* @return void
*/
-function like_puller($a, $item, &$arr, $mode) {
+function builtin_activity_puller($item, &$conv_responses) {
- $url = '';
- switch($mode) {
- case 'like':
- case 'unlike':
- $verb = ACTIVITY_LIKE;
- break;
- case 'dislike':
- case 'undislike':
- $verb = ACTIVITY_DISLIKE;
- break;
- case 'agree':
- case 'unagree':
- $verb = ACTIVITY_AGREE;
- break;
- case 'disagree':
- case 'undisagree':
- $verb = ACTIVITY_DISAGREE;
- break;
- case 'abstain':
- case 'unabstain':
- $verb = ACTIVITY_ABSTAIN;
- break;
- case 'attendyes':
- case 'unattendyes':
- $verb = ACTIVITY_ATTEND;
- break;
- case 'attendno':
- case 'unattendno':
- $verb = ACTIVITY_ATTENDNO;
- break;
- case 'attendmaybe':
- case 'unattendmaybe':
- $verb = ACTIVITY_ATTENDMAYBE;
- break;
- default:
- return;
- break;
- }
- if((activity_match($item['verb'], $verb)) && ($item['id'] != $item['parent'])) {
+ foreach($conv_responses as $mode => $v) {
- if($item['author']['xchan_url'])
- $url = chanlink_url($item['author']['xchan_url']);
+ $url = '';
- if(! $item['thr_parent'])
- $item['thr_parent'] = $item['parent_mid'];
+ switch($mode) {
+ case 'like':
+ $verb = ACTIVITY_LIKE;
+ break;
+ case 'dislike':
+ $verb = ACTIVITY_DISLIKE;
+ break;
+ case 'agree':
+ $verb = ACTIVITY_AGREE;
+ break;
+ case 'disagree':
+ $verb = ACTIVITY_DISAGREE;
+ break;
+ case 'abstain':
+ $verb = ACTIVITY_ABSTAIN;
+ break;
+ case 'attendyes':
+ $verb = ACTIVITY_ATTEND;
+ break;
+ case 'attendno':
+ $verb = ACTIVITY_ATTENDNO;
+ break;
+ case 'attendmaybe':
+ $verb = ACTIVITY_ATTENDMAYBE;
+ break;
+ default:
+ return;
+ break;
+ }
- if(! ((isset($arr[$mode][$item['thr_parent'] . '-l'])) && (is_array($arr[$mode][$item['thr_parent'] . '-l']))))
- $arr[$mode][$item['thr_parent'] . '-l'] = array();
- if(! isset($arr[$mode][$item['thr_parent']]))
- $arr[$mode][$item['thr_parent']] = 1;
- else
- $arr[$mode][$item['thr_parent']] ++;
- $name = (($item['author']['xchan_name']) ? $item['author']['xchan_name'] : t('Unknown'));
+ if((activity_match($item['verb'], $verb)) && ($item['id'] != $item['parent'])) {
- if($url)
- $arr[$mode][$item['thr_parent'] . '-l'][] = '<a href="'. $url . '">' . $name . '</a>';
- else
- $arr[$mode][$item['thr_parent'] . '-l'][] = '<a href="#" class="disabled">' . $name . '</a>';
+
+ $name = (($item['author']['xchan_name']) ? $item['author']['xchan_name'] : t('Unknown'));
+ $url = (($item['author']['xchan_url'])
+ ? '<a href="' . chanlink_url($item['author']['xchan_url']) . '">' . $name . '</a>'
+ : '<a href="#" class="disabled">' . $name . '</a>'
+ );
+
+ if(! $item['thr_parent'])
+ $item['thr_parent'] = $item['parent_mid'];
+
+ if(! ((isset($conv_responses[$mode][$item['thr_parent'] . '-l']))
+ && (is_array($conv_responses[$mode][$item['thr_parent'] . '-l']))))
+ $conv_responses[$mode][$item['thr_parent'] . '-l'] = array();
+
+ // only list each unique author once
+ if(in_array($url,$conv_responses[$mode][$item['thr_parent'] . '-l']))
+ continue;
+
+ if(! isset($conv_responses[$mode][$item['thr_parent']]))
+ $conv_responses[$mode][$item['thr_parent']] = 1;
+ else
+ $conv_responses[$mode][$item['thr_parent']] ++;
+
+ $conv_responses[$mode][$item['thr_parent'] . '-l'][] = $url;
+ }
}
- return;
}
// Format the like/dislike text for a profile item
@@ -1662,6 +1657,7 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
$ret[$v]['list_part'] = '';
}
$ret[$v]['button'] = get_response_button_text($v,$ret[$v]['count']);
+ $ret[$v]['title'] = $conv_responses[$v]['title'];
}
$ret['count'] = count($ret);
return $ret;
diff --git a/view/tpl/conv_item.tpl b/view/tpl/conv_item.tpl
index d1d197dc1..df20eadbb 100755
--- a/view/tpl/conv_item.tpl
+++ b/view/tpl/conv_item.tpl
@@ -56,21 +56,21 @@
<div class="wall-item-tools">
<div class="wall-item-tools-right btn-group pull-right">
{{if $item.like}}
- <button type="button" title="{{$item.like.0}}" class="btn btn-default btn-sm" onclick="dolike({{$item.id}},'like'); return false">
+ <button type="button" title="{{$item.like.0}}" class="btn btn-default btn-sm" onclick="dolike({{$item.id}},'like'); return false;">
<i class="icon-thumbs-up-alt" ></i>
</button>
{{/if}}
{{if $item.dislike}}
- <button type="button" title="{{$item.dislike.0}}" class="btn btn-default btn-sm" onclick="dolike({{$item.id}},'dislike'); return false">
+ <button type="button" title="{{$item.dislike.0}}" class="btn btn-default btn-sm" onclick="dolike({{$item.id}},'dislike'); return false;">
<i class="icon-thumbs-down-alt" ></i>
</button>
{{/if}}
{{if $item.isevent}}
<button type="button" title="{{$item.attend.0}}" class="btn btn-default btn-sm" onclick="itemAddToCal({{$item.id}}); dolike({{$item.id}},'attendyes'); return false;">
- <i class="icon-plus" ></i>
+ <i class="icon-check" ></i>
</button>
- <button type="button" title="{{$item.attend.1}}" class="btn btn-default btn-sm" onclick="itemAddToCal({{$item.id}}); dolike({{$item.id}},'attendno'); return false;">
- <i class="icon-minus" ></i>
+ <button type="button" title="{{$item.attend.1}}" class="btn btn-default btn-sm" onclick="dolike({{$item.id}},'attendno'); return false;">
+ <i class="icon-check-empty" ></i>
</button>
<button type="button" title="{{$item.attend.2}}" class="btn btn-default btn-sm" onclick="itemAddToCal({{$item.id}}); dolike({{$item.id}},'attendmaybe'); return false;">
<i class="icon-question" ></i>
@@ -136,7 +136,7 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
- <h4 class="modal-title">{{$response.modal_title}}</h4>
+ <h4 class="modal-title">{{$response.title}}</h4>
</div>
<div class="modal-body">
<ul>{{foreach $response.list as $liker}}<li role="presentation">{{$liker}}</li>{{/foreach}}</ul>
diff --git a/view/tpl/conv_list.tpl b/view/tpl/conv_list.tpl
index 3d4b7608d..ad086ee0a 100755
--- a/view/tpl/conv_list.tpl
+++ b/view/tpl/conv_list.tpl
@@ -143,7 +143,7 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
- <h4 class="modal-title">{{$response.modal_title}}</h4>
+ <h4 class="modal-title">{{$response.title}}</h4>
</div>
<div class="modal-body">
<ul>{{foreach $response.list as $liker}}<li role="presentation">{{$liker}}</li>{{/foreach}}</ul>
@@ -158,7 +158,7 @@
{{/foreach}}
</div>
{{/if}}
-
+ </div>
</div>
<div class="clear"></div>
</div>