You are here

function smart_ip_tokens in Smart IP 7

Same name and namespace in other branches
  1. 7.2 smart_ip.module \smart_ip_tokens()

Implements hook_tokens().

File

./smart_ip.module, line 285
Determines country, geo location (longitude/latitude), region, city and postal code of the user, based on IP address

Code

function smart_ip_tokens($type, $tokens, array $data = array(), array $options = array()) {

  /*
    if (isset($options['language'])) {
      $url_options['language'] = $options['language'];
      $language_code = $options['language']->language;
    }
    else {
      $language_code = NULL;
    }
    $sanitize = !empty($options['sanitize']);
  */
  $replacements = array();
  $smart_ip_session = smart_ip_session_get('smart_ip');
  if ($type == 'smart_ip' && !empty($smart_ip_session['location'])) {
    foreach ($tokens as $name => $original) {
      $replacements[$original] = $smart_ip_session['location'][$name];
    }
  }
  return $replacements;
}