You are here

function fb_url_outbound_alter in Drupal for Facebook 7.3

Same name and namespace in other branches
  1. 6.3 fb_url_rewrite.inc \fb_url_outbound_alter()
  2. 6.2 fb_url_rewrite.inc \fb_url_outbound_alter()
  3. 7.4 fb.module \fb_url_outbound_alter()

Implements hook_url_outbound_alter().

Parameters

$options: If $options['fb_url_alter'] == FALSE, this function will not alter the URL. If used with $options['absolute'] == TRUE, this will generate a link from a canvas page out to the server's URL.

1 call to fb_url_outbound_alter()
fb_process in ./fb.process.inc
This function uses regular expressions to convert links on canvas pages to URLs that begin http://apps.facebook.com/...
1 string reference to 'fb_url_outbound_alter'
fb_process in ./fb.process.inc
This function uses regular expressions to convert links on canvas pages to URLs that begin http://apps.facebook.com/...

File

./fb_url_rewrite.inc, line 85
Performs custom url rewriting for Drupal for Facebook.

Code

function fb_url_outbound_alter(&$path, &$options, $original_path) {
  if (isset($options['external']) && $options['external'] || isset($options['fb_url_alter']) && $options['fb_url_alter'] === FALSE) {
    return;
  }

  // For most hooks, fb should come before fb_.... modules.  But in this case we want fb_canvas to act first.
  if (function_exists('fb_canvas_url_outbound_alter')) {
    fb_canvas_url_outbound_alter($path, $options, $original_path);
  }
  $pre = '';

  // Prefix each known value to the URL
  foreach (_fb_settings_url_rewrite_prefixes() as $prefix) {
    if (!isset($options[$prefix]) || $options[$prefix] !== FALSE) {
      if ($value = fb_settings($prefix)) {
        $pre .= $prefix . '/' . $value . '/';
      }
    }
  }
  if ($pre) {
    if ($path == '<front>') {

      // Do we really have to do this here?
      $path = '';
    }
    $path = $pre . (!empty($options['prefix']) ? $options['prefix'] : '') . $path;

    // We have manually set the prefix, so remove the options prefix.
    $options['prefix'] = '';

    // Hack to workaround http://drupal.org/node/1801044
    $options['alias'] = TRUE;
  }

  // Since we called fb_canvas_url_alter already, supress it from acting again.
  $options['fb_url_alter'] = FALSE;
}