You are here

function fb_canvas_fix_url in Drupal for Facebook 5

Same name and namespace in other branches
  1. 5.2 fb_canvas.module \fb_canvas_fix_url()
  2. 6.3 fb_canvas.module \fb_canvas_fix_url()
  3. 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, I believe.

3 calls to fb_canvas_fix_url()
fb_canvas_fb in ./fb_canvas.module
Implementation of hook_fb.
fb_user_fb in ./fb_user.module
Implementation of hook_fb.
fb_user_post_add_check in ./fb_user.module
This method will redirect a user if the post-add page need not be displayed.
2 string references to 'fb_canvas_fix_url'
fb_user_fb in ./fb_user.module
Implementation of hook_fb.
fb_user_post_add_check in ./fb_user.module
This method will redirect a user if the post-add page need not be displayed.

File

./fb_canvas.module, line 284
This module provides some app-specific navigation to facebook apps. This is fairly experimental material. May change a lot in near future.

Code

function fb_canvas_fix_url($url, $fb_app) {
  global $base_url;
  $patterns[] = "|{$base_url}/" . FB_SETTINGS_APP_NID . "/{$fb_app->nid}/|";

  // Here we assume apps.facebook.com.  Is this safe?
  $replacements[] = "http://apps.facebook.com/{$fb_app->canvas}/";
  $patterns[] = "|fb_cb_type/[^/]*/|";
  $replacements[] = "";

  // Facebook will prepend "appNNN_" all our ids
  $patterns[] = "|#([^\\?]*)|";
  $replacements[] = "#app{$fb_app->id}_\$1";
  $url = preg_replace($patterns, $replacements, $url);
  return $url;
}