Index: facebookshare.admin.inc =================================================================== RCS file: /cvs/drupal/contributions/modules/facebookshare/facebookshare.admin.inc,v retrieving revision 1.2 diff -u -r1.2 facebookshare.admin.inc --- facebookshare.admin.inc 8 Apr 2010 15:54:37 -0000 1.2 +++ facebookshare.admin.inc 19 Jul 2010 14:16:11 -0000 @@ -1,56 +1,55 @@ - 'checkboxes', - '#title' => t('Content types'), - '#description' => t('Which content types to apply the Facebook Share button to.'), - '#options' => node_get_types('names'), - '#default_value' => variable_get('facebookshare_types', array()), - ); - $form['facebookshare_location'] = array( - '#type' => 'checkboxes', - '#title' => t('Location'), - '#description' => t('Where to show the Facebook Share button.'), - '#options' => array( - 'content' => t('Full view'), - 'teasers' => t('Teasers'), - ), - '#default_value' => variable_get('facebookshare_location', array()), - ); - $sizes = array('box_count' => '', 'button_count' => '', 'button' => '', 'icon_link' => '', 'icon' => ''); - foreach ($sizes as $size => $button) { - $sizes[$size] = theme( - 'facebookshare_button', - 'http://www.facebook.com/facebook-widgets/share.php', - $size, - variable_get('facebookshare_text', '') - ); - } - $form['facebookshare_size'] = array( - '#type' => 'radios', - '#title' => t('Button size'), - '#required' => TRUE, - '#options' => $sizes, - '#default_value' => variable_get('facebookshare_size', ''), - ); - $form['facebookshare_text'] = array( - '#type' => 'textfield', - '#title' => t('Share button text'), - '#default_value' => variable_get('facebookshare_text', ''), - '#description' => t('Leave blank for default "Share" text'), - ); - - return system_settings_form($form); -} \ No newline at end of file + 'checkboxes', + '#title' => t('Content types'), + '#description' => t('Which content types to apply the Facebook Share button to.'), + '#options' => node_type_get_names(), + '#default_value' => variable_get('facebookshare_types'), + ); + $form['facebookshare_location'] = array( + '#type' => 'checkboxes', + '#title' => t('Location'), + '#description' => t('Where to show the Facebook Share button.'), + '#options' => array( + 'content' => t('Full view'), + 'teasers' => t('Teasers'), + ), + '#default_value' => variable_get('facebookshare_location'), + ); + $sizes = array('box_count' => '', 'button_count' => '', 'button' => '', 'icon_link' => '', 'icon' => ''); + foreach ($sizes as $size => $button) { + $sizes[$size] = theme( + 'facebookshare_button', + array('url' => 'http://www.facebook.com/facebook-widgets/share.php', + 'size' => $size, + 'text' => variable_get('facebookshare_text')) + ); + } + $form['facebookshare_size'] = array( + '#type' => 'radios', + '#title' => t('Button size'), + '#required' => TRUE, + '#description' => t('What kind of button to show.'), + '#options' => $sizes, + '#default_value' => variable_get('facebookshare_size', ''), + ); + $form['facebookshare_text'] = array( + '#type' => 'textfield', + '#title' => t('Share button text'), + '#default_value' => variable_get('facebookshare_text'), + '#description' => t('Leave blank for default "Share" text'), + ); + + return system_settings_form($form); +} Index: facebookshare.module =================================================================== RCS file: /cvs/drupal/contributions/modules/facebookshare/facebookshare.module,v retrieving revision 1.2 diff -u -r1.2 facebookshare.module --- facebookshare.module 8 Apr 2010 15:54:37 -0000 1.2 +++ facebookshare.module 19 Jul 2010 14:16:11 -0000 @@ -1,129 +1,145 @@ -'. t('Provides a way for viewers to share a link to a node on' . - ' their Facebook stream.') .'

