-
Notifications
You must be signed in to change notification settings - Fork 0
/
SnowEffect.php
94 lines (78 loc) · 2.75 KB
/
SnowEffect.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
<?php
class SnowEffectPlugin extends MantisPlugin{
/**
* A method that populates the plugin information and minimum requirements.
* @return void
*/
function register() {
$this->name = 'SnowEffect';
$this->description = 'Happy Christmas - Oh oh oh';
$this->version = '1.0';
$this->requires = array(
'MantisCore' => '2.0.0',
);
$this->author = 'Alexis POKORSKI';
$this->contact = '';
$this->url = '';
}
/**
* Event hook declaration.
* @return array
*/
function hooks(){
return array(
"EVENT_LAYOUT_RESOURCES" => "resources",
"EVENT_LAYOUT_BODY_BEGIN" => "snow_html",
"EVENT_LAYOUT_CONTENT_BEGIN" => "snowButton"
);
}
/**
* Importe le nécessaire pour fonctionner
*/
function resources(){
/*Créer le cookie s'il n'existe pas*/
if(!isset($_COOKIE['snowActive'])){
error_reporting(0);
echo '<script type="text/javascript">document.cookie = "snowActive=1; expires=\'\'; path=/";</script>';
}
echo '<link rel="stylesheet" type="text/css" href="' . plugin_file( 'neige.css' ) . '" />';
echo '<script type="text/javascript" src="' . plugin_file('snowEffect.js') . '" ></script>';
}
/**
* Déclaration du code html permettant la gestion de la neige
*/
function snow_html(){
if($_COOKIE["snowActive"] == '1') {
echo "<div class=\"snow active\" id=\"snow\">";
}
else{
echo "<div class=\"snow hide\" id=\"snow\">";
}
echo "<div class=\"snow__layer\">
<div class=\"snow__fall\"></div>
</div>
<div class=\"snow__layer\">
<div class=\"snow__fall\"></div>
</div>
<div class=\"snow__layer\">
<div class=\"snow__fall\"></div>
<div class=\"snow__fall\"></div>
<div class=\"snow__fall\"></div>
</div>
<div class=\"snow__layer\">
<div class=\"snow__fall\"></div>
</div>
</div>";
}
/**
* Bouton permettant d'activer ou désactiver la neige
*/
function snowButton(){
if (preg_match('~MSIE|Internet Explorer~i', $_SERVER['HTTP_USER_AGENT']) || preg_match('~Trident/7.0(; Touch)?; rv:11.0~',$_SERVER['HTTP_USER_AGENT'])) {
//IE do nothing
}
else{
echo "<input id=\"activeSnow\" type=\"button\" class='btn btn-primary btn-white btn-round btn-xs' value=\"Snow On/Off\">";
}
}
}