class fb_social_handler_field in Facebook social plugins integration 6.2
Same name and namespace in other branches
- 7.2 plugins/views/fb_social_handler_field.inc \fb_social_handler_field
A handler to provide a field for Facebook Social plugins.
Hierarchy
- class \fb_social_handler_field extends \views_handler_field
Expanded class hierarchy of fb_social_handler_field
1 string reference to 'fb_social_handler_field'
- fb_social_views_data in ./
fb_social.views.inc - Implementation of hook_views_data()
File
- plugins/
views/ fb_social_handler_field.inc, line 13 - Provide views handler for Facebook Social plugins.
View source
class fb_social_handler_field extends views_handler_field {
/**
* query() override to not query this fake field.
*/
function query() {
$this
->ensure_my_table();
}
/**
* Implements views_object#option_definition().
*/
function option_definition() {
$options = parent::option_definition();
$options['fb_social_plugins'] = array(
'default' => '',
);
return $options;
}
/**
* Implements views_handler#options_form().
*/
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$presets = fb_social_get_presets();
foreach ($presets as $preset) {
$preset_list[$preset->name] = $preset->name;
}
$form['fb_social_plugins'] = array(
'#title' => t('Facebook Social Preset'),
'#options' => array(
'' => '<select>',
) + $preset_list,
'#type' => 'select',
'#required' => TRUE,
'#default_value' => $this->options['fb_social_plugins'],
'#description' => t('Choose a Facebook Social Preset'),
);
}
/**
* Implements views_handler_field#render().
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
fb_social_handler_field:: |
function | Implements views_handler#options_form(). | ||
fb_social_handler_field:: |
function | Implements views_object#option_definition(). | ||
fb_social_handler_field:: |
function | query() override to not query this fake field. | ||
fb_social_handler_field:: |
function | Implements views_handler_field#render(). |