1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Variable hooks.
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
/**
|
8 |
|
|
* Implements hook_variable_info().
|
9 |
|
|
*/
|
10 |
|
|
function variable_realm_variable_info($options) {
|
11 |
|
|
$variables['variable_realm_list_[variable_realm]'] = array(
|
12 |
|
|
'type' => 'multiple',
|
13 |
|
|
'group' => 'variable',
|
14 |
|
|
'multiple' => 'variable_realm',
|
15 |
|
|
'title' => t('Realm list', array(), $options),
|
16 |
|
|
'description' => t('List of variables that can be set for a realm.', array(), $options),
|
17 |
|
|
'repeat' => array(
|
18 |
|
|
'type' => 'array',
|
19 |
|
|
),
|
20 |
|
|
);
|
21 |
|
|
$variables['variable_realm_weight_[variable_realm]'] = array(
|
22 |
|
|
'type' => 'multiple',
|
23 |
|
|
'group' => 'variable',
|
24 |
|
|
'multiple' => 'variable_realm',
|
25 |
|
|
'title' => t('Realm weight', array(), $options),
|
26 |
|
|
'description' => t('Override default weight for realm variables.', array(), $options),
|
27 |
|
|
'repeat' => array(
|
28 |
|
|
'type' => 'number',
|
29 |
|
|
),
|
30 |
|
|
);
|
31 |
|
|
return $variables;
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
/**
|
35 |
|
|
* Implements hook_variable_type_info().
|
36 |
|
|
*/
|
37 |
|
|
function variable_realm_variable_type_info() {
|
38 |
|
|
$type['variable_realm'] = array(
|
39 |
|
|
'title' => t('Variable realm'),
|
40 |
|
|
'type' => 'select',
|
41 |
|
|
'options callback' => 'variable_realm_list',
|
42 |
|
|
);
|
43 |
|
|
return $type;
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
/**
|
47 |
|
|
* Implements hook_variable_settings_form_alter().
|
48 |
|
|
*/
|
49 |
|
|
function variable_realm_variable_settings_form_alter(&$form, &$form_state, $form_id) {
|
50 |
|
|
form_load_include($form_state, 'form.inc', 'variable_realm');
|
51 |
|
|
foreach (_variable_realm_variable_settings_form_list() as $realm_name => $variables) {
|
52 |
|
|
if ($realm_variables = _variable_realm_variable_settings_form_alter($form, $realm_name, variable_children($variables))) {
|
53 |
|
|
$form['#realm_variables'][$realm_name] = $realm_variables;
|
54 |
|
|
}
|
55 |
|
|
}
|
56 |
|
|
if (!empty($form['#realm_variables'])) {
|
57 |
|
|
array_unshift($form['#submit'], 'variable_realm_variable_settings_form_submit');
|
58 |
|
|
// Add form switcher and current key for each realm.
|
59 |
|
|
_variable_realm_variable_settings_form_switcher($form);
|
60 |
|
|
}
|
61 |
|
|
} |