You are here

function fb_tokens in Drupal for Facebook 7.3

Implements hook_tokens().

Nothing to do with facebook access tokens. This drupal hook supports token replacement via token_replace().

File

./fb.module, line 370
This is the core required module of Drupal for Facebook.

Code

function fb_tokens($type, $tokens, array $data = array(), array $options = array()) {
  if (strpos($type, 'fb') === 0) {
    $items = array();

    // Add defaults to $data array.
    $data = $data + fb_vars();
    if (!isset($data['fb_signed_request']) && !empty($data['fb'])) {
      $data['fb_signed_request'] = $data['fb']
        ->getSignedRequest();
    }
    if (!isset($data['fb_settings']) && function_exists('fb_settings')) {
      $data['fb_settings'] = fb_settings();
    }
    if (is_array($data[$type])) {
      foreach ($data[$type] as $key => $value) {
        if (!is_array($value)) {
          $items["[{$type}:{$key}]"] = $value;
        }

        // TODO: support nested values (i.e. recurse into arrays)
      }
    }

    // TODO support additional fb token types.  I.e. fb_app, fb_settings.
    return $items;
  }
}