1
|
<?php
|
2
|
/**
|
3
|
* @file
|
4
|
* Variable API module. Definition for some xample variables
|
5
|
*/
|
6
|
|
7
|
/**
|
8
|
* Implements hook_variable_info().
|
9
|
*/
|
10
|
function variable_example_variable_info($options) {
|
11
|
// Simple text
|
12
|
$variables['variable_example_text'] = array(
|
13
|
'type' => 'text',
|
14
|
'title' => t('Simple text', array(), $options),
|
15
|
'default' => 'Example text.',
|
16
|
'description' => t('Example of text variable.', array(), $options),
|
17
|
'required' => TRUE,
|
18
|
'group' => 'variable_example',
|
19
|
);
|
20
|
// Simple number, demonstrates validate callback.
|
21
|
$variables['variable_example_number'] = array(
|
22
|
'type' => 'number',
|
23
|
'title' => t('Number', array(), $options),
|
24
|
'default' => 0,
|
25
|
'description' => t('Example of numeric variable.', array(), $options),
|
26
|
'required' => TRUE,
|
27
|
'group' => 'variable_example',
|
28
|
);
|
29
|
// Text with format
|
30
|
$variables['variable_example_text_format'] = array(
|
31
|
'type' => 'text_format',
|
32
|
'title' => t('Text format', array(), $options),
|
33
|
// The default value may be a string (default format will be added) or
|
34
|
// an array with 'format' (format name) and 'value' (string) elements
|
35
|
'default' => 'Example text with default format',
|
36
|
'description' => t('Example of text variable with text format.', array(), $options),
|
37
|
'required' => TRUE,
|
38
|
'group' => 'variable_example',
|
39
|
);
|
40
|
// Text with format
|
41
|
$variables['variable_example_mail_[mail_part]'] = array(
|
42
|
'type' => 'mail_text',
|
43
|
'title' => t('Example mail', array(), $options),
|
44
|
'default' => array(
|
45
|
'subject' => t('Example mail subject', array(), $options),
|
46
|
'body' => t('Example mail body.', array(), $options),
|
47
|
),
|
48
|
'description' => t('Example mail variable with subject and body.', array(), $options),
|
49
|
'required' => TRUE,
|
50
|
'group' => 'variable_example',
|
51
|
);
|
52
|
return $variables;
|
53
|
}
|
54
|
|
55
|
/**
|
56
|
* Implements hook_variable_group_info().
|
57
|
*/
|
58
|
function variable_example_variable_group_info() {
|
59
|
$groups['variable_example'] = array(
|
60
|
'title' => t('Examples'),
|
61
|
'description' => t('Variable examples of different types.'),
|
62
|
'access' => 'administer site configuration',
|
63
|
'path' => array('admin/config/system/variable/example'),
|
64
|
);
|
65
|
return $groups;
|
66
|
}
|
67
|
|