1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | PiwiShack - a Piwigo Plugin | |
---|
4 | // | Copyright (C) 2009 MOREAU Julien - gotcha@piwigo.org | |
---|
5 | // +-----------------------------------------------------------------------+ |
---|
6 | // | This program is free software; you can redistribute it and/or modify | |
---|
7 | // | it under the terms of the GNU General Public License as published by | |
---|
8 | // | the Free Software Foundation | |
---|
9 | // | | |
---|
10 | // | This program is distributed in the hope that it will be useful, but | |
---|
11 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
12 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
13 | // | General Public License for more details. | |
---|
14 | // | | |
---|
15 | // | You should have received a copy of the GNU General Public License | |
---|
16 | // | along with this program; if not, write to the Free Software | |
---|
17 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
18 | // | USA. | |
---|
19 | // +-----------------------------------------------------------------------+ |
---|
20 | |
---|
21 | class PiwiShack |
---|
22 | { |
---|
23 | var $plugin_name, $plugin_path; |
---|
24 | var $opened, $to_close; |
---|
25 | |
---|
26 | function PiwiShack($plugin_name, $plugin_path) |
---|
27 | { |
---|
28 | // Args |
---|
29 | $this->plugin_name = $plugin_name; |
---|
30 | $this->plugin_path = $plugin_path; |
---|
31 | // handler |
---|
32 | $this->initialize_event_handler(); |
---|
33 | } |
---|
34 | |
---|
35 | function initialize_event_handler() |
---|
36 | { |
---|
37 | if (script_basename() != $this->plugin_name.'_controller') |
---|
38 | { |
---|
39 | add_event_handler('loc_end_page_header', array(&$this, 'loc_end_page_header')); |
---|
40 | add_event_handler('loc_end_index', array(&$this, 'loc_end_index')); |
---|
41 | add_event_handler('picture_pictures_data', array(&$this, 'picture_pictures_data')); |
---|
42 | } |
---|
43 | |
---|
44 | if (isset($_GET[$this->plugin_name])) |
---|
45 | { |
---|
46 | add_event_handler('loc_begin_page_header', array(&$this, 'loc_begin_page_header')); |
---|
47 | pwg_set_session_var($this->plugin_name, ($_GET[$this->plugin_name] === 'open')); |
---|
48 | } |
---|
49 | $this->opened = pwg_get_session_var($this->plugin_name, false); |
---|
50 | $this->to_close = (isset($_GET[$this->plugin_name]) and ($_GET[$this->plugin_name] === 'close')); |
---|
51 | } |
---|
52 | |
---|
53 | function get_thumb_post_on_a_website() |
---|
54 | { |
---|
55 | global $page, $lang_info; |
---|
56 | |
---|
57 | $list = array(); |
---|
58 | |
---|
59 | $S = ''; |
---|
60 | |
---|
61 | switch (script_basename()) |
---|
62 | { |
---|
63 | case 'index': |
---|
64 | { |
---|
65 | global $pictures; |
---|
66 | |
---|
67 | if (isset($pictures)) |
---|
68 | { |
---|
69 | $list = $pictures; |
---|
70 | } |
---|
71 | break; |
---|
72 | } |
---|
73 | case 'picture': |
---|
74 | { |
---|
75 | global $picture; |
---|
76 | |
---|
77 | if (isset($picture['current'])) |
---|
78 | { |
---|
79 | $list[] = $picture['current']; |
---|
80 | } |
---|
81 | break; |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | if (empty($list) and !empty($page['items'])) |
---|
86 | { |
---|
87 | $rank_of = array_flip($page['items']); |
---|
88 | $query = ' |
---|
89 | SELECT * |
---|
90 | FROM '.IMAGES_TABLE.' |
---|
91 | WHERE id IN ('.implode(',', $page['items']).') |
---|
92 | ;'; |
---|
93 | |
---|
94 | $result = pwg_query($query); |
---|
95 | |
---|
96 | while ($row = mysql_fetch_assoc($result)) |
---|
97 | { |
---|
98 | $row['rank'] = $rank_of[ $row['id'] ]; |
---|
99 | array_push($list, $row); |
---|
100 | } |
---|
101 | |
---|
102 | usort($list, 'rank_compare'); |
---|
103 | } |
---|
104 | if (!empty($list)) |
---|
105 | { |
---|
106 | set_make_full_url(); |
---|
107 | |
---|
108 | foreach ($list as $row) |
---|
109 | { |
---|
110 | /* |
---|
111 | Affichage de la miniature sur des sites. Cliquable. |
---|
112 | EXEMPLE |
---|
113 | <a href="{$ROOT_WAY}{$current.U_IMG}" target=_blank><img src="{$ROOT_WAY}{$current.THUMB_SRC|@replace:'./':''}" /></a> |
---|
114 | */ |
---|
115 | $S .= '<a href=\"'. |
---|
116 | duplicate_picture_url( |
---|
117 | array( |
---|
118 | 'image_id' => $row['id'], |
---|
119 | 'image_file' => $row['file'], |
---|
120 | )).'\" target=_blank><img src=\"'. |
---|
121 | str_replace('/./', '/', DerivativeImage::thumb_url($row)).'\" /></a>'; |
---|
122 | $S .= '\n\n'; |
---|
123 | } |
---|
124 | |
---|
125 | unset_make_full_url(); |
---|
126 | } |
---|
127 | |
---|
128 | return $S; |
---|
129 | } |
---|
130 | |
---|
131 | function get_thumb_post_on_a_forum() |
---|
132 | { |
---|
133 | global $page, $lang_info; |
---|
134 | |
---|
135 | $list = array(); |
---|
136 | |
---|
137 | $S = ''; |
---|
138 | |
---|
139 | switch (script_basename()) |
---|
140 | { |
---|
141 | case 'index': |
---|
142 | { |
---|
143 | global $pictures; |
---|
144 | |
---|
145 | if (isset($pictures)) |
---|
146 | { |
---|
147 | $list = $pictures; |
---|
148 | } |
---|
149 | break; |
---|
150 | } |
---|
151 | case 'picture': |
---|
152 | { |
---|
153 | global $picture; |
---|
154 | |
---|
155 | if (isset($picture['current'])) |
---|
156 | { |
---|
157 | $list[] = $picture['current']; |
---|
158 | } |
---|
159 | break; |
---|
160 | } |
---|
161 | } |
---|
162 | |
---|
163 | if (empty($list) and !empty($page['items'])) |
---|
164 | { |
---|
165 | $rank_of = array_flip($page['items']); |
---|
166 | $query = ' |
---|
167 | SELECT * |
---|
168 | FROM '.IMAGES_TABLE.' |
---|
169 | WHERE id IN ('.implode(',', $page['items']).') |
---|
170 | ;'; |
---|
171 | |
---|
172 | $result = pwg_query($query); |
---|
173 | |
---|
174 | while ($row = mysql_fetch_assoc($result)) |
---|
175 | { |
---|
176 | $row['rank'] = $rank_of[ $row['id'] ]; |
---|
177 | array_push($list, $row); |
---|
178 | } |
---|
179 | |
---|
180 | usort($list, 'rank_compare'); |
---|
181 | } |
---|
182 | if (!empty($list)) |
---|
183 | { |
---|
184 | |
---|
185 | set_make_full_url(); |
---|
186 | |
---|
187 | foreach ($list as $row) |
---|
188 | { |
---|
189 | /* |
---|
190 | Affichage de la miniature sur des forums. Cliquable. |
---|
191 | EXEMPLE |
---|
192 | [url={$ROOT_WAY}{$current.U_IMG}][img]{$ROOT_WAY}{$current.THUMB_SRC|@replace:'./':''}[/img][/url] |
---|
193 | */ |
---|
194 | $S .= '[url='. |
---|
195 | duplicate_picture_url( |
---|
196 | array( |
---|
197 | 'image_id' => $row['id'], |
---|
198 | 'image_file' => $row['file'], |
---|
199 | )).'][img]'. |
---|
200 | str_replace('/./', '/', DerivativeImage::thumb_url($row)).'[/img][/url]'; |
---|
201 | $S .= '\n\n'; |
---|
202 | } |
---|
203 | |
---|
204 | unset_make_full_url(); |
---|
205 | } |
---|
206 | |
---|
207 | return $S; |
---|
208 | } |
---|
209 | |
---|
210 | function get_view_post_on_a_website() |
---|
211 | { |
---|
212 | global $page, $lang_info; |
---|
213 | |
---|
214 | $list = array(); |
---|
215 | |
---|
216 | $S = ''; |
---|
217 | |
---|
218 | switch (script_basename()) |
---|
219 | { |
---|
220 | case 'index': |
---|
221 | { |
---|
222 | global $pictures; |
---|
223 | |
---|
224 | if (isset($pictures)) |
---|
225 | { |
---|
226 | $list = $pictures; |
---|
227 | } |
---|
228 | break; |
---|
229 | } |
---|
230 | case 'picture': |
---|
231 | { |
---|
232 | global $picture; |
---|
233 | |
---|
234 | if (isset($picture['current'])) |
---|
235 | { |
---|
236 | $list[] = $picture['current']; |
---|
237 | } |
---|
238 | break; |
---|
239 | } |
---|
240 | } |
---|
241 | |
---|
242 | if (empty($list) and !empty($page['items'])) |
---|
243 | { |
---|
244 | $rank_of = array_flip($page['items']); |
---|
245 | $query = ' |
---|
246 | SELECT * |
---|
247 | FROM '.IMAGES_TABLE.' |
---|
248 | WHERE id IN ('.implode(',', $page['items']).') |
---|
249 | ;'; |
---|
250 | |
---|
251 | $result = pwg_query($query); |
---|
252 | |
---|
253 | while ($row = mysql_fetch_assoc($result)) |
---|
254 | { |
---|
255 | $row['rank'] = $rank_of[ $row['id'] ]; |
---|
256 | array_push($list, $row); |
---|
257 | } |
---|
258 | |
---|
259 | usort($list, 'rank_compare'); |
---|
260 | } |
---|
261 | if (!empty($list)) |
---|
262 | { |
---|
263 | include_once(PHPWG_ROOT_PATH.'/include/functions_picture.inc.php'); |
---|
264 | set_make_full_url(); |
---|
265 | |
---|
266 | foreach ($list as $row) |
---|
267 | { |
---|
268 | /* |
---|
269 | Affichage de la vue normale sur des sites. Non cliquable. |
---|
270 | EXEMPLE |
---|
271 | <a href="{$ROOT_WAY}{$current.U_IMG}" target=_blank><img src="{$ROOT_WAY}{$SRC_IMG|@replace:'./':''}" /></a> |
---|
272 | */ |
---|
273 | $src_image = new SrcImage($row); |
---|
274 | if (strpos( $image_url = DerivativeImage::url(IMG_MEDIUM, $src_image), get_absolute_root_url() ) === false) { |
---|
275 | $abs_root_img= get_absolute_root_url(). str_replace('./', '', $image_url = DerivativeImage::url(IMG_MEDIUM, $src_image)) ; |
---|
276 | } else { |
---|
277 | $abs_root_img= DerivativeImage::url(IMG_MEDIUM, $src_image) ; |
---|
278 | } |
---|
279 | $S .= '<a href=\"'. |
---|
280 | duplicate_picture_url( |
---|
281 | array( |
---|
282 | 'image_id' => $row['id'], |
---|
283 | 'image_file' => $row['file'], |
---|
284 | )).'\" target=_blank><img src=\"'.$abs_root_img.'\" /></a>'; |
---|
285 | $S .= '\n\n'; |
---|
286 | } |
---|
287 | |
---|
288 | unset_make_full_url(); |
---|
289 | } |
---|
290 | |
---|
291 | return $S; |
---|
292 | } |
---|
293 | |
---|
294 | function get_view_post_on_a_forum() |
---|
295 | { |
---|
296 | global $page, $lang_info; |
---|
297 | |
---|
298 | $list = array(); |
---|
299 | |
---|
300 | $S = ''; |
---|
301 | |
---|
302 | switch (script_basename()) |
---|
303 | { |
---|
304 | case 'index': |
---|
305 | { |
---|
306 | global $pictures; |
---|
307 | |
---|
308 | if (isset($pictures)) |
---|
309 | { |
---|
310 | $list = $pictures; |
---|
311 | } |
---|
312 | break; |
---|
313 | } |
---|
314 | case 'picture': |
---|
315 | { |
---|
316 | global $picture; |
---|
317 | |
---|
318 | if (isset($picture['current'])) |
---|
319 | { |
---|
320 | $list[] = $picture['current']; |
---|
321 | } |
---|
322 | break; |
---|
323 | } |
---|
324 | } |
---|
325 | |
---|
326 | if (empty($list) and !empty($page['items'])) |
---|
327 | { |
---|
328 | $rank_of = array_flip($page['items']); |
---|
329 | $query = ' |
---|
330 | SELECT * |
---|
331 | FROM '.IMAGES_TABLE.' |
---|
332 | WHERE id IN ('.implode(',', $page['items']).') |
---|
333 | ;'; |
---|
334 | |
---|
335 | $result = pwg_query($query); |
---|
336 | |
---|
337 | while ($row = mysql_fetch_assoc($result)) |
---|
338 | { |
---|
339 | $row['rank'] = $rank_of[ $row['id'] ]; |
---|
340 | array_push($list, $row); |
---|
341 | } |
---|
342 | |
---|
343 | usort($list, 'rank_compare'); |
---|
344 | } |
---|
345 | if (!empty($list)) |
---|
346 | { |
---|
347 | include_once(PHPWG_ROOT_PATH.'/include/functions_picture.inc.php'); |
---|
348 | set_make_full_url(); |
---|
349 | |
---|
350 | foreach ($list as $row) |
---|
351 | { |
---|
352 | /* |
---|
353 | Affichage de la vue normale sur des forums. |
---|
354 | EXEMPLE |
---|
355 | [url={$ROOT_WAY}{$current.U_IMG}][img]{$ROOT_WAY}{$SRC_IMG|@replace:'./':''}[/img][/url] |
---|
356 | */ |
---|
357 | $src_image = new SrcImage($row); |
---|
358 | if (strpos( $image_url = DerivativeImage::url(IMG_MEDIUM, $src_image), get_absolute_root_url() ) === false) { |
---|
359 | $abs_root_img= get_absolute_root_url(). str_replace('./', '', $image_url = DerivativeImage::url(IMG_MEDIUM, $src_image)) ; |
---|
360 | } else { |
---|
361 | $abs_root_img= DerivativeImage::url(IMG_MEDIUM, $src_image) ; |
---|
362 | } |
---|
363 | $S .= '[url='. |
---|
364 | duplicate_picture_url( |
---|
365 | array( |
---|
366 | 'image_id' => $row['id'], |
---|
367 | 'image_file' => $row['file'], |
---|
368 | )).'][img]'.$abs_root_img.'[/img][/url]'; |
---|
369 | $S .= '\n\n'; |
---|
370 | } |
---|
371 | |
---|
372 | unset_make_full_url(); |
---|
373 | } |
---|
374 | |
---|
375 | return $S; |
---|
376 | } |
---|
377 | |
---|
378 | function get_view_direct_link() |
---|
379 | { |
---|
380 | global $page, $lang_info; |
---|
381 | |
---|
382 | $list = array(); |
---|
383 | |
---|
384 | $S = ''; |
---|
385 | |
---|
386 | switch (script_basename()) |
---|
387 | { |
---|
388 | case 'index': |
---|
389 | { |
---|
390 | global $pictures; |
---|
391 | |
---|
392 | if (isset($pictures)) |
---|
393 | { |
---|
394 | $list = $pictures; |
---|
395 | } |
---|
396 | break; |
---|
397 | } |
---|
398 | case 'picture': |
---|
399 | { |
---|
400 | global $picture; |
---|
401 | |
---|
402 | if (isset($picture['current'])) |
---|
403 | { |
---|
404 | $list[] = $picture['current']; |
---|
405 | } |
---|
406 | break; |
---|
407 | } |
---|
408 | } |
---|
409 | |
---|
410 | if (empty($list) and !empty($page['items'])) |
---|
411 | { |
---|
412 | $rank_of = array_flip($page['items']); |
---|
413 | $query = ' |
---|
414 | SELECT * |
---|
415 | FROM '.IMAGES_TABLE.' |
---|
416 | WHERE id IN ('.implode(',', $page['items']).') |
---|
417 | ;'; |
---|
418 | |
---|
419 | $result = pwg_query($query); |
---|
420 | |
---|
421 | while ($row = mysql_fetch_assoc($result)) |
---|
422 | { |
---|
423 | $row['rank'] = $rank_of[ $row['id'] ]; |
---|
424 | array_push($list, $row); |
---|
425 | } |
---|
426 | |
---|
427 | usort($list, 'rank_compare'); |
---|
428 | } |
---|
429 | if (!empty($list)) |
---|
430 | { |
---|
431 | include_once(PHPWG_ROOT_PATH.'/include/functions_picture.inc.php'); |
---|
432 | set_make_full_url(); |
---|
433 | |
---|
434 | $page_name = script_basename(); |
---|
435 | foreach ($list as $row) |
---|
436 | { |
---|
437 | /* |
---|
438 | Affichage du chemin en clair du lien vers la vue normale. |
---|
439 | EXEMPLE |
---|
440 | {$ROOT_WAY}{$SRC_IMG|@replace:'./':''} |
---|
441 | */ |
---|
442 | $src_image = new SrcImage($row); |
---|
443 | $S .= $image_url = DerivativeImage::url(IMG_MEDIUM, $src_image); |
---|
444 | $S .= '\n\n'; |
---|
445 | } |
---|
446 | |
---|
447 | unset_make_full_url(); |
---|
448 | } |
---|
449 | |
---|
450 | return $S; |
---|
451 | } |
---|
452 | |
---|
453 | function get_p_perso_writer_01() |
---|
454 | { |
---|
455 | global $page, $lang_info; |
---|
456 | |
---|
457 | $list = array(); |
---|
458 | |
---|
459 | $S = ''; |
---|
460 | |
---|
461 | switch (script_basename()) |
---|
462 | { |
---|
463 | case 'index': |
---|
464 | { |
---|
465 | global $pictures; |
---|
466 | |
---|
467 | if (isset($pictures)) |
---|
468 | { |
---|
469 | $list = $pictures; |
---|
470 | } |
---|
471 | break; |
---|
472 | } |
---|
473 | case 'picture': |
---|
474 | { |
---|
475 | global $picture; |
---|
476 | |
---|
477 | if (isset($picture['current'])) |
---|
478 | { |
---|
479 | $list[] = $picture['current']; |
---|
480 | } |
---|
481 | break; |
---|
482 | } |
---|
483 | } |
---|
484 | |
---|
485 | if (empty($list) and !empty($page['items'])) |
---|
486 | { |
---|
487 | $rank_of = array_flip($page['items']); |
---|
488 | $query = ' |
---|
489 | SELECT * |
---|
490 | FROM '.IMAGES_TABLE.' |
---|
491 | WHERE id IN ('.implode(',', $page['items']).') |
---|
492 | ;'; |
---|
493 | |
---|
494 | $result = pwg_query($query); |
---|
495 | |
---|
496 | while ($row = mysql_fetch_assoc($result)) |
---|
497 | { |
---|
498 | $row['rank'] = $rank_of[ $row['id'] ]; |
---|
499 | array_push($list, $row); |
---|
500 | } |
---|
501 | |
---|
502 | usort($list, 'rank_compare'); |
---|
503 | } |
---|
504 | if (!empty($list)) |
---|
505 | { |
---|
506 | include_once(PHPWG_ROOT_PATH.'/include/functions_picture.inc.php'); |
---|
507 | set_make_full_url(); |
---|
508 | |
---|
509 | foreach ($list as $row) |
---|
510 | { |
---|
511 | /* |
---|
512 | Affichage Personnalisé, 01. |
---|
513 | EXEMPLE |
---|
514 | <h6 style="text-align: center;"><a href="{$ROOT_WAY}{$current.U_IMG}" target="_blank"><img class="aligncenter" style="width: 100%; height: 100%;" src="{$ROOT_WAY}{$SRC_IMG|@replace:'./':''}" alt="{$ALT_IMG}" /></a><em><a href="{$ROOT_WAY}{$U_UP}"; target="_blank">Galerie complète à visiter</a></em></h6> |
---|
515 | */ |
---|
516 | |
---|
517 | $src_image = new SrcImage($row); |
---|
518 | $S .= '<h6 style=\"text-align: center;\"><a href=\"'. // Arguments à transmettre |
---|
519 | duplicate_picture_url( // Lien Piwigo vers la page de la vue normale |
---|
520 | array( |
---|
521 | 'image_id' => $row['id'], |
---|
522 | 'image_file' => $row['file'], |
---|
523 | )). |
---|
524 | '\" target=\"_blank\"><img class=\"aligncenter\" style=\"width: 100%; height: 100%;\" src=\"'. // Arguments à transmettre |
---|
525 | get_absolute_root_url().str_replace('./', '', $image_url = DerivativeImage::url(IMG_MEDIUM, $src_image)). // Liens direct vers la vue normale |
---|
526 | '\" alt=\"'. // Arguments à transmettre |
---|
527 | $row['file']. // Noms du fichier |
---|
528 | '\" /></a><em><a href=\"'. // Arguments à transmettre |
---|
529 | duplicate_index_url(). // Catégorie parente |
---|
530 | '\"; target=\"_blank\"><br />Galerie complète à visiter</a></em></h6>'; // Arguments à transmettre |
---|
531 | $S .= '\n\n'; |
---|
532 | } |
---|
533 | |
---|
534 | unset_make_full_url(); |
---|
535 | } |
---|
536 | |
---|
537 | return $S; |
---|
538 | } |
---|
539 | |
---|
540 | function get_p_perso_writer_02() |
---|
541 | { |
---|
542 | global $page, $lang_info; |
---|
543 | |
---|
544 | $list = array(); |
---|
545 | |
---|
546 | $S = ''; |
---|
547 | |
---|
548 | switch (script_basename()) |
---|
549 | { |
---|
550 | case 'index': |
---|
551 | { |
---|
552 | global $pictures; |
---|
553 | |
---|
554 | if (isset($pictures)) |
---|
555 | { |
---|
556 | $list = $pictures; |
---|
557 | } |
---|
558 | break; |
---|
559 | } |
---|
560 | case 'picture': |
---|
561 | { |
---|
562 | global $picture; |
---|
563 | |
---|
564 | if (isset($picture['current'])) |
---|
565 | { |
---|
566 | $list[] = $picture['current']; |
---|
567 | } |
---|
568 | break; |
---|
569 | } |
---|
570 | } |
---|
571 | |
---|
572 | if (empty($list) and !empty($page['items'])) |
---|
573 | { |
---|
574 | $rank_of = array_flip($page['items']); |
---|
575 | $query = ' |
---|
576 | SELECT * |
---|
577 | FROM '.IMAGES_TABLE.' |
---|
578 | WHERE id IN ('.implode(',', $page['items']).') |
---|
579 | ;'; |
---|
580 | |
---|
581 | $result = pwg_query($query); |
---|
582 | |
---|
583 | while ($row = mysql_fetch_assoc($result)) |
---|
584 | { |
---|
585 | $row['rank'] = $rank_of[ $row['id'] ]; |
---|
586 | array_push($list, $row); |
---|
587 | } |
---|
588 | |
---|
589 | usort($list, 'rank_compare'); |
---|
590 | } |
---|
591 | |
---|
592 | if (!empty($list)) |
---|
593 | { |
---|
594 | include_once(PHPWG_ROOT_PATH.'/include/functions_url.inc.php'); |
---|
595 | set_make_full_url(); |
---|
596 | |
---|
597 | foreach ($list as $row) |
---|
598 | { |
---|
599 | //'[(('.$picture['current']['thumbnail'].'))|'.$picture['current']['url'].'|'.$lang_info['code'].']'; |
---|
600 | $S .= '*** '.(!empty($row['name']) ? $row['name'] : $row['file']).' ***\n'; |
---|
601 | $S .= '[(('. |
---|
602 | str_replace('/./', '/', DerivativeImage::thumb_url($row)).'))|'. |
---|
603 | duplicate_picture_url( |
---|
604 | array( |
---|
605 | 'image_id' => $row['id'], |
---|
606 | 'image_file' => $row['file'], |
---|
607 | )).'|'. |
---|
608 | $lang_info['code'].']'; |
---|
609 | $S .= '\n\n'; |
---|
610 | } |
---|
611 | |
---|
612 | unset_make_full_url(); |
---|
613 | |
---|
614 | } |
---|
615 | |
---|
616 | return $S; |
---|
617 | } |
---|
618 | |
---|
619 | // Fin de la définition des champs |
---|
620 | |
---|
621 | function loc_begin_page_header() |
---|
622 | { |
---|
623 | global $template; |
---|
624 | |
---|
625 | $redirect_url = ( script_basename()=='picture' |
---|
626 | ? duplicate_picture_url(array(), array($this->plugin_name)) |
---|
627 | : duplicate_index_url(array(), array($this->plugin_name)) |
---|
628 | ); |
---|
629 | |
---|
630 | $template->assign( |
---|
631 | array( |
---|
632 | 'page_refresh' => array( |
---|
633 | 'TIME' => 1, |
---|
634 | 'U_REFRESH' => $redirect_url |
---|
635 | ) |
---|
636 | )); |
---|
637 | } |
---|
638 | |
---|
639 | function loc_end_page_header() |
---|
640 | { |
---|
641 | global $template, $conf; |
---|
642 | |
---|
643 | // force $conf['derivative_url_style'] to 2 (script) to make sure |
---|
644 | // exported HTML/BBCode will use i.php?/upload and not _data/i/upload |
---|
645 | // because you don't know when the cache will be flushed |
---|
646 | $previous_derivative_url_style = $conf['derivative_url_style']; |
---|
647 | $conf['derivative_url_style'] = 2; |
---|
648 | |
---|
649 | if ($this->opened or $this->to_close) |
---|
650 | { |
---|
651 | $plugin_root_url = get_root_url().'plugins/'.$this->plugin_name.'/'; |
---|
652 | |
---|
653 | $js = ' |
---|
654 | <script type="text/javascript"> |
---|
655 | var theController = window.open("", "'.$this->plugin_name.'_controller", "alwaysRaised=yes,dependent=yes,toolbar=no,height=807,width=1220,menubar=no,resizable=yes,scrollbars=yes,status=no");'; |
---|
656 | |
---|
657 | if ($this->to_close) |
---|
658 | { |
---|
659 | $js .= ' |
---|
660 | theController.close();'; |
---|
661 | } |
---|
662 | else |
---|
663 | { |
---|
664 | $js .= ' |
---|
665 | if (theController.location.toString()=="about:blank" || !theController.location.toString().match(/^(https?.*\/)'.$this->plugin_name.'_controller\.php(\?.+)?$/)) |
---|
666 | { |
---|
667 | theController.location = "'.$plugin_root_url.$this->plugin_name.'_controller.php"; |
---|
668 | } |
---|
669 | else |
---|
670 | { |
---|
671 | theController.focus(); |
---|
672 | } |
---|
673 | theController.document.getElementsByName("thumb_Post_on_a_website")[0].value = "'.$this->get_thumb_post_on_a_website().'"; |
---|
674 | theController.document.getElementsByName("thumb_Post_on_a_forum")[0].value = "'.$this->get_thumb_post_on_a_forum().'"; |
---|
675 | theController.document.getElementsByName("view_Post_on_a_website")[0].value = "'.$this->get_view_post_on_a_website().'"; |
---|
676 | theController.document.getElementsByName("view_Post_on_a_forum")[0].value = "'.$this->get_view_post_on_a_forum().'"; |
---|
677 | theController.document.getElementsByName("view_Direct_link")[0].value = "'.$this->get_view_direct_link().'"; |
---|
678 | theController.document.getElementsByName("p_Perso_writer_01")[0].value = "'.$this->get_p_perso_writer_01().'"; |
---|
679 | theController.document.getElementsByName("p_Perso_writer_02")[0].value = "'.$this->get_p_perso_writer_02().'";'; |
---|
680 | } |
---|
681 | $js .= ' |
---|
682 | </script>'; |
---|
683 | |
---|
684 | $template->append('head_elements', $js); |
---|
685 | } |
---|
686 | |
---|
687 | // restore configuration setting |
---|
688 | $conf['derivative_url_style'] = $previous_derivative_url_style; |
---|
689 | } |
---|
690 | |
---|
691 | function get_link_icon($main_link) |
---|
692 | { |
---|
693 | global $page; |
---|
694 | |
---|
695 | if (empty($page['items'])) |
---|
696 | { |
---|
697 | return; |
---|
698 | } |
---|
699 | |
---|
700 | $this->loading_lang(); |
---|
701 | |
---|
702 | if ($this->opened) |
---|
703 | { |
---|
704 | $suffix_url = 'close'; |
---|
705 | $link_title = l10n('close_window_piwishack'); |
---|
706 | } |
---|
707 | else |
---|
708 | { |
---|
709 | $suffix_url = 'open'; |
---|
710 | $link_title = l10n('open_window_piwishack'); |
---|
711 | } |
---|
712 | |
---|
713 | $link_url = add_url_params($main_link, array($this->plugin_name => $suffix_url)); |
---|
714 | if (!empty($link_url)) |
---|
715 | { |
---|
716 | $link_url = |
---|
717 | '<a class="pwg-state-default pwg-button" rel="nofollow" title="'.$link_title.'" href="'.$link_url.'"><img src="'.get_root_url().'plugins/'.$this->plugin_name.'/icon/controller_'.$suffix_url.'.png" class="button" alt="PiwiShack controller"></a>'; |
---|
718 | } |
---|
719 | |
---|
720 | return $link_url; |
---|
721 | } |
---|
722 | |
---|
723 | function loc_end_index() |
---|
724 | { |
---|
725 | global $template; |
---|
726 | |
---|
727 | $link_url = $this->get_link_icon(duplicate_index_url()); |
---|
728 | if (!empty($link_url)) |
---|
729 | { |
---|
730 | $template->concat( |
---|
731 | 'PLUGIN_INDEX_ACTIONS', |
---|
732 | '<li>'.$link_url.'</li>'); |
---|
733 | } |
---|
734 | } |
---|
735 | |
---|
736 | function picture_pictures_data($pictures) |
---|
737 | { |
---|
738 | global $template; |
---|
739 | |
---|
740 | $link_url = $this->get_link_icon(duplicate_picture_url()); |
---|
741 | if (!empty($link_url)) |
---|
742 | { |
---|
743 | $template->concat( |
---|
744 | 'PLUGIN_PICTURE_ACTIONS', |
---|
745 | $link_url); |
---|
746 | } |
---|
747 | |
---|
748 | return $pictures; |
---|
749 | } |
---|
750 | |
---|
751 | function loading_lang() |
---|
752 | { |
---|
753 | load_language('plugin.lang', $this->plugin_path); |
---|
754 | } |
---|
755 | } |
---|
756 | |
---|
757 | ?> |
---|