You are here

protected function SocialGoogleFormatter::renderComments in Open Social 7

Collect data from google response.

Parameters

array $items: JSON decoded response string.

Return value

array Data with comments.

1 call to SocialGoogleFormatter::renderComments()
SocialGoogleFormatter::getData in includes/social_comments.google.inc

File

includes/social_comments.google.inc, line 146
Google class

Class

SocialGoogleFormatter
@file Google class

Code

protected function renderComments($items) {
  $comments = array();
  if (is_array($items)) {
    if (!empty($this->max_items)) {
      $items = array_slice($items, 0, $this->max_items);
    }
    foreach ($items as $item) {
      $data = array();
      $comment = $item['object'];

      // Get user data.
      $user = !empty($item['actor']) ? $item['actor'] : NULL;
      $data['id'] = check_plain($item['id']);
      $data['username'] = !empty($user['displayName']) ? check_plain($user['displayName']) : NULL;
      $data['user_url'] = !empty($user['url']) ? filter_xss($user['url']) : NULL;
      $data['userphoto'] = !empty($user['image']['url']) ? filter_xss($user['image']['url']) : NULL;
      $data['text'] = filter_xss($comment['content']);
      $data['timestamp'] = strtotime($item['published']);
      $comments[] = $data;
    }
  }
  return $comments;
}