-
Notifications
You must be signed in to change notification settings - Fork 0
/
i18n_selection_page.install
71 lines (65 loc) · 2.29 KB
/
i18n_selection_page.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* @file
* Module installation code
*/
/*
* Implements hook_requirements().
*/
function i18n_selection_page_requirements($phase) {
module_load_include('inc', 'i18n_selection_page', 'includes/i18n_selection_page.helpers');
$requirements = array();
$lang_list = language_list('enabled');
$language_count = _i18n_selection_page_check_language_count();
if ($language_count['db'] != $language_count['vars']) {
$requirements['i18n_selection_page'] = array(
'title' => 'Language Selection Page',
'value' => _i18n_selection_page_get_error_messages('language_count', $language_count['db'], $language_count['vars']),
'severity' => REQUIREMENT_ERROR
);
return $requirements;
}
if ($language_count['db'] > 1) {
$lang_list_without_prefix = array();
foreach ($lang_list[1] as $lang) {
if (empty($lang->prefix)) {
$lang_list_without_prefix[$lang->language] = _i18n_selection_page_get_error_messages('language_prefix', url('admin/config/regional/language/edit/' . $lang->language), $lang->name);
}
}
if (count($lang_list_without_prefix) >= 1) {
$requirements['i18n_selection_page'] = array(
'title' => 'Language Selection Page',
'value' => implode('<br/>', $lang_list_without_prefix),
'severity' => REQUIREMENT_WARNING
);
}
else {
$requirements['i18n_selection_page'] = array(
'title' => 'Language Selection Page',
'value' => _i18n_selection_page_get_error_messages('language_all_good'),
'severity' => REQUIREMENT_OK
);
}
}
else {
$link = url('admin/config/regional/language');
$requirements['i18n_selection_page'] = array(
'title' => 'Language Selection Page',
'value' => _i18n_selection_page_get_error_messages('language_only_one', $link),
'severity' => REQUIREMENT_WARNING
);
}
return $requirements;
}
/**
* Implements hook_uninstall().
*
* @return void
*/
function i18n_selection_page_uninstall() {
variable_del('i18n_selection_page_use_language_cookie');
variable_del('i18n_selection_page_redirect_type');
variable_del('i18n_selection_page_blacklisted_paths');
variable_del('i18n_selection_page_cookie_lifetime');
drupal_set_message(t('The Language Selection Page variables and cookie has been removed successfully.'));
}