-
Notifications
You must be signed in to change notification settings - Fork 0
/
plxdiapo.php
259 lines (192 loc) · 8.9 KB
/
plxdiapo.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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?php
/**
* Plugin plxEditor
*
* @package PLX
* @version 1.0 beta 1
* @date 01/07/2011
* @author Stephane F
**/
class plxdiapo extends plxPlugin {
/**
* Constructeur de la classe
*
* @param default_lang langue par défaut utilisée par PluXml
* @return null
* @author Stephane F
**/
public function __construct($default_lang) {
# Appel du constructeur de la classe plxPlugin (obligatoire)
parent::__construct($default_lang);
# droits pour accèder à la page config.php du plugin
$this->setConfigProfil(PROFIL_ADMIN);
# Déclarations des hooks
$this->addHook('plxEditorMediasEndHead', 'plxEditorMediasEndHead');
$this->addHook('plxEditorMediasEndBody', 'plxEditorMediasEndBody');
$this->addHook('ThemeEndHead', 'ThemeEndHead');
$this->addHook('ThemeEndBody', 'ThemeEndBody');
$this->loadParams();
}
#----------
/**
* Méthode appelé lors du préview d'un article: conversion des liens des images et des documents
*
* @return stdio
* @author Stephane F
**/
public function plxEditorMediasEndHead() {
echo "
<script>
function formatHTML(p_href, p_src, type) {
var p_title = document.getElementById('p_title') ? ' title=\"'+document.getElementById('p_title').value+'\"' : ''; // not implemented yet
var p_rel = document.getElementById('p_rel') ? ' rel=\"'+document.getElementById('p_rel').value+'\"' : ''; // not implemented yet
var p_class = document.getElementById('p_class') ? ' class=\"'+document.getElementById('p_class').value+'\"' : ''; // not implemented yet
var alignStart ='';
var alignEnd = '';
var alignment = document.forms[1].alignment;
if(alignment!=undefined || alignment!=null) {
for(var i = 0; i < 4; i++) {
if(alignment[i].checked && alignment[i].value!='none') {
if(alignment[i].value=='center') {
alignStart = '<div style=\"text-align:center\">';
} else {
alignStart = '<div style=\"float:'+alignment[i].value+'\">';
}
alignEnd = '</div> ';
break;
}
}
}
if(type=='1') {
if(p_src!='') {
return alignStart+'<a href=\"'+p_href+'\"'+p_title+p_class+p_rel+'><img src=\"'+p_src+'\" alt=\"\" /></a>'+alignEnd;
} else {
return alignStart+'<img src=\"'+p_href+'\" alt=\"\" />'+alignEnd;
}
}
else if (type=='2') {
return alignStart+'<a href=\"'+p_href+'\" class=\"diaporama\"><img src=\"'+p_src+'\" alt=\"\" /></a>'+alignEnd;
}
else {
return alignStart+'<a href=\"'+p_href+'\"'+p_title+p_rel+'>'+basename(p_href)+'</a>'+alignEnd;
}
}
function addDiapoLink() {
var editor = document.location.search.split('&')[0].split('=')[1];
var rows = document.getElementsByTagName(\"tr\");
if (editor && rows && rows[1])
{
var l = rows.length;
var i;
var img;
for (i = 1; i < l;i++) {
if (rows[i].childNodes[1] && rows[i].childNodes[2])
{
if (rows[i].childNodes[1].childNodes[0])
{
img = rows[i].childNodes[1].childNodes[0].href;
tb = img.substr(0, img.lastIndexOf(\".\")) + '.tb' + img.substr(img.lastIndexOf(\".\"));
}
rows[i].childNodes[2].innerHTML = rows[i].childNodes[2].innerHTML + '<br /><a onclick=\"window.opener.' + editor + '.execCommand(\'inserthtml\', formatHTML(\'' + img + '\', \'' + tb + '\', \'2\'));self.close();return false;\" title=\"\" href=\"javascript:void(0)\">Diaporama</a>';
}
}
}
}
</script>";
}
/**
* Méthode du hook plxEditorMediasEndBody
*
* @return stdio
* @author Stephane F
**/
public function plxEditorMediasEndBody() {
echo "<script type=\"text/javascript\">
addDiapoLink();
</script>";
}
/**
* Méthode du hook AdminFootEndBody
*
* @return stdio
* @author Stephane F
**/
public function ThemeEndHead() {
global $plxAdmin, $plxShow;
echo '<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>';
echo '<script src="plugins/plxdiapo/js/reflection.js"></script>';
echo '<script src="plugins/plxdiapo/js/colorbox/jquery.colorbox.js"></script>';
echo '<link rel="stylesheet" type="text/css" href="plugins/plxdiapo/js/colorbox/colorbox.css" media="screen" />';
}
/**
* Méthode du hook AdminFootEndBody
*
* @return stdio
* @author Stephane F
**/
public function ThemeEndBody() {
echo '
<script type="text/javascript">
var xhr = [];
var arrA = $(".diaporama");
var len = arrA.length;
for (var i = 0; i < len; i++)
{
try { xhr[i] = new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e)
{
try { xhr[i] = new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e2)
{
try { xhr[i] = new XMLHttpRequest(); }
catch (e3) { xhr[i] = false; }
}
}
xhr[i].onreadystatechange = function()
{
if(this.readyState == 4)
{
if(this.status == 200)
{
var response, a, img;
try {
response = eval(this.responseText);
} catch(e) {}
if (response) {
for (var i = 0; i < response.length; i++)
{
a = document.createElement("a");
a.href = response[i];
a.rel = "modal" + this.cpt;
a.style.display = "none";
img = document.createElement("img");
img.src = response[i];
a.appendChild(img);
this.element.parentNode.insertBefore(a, this.element.nextSibling);
}
this.element.rel = "modal" + this.cpt;
this.element.firstChild.className = "myreflect";
if (this.cpt + 1 == this.len)
{
while (this.len != 0)
{
this.len--;
$("a[rel=\'modal" + this.len + "\']").colorbox({current:"image {current} sur {total}"});
$(".myreflect").reflect({height:62});
}
}
}
}
}
};
xhr[i].element = arrA[i];
xhr[i].cpt = i;
xhr[i].len = len;
xhr[i].open("GET", "plugins/plxdiapo/ajax.php?image=" + arrA[i].href, true);
xhr[i].send(null);
}
</script>
';
}
}
?>