From 687fa1fc981b49893a34dba788a1775f78530557 Mon Sep 17 00:00:00 2001 From: Andrew Ellis Date: Mon, 3 Oct 2011 09:48:50 -0600 Subject: [PATCH] Now showing the retweets for the original broadcasted post. --- assets/comments.css | 24 ++++++++++++++++++++++++ assets/retweet.png | Bin 0 -> 995 bytes assets/social.js | 11 +++++++++++ lib/social/plugin.php | 2 +- lib/social/service/twitter.php | 26 ++++++++++++++++++++++++++ social-twitter.php | 18 +++++++++++++----- views/comment/social_item.php | 5 +++-- 7 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 assets/retweet.png diff --git a/assets/comments.css b/assets/comments.css index 33065507..c29cc77b 100755 --- a/assets/comments.css +++ b/assets/comments.css @@ -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; } \ No newline at end of file diff --git a/assets/retweet.png b/assets/retweet.png new file mode 100644 index 0000000000000000000000000000000000000000..b74317b3e80299d57205a54364fbb39b663fb1c8 GIT binary patch literal 995 zcmaJ=J#5oJ7&R&irKqSKkbo{Hmj$Wu`5Zf`t-7U+6B>b|C=DVbj(u&c)IMWhiQB1k zY9$6n7}*#Q5~yMTi4IJa5M`ng0~@FtBOCObCMg5K()sQ_eeZpL?{+HXo1-IFM>vif zEiD>VwqImxcsRxW`{SQJvh4~j)aepgrfn<4+`K~?7?eC~1y`}Y#1pK~TirSm6A)y)dXlMn+%5Yx7pMIb8+ zNETIDodS}GM2I9P=F&*il$<6a(EWH8Ep(Q(s!{C5VmF;{QW|Iww%cu?oe@a50+Fh! zP?Vq~rI|-MTKB0Hr~PQM$6(;d4&8vd#0LqZ)gWtB=UJvFC3r!f){nYvVhw|_6+k42 zNl86N)BL}y=k>iKTE(aN{*ySWtp^xZaYWWan+u5;HP8W@ZOhGB;5Gsh%IcYvG=L)iv zQPixQ>0u3GuX)&~J*;zzl?P%IF?a!sY~av+fSqDUJkTjxa|h>w2J&^W&fr|6fmq0r zfyrq98g!ey7f^s&$M9x`FS`Su*JM{%cQ%-7_key); + return ''.$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('', $item->social_profile_image_url, $style); + return sprintf('%s', $this->status_url($item->comment_author, $item->social_status_id), $image); + } + /** * Returns the status URL to a broadcasted item. * diff --git a/social-twitter.php b/social-twitter.php index 1bb359c8..9ab8de75 100755 --- a/social-twitter.php +++ b/social-twitter.php @@ -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); @@ -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; + } + } } } diff --git a/views/comment/social_item.php b/views/comment/social_item.php index c25400d3..5be7e129 100644 --- a/views/comment/social_item.php +++ b/views/comment/social_item.php @@ -4,11 +4,12 @@ social_item_output($item, $i); + echo $service->social_item_output($item, $i); + ++$i; } if ($i >= 10) { - echo sprintf(__('... and %s more', Social::$i18n), '', ($i - 10)); + echo sprintf(__('', Social::$i18n), '', ($i - 10)); } ?>