-
Notifications
You must be signed in to change notification settings - Fork 10
/
hook.php
124 lines (111 loc) · 3.9 KB
/
hook.php
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
122
123
124
<?php
function plugin_trademark_display_login() {
$themeInfo = null;
if (isset($_GET['theme'])) {
$themeInfo = PluginTrademarkTheme::getThemeInfo($_GET['theme']);
}
if (!$themeInfo) {
$theme = PluginTrademarkConfig::getConfig("login_theme", '');
$themeInfo = PluginTrademarkTheme::getThemeInfo($theme);
}
$loginPicture = PluginTrademarkConfig::getConfig('login_picture');
if (!$loginPicture && $themeInfo && $themeInfo['login-background']) {
$loginPicture = $themeInfo['login-logo'] . '&theme=' . $themeInfo['id'];
}
if ($loginPicture && version_compare(GLPI_VERSION, '9.5.0', '<')) {
echo Html::css("/plugins/trademark/css/login.base.css", [
'version' => PLUGIN_TRADEMARK_VERSION,
]);
}
$timestamp = PluginTrademarkToolbox::getTimestamp();
$cssUrl = "/plugins/trademark/front/login.css.php?_=$timestamp";
if (isset($_GET['theme'])) {
$cssUrl .= "&theme=" . $_GET['theme'];
}
echo Html::css($cssUrl, [
'version' => PLUGIN_TRADEMARK_VERSION,
]);
?>
<script type="text/javascript">
var $box = jQuery('#firstboxlogin');
var $wrapper = jQuery('<div />', {
class: 'login_wrapper'
}).append($box.contents());
$wrapper.prependTo($box);
jQuery('#display-login').appendTo($box);
<?php
if ($loginPicture) :
$pictureUrl = PluginTrademarkToolbox::getPictureUrl($loginPicture);
$css = [
'max-width' => PluginTrademarkConfig::getConfig('login_picture_max_width', '145px'),
'max-height' => PluginTrademarkConfig::getConfig('login_picture_max_height', '80px'),
];
?>
var $logo_login = jQuery('#logo_login');
var $img = $logo_login.find('img');
if (!$img.length) {
$logo_login.replaceWith(jQuery('<h1 />', {
id: 'logo_login',
html: jQuery('<img />', {
src: <?php echo json_encode($pictureUrl) ?>,
css: <?php echo json_encode($css) ?>
})
}));
$logo_login = jQuery('#logo_login');
} else {
$img.css(<?php echo json_encode($css) ?>);
$img.attr('src', <?php echo json_encode($pictureUrl) ?>);
}
// $logo_login.css(<?php echo json_encode($css) ?>);
// $logo_login.css({
// 'background-repeat': 'no-repeat',
// 'background-size': 'contain',
// 'background-position': 'center',
// 'background-image': 'url(<?php echo json_encode($pictureUrl) ?>)'
// });
<?php
endif;
$favicon = PluginTrademarkConfig::getConfig('favicon_picture');
if ($favicon) :
$faviconUrl = PluginTrademarkToolbox::getPictureUrl($favicon);
?>
var $icon = jQuery('link[rel*=icon]');
$icon.attr('type', null);
$icon.attr('href', <?php echo json_encode($faviconUrl) ?>);
<?php
endif;
$pageTitle = PluginTrademarkConfig::getConfig('page_title');
if ($pageTitle) :
?>
var $title = jQuery('title');
var newTitle = $title.text().replace('GLPI', <?php echo json_encode($pageTitle) ?>);
$title.text(newTitle);
<?php
endif;
$footerDisplay = PluginTrademarkConfig::getConfig('page_footer_display', 'original');
$footerText = PluginTrademarkConfig::getConfig('page_footer_text', '');
if ($footerDisplay === 'hide') :
?>
jQuery(function() {
jQuery('.copyright').parent().hide();
});
<?php
endif;
if ($footerDisplay === 'custom') :
$footerText = Glpi\RichText\RichText::getEnhancedHtml($footerText);
?>
jQuery(function() {
jQuery('.copyright').parent().html(<?php echo json_encode($footerText) ?>);
});
<?php
endif;
?>
</script>
<?php
}
function plugin_trademark_install() {
return true;
}
function plugin_trademark_uninstall() {
return true;
}