You are here

function smart_ip_tokens in Smart IP 7.2

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

Implements hook_tokens().

File

./smart_ip.module, line 310
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();
  if ($type == 'smart_ip') {
    $smart_ip_session = smart_ip_session_get('smart_ip');
    if (!empty($smart_ip_session['location'])) {
      foreach ($tokens as $name => $original) {
        if (!empty($smart_ip_session['location'][$name])) {
          $replacements[$original] = $smart_ip_session['location'][$name];
        }
      }
    }
  }
  return $replacements;
}