[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 | */ |
---|
| 271 | $S .= '<a href=\"'. |
---|
| 272 | duplicate_picture_url( |
---|
| 273 | array( |
---|
| 274 | 'image_id' => $row['id'], |
---|
| 275 | 'image_file' => $row['file'], |
---|
[4376] | 276 | )).'\" target=_blank><img src=\"'.get_absolute_root_url(). |
---|
[4356] | 277 | str_replace('/./', '/', get_image_url($row)).'\" /></a>'; |
---|
| 278 | $S .= '\n\n'; |
---|
[4354] | 279 | } |
---|
| 280 | |
---|
| 281 | unset_make_full_url(); |
---|
| 282 | } |
---|
| 283 | |
---|
| 284 | return $S; |
---|
| 285 | } |
---|
| 286 | |
---|
[4358] | 287 | function get_view_direct_link() |
---|
[4354] | 288 | { |
---|
| 289 | global $page, $lang_info; |
---|
| 290 | |
---|
| 291 | $list = array(); |
---|
| 292 | |
---|
| 293 | $S = ''; |
---|
| 294 | |
---|
| 295 | switch (script_basename()) |
---|
| 296 | { |
---|
| 297 | case 'index': |
---|
| 298 | { |
---|
| 299 | global $pictures; |
---|
| 300 | |
---|
| 301 | if (isset($pictures)) |
---|
| 302 | { |
---|
| 303 | $list = $pictures; |
---|
| 304 | } |
---|
| 305 | break; |
---|
| 306 | } |
---|
| 307 | case 'picture': |
---|
| 308 | { |
---|
| 309 | global $picture; |
---|
| 310 | |
---|
| 311 | if (isset($picture['current'])) |
---|
| 312 | { |
---|
| 313 | $list[] = $picture['current']; |
---|
| 314 | } |
---|
| 315 | break; |
---|
| 316 | } |
---|
| 317 | } |
---|
| 318 | |
---|
| 319 | if (empty($list) and !empty($page['items'])) |
---|
| 320 | { |
---|
| 321 | $query = ' |
---|
[4358] | 322 | SELECT * |
---|
| 323 | FROM '.IMAGES_TABLE.' |
---|
| 324 | WHERE id IN ('.implode(',', $page['items']).') |
---|
| 325 | ;'; |
---|
[4354] | 326 | |
---|
| 327 | $result = pwg_query($query); |
---|
| 328 | |
---|
| 329 | while ($row = mysql_fetch_assoc($result)) |
---|
| 330 | { |
---|
| 331 | $row['rank'] = $page['rank_of'][ $row['id'] ]; |
---|
| 332 | array_push($list, $row); |
---|
| 333 | } |
---|
| 334 | |
---|
| 335 | usort($list, 'rank_compare'); |
---|
| 336 | } |
---|
| 337 | if (!empty($list)) |
---|
| 338 | { |
---|
[4356] | 339 | include_once(PHPWG_ROOT_PATH.'/include/functions_picture.inc.php'); |
---|
[4354] | 340 | set_make_full_url(); |
---|
| 341 | |
---|
| 342 | foreach ($list as $row) |
---|
| 343 | { |
---|
| 344 | /* |
---|
| 345 | Affichage du chemin en clair du lien vers la vue normale. |
---|
| 346 | EXEMPLE |
---|
| 347 | {$ROOT_WAY}{$SRC_IMG|@replace:'./':''} |
---|
| 348 | */ |
---|
| 349 | $S .= get_absolute_root_url(). |
---|
| 350 | str_replace('./', '', get_image_url($row)); |
---|
[4356] | 351 | $S .= '\n\n'; |
---|
[4354] | 352 | } |
---|
| 353 | |
---|
| 354 | unset_make_full_url(); |
---|
| 355 | } |
---|
| 356 | |
---|
| 357 | return $S; |
---|
| 358 | } |
---|
| 359 | |
---|
| 360 | function get_p_perso_writer_01() |
---|
| 361 | { |
---|
| 362 | global $page, $lang_info; |
---|
| 363 | |
---|
| 364 | $list = array(); |
---|
| 365 | |
---|
| 366 | $S = ''; |
---|
| 367 | |
---|
| 368 | switch (script_basename()) |
---|
| 369 | { |
---|
| 370 | case 'index': |
---|
| 371 | { |
---|
| 372 | global $pictures; |
---|
| 373 | |
---|
| 374 | if (isset($pictures)) |
---|
| 375 | { |
---|
| 376 | $list = $pictures; |
---|
| 377 | } |
---|
| 378 | break; |
---|
| 379 | } |
---|
| 380 | case 'picture': |
---|
| 381 | { |
---|
| 382 | global $picture; |
---|
| 383 | |
---|
| 384 | if (isset($picture['current'])) |
---|
| 385 | { |
---|
| 386 | $list[] = $picture['current']; |
---|
| 387 | } |
---|
| 388 | break; |
---|
| 389 | } |
---|
| 390 | } |
---|
| 391 | |
---|
| 392 | if (empty($list) and !empty($page['items'])) |
---|
| 393 | { |
---|
| 394 | $query = ' |
---|
[4358] | 395 | SELECT * |
---|
| 396 | FROM '.IMAGES_TABLE.' |
---|
| 397 | WHERE id IN ('.implode(',', $page['items']).') |
---|
| 398 | ;'; |
---|
[4354] | 399 | |
---|
| 400 | $result = pwg_query($query); |
---|
| 401 | |
---|
| 402 | while ($row = mysql_fetch_assoc($result)) |
---|
| 403 | { |
---|
| 404 | $row['rank'] = $page['rank_of'][ $row['id'] ]; |
---|
| 405 | array_push($list, $row); |
---|
| 406 | } |
---|
| 407 | |
---|
| 408 | usort($list, 'rank_compare'); |
---|
| 409 | } |
---|
| 410 | if (!empty($list)) |
---|
| 411 | { |
---|
[4356] | 412 | include_once(PHPWG_ROOT_PATH.'/include/functions_picture.inc.php'); |
---|
[4354] | 413 | set_make_full_url(); |
---|
| 414 | |
---|
| 415 | foreach ($list as $row) |
---|
| 416 | { |
---|
| 417 | /* |
---|
[4358] | 418 | Affichage Personnalisé, 01. |
---|
[4354] | 419 | EXEMPLE |
---|
[4358] | 420 | <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] | 421 | */ |
---|
| 422 | |
---|
[4358] | 423 | $S .= '<h6 style=\"text-align: center;\"><a href=\"'. // Arguments à transmettre |
---|
| 424 | duplicate_picture_url( // Lien Piwigo vers la page de la vue normale |
---|
[4354] | 425 | array( |
---|
| 426 | 'image_id' => $row['id'], |
---|
| 427 | 'image_file' => $row['file'], |
---|
| 428 | )). |
---|
[4635] | 429 | '\" target=\"_blank\"><img class=\"aligncenter\" style=\"width: 100%; height: 100%;\" src=\"'. // Arguments à transmettre |
---|
[4358] | 430 | get_absolute_root_url().str_replace('./', '', get_image_url($row)). // Liens direct vers la vue normale |
---|
| 431 | '\" alt=\"'. // Arguments à transmettre |
---|
| 432 | $row['file']. // Noms du fichier |
---|
| 433 | '\" /></a><em><a href=\"'. // Arguments à transmettre |
---|
[4360] | 434 | duplicate_index_url(). // Catégorie parente |
---|
[4536] | 435 | '\"; target=\"_blank\"><br />Galerie complète à visiter</a></em></h6>'; // Arguments à transmettre |
---|
[4356] | 436 | $S .= '\n\n'; |
---|
[4354] | 437 | } |
---|
| 438 | |
---|
| 439 | unset_make_full_url(); |
---|
| 440 | } |
---|
| 441 | |
---|
| 442 | return $S; |
---|
| 443 | } |
---|
| 444 | |
---|
| 445 | function get_p_perso_writer_02() |
---|
| 446 | { |
---|
| 447 | global $page, $lang_info; |
---|
| 448 | |
---|
| 449 | $list = array(); |
---|
| 450 | |
---|
| 451 | $S = ''; |
---|
| 452 | |
---|
| 453 | switch (script_basename()) |
---|
| 454 | { |
---|
| 455 | case 'index': |
---|
| 456 | { |
---|
| 457 | global $pictures; |
---|
| 458 | |
---|
| 459 | if (isset($pictures)) |
---|
| 460 | { |
---|
| 461 | $list = $pictures; |
---|
| 462 | } |
---|
| 463 | break; |
---|
| 464 | } |
---|
| 465 | case 'picture': |
---|
| 466 | { |
---|
| 467 | global $picture; |
---|
| 468 | |
---|
| 469 | if (isset($picture['current'])) |
---|
| 470 | { |
---|
| 471 | $list[] = $picture['current']; |
---|
| 472 | } |
---|
| 473 | break; |
---|
| 474 | } |
---|
| 475 | } |
---|
| 476 | |
---|
| 477 | if (empty($list) and !empty($page['items'])) |
---|
| 478 | { |
---|
| 479 | $query = ' |
---|
[4358] | 480 | SELECT * |
---|
| 481 | FROM '.IMAGES_TABLE.' |
---|
| 482 | WHERE id IN ('.implode(',', $page['items']).') |
---|
| 483 | ;'; |
---|
[4354] | 484 | |
---|
| 485 | $result = pwg_query($query); |
---|
| 486 | |
---|
| 487 | while ($row = mysql_fetch_assoc($result)) |
---|
| 488 | { |
---|
| 489 | $row['rank'] = $page['rank_of'][ $row['id'] ]; |
---|
| 490 | array_push($list, $row); |
---|
| 491 | } |
---|
| 492 | |
---|
| 493 | usort($list, 'rank_compare'); |
---|
| 494 | } |
---|
| 495 | |
---|
| 496 | if (!empty($list)) |
---|
| 497 | { |
---|
| 498 | include_once(PHPWG_ROOT_PATH.'/include/functions_url.inc.php'); |
---|
| 499 | set_make_full_url(); |
---|
| 500 | |
---|
| 501 | foreach ($list as $row) |
---|
| 502 | { |
---|
| 503 | //'[(('.$picture['current']['thumbnail'].'))|'.$picture['current']['url'].'|'.$lang_info['code'].']'; |
---|
| 504 | $S .= '*** '.(!empty($row['name']) ? $row['name'] : $row['file']).' ***\n'; |
---|
| 505 | $S .= '[(('. |
---|
| 506 | str_replace('/./', '/', get_thumbnail_url($row)).'))|'. |
---|
| 507 | duplicate_picture_url( |
---|
| 508 | array( |
---|
| 509 | 'image_id' => $row['id'], |
---|
| 510 | 'image_file' => $row['file'], |
---|
| 511 | )).'|'. |
---|
| 512 | $lang_info['code'].']\n\n'; |
---|
| 513 | } |
---|
| 514 | |
---|
| 515 | unset_make_full_url(); |
---|
[4358] | 516 | |
---|
[4354] | 517 | } |
---|
| 518 | |
---|
| 519 | return $S; |
---|
| 520 | } |
---|
| 521 | |
---|
[4358] | 522 | // Fin de la définition des champs |
---|
[4354] | 523 | |
---|
| 524 | function loc_begin_page_header() |
---|
| 525 | { |
---|
| 526 | global $template; |
---|
| 527 | |
---|
| 528 | $redirect_url = ( script_basename()=='picture' |
---|
| 529 | ? duplicate_picture_url(array(), array($this->plugin_name)) |
---|
| 530 | : duplicate_index_url(array(), array($this->plugin_name)) |
---|
| 531 | ); |
---|
| 532 | |
---|
| 533 | $template->assign( |
---|
| 534 | array( |
---|
| 535 | 'page_refresh' => array( |
---|
| 536 | 'TIME' => 1, |
---|
| 537 | 'U_REFRESH' => $redirect_url |
---|
| 538 | ) |
---|
| 539 | )); |
---|
| 540 | } |
---|
| 541 | |
---|
| 542 | function loc_end_page_header() |
---|
| 543 | { |
---|
| 544 | global $template; |
---|
| 545 | |
---|
| 546 | if ($this->opened or $this->to_close) |
---|
| 547 | { |
---|
| 548 | $plugin_root_url = get_root_url().'plugins/'.$this->plugin_name.'/'; |
---|
| 549 | |
---|
| 550 | $js = ' |
---|
| 551 | <script type="text/javascript"> |
---|
[4359] | 552 | var theController = window.open("", "'.$this->plugin_name.'_controller", "alwaysRaised=yes,dependent=yes,toolbar=no,height=843,width=1044,menubar=no,resizable=yes,scrollbars=yes,status=no");'; |
---|
[4354] | 553 | |
---|
| 554 | if ($this->to_close) |
---|
| 555 | { |
---|
| 556 | $js .= ' |
---|
| 557 | theController.close();'; |
---|
| 558 | } |
---|
| 559 | else |
---|
| 560 | { |
---|
| 561 | $js .= ' |
---|
| 562 | if (theController.location.toString()=="about:blank" || !theController.location.toString().match(/^(https?.*\/)'.$this->plugin_name.'_controller\.php(\?.+)?$/)) |
---|
| 563 | { |
---|
| 564 | theController.location = "'.$plugin_root_url.$this->plugin_name.'_controller.php"; |
---|
| 565 | } |
---|
| 566 | else |
---|
| 567 | { |
---|
| 568 | theController.focus(); |
---|
| 569 | } |
---|
| 570 | theController.document.getElementsByName("thumb_Post_on_a_website")[0].value = "'.$this->get_thumb_post_on_a_website().'"; |
---|
| 571 | theController.document.getElementsByName("thumb_Post_on_a_forum")[0].value = "'.$this->get_thumb_post_on_a_forum().'"; |
---|
| 572 | theController.document.getElementsByName("view_Post_on_a_website")[0].value = "'.$this->get_view_post_on_a_website().'"; |
---|
| 573 | theController.document.getElementsByName("view_Direct_link")[0].value = "'.$this->get_view_direct_link().'"; |
---|
| 574 | theController.document.getElementsByName("p_Perso_writer_01")[0].value = "'.$this->get_p_perso_writer_01().'"; |
---|
| 575 | theController.document.getElementsByName("p_Perso_writer_02")[0].value = "'.$this->get_p_perso_writer_02().'";'; |
---|
| 576 | } |
---|
| 577 | $js .= ' |
---|
| 578 | </script>'; |
---|
| 579 | |
---|
| 580 | $template->append('head_elements', $js); |
---|
| 581 | } |
---|
| 582 | } |
---|
| 583 | |
---|
| 584 | function get_link_icon($main_link) |
---|
| 585 | { |
---|
| 586 | global $page; |
---|
| 587 | |
---|
| 588 | if (empty($page['items'])) |
---|
| 589 | { |
---|
| 590 | return; |
---|
| 591 | } |
---|
| 592 | |
---|
| 593 | $this->loading_lang(); |
---|
| 594 | |
---|
| 595 | if ($this->opened) |
---|
| 596 | { |
---|
| 597 | $suffix_url = 'close'; |
---|
| 598 | $link_title = l10n('close_window_piwishack'); |
---|
| 599 | } |
---|
| 600 | else |
---|
| 601 | { |
---|
| 602 | $suffix_url = 'open'; |
---|
| 603 | $link_title = l10n('open_window_piwishack'); |
---|
| 604 | } |
---|
| 605 | |
---|
| 606 | $link_url = add_url_params($main_link, array($this->plugin_name => $suffix_url)); |
---|
| 607 | if (!empty($link_url)) |
---|
| 608 | { |
---|
| 609 | $link_url = |
---|
| 610 | '<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>'; |
---|
| 611 | } |
---|
| 612 | |
---|
| 613 | return $link_url; |
---|
| 614 | } |
---|
| 615 | |
---|
| 616 | function loc_end_index() |
---|
| 617 | { |
---|
| 618 | global $template; |
---|
| 619 | |
---|
| 620 | $link_url = $this->get_link_icon(duplicate_index_url()); |
---|
| 621 | if (!empty($link_url)) |
---|
| 622 | { |
---|
| 623 | $template->concat( |
---|
| 624 | 'PLUGIN_INDEX_ACTIONS', |
---|
| 625 | '<li>'.$link_url.'</li>'); |
---|
| 626 | } |
---|
| 627 | } |
---|
| 628 | |
---|
| 629 | function picture_pictures_data($pictures) |
---|
| 630 | { |
---|
| 631 | global $template; |
---|
| 632 | |
---|
| 633 | $link_url = $this->get_link_icon(duplicate_picture_url()); |
---|
| 634 | if (!empty($link_url)) |
---|
| 635 | { |
---|
| 636 | $template->concat( |
---|
| 637 | 'PLUGIN_PICTURE_ACTIONS', |
---|
| 638 | $link_url); |
---|
| 639 | } |
---|
| 640 | |
---|
| 641 | return $pictures; |
---|
| 642 | } |
---|
| 643 | |
---|
| 644 | function loading_lang() |
---|
| 645 | { |
---|
| 646 | load_language('plugin.lang', $this->plugin_path); |
---|
| 647 | } |
---|
| 648 | } |
---|
| 649 | |
---|
[4350] | 650 | ?> |
---|