-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathie6update.module
121 lines (111 loc) · 4.1 KB
/
ie6update.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
/**
* @file
*
* In IE6, pops up a IE style dialog notifying the user that there is an update
* to their browser, hoping to trick the user into updating to the latest
* version of IE.
*/
/**
* Implements hook_menu().
*/
function ie6update_menu() {
$items = array();
$items['admin/config/user-interface/ie6update'] = array(
'title' => 'IE6 Update',
'page callback' => 'drupal_get_form',
'page arguments' => array('ie6update_admin_settings'),
'access arguments' => array('administer site configuration'),
);
return $items;
}
/**
* Implements hook_help().
*/
function ie6update_help($path, $arg) {
switch ($path) {
case 'admin/help#ie6update':
return check_markup(file_get_contents(dirname(__FILE__) . "/README.txt"), 'plain_text', TRUE);
}
}
/**
* Implements hook_variable_info().
*/
function ie6update_variable_info($options) {
// Declare translatable variables for Variable module.
$variable['ie6update_destination_url'] = array(
'title' => t('Destination URL', array(), $options),
'type' => 'string',
'description' => t('Where do you want the user directed when they click on the IE6 Update bar?'),
'default' => 'http://www.microsoft.com/windows/internet-explorer/default.aspx',
);
$variable['ie6update_update_bar_message'] = array(
'title' => t('Update Message', array(), $options),
'type' => 'string',
'description' => t('What do you want the user to be told on the IE6 Update bar?'),
'default' => 'Internet Explorer is missing updates required to view this site. Click here to update...',
);
return $variable;
}
/**
* Return the module admin settings form to be rendered
*/
function ie6update_admin_settings() {
$form = array();
$form['ie6update_destination_url'] = array(
'#title' => t('Destination URL'),
'#description' => t('Where do you want the user directed when they click on the bar?'),
'#type' => 'textfield',
'#default_value' => variable_get('ie6update_destination_url', 'http://www.microsoft.com/windows/internet-explorer/default.aspx'),
);
$form['ie6update_update_bar_message'] = array(
'#title' => t('Update Message'),
'#description' => t('What do you want the user to be told?'),
'#type' => 'textfield',
'#default_value' => variable_get('ie6update_update_bar_message', 'Internet Explorer is missing updates required to view this site. Click here to update... '),
);
$form['ie6update_ie_versions'] = array(
'#title' => t('IE Versions'),
'#description' => t('The versions of IE for which the update message should be shown.'),
'#type' => 'checkboxes',
'#options' => drupal_map_assoc(array('IE 6', 'IE 7', 'IE 8', 'IE 9')),
'#default_value' => variable_get('ie6update_ie_versions', array('IE 6' => 'IE 6')),
);
return system_settings_form($form);
}
/**
* Implements hook_page_alter().
*/
function ie6update_page_alter(&$page) {
global $base_url;
$message = variable_get('ie6update_update_bar_message', 'Internet Explorer is missing updates required to view this site. Click here to update... ');
$url = variable_get('ie6update_destination_url', 'http://www.microsoft.com/windows/internet-explorer/default.aspx');
$ie_versions = variable_get('ie6update_ie_versions', array('IE 6' => 'IE 6'));
$icon_path = $base_url . '/' . drupal_get_path('module', 'ie6update') . '/images/';
// Generate IE condition string.
$ie_conditions = array();
foreach ($ie_versions as $version) {
if ($version) {
$ie_conditions[] = '(' . $version . ')';
}
}
$ie_condition = implode('|', $ie_conditions);
$js = '
<!--[if ' . $ie_condition . ']>
<script type="text/javascript">
var IE6UPDATE_OPTIONS = {
icons_path: "' . $icon_path .'",
message: "' . filter_xss_admin($message) . '",
url: "' . $url . '"
}
</script>
<script type="text/javascript" src="' . $base_url . '/' . drupal_get_path('module', 'ie6update') .'/ie6update.js' . '"></script>
<![endif]-->
';
if ($message && $url && !empty($ie_conditions)) {
$page['page_bottom']['ie6update']= array(
'#type' => 'markup',
'#markup' => $js,
);
}
}