-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtokenArgument.module
43 lines (38 loc) · 1.11 KB
/
tokenArgument.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* @file
* The tokenArgument module.
*
* Provides current arguments as tokens. See the README.txt for more information.
*
* @ingroup token
*/
// Set the number of [argN] and [argN-alias] tokens.
define('TOKEN_NUM_ARG_TOKENS', defined('MENU_MAX_PARTS') ? MENU_MAX_PARTS : 7);
/**
* Implementation of hook_token_list().
*/
function tokenArgument_token_list($type = 'all') {
$tokens = array();
if ($type == 'global' || $type == 'all') {
// Declare the arg tokens.
$tokens['global']['argN'] = t('Url argument N (N = 0, 1, ..., %max).', array('%max' => TOKEN_NUM_ARG_TOKENS - 1));
$tokens['global']['argN-alias'] = t('Url alias argument N - defaults to url if no alias is found.');
}
return $tokens;
}
/**
* Implementation of hook_token_values().
*/
function tokenArgument_token_values($type, $object = NULL) {
$values = array();
switch ($type) {
case 'global':
for ($count = 0; $count < TOKEN_NUM_ARG_TOKENS; ++$count ) {
$values['arg'. $count] = arg($count);
$values['arg'. $count .'-alias'] = arg($count, $alias);
}
break;
}
return $values;
}