You are here

function theme_fboauth_action in Facebook OAuth (FBOAuth) 6

Same name and namespace in other branches
  1. 7.2 fboauth.module \theme_fboauth_action()
  2. 7 fboauth.module \theme_fboauth_action()

Return a link to initiate a Facebook Connect login or association.

Parameters

$link: An array of properties to be used to generate a login link. Note that all provided properties are required for the Facebook login to succeed and must not be changed. If $link is FALSE, Facebook OAuth is not yet configured.

See also

fboauth_link_properties()

File

./fboauth.module, line 399

Code

function theme_fboauth_action($action, $link) {

  // Because most Facebook actions initiate one-time actions, render it as a
  // button instead of a link. This makes for expected behavior that buttons
  // execute actions, not links.
  $link['attributes']['class'] = isset($link['attributes']['class']) ? $link['attributes']['class'] : 'form-button facebook-button facebook-action-' . str_replace('_', '-', $action['name']);
  $link['attributes']['name'] = isset($link['attributes']['name']) ? $link['attributes']['name'] : 'facebook_action_' . $action['name'];
  $link['attributes']['type'] = 'button';
  $attributes = drupal_attributes($link['attributes']);
  $url = url($link['href'], array(
    'query' => $link['query'],
  ));
  $content = '<button ' . $attributes . ' onclick="window.location = \'' . $url . '\'; return false;">' . check_plain($action['title']) . '</button>';
  return $content;
}