Skip to content

Commit

Permalink
Now showing the retweets for the original broadcasted post.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Ellis committed Oct 3, 2011
1 parent 99cc8cf commit 687fa1f
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 8 deletions.
24 changes: 24 additions & 0 deletions assets/comments.css
Original file line number Diff line number Diff line change
Expand Up @@ -802,4 +802,28 @@ override submit styles in TwentyEleven theme */
}
.social-aggregation-results {
white-space: nowrap;
}

/**
* Social items display (retweets, likes, etc...)
*/
.social-items {
clear: both;
}

#social .social-items-icon {
float: left;
margin: 2px 5px;
}

#social .social-items-comments img {
float: left;
margin: 2px;
}

#social .social-items-and-more {
float: left;
margin: 8px 0 0 5px;
font-size: 11px;
color: #666;
}
Binary file added assets/retweet.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions assets/social.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,5 +268,16 @@
T.hovercards();
});
}

/**
* Social items
*/
if ($('.social-items-and-more').length) {
$('.social-items-and-more').click(function(e){
e.preventDefault();

$(this).hide().parent().find('img').show();
});
}
});
})(jQuery);
2 changes: 1 addition & 1 deletion lib/social/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function add_to_social_items($key, $comment_id, array &$comments,
$comments['social_items']['parent'][$key] = array();
}

$comments['social_items']['parent'][$key][] = $object;
$comments['social_items']['parent'][$key][$comment_id] = $object;
}
else {
if (!isset($comments['social_items'])) {
Expand Down
26 changes: 26 additions & 0 deletions lib/social/service/twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,32 @@ public function response_id_key() {
return 'id_str';
}

/**
* Returns the Social items icon.
*
* @return string
*/
public function social_items_icon() {
$icon = apply_filters('social_items_icon', Social::$plugins_url.'assets/retweet.png', $this->_key);
return '<img src="'.$icon.'" alt="'.$this->_key.'" />';
}

/**
* Returns the avatar of the retweeted status.
*
* @param object $item
* @param int $count
* @return string
*/
public function social_item_output($item, $count = 0) {
$style = '';
if ($count >= 10) {
$style = ' style="display:none"';
}
$image = sprintf('<img src="%s" width="24" height="24"%s />', $item->social_profile_image_url, $style);
return sprintf('<a href="%s">%s</a>', $this->status_url($item->comment_author, $item->social_status_id), $image);
}

/**
* Returns the status URL to a broadcasted item.
*
Expand Down
18 changes: 13 additions & 5 deletions social-twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public static function comments_array(array $comments, $post_id) {
AND meta_key = 'social_in_reply_to_status_id'
OR meta_key = 'social_status_id'
OR meta_key = 'social_raw_data'
OR meta_key = 'social_profile_image_url'
");

$broadcasted_ids = get_post_meta($post_id, '_social_broadcasted_ids', true);
Expand Down Expand Up @@ -92,11 +93,18 @@ public static function comments_array(array $comments, $post_id) {
if (count($_results)) {
$parents = array();
foreach ($_results as $result) {
if (isset($in_reply_ids[$result->meta_value])) {
foreach ($in_reply_ids[$result->meta_value] AS $comment_id) {
$parents[$comment_id] = $result->comment_id;
}
}
if (in_array($result->meta_key, array('social_status_id', 'social_profile_image_url')) and isset($comments['social_items'])) {
if (isset($comments['social_items']['parent']) and
isset($comments['social_items']['parent']['twitter']) and
isset($comments['social_items']['parent']['twitter'][$result->comment_id])) {
$comments['social_items']['parent']['twitter'][$result->comment_id]->{$result->meta_key} = $result->meta_value;
}
}
else if (isset($in_reply_ids[$result->meta_value])) {
foreach ($in_reply_ids[$result->meta_value] AS $comment_id) {
$parents[$comment_id] = $result->comment_id;
}
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions views/comment/social_item.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
<?php
$i = 0;
foreach ($items as $item) {
echo $service->social_item_output($item, $i);
echo $service->social_item_output($item, $i);
++$i;
}

if ($i >= 10) {
echo sprintf(__('<a href="%s">... and %s more</a>', Social::$i18n), '', ($i - 10));
echo sprintf(__('<a href="%s" class="social-items-and-more">... and %s more</a>', Social::$i18n), '', ($i - 10));
}
?>
</div>
Expand Down

0 comments on commit 687fa1f

Please sign in to comment.