-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcampaignion.module
65 lines (59 loc) · 2.03 KB
/
campaignion.module
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
<?php
/**
* Implements hook_language_switch_links_alter().
*
* Remove switch links to non-node_view() paths created by the translation module.
* This is to avoid geoip_language_redirect from redirecting there.
*/
function campaignion_language_switch_links_alter(array &$links, $type, $path) {
$language_type = variable_get('translation_language_type', LANGUAGE_TYPE_INTERFACE);
if ($type == $language_type && preg_match("!^node/(\d+)(/.+|)!", $path, $matches)) {
if (!empty($matches[2]) && $matches[2] != '/' && $matches[2] != '/view') {
$node = node_load((int) $matches[1]);
foreach ($links as $langcode => &$link) {
if ($langcode != $node->language && isset($link['href'])) {
// No translation in this language, or no permission to view.
unset($link['href']);
$link['attributes']['class'][] = 'locale-untranslated';
}
}
}
}
}
/**
* Implements hook_entity_info_alter().
*
* Use our own extended contact class.
*/
function campaignion_entity_info_alter(&$entity_info) {
if (isset($entity_info['redhen_contact'])) {
$entity_info['redhen_contact']['entity class'] = '\\Drupal\\campaignion\\Contact';
}
}
/**
* Implements hook_share_light_options_alter().
*/
function campaignion_share_light_options_alter(&$options) {
if (!empty($_GET['sid'])) {
$options['link']['query']['refsid'] = $_GET['sid'];
}
}
/**
* Implements hook_variable_info_alter().
*/
function campaignion_variable_info_alter(array &$info) {
$info['site_default_country']['localize'] = TRUE;
$info['site_default_country']['default callback'] = '_campaignion_site_default_country_from_language';
}
/**
* Variable default value callback: Get the default country from the language.
*/
function _campaignion_site_default_country_from_language($variable, array $options) {
if ($language = $options['langcode']) {
$countries = country_get_list();
$parts = explode('-', $language, 2);
if (count($parts) == 2 && isset($countries[$country = $parts[1]])) {
return $country;
}
}
}