You are here

token_var.module in Token Variable 6

Same filename and directory in other branches
  1. 8 token_var.module
  2. 7 token_var.module

File

token_var.module
View source
<?php

/**
 * Implementation of hook_token_info
 */
function token_var_token_list($type = 'all') {
  global $conf;
  if ($type == 'global' || $type == 'all') {
    $info = array();
    foreach ($conf as $key => $var) {
      if (!is_array($var)) {
        if (is_string($var) && empty($var)) {
          continue;
        }
        $info['global']['variable-' . $key] = substr($var, 0, 10);
      }
    }
    return $info;
  }
}

/**
 * Implements hook_tokens().
 */
function token_var_token_values($type, $object = NULL, $options = array()) {
  dpm('test');
  if ($type == 'global') {
    global $conf;
    foreach ($conf as $key => $var) {
      if (!is_array($var)) {
        if (is_string($var) && empty($var)) {
          continue;
        }
        $info['variable-' . $key] = variable_get($key, '');
      }
    }
  }
  return $info;
}

Functions

Namesort descending Description
token_var_token_list Implementation of hook_token_info
token_var_token_values Implements hook_tokens().