variable_example.variable.inc 2.1 KB

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