Project

General

Profile

Paste
Download (3.45 KB) Statistics
| Branch: | Revision:

root / drupal7 / sites / all / modules / i18n / i18n_string / i18n_string.variable.inc @ 01f36513

1
<?php
2
/**
3
 * @file
4
 * Variable information
5
 */
6

    
7
/**
8
 * Implements hook_variable_info().
9
 */
10
function i18n_string_variable_info($options = array()) {
11
  $variables['i18n_string_translate_langcode_[language]'] = array(
12
    'type' => 'multiple_language',
13
    'title' => t('Enable translation for language'),
14
    'multiple values' => array('type' => 'boolean'),
15
    'group' => 'i18n',
16
  );
17
  $variables['i18n_string_allowed_formats'] = array(
18
    'title' => t('Translatable text formats'),
19
    'options callback' => 'i18n_string_variable_format_list',
20
    'type' => 'options',
21
    'default callback' => 'i18n_string_variable_format_default',
22
    'access' => 'administer filters',
23
    'description' => t('The translation system only translates strings with the selected text formats. All other strings will be ignored and removed from the list of translatable strings.'),
24
  );
25
  $variables['i18n_string_source_language'] = array(
26
    'title' => t('Source language'),
27
    'type' => 'language',
28
    'default callback' => 'i18n_string_source_language',
29
    'description' => t('Language that will be used as the source language for string translations. The default is the site default language.'),
30
  );
31
  $variables['i18n_string_debug'] = array(
32
    'type' => 'enable',
33
    'title' => t('Debug string translation', array(), $options),
34
    'default' => 0,
35
    'group' => 'debug',
36
  );
37
  $variables['i18n_string_textgroup_class_[textgroup]'] = array(
38
    'title' => t('Class to use for the text group'),
39
    'description' => t('Determines which the class will be use for string translation in the text group.', array(), $options),
40
    'repeat' => array(
41
      'type' => 'select',
42
      'default' => 'i18n_string_textgroup_default',
43
      'options callback' => 'i18n_string_variable_textgroup_class_list',
44
    ),
45
    'submit callback' => 'i18n_string_variable_textgroup_class_submit_callback',
46
    'group' => 'i18n',
47
  );
48
  return $variables;
49
}
50

    
51
/**
52
 * Implements hook_variable_type_info().
53
 */
54
function i18n_string_variable_type_info() {
55
  $type['textgroup'] = array(
56
    'title' => t('Text group'),
57
    'type' => 'select',
58
    'options callback' => 'i18n_string_variable_textgroup_list',
59
  );
60
  return $type;
61
}
62

    
63
/**
64
 * Options callback, format list
65
 */
66
function i18n_string_variable_format_list() {
67
  $list = array();
68
  // As the user has administer filters permissions we get a full list here
69
  foreach (filter_formats() as $fid => $format) {
70
    $list[$fid] = $format->name;
71
  }
72
  return $list;
73
}
74

    
75
/**
76
 * Allowed formats default value
77
 */
78
function i18n_string_variable_format_default() {
79
  return array(filter_fallback_format());
80
}
81

    
82
/**
83
 * Options callback, text groups list.
84
 */
85
function i18n_string_variable_textgroup_list() {
86
  $groups = array();
87
  foreach (i18n_string_group_info() as $name => $info) {
88
    $groups[$name] = $info['title'];
89
  }
90
  return $groups;
91
}
92

    
93
/**
94
 * Options callback, text group classes list.
95
 */
96
function i18n_string_variable_textgroup_class_list($variable, $options = array()) {
97
  return array(
98
    'i18n_string_textgroup_default' => t('Text group handler default.', array(), $options),
99
    'i18n_string_textgroup_cached' => t('Text group handler which include persistent caching.', array(), $options),
100
  );
101
}
102

    
103
/**
104
 * Submit callback. Execute Reset the persistent caches after save the text group class variables.
105
 */
106
function i18n_string_variable_textgroup_class_submit_callback($variable, $options, $form, $form_state) {
107
  // Reset the persistent caches.
108
  cache_clear_all('i18n:string:' , 'cache', TRUE);
109
}