function fb_footer in Drupal for Facebook 6.3
Implements hook_footer().
File
- ./
fb.module, line 743 - This is the core required module of Drupal for Facebook.
Code
function fb_footer($is_front) {
global $_fb, $_fb_app;
// This element recommended by facebook. http://developers.facebook.com/docs/reference/javascript/
$output = "<div id=\"fb-root\"></div>\n";
$settings = fb_js_settings();
$output .= "<script type=\"text/javascript\">\n";
$output .= "<!--//--><![CDATA[//><!--\n";
// Put this here instead of fb_devel.module because it must come first.
if (module_exists('fb_devel')) {
$output .= "if (typeof(FB_Devel) != 'undefined') {\n";
$output .= " FB_Devel.sanityCheck()\n";
$output .= "}\n";
}
// Pending javascript that needs to execute after FB is initialized.
$js_array = fb_invoke(FB_OP_JS, array(
'fb' => $GLOBALS['_fb'],
'fb_app' => $GLOBALS['_fb_app'],
), array());
if (count($js_array)) {
// The function we define in the footer will be called after FB is initialized.
$output .= "FB_JS.initHandler = function() {\n";
//$output .= "debugger;\n";
$output .= implode("\n ", $js_array);
$output .= "};\n";
$output .= "jQuery(document).bind('fb_init', FB_JS.initHandler);\n\n";
}
// Our settings. We add them here, as late during request as possible.
$output .= " jQuery.extend(Drupal.settings, " . json_encode(array(
'fb' => fb_js_settings(),
)) . ");\n\n";
// Initialize FB.
$output .= "if (typeof(FB) == 'undefined') {\n";
// Load the JS SDK asynchronously.
// http://developers.facebook.com/docs/reference/javascript/
$output .= " var e = document.createElement('script');\n";
$output .= " e.async = true;\n";
$output .= " e.src = Drupal.settings.fb.js_sdk_url;\n";
$output .= " document.getElementById('fb-root').appendChild(e);\n";
$output .= "}\n\n";
$output .= "\n//--><!]]>\n";
$output .= "\n</script>\n";
return $output;
}