-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.php
226 lines (198 loc) · 7.55 KB
/
config.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<?php
/**
* Classe scrollToTop
*
* @version 2.1
* @date 05/07/2014
* @author Cyril MAGUIRE
**/
if(!defined('PLX_ROOT')) exit;
?>
<style type="text/css">
#radio label {
font-size:230%;
margin-left: 20px;
}
</style>
<?php
# Control du token du formulaire
plxToken::validateFormToken($_POST);
$aLinkToTop = array(
'\u21E7'=>'⇧',
'\u21E1'=>'⇡',
'\u219F'=>'↟',
'\u2191'=>'↑',
'\u21DE'=>'⇞',
'\u27F0'=>'⟰',
'\u25B2'=>'▲',
'\u261D'=>'☝'
);
if(!empty($_POST)) {
if (!empty($_POST['color']) ) {
$plxPlugin->setParam('color', $_POST['color'], 'cdata');
$plxPlugin->setParam('speed', ($_POST['speed'] <= 0 ? 40 : $_POST['speed']), 'numeric');
if (!empty($_POST['textToTop']) && !empty($_POST['colorTextToTop'])) {
$plxPlugin->setParam('colorTextToTop', $_POST['colorTextToTop'], 'cdata');
}
if (!empty($_POST['textToTop']) && empty($_POST['colorTextToTop'])) {
$plxPlugin->setParam('colorTextToTop', '#B2B2B2', 'cdata');
}
if (empty($_POST['textToTop'])) {
$plxPlugin->setParam('colorTextToTop', '', 'cdata');
}
} else {
$plxPlugin->setParam('color', '#A1A1A1', 'cdata');
}
$plxPlugin->saveParams();
$css = '/** Bouton haut de page **/
#toplink {font-size: 0.9em;}
#toplink a,
#toplink a:visited,
#toplink a:link,
#toplink a:hover,
#toplink a:focus,
#toplink a:active {
display:block;
color: '.plxUtils::strCheck($_POST['color']).';
position: fixed;
right: 10px;
bottom: 16px;
height:30px;
font-family: Times, Serif; /* Pour une compatibilité maximale de l\'affichage de la flèche, ne pas modifier la police */
font-size:230%;
line-height:0;
opacity:0.6;
text-decoration: none;
outline:0;
}'.(!empty($_POST['textToTop']) ?
'#toplink a span {
border:1px solid #A1A1A1;
text-align:right;
right:0;
padding:5px;
background:'.(!empty($_POST['colorTextToTop']) ? plxUtils::strCheck($_POST['colorTextToTop']) : '#B2B2B2').';
color:'.(!empty($_POST['color']) ? plxUtils::strCheck($_POST['color']) : '#FFF').';
}' : '');
plxUtils::write($css, PLX_PLUGINS.'scrollToTop/scrolltotop.css');
if (!empty($_POST['textToTop'])) {
$_POST['linkToTop'] = $_POST['textToTop'];
}
if ( !empty($_POST['linkToTop']) && ( (array_key_exists($_POST['linkToTop'], $aLinkToTop) && empty($_POST['textToTop']) ) || !empty($_POST['textToTop']) ) ) {
$plxPlugin->setParam('linkToTop', $_POST['linkToTop'], 'cdata');
$plxPlugin->saveParams();
$licence = '/*
# ------------------ BEGIN LICENSE BLOCK ------------------
#
# Copyright (c) 2009 - 2014 Cyril MAGUIRE
# Licensed under the CeCILL v2.1 license.
# See http://www.cecill.info/licences.fr.html
#
# ------------------- END LICENSE BLOCK -------------------
*/';
$js = '
;(function(window,undefined) {
\'use_strict\';
var timeOut;
var isIE = isIE();
var bodyTag = document.getElementsByTagName(\'body\');
var idOfBody = bodyTag[0].getAttribute(\'id\');
if (idOfBody == null) {
idOfBody = \'top\';
bodyTag[0].setAttribute(\'id\', \'top\');
}
function isIE() {
var nav = navigator.userAgent.toLowerCase();
return (nav.indexOf(\'msie\') != -1) ? parseInt(nav.split(\'msie\')[1]) : false;
}
function backToTop() {
if (document.body.scrollTop!=0 || document.documentElement.scrollTop!=0){
window.scrollBy(0,-50);
timeOut=setTimeout(\'backToTop()\',40);
}
else {
clearTimeout(timeOut);
}
}
function getScrollPosition() {
return Array((document.documentElement && document.documentElement.scrollLeft) || window.pageXOffset || self.pageXOffset || document.body.scrollLeft,(document.documentElement && document.documentElement.scrollTop) || window.pageYOffset || self.pageYOffset || document.body.scrollTop);
}
function Remove(idOfParent,idToRemove) {
if (isIE) {
document.getElementById(idToRemove).removeNode(true);
} else {
var Node1 = document.getElementById(idOfParent);
var len = Node1.childNodes.length;
for(var i = 0; i < len; i++){
if (Node1.childNodes[i] != undefined && Node1.childNodes[i].id != undefined && Node1.childNodes[i].id == idToRemove){
Node1.removeChild(Node1.childNodes[i]);
}
}
}
}
function addElement(idOfParent,idToAdd,htmlToInsert) {
var DomParent = document.getElementById(idOfParent);//id of body
var newdiv = document.createElement(\'div\');
newdiv.setAttribute(\'id\',idToAdd);
newdiv.innerHTML = htmlToInsert;
DomParent.appendChild(newdiv);
}
function displayBackButton() {
var pos = [];
var fleche = \''.(array_key_exists($plxPlugin->getParam('linkToTop'), $aLinkToTop) ? plxUtils::strCheck($_POST['linkToTop']) : '<span>'.plxUtils::strCheck($_POST['linkToTop']).'</span>').'\';
if (isIE) {
fleche = \'\u25B2\';
}
pos = getScrollPosition();
var topLink = document.getElementById(\'toplink\');
if (pos[1] > 150) {
if (topLink == null) {
addElement(idOfBody,\'toplink\',\'<a href="#" onclick="backToTop();return false;">\'+fleche+\'</a>\');
}
} else {
if (topLink != null) {
Remove(idOfBody,\'toplink\');
}
}
}
//add to global namespace
window.onscroll = displayBackButton;
window.displayBackButton = displayBackButton;
window.backToTop = backToTop;
})(window);
';
$encoding = 10;
$fast_decode = true;
$special_char = false;
$css = false;
require 'class.JavaScriptPacker.php';
$packer = new JavaScriptPacker($js, $encoding, $fast_decode, $special_char);
$packed = $packer->pack();
plxUtils::write($licence.$packed, PLX_PLUGINS.'scrollToTop/min.scrolltotop.js');
}
header('Location: parametres_plugin.php?p=scrollToTop');
exit;
}
?>
<h2><?php $plxPlugin->lang('L_TITLE') ?></h2>
<form action="parametres_plugin.php?p=scrollToTop" method="post">
<fieldset class="withlabel">
<p><?php echo $plxPlugin->getLang('L_CONFIG_COLOR') ?> #A1A1A1</p>
<?php plxUtils::printInput('color', $plxPlugin->getParam('color'), 'text'); ?>
<p><?php echo $plxPlugin->getLang('L_CONFIG_ARROW') ?></p>
<div id="radio">
<?php $i=0;foreach ($aLinkToTop as $k => $v) {
$i++;
echo '<input id="id_'.$i.'linkToTop" name="linkToTop" type="radio" value="'.$k.'" '.($k == $plxPlugin->getParam('linkToTop') ? 'checked="checked"' : '').'/><label for="id_'.$i.'linkToTop">'.$v.'</label><br/>'."\n";
} ?>
</div>
<p><?php echo $plxPlugin->getLang('L_CONFIG_FREE_TXT') ?></p>
<?php plxUtils::printInput('textToTop', (array_key_exists($plxPlugin->getParam('linkToTop'), $aLinkToTop) ? '' : $plxPlugin->getParam('linkToTop') ), 'text'); ?><a class="help" title="<?php echo $plxPlugin->getLang('L_HELP_FREE_TXT'); ?>"> </a>
<p><?php echo $plxPlugin->getLang('L_CONFIG_COLOR_FREE_TXT') ?> #B2B2B2</p>
<?php plxUtils::printInput('colorTextToTop', (array_key_exists($plxPlugin->getParam('linkToTop'), $aLinkToTop) ? '' : $plxPlugin->getParam('colorTextToTop') ), 'text'); ?>
<p><?php echo $plxPlugin->getLang('L_CONFIG_SPEED') ?></p>
<?php plxUtils::printInput('speed', $plxPlugin->getParam('speed'), 'numeric'); ?>
</fieldset>
<br />
<?php echo plxToken::getTokenPostMethod() ?>
<input type="submit" name="submit" value="<?php echo $plxPlugin->getLang('L_CONFIG_SAVE') ?>" />
</form>