-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhosted_by.module
62 lines (50 loc) · 1.38 KB
/
hosted_by.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
<?php
/**
* @file
* Code for the Hosted By module.
*/
/**
* Implements hook_block_info().
*/
function hosted_by_block_info() {
$blocks = array();
$blocks['hosted-by'] = array(
'info' => t('Hosted By (hosting provider block)'),
'weight' => '10',
'cache' => DRUPAL_CACHE_GLOBAL,
'region' => 'footer',
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function hosted_by_block_view() {
$block = array();
$block['subject'] = NULL;
$hosting_provider_name = variable_get('hosted_by_name', NULL);
$hosting_provider_link = variable_get('hosted_by_link', NULL);
$hosted_by_custom_html = variable_get('hosted_by_custom_html', NULL);
$t_array = array(
'!hosted_by_name' => $hosting_provider_name,
'!hosted_by_link' => $hosting_provider_link,
);
$content = '<span class="hosted-by">';
if (!empty($hosted_by_custom_html)) {
$content .= t($hosted_by_custom_html, $t_array);
}
else {
if (empty($hosting_provider_name)) { // Default block needs this
return array();
}
if (empty($hosting_provider_link)) {
$content .= t('Hosted by !hosted_by_name. !hosted_by_more', $t_array);
}
else {
$content .= t('Hosted by <a href="!hosted_by_link" class="hosted-by-link">!hosted_by_name</a>. !hosted_by_more', $t_array);
}
}
$content .= '</span>';
$block['content'] = $content;
return $block;
}