root/releases/0.672/_files/rss2.php

Revision 659, 2.0 kB (checked in by misja, 2 years ago)

Taking gettext to a new level, see message <http://lists.elgg.org/pipermail/development/2006-October/000590.html>. In a nutshell: all gettext calls are replaced by gettext, revamped gettext handling plus some additional fixes.

  • Property svn:eol-style set to native
Line 
1 <?php
2 global $CFG;
3 //    ELGG files RSS 2.0 page
4 // this is now only used for tag-search feeds
5
6 // Run includes
7 require_once(dirname(dirname(__FILE__))."/includes.php");
8
9 run("profile:init");
10 run("friends:init");
11 run("files:init");
12         
13 global $profile_id;
14 global $individual;
15 global $page_owner;
16
17 $individual = 1;
18
19 $sitename = htmlspecialchars(sitename, ENT_COMPAT, 'utf-8');
20 $tag = trim(optional_param('tag'));
21 $output = "";
22       
23 if (isset($profile_id)) {
24
25     $rssfiles = sprintf(__gettext("Files tagged with %s"),$tag);
26
27     if ($info = get_record('users','ident',$page_owner)) {
28         $name = stripslashes($info->name);
29         $mainurl = $CFG->wwwroot . $info->username . "/files/";
30         $rssurl = $mainurl . "rss/" . urlencode($tag);
31         $rssdescription = sprintf(__gettext("Files for %s, hosted on %s."),$name,$sitename);
32         $output .= <<< END
33 <?xml-stylesheet type="text/xsl" href="{$rssurl}/rssstyles.xsl"?>
34 <rss version='2.0'   xmlns:dc='http://purl.org/dc/elements/1.1/'>
35     <channel xml:base='$mainurl'>
36         <title><![CDATA[$name : $rssfiles]]></title>
37         <description><![CDATA[$rssdescription]]></description>
38         <link>$mainurl</link>
39 END;
40         $output .= run("files:rss:getitems", array($page_owner, 10, $tag));
41         $output .= <<< END
42
43     </channel>
44 </rss>
45 END;
46     }
47     if ($output) {
48         header("Pragma: public");
49         header("Cache-Control: public");
50         header('Expires: ' . gmdate("D, d M Y H:i:s", (time()+3600)) . " GMT");
51         
52         $if_none_match = (isset($_SERVER['HTTP_IF_NONE_MATCH'])) ? preg_replace('/[^0-9a-f]/', '', $_SERVER['HTTP_IF_NONE_MATCH']) : false;
53         
54         $etag = md5($output);
55                 header('ETag: "' . $etag . '"');
56         
57         if ($if_none_match && $if_none_match == $etag) {
58             header("{$_SERVER['SERVER_PROTOCOL']} 304 Not Modified");
59             exit;
60         }
61         
62         header("Content-Length: " . strlen($output));
63         
64         header("Content-type: text/xml; charset=utf-8");
65         echo $output;
66     }
67 }
Note: See TracBrowser for help on using the browser.