function tokenSTARTER_token_values in Token 6
Implementation of hook_token_values().
File
- ./
tokenSTARTER.module, line 41 - The Token API module.
Code
function tokenSTARTER_token_values($type, $object = NULL, $options = array()) {
$values = array();
switch ($type) {
case 'global':
$values['random-sha1'] = sha1(rand());
// Create random numbers.
$values['random-num-1'] = mt_rand(0, 9);
$values['random-num-3'] = mt_rand(100, 999);
$values['random-num-10'] = mt_rand(10000, 99999) . mt_rand(10000, 99999);
// Create random letters.
$letters = range('a', 'z');
$values['random-alpha-1'] = $letters[array_rand($letters, 1)];
shuffle($letters);
$values['random-alpha-3'] = implode('', array_slice($letters, 0, 3));
shuffle($letters);
$values['random-alpha-10'] = implode('', array_slice($letters, 0, 10));
// Create a UNIX timestamp token.
$time = time();
$tz = variable_get('date_default_timezone', 0);
$values['site-date-timestamp'] = format_date($time, 'custom', 'Y', $tz);
break;
case 'node':
// Node tokens here.
break;
}
return $values;
}