function fb_canvas_fix_url in Drupal for Facebook 6.3
Same name and namespace in other branches
- 5.2 fb_canvas.module \fb_canvas_fix_url()
- 5 fb_canvas.module \fb_canvas_fix_url()
- 6.2 fb_canvas.module \fb_canvas_fix_url()
Convert a local fully qualified path to a facebook app path. This needs to be used internally, to fix drupal_gotos upon form submission. Third party modules should not need to call this.
2 calls to fb_canvas_fix_url()
- fb_canvas_fb in ./
fb_canvas.module - Implementation of hook_fb().
- fb_canvas_goto in ./
fb_canvas.module - Uses javascript on iframe canvas pages change top frame, otherwise drupal_goto().
File
- ./
fb_canvas.module, line 287 - This module provides support for Canvas page applications. Use Drupal to power traditional Facebook Apps.
Code
function fb_canvas_fix_url($url, $fb_app) {
//dpm(debug_backtrace(), "fb_canvas_fix_url($url)");
global $base_url;
// Url rewrites still used for iframe canvas pages.
$patterns[] = "|{$base_url}/" . FB_SETTINGS_CB . "/{$fb_app->apikey}/|";
// Here we hard-wire apps.facebook.com. Is there an API to get that?
// base_root is from Drupal's conf_init().
$replacements[] = fb_protocol() . "://apps.facebook.com/{$fb_app->canvas}/";
// Fully qualified paths.
$patterns[] = "|" . url('', array(
'absolute' => TRUE,
)) . "|";
$replacements[] = fb_protocol() . "://apps.facebook.com/{$fb_app->canvas}/";
// Facebook will prepend "appNNN_" all our ids
$patterns[] = "|#([^\\?]*)|";
$replacements[] = "#app{$fb_app->id}_\$1";
$url = preg_replace($patterns, $replacements, $url);
return $url;
}