| 1 |
<?php |
<?php |
| 2 |
// $Id: i18nstrings.admin.inc,v 1.1.2.5 2008/10/03 11:32:23 hass Exp $ |
// $Id: i18nstrings.admin.inc,v 1.1.2.6 2009/01/03 19:07:52 jareyero Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 16 |
* Form callback. Refresh textgroups. |
* Form callback. Refresh textgroups. |
| 17 |
*/ |
*/ |
| 18 |
function i18nstrings_admin_refresh() { |
function i18nstrings_admin_refresh() { |
| 19 |
// Select textgroup/s. |
// Select textgroup/s. Just the ones that have a 'refresh callback' |
| 20 |
$groups = module_invoke_all('locale', 'groups'); |
$groups = module_invoke_all('locale', 'groups'); |
| 21 |
unset($groups['default']); |
unset($groups['default']); |
| 22 |
|
foreach (array_keys($groups) as $key) { |
| 23 |
|
if (!i18nstrings_group_info($key, 'refresh callback')) { |
| 24 |
|
unset($groups[$key]); |
| 25 |
|
} |
| 26 |
|
} |
| 27 |
$form['groups'] = array( |
$form['groups'] = array( |
| 28 |
'#type' => 'checkboxes', |
'#type' => 'checkboxes', |
| 29 |
'#title' => t('Select text groups'), |
'#title' => t('Select text groups'), |
| 30 |
'#options' => $groups, |
'#options' => $groups, |
| 31 |
|
'#description' => t('If a text group is no showing up here it means this feature is not implemented for it.'), |
| 32 |
); |
); |
| 33 |
$form['refresh'] = array( |
$form['refresh'] = array( |
| 34 |
'#type' => 'submit', |
'#type' => 'submit', |
| 58 |
$op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
$op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
| 59 |
$groups = array_filter($form_state['values']['groups']); |
$groups = array_filter($form_state['values']['groups']); |
| 60 |
$languages = array_filter($form_state['values']['languages']); |
$languages = array_filter($form_state['values']['languages']); |
| 61 |
|
$group_names = module_invoke_all('locale', 'groups'); |
| 62 |
if ($op == t('Refresh strings') && $groups) { |
if ($op == t('Refresh strings') && $groups) { |
| 63 |
foreach ($groups as $group) { |
foreach ($groups as $group) { |
| 64 |
i18nstrings_refresh_group($group, TRUE); |
if (i18nstrings_refresh_group($group, TRUE)) { |
| 65 |
|
drupal_set_message(t("Successfully refreshed strings for %group", array('%group' => $group_names[$group]))); |
| 66 |
|
} |
| 67 |
|
else { |
| 68 |
|
drupal_set_message(t("Cannot refresh strings for %group.", array('%group' => $group_names[$group])), 'warning'); |
| 69 |
|
} |
| 70 |
} |
} |
| 71 |
} |
} |
| 72 |
elseif ($op == t('Update translations') && $groups && $languages) { |
elseif ($op == t('Update translations') && $groups && $languages) { |