root/trunk/gregarius/plugins/rssview.php

Revision 1783, 3.1 kB (checked in by cfriesen, 8 months ago)

revert the plugin back the way it was

Line 
1<?php
2###############################################################################
3# Gregarius - A PHP based RSS aggregator.
4# Copyright (C) 2003 - 2006 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: RSS View
30/// Author: Marco Bonetti
31/// Description: Adds a RSS link to the header and the footer of each page
32/// Version: 0.7
33
34/**
35 * Changes:
36 * 0.4 - Properly escape the RSS url's entities.
37 * 0.5 - Adapted to the new theme model
38 * 0.6 - Don't put a link in admin and other locations
39 * 0.7 - Show ATOM link as well.
40 */
41
42function __rss_view_url($type = "rss") {
43    $url        = guessTransportProto() . $_SERVER['HTTP_HOST'];
44    $url .= $_SERVER["REQUEST_URI"];
45
46    if (strstr($_SERVER['REQUEST_URI'],"?") !== FALSE) {
47        $url .= "&amp;media=$type&amp;";
48    } else {
49        $url .= "?media=$type";
50    }
51    $url .= __rss_view_post2get();
52    $url = str_replace('&amp;','&',$url);
53    return str_replace('&','&amp;',$url);
54}
55
56/**
57 * look for POST parameters prefixed with "rss_" and add them to the RSS url
58 */
59function __rss_view_post2get() {
60    $ret = "";
61    foreach($_POST as $key => $val) {
62        if (substr($key,0,4) == 'rss_') {
63            $ret .= "&" ."$key=" . $_POST[$key];
64        }
65    }
66    return $ret;
67}
68
69function __rss_view_footerlink($dummy) {
70    if (!defined('RSS_FILE_LOCATION')) {
71        echo "<span><a href=\"".__rss_view_url()."\">RSS</a></span>\n";
72        echo "<span><a href=\"".__rss_view_url("atom")."\">Atom</a></span>\n";
73    }
74    return $dummy;
75}
76
77function __rss_view_headerlink($dummy) {
78    if (!defined('RSS_FILE_LOCATION')) {
79        echo "\t<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"".__rss_view_url()."\" />\n";
80        echo "\t<link rel=\"alternate\" type=\"application/atom+xml\" title=\"Atom\" href=\"".__rss_view_url("atom")."\" />\n";
81    }
82    return $dummy;
83}
84
85rss_set_hook("rss.plugins.footer.span", "__rss_view_footerlink");
86rss_set_hook("rss.plugins.stylesheets",'__rss_view_headerlink');
87
88?>
Note: See TracBrowser for help on using the browser.