[4354] | 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 | |
---|
[4358] | 53 | function get_thumb_post_on_a_website() |
---|
[4354] | 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 | $query = ' |
---|
[4358] | 88 | SELECT * |
---|
| 89 | FROM '.IMAGES_TABLE.' |
---|
| 90 | WHERE id IN ('.implode(',', $page['items']).') |
---|
| 91 | ;'; |
---|
[4354] | 92 | |
---|
| 93 | $result = pwg_query($query); |
---|
| 94 | |
---|
| 95 | while ($row = mysql_fetch_assoc($result)) |
---|
| 96 | { |
---|
| 97 | $row['rank'] = $page['rank_of'][ $row['id'] ]; |
---|
| 98 | array_push($list, $row); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | usort($list, 'rank_compare'); |
---|
| 102 | } |
---|
| 103 | if (!empty($list)) |
---|
| 104 | { |
---|
[4356] | 105 | |
---|
[4354] | 106 | set_make_full_url(); |
---|
| 107 | |
---|
| 108 | foreach ($list as $row) |
---|
| 109 | { |
---|
| 110 | /* |
---|
| 111 | Affichage de la miniature sur des sites. Cliquable. |
---|
| 112 | EXEMPLE |
---|
[4376] | 113 | <a href="{$ROOT_WAY}{$current.U_IMG}" target=_blank><img src="{$ROOT_WAY}{$current.THUMB_SRC|@replace:'./':''}" /></a> |
---|
[4354] | 114 | */ |
---|
| 115 | $S .= '<a href=\"'. |
---|
| 116 | duplicate_picture_url( |
---|
| 117 | array( |
---|
| 118 | 'image_id' => $row['id'], |
---|
| 119 | 'image_file' => $row['file'], |
---|
[4376] | 120 | )).'\" target=_blank><img src=\"'. |
---|
[4354] | 121 | str_replace('/./', '/', get_thumbnail_url($row)).'\" /></a>'; |
---|
[4356] | 122 | $S .= '\n\n'; |
---|
[4354] | 123 | } |
---|
| 124 | |
---|
| 125 | unset_make_full_url(); |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | return $S; |
---|
| 129 | } |
---|
| 130 | |
---|
[4358] | 131 | function get_thumb_post_on_a_forum() |
---|
[4354] | 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 | $query = ' |
---|
[4358] | 166 | SELECT * |
---|
| 167 | FROM '.IMAGES_TABLE.' |
---|
| 168 | WHERE id IN ('.implode(',', $page['items']).') |
---|
| 169 | ;'; |
---|
[4354] | 170 | |
---|
| 171 | $result = pwg_query($query); |
---|
| 172 | |
---|
| 173 | while ($row = mysql_fetch_assoc($result)) |
---|
| 174 | { |
---|
| 175 | $row['rank'] = $page['rank_of'][ $row['id'] ]; |
---|
| 176 | array_push($list, $row); |
---|
| 177 | } |
---|
| 178 | |
---|
| 179 | usort($list, 'rank_compare'); |
---|
| 180 | } |
---|
| 181 | if (!empty($list)) |
---|
| 182 | { |
---|
[4356] | 183 | |
---|
[4354] | 184 | set_make_full_url(); |
---|
| 185 | |
---|
| 186 | foreach ($list as $row) |
---|
| 187 | { |
---|
| 188 | /* |
---|
| 189 | Affichage de la miniature sur des forums. Cliquable. |
---|
| 190 | EXEMPLE |
---|
| 191 | [url={$ROOT_WAY}{$current.U_IMG}][img]{$ROOT_WAY}{$current.THUMB_SRC|@replace:'./':''}[/img][/url] |
---|
| 192 | */ |
---|
| 193 | $S .= '[url='. |
---|
| 194 | duplicate_picture_url( |
---|
| 195 | array( |
---|
| 196 | 'image_id' => $row['id'], |
---|
| 197 | 'image_file' => $row['file'], |
---|
| 198 | )).'][img]'. |
---|
| 199 | str_replace('/./', '/', get_thumbnail_url($row)).'[/img][/url]'; |
---|
[4356] | 200 | $S .= '\n\n'; |
---|
[4354] | 201 | } |
---|
| 202 | |
---|
| 203 | unset_make_full_url(); |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | return $S; |
---|
| 207 | } |
---|
| 208 | |
---|
[4358] | 209 | function get_view_post_on_a_website() |
---|
[4354] | 210 | { |
---|
| 211 | global $page, $lang_info; |
---|
| 212 | |
---|
| 213 | $list = array(); |
---|
| 214 | |
---|
| 215 | $S = ''; |
---|
| 216 | |
---|
| 217 | switch (script_basename()) |
---|
| 218 | { |
---|
| 219 | case 'index': |
---|
| 220 | { |
---|
| 221 | global $pictures; |
---|
| 222 | |
---|
| 223 | if (isset($pictures)) |
---|
| 224 | { |
---|
| 225 | $list = $pictures; |
---|
| 226 | } |
---|
| 227 | break; |
---|
| 228 | } |
---|
| 229 | case 'picture': |
---|
| 230 | { |
---|
| 231 | global $picture; |
---|
| 232 | |
---|
| 233 | if (isset($picture['current'])) |
---|
| 234 | { |
---|
| 235 | $list[] = $picture['current']; |
---|
| 236 | } |
---|
| 237 | break; |
---|
| 238 | } |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | if (empty($list) and !empty($page['items'])) |
---|
| 242 | { |
---|
| 243 | $query = ' |
---|
[4358] | 244 | SELECT * |
---|
| 245 | FROM '.IMAGES_TABLE.' |
---|
| 246 | WHERE id IN ('.implode(',', $page['items']).') |
---|
| 247 | ;'; |
---|
[4354] | 248 | |
---|
| 249 | $result = pwg_query($query); |
---|
| 250 | |
---|
| 251 | while ($row = mysql_fetch_assoc($result)) |
---|
| 252 | { |
---|
| 253 | $row['rank'] = $page['rank_of'][ $row['id'] ]; |
---|
| 254 | array_push($list, $row); |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | usort($list, 'rank_compare'); |
---|
| 258 | } |
---|
| 259 | if (!empty($list)) |
---|
| 260 | { |
---|
[4356] | 261 | include_once(PHPWG_ROOT_PATH.'/include/functions_picture.inc.php'); |
---|
[4354] | 262 | set_make_full_url(); |
---|
| 263 | |
---|
| 264 | foreach ($list as $row) |
---|
| 265 | { |
---|
| 266 | /* |
---|
| 267 | Affichage de la vue normale sur des sites. Non cliquable. |
---|
| 268 | EXEMPLE |
---|
[4376] | 269 | <a href="{$ROOT_WAY}{$current.U_IMG}" target=_blank><img src="{$ROOT_WAY}{$SRC_IMG|@replace:'./':''}" /></a> |
---|
[4354] | 270 | */ |
---|
[9114] | 271 | if (strpos( get_image_url($row), get_absolute_root_url() ) === false) { |
---|
| 272 | $abs_root_img= get_absolute_root_url(). str_replace('./', '', get_image_url($row)) ; |
---|
| 273 | } else { |
---|
| 274 | $abs_root_img= get_image_url($row) ; |
---|
| 275 | } |
---|
[4354] | 276 | $S .= '<a href=\"'. |
---|
| 277 | duplicate_picture_url( |
---|
| 278 | array( |
---|
| 279 | 'image_id' => $row['id'], |
---|
| 280 | 'image_file' => $row['file'], |
---|
[9114] | 281 | )).'\" target=_blank><img src=\"'.$abs_root_img.'\" /></a>'; |
---|
[4356] | 282 | $S .= '\n\n'; |
---|
[4354] | 283 | } |
---|
| 284 | |
---|
| 285 | unset_make_full_url(); |
---|
| 286 | } |
---|
| 287 | |
---|
| 288 | return $S; |
---|
| 289 | } |
---|
| 290 | |
---|
[6771] | 291 | function get_view_post_on_a_forum() |
---|
| 292 | { |
---|
| 293 | global $page, $lang_info; |
---|
| 294 | |
---|
| 295 | $list = array(); |
---|
| 296 | |
---|
| 297 | $S = ''; |
---|
| 298 | |
---|
| 299 | switch (script_basename()) |
---|
| 300 | { |
---|
| 301 | case 'index': |
---|
| 302 | { |
---|
| 303 | global $pictures; |
---|
| 304 | |
---|
| 305 | if (isset($pictures)) |
---|
| 306 | { |
---|
| 307 | $list = $pictures; |
---|
| 308 | } |
---|
| 309 | break; |
---|
| 310 | } |
---|
| 311 | case 'picture': |
---|
| 312 | { |
---|
| 313 | global $picture; |
---|
| 314 | |
---|
| 315 | if (isset($picture['current'])) |
---|
| 316 | { |
---|
| 317 | $list[] = $picture['current']; |
---|
| 318 | } |
---|
| 319 | break; |
---|
| 320 | } |
---|
| 321 | } |
---|
| 322 | |
---|
| 323 | if (empty($list) and !empty($page['items'])) |
---|
| 324 | { |
---|
| 325 | $query = ' |
---|
| 326 | SELECT * |
---|
| 327 | FROM '.IMAGES_TABLE.' |
---|
| 328 | WHERE id IN ('.implode(',', $page['items']).') |
---|
| 329 | ;'; |
---|
| 330 | |
---|
| 331 | $result = pwg_query($query); |
---|
| 332 | |
---|
| 333 | while ($row = mysql_fetch_assoc($result)) |
---|
| 334 | { |
---|
| 335 | $row['rank'] = $page['rank_of'][ $row['id'] ]; |
---|
| 336 | array_push($list, $row); |
---|
| 337 | } |
---|
| 338 | |
---|
| 339 | usort($list, 'rank_compare'); |
---|
| 340 | } |
---|
| 341 | if (!empty($list)) |
---|
| 342 | { |
---|
| 343 | include_once(PHPWG_ROOT_PATH.'/include/functions_picture.inc.php'); |
---|
| 344 | set_make_full_url(); |
---|
| 345 | |
---|
| 346 | foreach ($list as $row) |
---|
| 347 | { |
---|
| 348 | /* |
---|
| 349 | Affichage de la vue normale sur des forums. |
---|
| 350 | EXEMPLE |
---|
| 351 | [url={$ROOT_WAY}{$current.U_IMG}][img]{$ROOT_WAY}{$SRC_IMG|@replace:'./':''}[/img][/url] |
---|
| 352 | */ |
---|
[9114] | 353 | if (strpos( get_image_url($row), get_absolute_root_url() ) === false) { |
---|
| 354 | $abs_root_img= get_absolute_root_url(). str_replace('./', '', get_image_url($row)) ; |
---|
| 355 | } else { |
---|
| 356 | $abs_root_img= get_image_url($row) ; |
---|
| 357 | } |
---|
[6771] | 358 | $S .= '[url='. |
---|
| 359 | duplicate_picture_url( |
---|
| 360 | array( |
---|
| 361 | 'image_id' => $row['id'], |
---|
| 362 | 'image_file' => $row['file'], |
---|
[9114] | 363 | )).'][img]'.$abs_root_img.'[/img][/url]'; |
---|
[6771] | 364 | $S .= '\n\n'; |
---|
| 365 | } |
---|
| 366 | |
---|
| 367 | unset_make_full_url(); |
---|
| 368 | } |
---|
| 369 | |
---|
| 370 | return $S; |
---|
| 371 | } |
---|
| 372 | |
---|
[4358] | 373 | function get_view_direct_link() |
---|
[4354] | 374 | { |
---|
| 375 | global $page, $lang_info; |
---|
| 376 | |
---|
| 377 | $list = array(); |
---|
| 378 | |
---|
| 379 | $S = ''; |
---|
| 380 | |
---|
| 381 | switch (script_basename()) |
---|
| 382 | { |
---|
| 383 | case 'index': |
---|
| 384 | { |
---|
| 385 | global $pictures; |
---|
| 386 | |
---|
| 387 | if (isset($pictures)) |
---|
| 388 | { |
---|
| 389 | $list = $pictures; |
---|
| 390 | } |
---|
| 391 | break; |
---|
| 392 | } |
---|
| 393 | case 'picture': |
---|
| 394 | { |
---|
| 395 | global $picture; |
---|
| 396 | |
---|
| 397 | if (isset($picture['current'])) |
---|
| 398 | { |
---|
| 399 | $list[] = $picture['current']; |
---|
| 400 | } |
---|
| 401 | break; |
---|
| 402 | } |
---|
| 403 | } |
---|
| 404 | |
---|
| 405 | if (empty($list) and !empty($page['items'])) |
---|
| 406 | { |
---|
| 407 | $query = ' |
---|
[4358] | 408 | SELECT * |
---|
| 409 | FROM '.IMAGES_TABLE.' |
---|
| 410 | WHERE id IN ('.implode(',', $page['items']).') |
---|
| 411 | ;'; |
---|
[4354] | 412 | |
---|
| 413 | $result = pwg_query($query); |
---|
| 414 | |
---|
| 415 | while ($row = mysql_fetch_assoc($result)) |
---|
| 416 | { |
---|
| 417 | $row['rank'] = $page['rank_of'][ $row['id'] ]; |
---|
| 418 | array_push($list, $row); |
---|
| 419 | } |
---|
| 420 | |
---|
| 421 | usort($list, 'rank_compare'); |
---|
| 422 | } |
---|
| 423 | if (!empty($list)) |
---|
| 424 | { |
---|
[4356] | 425 | include_once(PHPWG_ROOT_PATH.'/include/functions_picture.inc.php'); |
---|
[4354] | 426 | set_make_full_url(); |
---|
[5057] | 427 | |
---|
| 428 | $page_name = script_basename(); |
---|
| 429 | if ( $page_name == 'picture') |
---|
| 430 | { |
---|
| 431 | foreach ($list as $row) |
---|
| 432 | { |
---|
| 433 | /* |
---|
| 434 | Affichage du chemin en clair du lien vers la vue normale. |
---|
| 435 | EXEMPLE |
---|
| 436 | {$ROOT_WAY}{$SRC_IMG|@replace:'./':''} |
---|
| 437 | */ |
---|
| 438 | $S .= get_absolute_root_url(). |
---|
| 439 | str_replace('./', '', get_image_url($row)); |
---|
| 440 | $S .= '\n\n'; |
---|
| 441 | } |
---|
[4354] | 442 | |
---|
[5057] | 443 | unset_make_full_url(); |
---|
[4354] | 444 | } |
---|
[5057] | 445 | else |
---|
| 446 | { |
---|
| 447 | foreach ($list as $row) |
---|
| 448 | { |
---|
| 449 | /* |
---|
| 450 | Affichage du chemin en clair du lien vers la vue normale. |
---|
| 451 | EXEMPLE |
---|
| 452 | {$ROOT_WAY}{$SRC_IMG|@replace:'./':''} |
---|
| 453 | */ |
---|
| 454 | $S .= get_image_url($row); |
---|
| 455 | $S .= '\n\n'; |
---|
| 456 | } |
---|
| 457 | } |
---|
[4354] | 458 | |
---|
| 459 | unset_make_full_url(); |
---|
[5057] | 460 | } |
---|
[4354] | 461 | |
---|
[5057] | 462 | |
---|
[4354] | 463 | return $S; |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | function get_p_perso_writer_01() |
---|
| 467 | { |
---|
| 468 | global $page, $lang_info; |
---|
| 469 | |
---|
| 470 | $list = array(); |
---|
| 471 | |
---|
| 472 | $S = ''; |
---|
| 473 | |
---|
| 474 | switch (script_basename()) |
---|
| 475 | { |
---|
| 476 | case 'index': |
---|
| 477 | { |
---|
| 478 | global $pictures; |
---|
| 479 | |
---|
| 480 | if (isset($pictures)) |
---|
| 481 | { |
---|
| 482 | $list = $pictures; |
---|
| 483 | } |
---|
| 484 | break; |
---|
| 485 | } |
---|
| 486 | case 'picture': |
---|
| 487 | { |
---|
| 488 | global $picture; |
---|
| 489 | |
---|
| 490 | if (isset($picture['current'])) |
---|
| 491 | { |
---|
| 492 | $list[] = $picture['current']; |
---|
| 493 | } |
---|
| 494 | break; |
---|
| 495 | } |
---|
| 496 | } |
---|
| 497 | |
---|
| 498 | if (empty($list) and !empty($page['items'])) |
---|
| 499 | { |
---|
| 500 | $query = ' |
---|
[4358] | 501 | SELECT * |
---|
| 502 | FROM '.IMAGES_TABLE.' |
---|
| 503 | WHERE id IN ('.implode(',', $page['items']).') |
---|
| 504 | ;'; |
---|
[4354] | 505 | |
---|
| 506 | $result = pwg_query($query); |
---|
| 507 | |
---|
| 508 | while ($row = mysql_fetch_assoc($result)) |
---|
| 509 | { |
---|
| 510 | $row['rank'] = $page['rank_of'][ $row['id'] ]; |
---|
| 511 | array_push($list, $row); |
---|
| 512 | } |
---|
| 513 | |
---|
| 514 | usort($list, 'rank_compare'); |
---|
| 515 | } |
---|
| 516 | if (!empty($list)) |
---|
| 517 | { |
---|
[4356] | 518 | include_once(PHPWG_ROOT_PATH.'/include/functions_picture.inc.php'); |
---|
[4354] | 519 | set_make_full_url(); |
---|
| 520 | |
---|
| 521 | foreach ($list as $row) |
---|
| 522 | { |
---|
| 523 | /* |
---|
[4358] | 524 | Affichage Personnalisé, 01. |
---|
[4354] | 525 | EXEMPLE |
---|
[4358] | 526 | <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> |
---|
[4354] | 527 | */ |
---|
| 528 | |
---|
[4358] | 529 | $S .= '<h6 style=\"text-align: center;\"><a href=\"'. // Arguments à transmettre |
---|
| 530 | duplicate_picture_url( // Lien Piwigo vers la page de la vue normale |
---|
[4354] | 531 | array( |
---|
| 532 | 'image_id' => $row['id'], |
---|
| 533 | 'image_file' => $row['file'], |
---|
| 534 | )). |
---|
[4635] | 535 | '\" target=\"_blank\"><img class=\"aligncenter\" style=\"width: 100%; height: 100%;\" src=\"'. // Arguments à transmettre |
---|
[4358] | 536 | get_absolute_root_url().str_replace('./', '', get_image_url($row)). // Liens direct vers la vue normale |
---|
| 537 | '\" alt=\"'. // Arguments à transmettre |
---|
| 538 | $row['file']. // Noms du fichier |
---|
| 539 | '\" /></a><em><a href=\"'. // Arguments à transmettre |
---|
[4360] | 540 | duplicate_index_url(). // Catégorie parente |
---|
[4536] | 541 | '\"; target=\"_blank\"><br />Galerie complète à visiter</a></em></h6>'; // Arguments à transmettre |
---|
[4356] | 542 | $S .= '\n\n'; |
---|
[4354] | 543 | } |
---|
| 544 | |
---|
| 545 | unset_make_full_url(); |
---|
| 546 | } |
---|
| 547 | |
---|
| 548 | return $S; |
---|
| 549 | } |
---|
| 550 | |
---|
| 551 | function get_p_perso_writer_02() |
---|
| 552 | { |
---|
| 553 | global $page, $lang_info; |
---|
| 554 | |
---|
| 555 | $list = array(); |
---|
| 556 | |
---|
| 557 | $S = ''; |
---|
| 558 | |
---|
| 559 | switch (script_basename()) |
---|
| 560 | { |
---|
| 561 | case 'index': |
---|
| 562 | { |
---|
| 563 | global $pictures; |
---|
| 564 | |
---|
| 565 | if (isset($pictures)) |
---|
| 566 | { |
---|
| 567 | $list = $pictures; |
---|
| 568 | } |
---|
| 569 | break; |
---|
| 570 | } |
---|
| 571 | case 'picture': |
---|
| 572 | { |
---|
| 573 | global $picture; |
---|
| 574 | |
---|
| 575 | if (isset($picture['current'])) |
---|
| 576 | { |
---|
| 577 | $list[] = $picture['current']; |
---|
| 578 | } |
---|
| 579 | break; |
---|
| 580 | } |
---|
| 581 | } |
---|
| 582 | |
---|
| 583 | if (empty($list) and !empty($page['items'])) |
---|
| 584 | { |
---|
| 585 | $query = ' |
---|
[4358] | 586 | SELECT * |
---|
| 587 | FROM '.IMAGES_TABLE.' |
---|
| 588 | WHERE id IN ('.implode(',', $page['items']).') |
---|
| 589 | ;'; |
---|
[4354] | 590 | |
---|
| 591 | $result = pwg_query($query); |
---|
| 592 | |
---|
| 593 | while ($row = mysql_fetch_assoc($result)) |
---|
| 594 | { |
---|
| 595 | $row['rank'] = $page['rank_of'][ $row['id'] ]; |
---|
| 596 | array_push($list, $row); |
---|
| 597 | } |
---|
| 598 | |
---|
| 599 | usort($list, 'rank_compare'); |
---|
| 600 | } |
---|
| 601 | |
---|
| 602 | if (!empty($list)) |
---|
| 603 | { |
---|
| 604 | include_once(PHPWG_ROOT_PATH.'/include/functions_url.inc.php'); |
---|
| 605 | set_make_full_url(); |
---|
| 606 | |
---|
| 607 | foreach ($list as $row) |
---|
| 608 | { |
---|
| 609 | //'[(('.$picture['current']['thumbnail'].'))|'.$picture['current']['url'].'|'.$lang_info['code'].']'; |
---|
| 610 | $S .= '*** '.(!empty($row['name']) ? $row['name'] : $row['file']).' ***\n'; |
---|
| 611 | $S .= '[(('. |
---|
| 612 | str_replace('/./', '/', get_thumbnail_url($row)).'))|'. |
---|
| 613 | duplicate_picture_url( |
---|
| 614 | array( |
---|
| 615 | 'image_id' => $row['id'], |
---|
| 616 | 'image_file' => $row['file'], |
---|
| 617 | )).'|'. |
---|
[5057] | 618 | $lang_info['code'].']'; |
---|
| 619 | $S .= '\n\n'; |
---|
[4354] | 620 | } |
---|
| 621 | |
---|
| 622 | unset_make_full_url(); |
---|
[4358] | 623 | |
---|
[4354] | 624 | } |
---|
| 625 | |
---|
| 626 | return $S; |
---|
| 627 | } |
---|
| 628 | |
---|
[4358] | 629 | // Fin de la définition des champs |
---|
[4354] | 630 | |
---|
| 631 | function loc_begin_page_header() |
---|
| 632 | { |
---|
| 633 | global $template; |
---|
| 634 | |
---|
| 635 | $redirect_url = ( script_basename()=='picture' |
---|
| 636 | ? duplicate_picture_url(array(), array($this->plugin_name)) |
---|
| 637 | : duplicate_index_url(array(), array($this->plugin_name)) |
---|
| 638 | ); |
---|
| 639 | |
---|
| 640 | $template->assign( |
---|
| 641 | array( |
---|
| 642 | 'page_refresh' => array( |
---|
| 643 | 'TIME' => 1, |
---|
| 644 | 'U_REFRESH' => $redirect_url |
---|
| 645 | ) |
---|
| 646 | )); |
---|
| 647 | } |
---|
| 648 | |
---|
| 649 | function loc_end_page_header() |
---|
| 650 | { |
---|
| 651 | global $template; |
---|
| 652 | |
---|
| 653 | if ($this->opened or $this->to_close) |
---|
| 654 | { |
---|
| 655 | $plugin_root_url = get_root_url().'plugins/'.$this->plugin_name.'/'; |
---|
| 656 | |
---|
| 657 | $js = ' |
---|
| 658 | <script type="text/javascript"> |
---|
[6771] | 659 | 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");'; |
---|
[4354] | 660 | |
---|
| 661 | if ($this->to_close) |
---|
| 662 | { |
---|
| 663 | $js .= ' |
---|
| 664 | theController.close();'; |
---|
| 665 | } |
---|
| 666 | else |
---|
| 667 | { |
---|
| 668 | $js .= ' |
---|
| 669 | if (theController.location.toString()=="about:blank" || !theController.location.toString().match(/^(https?.*\/)'.$this->plugin_name.'_controller\.php(\?.+)?$/)) |
---|
| 670 | { |
---|
| 671 | theController.location = "'.$plugin_root_url.$this->plugin_name.'_controller.php"; |
---|
| 672 | } |
---|
| 673 | else |
---|
| 674 | { |
---|
| 675 | theController.focus(); |
---|
| 676 | } |
---|
| 677 | theController.document.getElementsByName("thumb_Post_on_a_website")[0].value = "'.$this->get_thumb_post_on_a_website().'"; |
---|
| 678 | theController.document.getElementsByName("thumb_Post_on_a_forum")[0].value = "'.$this->get_thumb_post_on_a_forum().'"; |
---|
| 679 | theController.document.getElementsByName("view_Post_on_a_website")[0].value = "'.$this->get_view_post_on_a_website().'"; |
---|
[6771] | 680 | theController.document.getElementsByName("view_Post_on_a_forum")[0].value = "'.$this->get_view_post_on_a_forum().'"; |
---|
[4354] | 681 | theController.document.getElementsByName("view_Direct_link")[0].value = "'.$this->get_view_direct_link().'"; |
---|
| 682 | theController.document.getElementsByName("p_Perso_writer_01")[0].value = "'.$this->get_p_perso_writer_01().'"; |
---|
| 683 | theController.document.getElementsByName("p_Perso_writer_02")[0].value = "'.$this->get_p_perso_writer_02().'";'; |
---|
| 684 | } |
---|
| 685 | $js .= ' |
---|
| 686 | </script>'; |
---|
| 687 | |
---|
| 688 | $template->append('head_elements', $js); |
---|
| 689 | } |
---|
| 690 | } |
---|
| 691 | |
---|
| 692 | function get_link_icon($main_link) |
---|
| 693 | { |
---|
| 694 | global $page; |
---|
| 695 | |
---|
| 696 | if (empty($page['items'])) |
---|
| 697 | { |
---|
| 698 | return; |
---|
| 699 | } |
---|
| 700 | |
---|
| 701 | $this->loading_lang(); |
---|
| 702 | |
---|
| 703 | if ($this->opened) |
---|
| 704 | { |
---|
| 705 | $suffix_url = 'close'; |
---|
| 706 | $link_title = l10n('close_window_piwishack'); |
---|
| 707 | } |
---|
| 708 | else |
---|
| 709 | { |
---|
| 710 | $suffix_url = 'open'; |
---|
| 711 | $link_title = l10n('open_window_piwishack'); |
---|
| 712 | } |
---|
| 713 | |
---|
| 714 | $link_url = add_url_params($main_link, array($this->plugin_name => $suffix_url)); |
---|
| 715 | if (!empty($link_url)) |
---|
| 716 | { |
---|
| 717 | $link_url = |
---|
| 718 | '<a href="'.$link_url.'" title="'.$link_title.'" rel="nofollow"><img src="'.get_root_url().'plugins/'.$this->plugin_name.'/icon/controller_'.$suffix_url.'.png" class="button" alt="PiwiShack controller"></a>'; |
---|
| 719 | } |
---|
| 720 | |
---|
| 721 | return $link_url; |
---|
| 722 | } |
---|
| 723 | |
---|
| 724 | function loc_end_index() |
---|
| 725 | { |
---|
| 726 | global $template; |
---|
| 727 | |
---|
| 728 | $link_url = $this->get_link_icon(duplicate_index_url()); |
---|
| 729 | if (!empty($link_url)) |
---|
| 730 | { |
---|
| 731 | $template->concat( |
---|
| 732 | 'PLUGIN_INDEX_ACTIONS', |
---|
| 733 | '<li>'.$link_url.'</li>'); |
---|
| 734 | } |
---|
| 735 | } |
---|
| 736 | |
---|
| 737 | function picture_pictures_data($pictures) |
---|
| 738 | { |
---|
| 739 | global $template; |
---|
| 740 | |
---|
| 741 | $link_url = $this->get_link_icon(duplicate_picture_url()); |
---|
| 742 | if (!empty($link_url)) |
---|
| 743 | { |
---|
| 744 | $template->concat( |
---|
| 745 | 'PLUGIN_PICTURE_ACTIONS', |
---|
| 746 | $link_url); |
---|
| 747 | } |
---|
| 748 | |
---|
| 749 | return $pictures; |
---|
| 750 | } |
---|
| 751 | |
---|
| 752 | function loading_lang() |
---|
| 753 | { |
---|
| 754 | load_language('plugin.lang', $this->plugin_path); |
---|
| 755 | } |
---|
| 756 | } |
---|
| 757 | |
---|
[4350] | 758 | ?> |
---|