ip_language_negotiation.install in IP Language Negotiation 7
Same filename and directory in other branches
Install/uninstall and update functions.
File
ip_language_negotiation.installView source
<?php
/**
* @file
* Install/uninstall and update functions.
*/
/**
* Implements hook_requirements().
*/
function ip_language_negotiation_requirements($phase) {
$requirements = array();
// Ensure translations don't break during installation.
$t = get_t();
if ($phase == 'runtime') {
$requirements['ip_language_negotiation'] = array(
'title' => $t('IP Language Negotiation'),
'value' => $t('Properly configured'),
);
$enabled_providers = variable_get('language_negotiation_language', array());
$countries = variable_get('ip_language_negotiation_countries', array());
$pos_of_url_method = array_search('locale-url', array_keys($enabled_providers));
$pos_of_ip_method = array_search('ip_language_negotiation', array_keys($enabled_providers));
if (!isset($enabled_providers['locale-url'])) {
$requirements['ip_language_negotiation']['value'] = $t('You need to <a href="@link">enable the URL language detection method</a> for the IP Language Negotiation method to work.', array(
'@link' => url('admin/config/regional/language/configure'),
));
$requirements['ip_language_negotiation']['severity'] = REQUIREMENT_ERROR;
}
elseif ($pos_of_url_method >= $pos_of_ip_method) {
$requirements['ip_language_negotiation']['value'] = $t('You need to <a href="@link">position the URL language detection method</a> before the IP Language Negotiation method to work.', array(
'@link' => url('admin/config/regional/language/configure'),
));
$requirements['ip_language_negotiation']['severity'] = REQUIREMENT_ERROR;
}
elseif (empty($countries)) {
$requirements['ip_language_negotiation']['value'] = $t('You need to <a href="@link">set default the language per country</a> for the IP Language Negotiation method to work.', array(
'@link' => url('admin/config/regional/language/configure/ip'),
));
$requirements['ip_language_negotiation']['severity'] = REQUIREMENT_WARNING;
}
}
return $requirements;
}
/**
* Implements hook_uninstall().
*/
function ip_language_negotiation_uninstall() {
variable_del('ip_language_negotiation_countries');
}
Functions
Name | Description |
---|---|
ip_language_negotiation_requirements | Implements hook_requirements(). |
ip_language_negotiation_uninstall | Implements hook_uninstall(). |