variable_realm.variable.inc 1.8 KB

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