You are here

function fb_social_footer in Facebook social plugins integration 6

Same name and namespace in other branches
  1. 6.2 fb_social.module \fb_social_footer()

Implementation of hook_footer

File

./fb_social.module, line 202
Common settings for all fb social plugins

Code

function fb_social_footer($main = 0) {
  global $language, $_fb_script_init, $base_url;

  // If their is no fb plugin enabled on this page, do not load fb script then
  if (!$_fb_script_init) {
    return;
  }
  $languages = _map_active_languages();
  if (fb_social_auto_language()) {
    if (array_key_exists($language->language, $languages)) {
      $fb_locale = $languages[$language->language];
    }
    else {
      drupal_set_message("There is no mapping for the current language. Using the default locale.");
    }
  }
  else {
    $fb_locale = variable_get('fb_social_locale', 'en_US');
  }
  $appid = variable_get('fb_social_appid', '');
  $channel_url = $base_url . "/fb_social/channel";
  $output = '<div id="fb-root"></div>';
  $output .= "<script type=\"text/javascript\">\n     window.fbAsyncInit = function() {\n       FB.init({\n         appId: " . drupal_to_js($appid) . ",\n         status: true, \n         cookie: true,\n         xfbml: true,\n         channelUrl: " . drupal_to_js($channel_url) . "\n       });\n       \n       ";

  // let each module subscribe to different events
  $output .= implode("\n", module_invoke_all('fb_social_event_subscribe'));
  $output .= "\n       \n         \n     };\n     (function() {\n       var e = document.createElement('script'); \n       e.async = true;\n       e.src = document.location.protocol + '//connect.facebook.net/" . $fb_locale . "/all.js';\n       document.getElementById('fb-root').appendChild(e);\n     }());\n  </script>";
  return $output;
}