You are here

function fb_social_handler_field::render in Facebook social plugins integration 6.2

Same name and namespace in other branches
  1. 7.2 plugins/views/fb_social_handler_field.inc \fb_social_handler_field::render()

Implements views_handler_field#render().

File

plugins/views/fb_social_handler_field.inc, line 55
Provide views handler for Facebook Social plugins.

Class

fb_social_handler_field
A handler to provide a field for Facebook Social plugins.

Code

function render($values) {
  if (!empty($this->options['fb_social_plugins'])) {
    $presets = fb_social_get_presets();
    $preset = $presets[$this->options['fb_social_plugins']];
    $type = $presets[$this->options['fb_social_plugins']]->plugin_type;
    $url = NULL;

    // Only supply url for node if nid exists and FB preset accepts url.
    // TODO: instead of hardcoded values, get this info from plugin defaults
    if ($type == 'like' || $type == 'send' || $type == 'facepile' || $type == 'comments') {
      if (!empty($values->nid)) {
        $url = fb_social_url('node/' . $values->nid);
      }
      elseif (!empty($values->uid)) {
        $url = fb_social_url('user/' . $values->uid);
      }
      $preset->fb_attrs['href'] = $url;
    }
    $value = fb_social_preset_view($preset);
  }
  return $value;
}