'; - } -} - -/** - * Implements hook_perm() - */ -function facebookshare_perm() { - return array( - 'administer facebookshare', - 'access facebookshare' - ); -} - -/** - * Implements hook_menu() - */ -function facebookshare_menu() { - $item['admin/settings/facebookshare'] = array( - 'title' => 'Facebook Share', - 'description' => 'Provides the configuration options for how Facebook Share operates on the site.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('facebookshare_admin_settings'), - 'access arguments' => array('administer facebookshare'), - 'file' => 'facebookshare.admin.inc', - ); - - return $item; -} - -/** - * Implements hook_nodeapi() - */ -function facebookshare_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { - if ($op == 'view') { - // Make sure we're on the right content type. - if (!in_array($node->type, variable_get('facebookshare_types', array()), TRUE)) { - return NULL; - } - - // Make sure we're actually building the page to render in a browser. - if ($node->build_mode != NODE_BUILD_NORMAL) { - return NULL; - } - - // Make sure the user has access to use Facebook Share. - if (!user_access('access facebookshare')) { - return NULL; - } - - // Retrieve the location where we should show it, the style and the URL of the button. - $location = variable_get('facebookshare_location', array()); - $url = url('node/' . $node->nid, array('absolute' => TRUE)); - - // Check in the teaser and full view. - if (($teaser && !empty($location['teasers'])) || (!$teaser && !empty($location['content']))) { - drupal_add_css(drupal_get_path('module', 'facebookshare') . '/facebookshare.css'); - $node->content['facebookshare'] = array( - '#value' => theme('facebookshare', $url), - '#weight' => -10, - ); - } - } -} - -/** - * Implements hook_theme() - */ -function facebookshare_theme($existing, $type, $theme, $path) { - return array( - 'facebookshare' => array( - 'arguments' => array( - 'url' => NULL, - ), - ), - 'facebookshare_button' => array( - 'arguments' => array( - 'url' => NULL, - 'size' => NULL, - 'text' => NULL, - ), - ), - ); -} - -/** - * Themes facebook share button box - */ -function theme_facebookshare($url) { - $output = '
'; - $output .= theme( - 'facebookshare_button', - $url, - variable_get('facebookshare_size', ''), - variable_get('facebookshare_text', '') - ); - $output .= '
'; - - return $output; -} - -/** - * Themes facebook share button - */ -function theme_facebookshare_button($url, $size, $text) { - $output = '' . - $text . '' . - ''; - - return $output; -} \ No newline at end of file +' . t('Provides a way for viewers to share a link to a node on' . + ' their Facebook stream.') . '

'; + } +} + +/** + * Implements hook_permission(). + */ +function facebookshare_permission() { + return array( + 'administer facebookshare' => array( + 'title' => t('administer facebookshare'), + ), + 'access facebookshare' => array( + 'title' => t('access facebookshare'), + ), + ); +} + +/** + * Implements hook_menu(). + */ +function facebookshare_menu() { + $item['admin/config/user-interface/facebookshare'] = array( + 'title' => 'Facebook Share', + 'description' => 'Provides the configuration options for how Facebook Share operates on the site.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('facebookshare_admin_settings'), + 'access arguments' => array('administer facebookshare'), + 'file' => 'facebookshare.admin.inc', + ); + + return $item; +} + +/** + * Implements hook_init(). + */ +function facebookshare_init() { + drupal_add_css(drupal_get_path('module', 'facebookshare') . '/facebookshare.css'); +} + + +/** + * Implements hook_node_view(). + */ +function facebookshare_node_view($node, $view_mode = 'full') { + + // Make sure we're on the right content type. + if (!in_array($node->type, variable_get('facebookshare_types', array()), TRUE)) { + return NULL; + } + + // Make sure we're actually building the page to render in a browser. + // We only render the button on full pages and on teasers + if (($view_mode != 'teaser') && ($view_mode != 'full')) { + return NULL; + } + + // Make sure the user has access to use Facebook Share. + if (!user_access('access facebookshare')) { + return NULL; + } + + // Retrieve the location where we should show it, the style and the URL of the button. + $location = variable_get('facebookshare_location', array()); + $url = url('node/' . $node->nid, array('absolute' => TRUE)); + + // Check in the teaser and full view. + if (($view_mode == 'teaser' && !empty($location['teasers'])) || ($view_mode == 'full' && !empty($location['content']))) { + $node->content['facebookshare'] = array( + '#markup' => theme('facebookshare', array('url' => $url)), + '#weight' => -10, + ); + } +} + +/** + * Implements hook_theme(). + */ +function facebookshare_theme($existing, $type, $theme, $path) { + return array( + 'facebookshare' => array( + 'variables' => array( + 'url' => NULL, + ), + ), + 'facebookshare_button' => array( + 'variables' => array( + 'url' => NULL, + 'size' => NULL, + 'text' => NULL, + ), + ), + ); +} + +/** + * Themes facebook share button box + */ +function theme_facebookshare($variables) { + $url = $variables['url']; + $output = '
'; + $output .= theme( + 'facebookshare_button', + array( + 'url' => $url, + 'size' => variable_get('facebookshare_size', ''), + 'text' => variable_get('facebookshare_text','') + ) + ); + $output .= '
'; + + return $output; +} + +/** + * Themes facebook share button + */ +function theme_facebookshare_button($variables) { + $url = $variables['url']; + $size = $variables['size']; + $text = $variables['text']; + $output = '' . + $text . '' . + ''; + + return $output; +} Index: facebookshare.admin.css =================================================================== RCS file: /cvs/drupal/contributions/modules/facebookshare/facebookshare.admin.css,v retrieving revision 1.2 diff -u -r1.2 facebookshare.admin.css --- facebookshare.admin.css 8 Apr 2010 15:54:37 -0000 1.2 +++ facebookshare.admin.css 19 Jul 2010 14:16:11 -0000 @@ -1,15 +1,13 @@ -/* $Id: facebookshare.admin.css,v 1.2 2010/04/08 15:54:37 willsteinmetz Exp $; */ - -/** - * @file - * CSS styles for the admin settings of the Facebook Share module boxes - */ - -#facebookshare-admin-settings .form-radios .form-item { - width: 130px; - float: left; -} - -#edit-facebookshare-text-wrapper { - clear: both; -} +/** + * @file + * CSS styles for the admin settings of the Facebook Share module boxes + */ + +#facebookshare-admin-settings .form-radios .form-item { + width: 130px; + float: left; +} + +#facebookshare-admin-settings .description { + clear: both; +} Index: README.txt =================================================================== RCS file: /cvs/drupal/contributions/modules/facebookshare/README.txt,v retrieving revision 1.2 diff -u -r1.2 README.txt --- README.txt 8 Apr 2010 15:54:37 -0000 1.2 +++ README.txt 19 Jul 2010 14:16:11 -0000 @@ -1,16 +1,16 @@ -Created by: Ralivue.com -Author: Will Steinmetz - -This module was created to help users easily share links to -nodes with their friends on Facebook. - -This node was created independent of Facebook and we make no -claim to be a member of Facebook or represent them in any way. - -TO INSTALL: -Simply untar the Facebook Share module archive and drop the -untarred folder in the appropriate place. -EX: if you want the module to be available to all of your sites -under a Drupal install, drop it in the sites/all/modules folder. -To install the module for just specific sites under a Drupal -install, drop it in the appropriate sites/*/modules folder(s). \ No newline at end of file +Created by: Ralivue.com +Author: Will Steinmetz + +This module was created to help users easily share links to +nodes with their friends on Facebook. + +This node was created independent of Facebook and we make no +claim to be a member of Facebook or represent them in any way. + +TO INSTALL: +Simply untar the Facebook Share module archive and drop the +untarred folder in the appropriate place. +EX: if you want the module to be available to all of your sites +under a Drupal install, drop it in the sites/all/modules folder. +To install the module for just specific sites under a Drupal +install, drop it in the appropriate sites/*/modules folder(s). Index: facebookshare.install =================================================================== RCS file: /cvs/drupal/contributions/modules/facebookshare/facebookshare.install,v retrieving revision 1.2 diff -u -r1.2 facebookshare.install --- facebookshare.install 8 Apr 2010 15:54:37 -0000 1.2 +++ facebookshare.install 19 Jul 2010 14:16:11 -0000 @@ -1,24 +1,22 @@ -