diff options
author | Silvio <silvio@socioambiental.org> | 2012-03-30 16:20:06 -0300 |
---|---|---|
committer | Silvio <silvio@socioambiental.org> | 2012-03-30 16:20:06 -0300 |
commit | edeae898f6d6bbe4fbcbe89079e1f7f7c13abf70 (patch) | |
tree | b5c74534f5c52e3fa55e98dffd8313233ebe7da5 | |
parent | fb5e2ad9c7e7f94c5acb2327b809b08583581bb5 (diff) | |
download | fblikebutton-edeae898f6d6bbe4fbcbe89079e1f7f7c13abf70.tar.gz fblikebutton-edeae898f6d6bbe4fbcbe89079e1f7f7c13abf70.tar.bz2 |
Initial view support (upstream #1121906)
-rw-r--r-- | fblikebutton.handlers.inc | 51 | ||||
-rw-r--r-- | fblikebutton.info | 1 | ||||
-rw-r--r-- | fblikebutton.module | 11 | ||||
-rw-r--r-- | fblikebutton.views.inc | 20 |
4 files changed, 82 insertions, 1 deletions
diff --git a/fblikebutton.handlers.inc b/fblikebutton.handlers.inc new file mode 100644 index 0000000..aeb40a3 --- /dev/null +++ b/fblikebutton.handlers.inc @@ -0,0 +1,51 @@ +<?php + +/** + * @file + * Contains the fblikebutton views field handler. + */ + +/** + * Field handler for fblikebutton total transactions. + */ +class fblikebutton_handler_field_fblikebutton extends views_handler_field { + /** + * Implements views_handler_field#query(). + */ + function query() { + // Provide an field alias but don't actually alter the query. + $this->field_alias = 'views_fblikebutton_button_' . $this->position; + } + + /** + * Renders the field. + */ + function render($values) { + if (isset($values->nid)) { + global $user, $base_url; + $types = variable_get('fblikebutton_node_types', array()); + $fullnodedisplay = variable_get('fblikebutton_full_node_display', 0); + $teaserdisplay = variable_get('fblikebutton_teaser_display', 0); + $full = ($view_mode == 'full') ? TRUE : FALSE; + $show = ( ! empty($types[$values->type]) && user_access('access fblikebutton')); + // Thanks to corbacho for supplying the code for the $webpage_to_like variable... + // (It was apparently throwing errors/notices the way I had it set up.) + $webpage_to_like = url("node/$values->nid", array('absolute' => TRUE)); + $likebutton_weight = variable_get('fblikebutton_weight', '0'); + $conf = array( + 'layout' => variable_get('fblikebutton_layout', 'standard'), + 'action' => variable_get('fblikebutton_action', 'like'), + 'color_scheme' => variable_get('fblikebutton_color_scheme', 'light'), + 'show_faces' => variable_get('fblikebutton_show_faces', 'true'), + 'font' => variable_get('fblikebutton_font', 'arial'), + 'height' => variable_get('fblikebutton_iframe_height', '80'), + 'width' => variable_get('fblikebutton_iframe_width', '450'), + 'send' => variable_get('fblikebutton_send', 'true'), + 'other_css' => variable_get('fblikebutton_iframe_css', ''), + 'language' => variable_get('fblikebutton_language', 'en_US'), + ); + + return _fblikebutton_field($webpage_to_like, $conf); + } + } +} diff --git a/fblikebutton.info b/fblikebutton.info index b9b5565..25c180f 100644 --- a/fblikebutton.info +++ b/fblikebutton.info @@ -3,3 +3,4 @@ name = Facebook Like Button description = Adds a configurable <em>Like</em> button for Facebook to each selected node type, as well as a configurable block with a <em>Like</em> box in it. core = 7.x configure = admin/config/fblikebutton +files[] = fblikebutton.handlers.inc diff --git a/fblikebutton.module b/fblikebutton.module index cb191b6..2ca00c5 100644 --- a/fblikebutton.module +++ b/fblikebutton.module @@ -225,4 +225,13 @@ function _fblikebutton_field($webpage_to_like, $conf) { $src = htmlentities($params); $output = '<iframe src="https://www.facebook.com/plugins/like.php?' . $src . '" scrolling="no" frameborder="0" style="border: none; overflow: hidden; width: ' . $width . 'px; height: ' . $height . 'px;' . $other_css . '" allowTransparency="true"></iframe>'; return $output; -}
\ No newline at end of file +} + +/** + * Implementes hook_views_data() + */ +function fblikebutton_views_api() { + return array( + 'api' => 3, + ); +} diff --git a/fblikebutton.views.inc b/fblikebutton.views.inc new file mode 100644 index 0000000..dd162dc --- /dev/null +++ b/fblikebutton.views.inc @@ -0,0 +1,20 @@ +<?php + +/** + * @file + */ + +/** + * Implements hook_views_data() + */ +function fblikebutton_views_data() { + $data['node']['fblikebutton'] = array( + 'field' => array( + 'title' => t('Facebook Like Button'), + 'help' => t('Adds a facebook like button.'), + 'handler' => 'fblikebutton_handler_field_fblikebutton', + ), + ); + + return $data; +} |