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