Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

feed.class.php 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?
  2. class FEED {
  3. function open_feed() {
  4. header("Content-type: application/xml; charset=UTF-8");
  5. echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n","<rss xmlns:dc=\"http://purl.org/dc/elements/1.1/\" version=\"2.0\">\n\t<channel>\n";
  6. }
  7. function close_feed() {
  8. echo "\t</channel>\n</rss>";
  9. }
  10. function channel($Title, $Description, $Section = '') {
  11. $Site = site_url();
  12. echo "\t\t<title>$Title :: ". SITE_NAME. "</title>\n";
  13. echo "\t\t<link>$Site$Section</link>\n";
  14. echo "\t\t<description>$Description</description>\n";
  15. echo "\t\t<language>en-us</language>\n";
  16. echo "\t\t<lastBuildDate>". date('r'). "</lastBuildDate>\n";
  17. echo "\t\t<docs>http://blogs.law.harvard.edu/tech/rss</docs>\n";
  18. echo "\t\t<generator>Gazelle Feed Class</generator>\n\n";
  19. }
  20. function item($Title, $Description, $Page, $Creator, $Comments = '', $Category = '', $Date = '') { //Escape with CDATA, otherwise the feed breaks.
  21. if ($Date == '') {
  22. $Date = date('r');
  23. } else {
  24. $Date = date('r', strtotime($Date));
  25. }
  26. $Site = site_url();
  27. $Item = "\t\t<item>\n";
  28. $Item .= "\t\t\t<title><![CDATA[$Title]]></title>\n";
  29. $Item .= "\t\t\t<description><![CDATA[$Description]]></description>\n";
  30. $Item .= "\t\t\t<pubDate>$Date</pubDate>\n";
  31. $Item .= "\t\t\t<link>$Site$Page</link>\n";
  32. $Item .= "\t\t\t<guid>$Site$Page</guid>\n";
  33. if ($Comments != '') {
  34. $Item .= "\t\t\t<comments>$Site$Comments</comments>\n";
  35. }
  36. if ($Category != '') {
  37. $Item .= "\t\t\t<category><![CDATA[$Category]]></category>\n";
  38. }
  39. $Item .= "\t\t\t<dc:creator>$Creator</dc:creator>\n\t\t</item>\n";
  40. return $Item;
  41. }
  42. function retrieve($CacheKey, $AuthKey, $PassKey) {
  43. global $Cache;
  44. $Entries = $Cache->get_value($CacheKey);
  45. if (!$Entries) {
  46. $Entries = array();
  47. } else {
  48. foreach ($Entries as $Item) {
  49. echo str_replace(array('[[PASSKEY]]', '[[AUTHKEY]]'), array(display_str($PassKey), display_str($AuthKey)), $Item);
  50. }
  51. }
  52. }
  53. function populate($CacheKey, $Item) {
  54. global $Cache;
  55. $Entries = $Cache->get_value($CacheKey, true);
  56. if (!$Entries) {
  57. $Entries = array();
  58. } else {
  59. if (count($Entries) >= 50) {
  60. array_pop($Entries);
  61. }
  62. }
  63. array_unshift($Entries, $Item);
  64. $Cache->cache_value($CacheKey, $Entries, 0); //inf cache
  65. }
  66. }