function theme_fb_login_button in Drupal for Facebook 6.3
Same name and namespace in other branches
- 7.4 fb.theme.inc \theme_fb_login_button()
- 7.3 fb.theme.inc \theme_fb_login_button()
Theme a Facebook Connect button.
Uses a link with onclick="FB.login()", because this works much better than fb:login-button on Firefox when third-party cookies disabled.
3 theme calls to theme_fb_login_button()
- fb_devel_info in ./
fb_devel.module - fb_user_form_alter in ./
fb_user.module - Implements hook_form_alter().
- fb_user_user in ./
fb_user.module - Implementation of hook_user().
File
- ./
fb.theme.inc, line 39
Code
function theme_fb_login_button($text = NULL, $options = array()) {
// Merge in defaults
$options += array(
'attributes' => array(),
'connected_markup' => NULL,
);
$options['attributes'] += array(
'class' => 'fb_login_button_wrapper fb_button_style',
);
if ($text === NULL) {
$text = t('Connect');
}
// For compatibility, pass in scope as an attribute.
if (!isset($options['attributes']['scope'])) {
// Which permissions to prompt for?
$perms = array();
drupal_alter('fb_required_perms', $perms);
if (count($perms)) {
$options['attributes']['scope'] = implode(',', $perms);
}
}
$scope = $options['attributes']['scope'];
unset($options['attributes']['scope']);
// New markup does not need this attr.
$markup = '<div ' . drupal_attributes($options['attributes']) . '><a href="#" onclick="FB.login(function(){}, {scope : \'' . $scope . '\'}); return false;"><div><span>' . $text . '</span></div></a></div>';
if ($options['connected_markup']) {
$markup = '<div class=fb_not_connected>' . $markup . '</div>' . '<div class=fb_connected>' . $options['connected_markup'] . '</div>';
}
return $markup;
}