function fb_url_inbound_alter in Drupal for Facebook 7.3
Same name and namespace in other branches
- 6.3 fb_url_rewrite.inc \fb_url_inbound_alter()
- 6.2 fb_url_rewrite.inc \fb_url_inbound_alter()
- 7.4 fb.module \fb_url_inbound_alter()
Implements hook_url_inbound_alter().
Rewrite URLs for facebook canvas pages, and connect callbacks.
2 string references to 'fb_url_inbound_alter'
- fb_canvas_fb_admin in ./
fb_canvas.admin.inc - Implements hook_fb_admin().
- fb_tab_fb_admin in ./
fb_tab.admin.inc - Implements hook_fb_admin().
File
- ./
fb_url_rewrite.inc, line 134 - Performs custom url rewriting for Drupal for Facebook.
Code
function fb_url_inbound_alter(&$path, $original_path, $path_language) {
// See if this is a request for us.
if (strpos($path, FB_SETTINGS_CB . '/') === 0) {
// Too soon for arg() function.
$args = explode('/', $path);
while (count($args) && in_array($args[0], _fb_settings_url_rewrite_prefixes())) {
$key = array_shift($args);
$value = array_shift($args);
if (fb_settings($key) === NULL) {
// defer to previously set values
fb_settings($key, $value);
}
// Store for use later.
}
if (fb_settings(FB_SETTINGS_CB)) {
if (count($args)) {
$path = implode('/', $args);
// remaining args
$alias = drupal_lookup_path('source', $path, $path_language);
//can't use drupal_get_normal_path, it calls custom_url_rewrite_inbound
if ($alias) {
$path = $alias;
}
}
else {
// frontpage
$path = variable_get('site_frontpage', 'node');
$alias = drupal_lookup_path('source', $path, $path_language);
if ($alias) {
$path = $alias;
}
$_REQUEST['destination'] = $path;
//required workaround for compatibility with Global Redirect module, best practice?
}
}
}
else {
//resolve aliases for non-fb-callbacks
$alias = drupal_lookup_path('source', $path, $path_language);
if ($alias) {
$path = $alias;
}
}
$result = $path;
}