i18n.variable.inc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * @file
  4. * Variable information
  5. */
  6. /**
  7. * Implements hook_variable_group_info().
  8. */
  9. function i18n_variable_group_info() {
  10. $groups['i18n'] = array(
  11. 'title' => t('Multilingual settings'),
  12. 'description' => t('Mixed options for multilingual sites.'),
  13. 'access' => 'administer site configuration',
  14. 'path' => 'admin/config/regional/i18n',
  15. );
  16. return $groups;
  17. }
  18. /**
  19. * Implements hook_variable_info().
  20. */
  21. function i18n_variable_info($options = array()) {
  22. $variables['i18n_language_list'] = array(
  23. 'title' => t('Languages for content', array(), $options),
  24. 'description' => t('Determines which languages will be allowed for content creation.', array(), $options),
  25. 'type' => 'select',
  26. 'options callback' => 'i18n_variable_option_list',
  27. 'default' => I18N_LANGUAGE_ENABLED,
  28. 'group' => 'i18n',
  29. );
  30. return $variables;
  31. }
  32. /**
  33. * Implements hook_variable_type_info().
  34. */
  35. function i18n_variable_type_info() {
  36. // Multiple variable per language options
  37. $types['multiple_language'] = array(
  38. 'title' => t('Multiple language'),
  39. 'element' => array('#type' => 'fieldset'),
  40. 'build callback' => 'variable_build_multiple',
  41. 'format callback' => 'variable_format_multiple',
  42. 'element callback' => 'variable_form_element_multiple',
  43. 'value callback' => 'variable_multiple_get_value',
  44. 'default callback' => 'variable_multiple_get_default',
  45. 'multiple callback' => 'i18n_variable_multiple_language_options',
  46. 'language list' => I18N_LANGUAGE_EXTENDED,
  47. );
  48. return $types;
  49. }
  50. /**
  51. * Options for content languages
  52. */
  53. function i18n_variable_option_list($variable, $options = array()) {
  54. return array(
  55. I18N_LANGUAGE_ENABLED => t('Enabled languages only.', array(), $options),
  56. I18N_LANGUAGE_EXTENDED => t('All defined languages will be allowed.', array(), $options),
  57. );
  58. }
  59. /**
  60. * Callback for multiple per-language variables
  61. */
  62. function i18n_variable_multiple_language_options($variable, $options = array()) {
  63. return i18n_language_list('name', $variable['language list']);
  64. }