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.3KB

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