function fb_connect_init_js in Drupal for Facebook 6.2
Add javascript to a facebook connect page.
Use this to add calls to facebook JS, http://wiki.developers.facebook.com/index.php/JS_API_Index.
We use Drupal's cache to store the javascript until it is rendered to a page. This approach is analogous to drupal_set_message storing data temporarily in the session. We use cache instead of session, because the session is not shared between Facebook's event callbacks and regular page requests.
3 calls to fb_connect_init_js()
- fb_canvas_iframe_excursion in ./
fb_canvas.module - This is intended to help sites which have some FBML and some iframe pages. Makes the current FBML canvas page an iframe. And attempts to preserve session while visiting multiple iframe pages.
- fb_connect_fb in ./
fb_connect.module - Implementation of hook_fb().
- fb_permission_fb in contrib/
fb_permission.module - Implementation of hook_fb(). Here we customize the behavior of Drupal for Facebook.
File
- ./
fb_connect.module, line 404 - Support for Facebook Connect features
Code
function fb_connect_init_js($js = NULL) {
$fbu = fb_facebook_user();
$fb_app = $GLOBALS['_fb_app'];
$cid = 'fb_connect_init_js_' . $fb_app->apikey . '_' . $fbu;
$cache = cache_get($cid, 'cache');
if (!isset($cache->data)) {
$cache = new stdClass();
$cache->data = array();
}
if ($js) {
$cache->data[] = $js;
cache_set($cid, $cache->data, 'cache', time() + 60000);
// Update cache
}
elseif ($js === NULL) {
cache_clear_all($cid, 'cache');
}
return $cache->data;
}