| 1 | <?php |
|---|
| 2 | ############################################################################### |
|---|
| 3 | # Gregarius - A PHP based RSS aggregator. |
|---|
| 4 | # Copyright (C) 2003, 2004 Marco Bonetti |
|---|
| 5 | # |
|---|
| 6 | ############################################################################### |
|---|
| 7 | # This program is free software and open source software; you can redistribute |
|---|
| 8 | # it and/or modify it under the terms of the GNU General Public License as |
|---|
| 9 | # published by the Free Software Foundation; either version 2 of the License, |
|---|
| 10 | # or (at your option) any later version. |
|---|
| 11 | # |
|---|
| 12 | # This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 13 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 14 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 15 | # more details. |
|---|
| 16 | # |
|---|
| 17 | # You should have received a copy of the GNU General Public License along |
|---|
| 18 | # with this program; if not, write to the Free Software Foundation, Inc., |
|---|
| 19 | # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit |
|---|
| 20 | # http://www.gnu.org/licenses/gpl.html |
|---|
| 21 | # |
|---|
| 22 | ############################################################################### |
|---|
| 23 | # E-mail: mbonetti at gmail dot com |
|---|
| 24 | # Web page: http://gregarius.net/ |
|---|
| 25 | # |
|---|
| 26 | ############################################################################### |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | /// Name: New window |
|---|
| 30 | /// Author: Marco Bonetti |
|---|
| 31 | /// Description: When active, this plugin will open off-site links in a new window |
|---|
| 32 | /// Version: 1.8 |
|---|
| 33 | |
|---|
| 34 | function __new_window_js_register($js) { |
|---|
| 35 | $js[] = getPath(). RSS_PLUGINS_DIR . "/newwindow.php?nwjs"; |
|---|
| 36 | return $js; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | function __new_window_init_js($dummy) { |
|---|
| 40 | echo "\n<script type=\"text/javascript\">\n" |
|---|
| 41 | ."<!--\n" |
|---|
| 42 | ."__new_window();\n" |
|---|
| 43 | ."-->\n" |
|---|
| 44 | ."</script>\n"; |
|---|
| 45 | return $dummy; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | if (isset($_REQUEST['nwjs'])) { |
|---|
| 49 | require_once('../core.php'); |
|---|
| 50 | rss_bootstrap(false,'$Revision$',24); |
|---|
| 51 | require_once('../init.php'); |
|---|
| 52 | |
|---|
| 53 | ?> |
|---|
| 54 | function __new_window() { |
|---|
| 55 | if (document.getElementsByTagName) { |
|---|
| 56 | var items = document.getElementById("items"); |
|---|
| 57 | if (items) { |
|---|
| 58 | var anchors = items.getElementsByTagName("a"); |
|---|
| 59 | for (var i=0; i<anchors.length; i++) { |
|---|
| 60 | var anchor = anchors[i]; |
|---|
| 61 | if (anchor.href && (anchor.href.indexOf('<?php echo $_SERVER['HTTP_HOST'] ?>') < 0)) { |
|---|
| 62 | anchor.target = '_blank'; |
|---|
| 63 | } |
|---|
| 64 | } |
|---|
| 65 | } |
|---|
| 66 | } |
|---|
| 67 | } |
|---|
| 68 | <?php |
|---|
| 69 | flush(); |
|---|
| 70 | exit(); |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | rss_set_hook('rss.plugins.javascript','__new_window_js_register'); |
|---|
| 74 | rss_set_hook('rss.plugins.bodyend','__new_window_init_js'); |
|---|
| 75 | |
|---|
| 76 | ?> |
|---|