- Timestamp:
- 08/16/10 09:55:22 (21 months ago)
- Location:
- trunk
- Files:
-
- 4 modified
-
. (modified) (1 prop)
-
content/plugins (modified) (1 prop)
-
libs/Feeds.php (modified) (1 diff)
-
libs/extensions/RSSWriterClass/rsswriter.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/1.5 merged: 2142-2143
- Property svn:mergeinfo changed
-
trunk/content/plugins
- Property svn:mergeinfo changed (with no actual effect on merging)
-
trunk/libs/Feeds.php
r2134 r2145 39 39 require_once(EXTENSIONS.'RSSWriterClass/rsswriter.php'); 40 40 41 $feed = new RSS( );41 $feed = new RSS($h->url(array('page'=>'rss'))); 42 42 $feed->title = stripslashes(html_entity_decode(urldecode($title), ENT_QUOTES, 'UTF-8')); 43 43 $feed->link = html_entity_decode($link, ENT_QUOTES, 'UTF-8'); -
trunk/libs/extensions/RSSWriterClass/rsswriter.php
r2134 r2145 1 1 <?php 2 /* Publishes content as an RSS feed 3 http://snipplr.com/view/23/rss-writer-class/ 2 4 3 /* Publishes content as an RSS feed 4 http://snipplr.com/view/23/rss-writer-class/ 5 6 E X A M P L E ----------------------------------------------- 7 $feed = new RSS(); 8 $feed->title = "RSS Feed Title"; 9 $feed->link = "http://website.com"; 10 $feed->description = "Recent articles on your website."; 5 E X A M P L E ----------------------------------------------- 6 $feed = new RSS(); 7 $feed->title = "RSS Feed Title"; 8 $feed->link = "http://website.com"; 9 $feed->description = "Recent articles on your website."; 11 10 12 $db->query($query);13 $result = $db->result;14 while($row = mysql_fetch_array($result, MYSQL_ASSOC))15 {16 $item = new RSSItem();17 $item->title = $title;18 $item->link = $link;19 $item->setPubDate($create_date); 20 $item->description = "<![CDATA[ $html ]]>";21 $feed->addItem($item);22 }23 echo $feed->serve();24 ---------------------------------------------------------------- */11 $db->query($query); 12 $result = $db->result; 13 while($row = mysql_fetch_array($result, MYSQL_ASSOC)) 14 { 15 $item = new RSSItem(); 16 $item->title = $title; 17 $item->link = $link; 18 $item->setPubDate($create_date); 19 $item->description = "<![CDATA[ $html ]]>"; 20 $feed->addItem($item); 21 } 22 echo $feed->serve(); 23 ---------------------------------------------------------------- */ 25 24 26 25 class RSS { 27 26 28 var $title; 29 var $link; 30 var $description; 31 var $language = "en-us"; 32 var $pubDate; 33 var $items = array(); 34 var $tags = array(); 27 public $title; 28 public $rss_link; 29 public $link; 30 public $description; 31 public $language = "en-us"; 32 public $pubDate; 33 public $items = array(); 34 public $tags = array(); 35 35 36 public function __construct() { 36 public function __construct($rss_link) { 37 $this->rss_link = (empty($rss_link))? SITEURL.'index.php?page=rss' : $rss_link ; 38 } 37 39 38 } 39 40 function addItem($item) 41 { 42 if( is_array($item) ) 43 { 44 foreach( $item as $i ) 45 { 40 public function addItem($item) { 41 if (is_array($item)) { 42 foreach ($item as $i) { 46 43 array_push($this->items, new RSSItem($i)); 47 }44 } 48 45 } 49 46 array_push($this->items, $item); 50 47 } 51 48 52 function setPubDate($when) {53 $this->pubDate = date("D, d M Y H:i:s ", ((strtotime($when)) ? strtotime($when) : $when))."GMT";54 }49 public function setPubDate($when) { 50 $this->pubDate = date("D, d M Y H:i:s O", ((strtotime($when)) ? strtotime($when) : $when)); 51 } 55 52 56 function addTag($tag, $value) {57 $this->tags[$tag] = $value;58 }53 public function addTag($tag, $value) { 54 $this->tags[$tag] = $value; 55 } 59 56 60 function out($serve_contentType = FALSE) {57 public function out($serve_contentType = FALSE) { 61 58 62 59 if (is_string($serve_contentType)) { … … 67 64 68 65 $out = '<?xml version="1.0" encoding="utf-8"?>'."\n"; 69 $out .= '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" >'."\n";70 $out .= "<channel>\n";66 $out .= '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">'."\n"; 67 $out .= "<channel>\n"; 71 68 $out .= "<title>".$this->title."</title>\n"; 69 $out .= '<atom:link href="'.$this->rss_link.'" rel="self" type="application/rss+xml" />'."\n"; 72 70 $out .= "<link>".$this->link."</link>\n"; 73 71 $out .= "<description>".$this->description."</description>\n"; 74 72 $out .= "<language>".$this->language."</language>\n"; 75 $out .= "<pubDate>".((empty($this->pubDate)) ? date("D, d M Y H:i:s \G\M\T") : $this->pubDate)."</pubDate>\n";73 $out .= "<pubDate>".((empty($this->pubDate)) ? date("D, d M Y H:i:s O") : $this->pubDate)."</pubDate>\n"; 76 74 77 75 foreach ($this->tags as $key => $val) { … … 80 78 81 79 foreach ($this->items as $item) { 82 if ($item instanceof RSSItem) {83 $out .= $item->out();80 if ($item instanceof RSSItem) { 81 $out .= $item->out(); 84 82 } 85 83 } 86 84 87 $out .= "</channel>\n";88 85 $out .= "</channel>\n"; 86 89 87 $out .= "</rss>"; 90 88 91 89 return str_replace("&", "&", $out); 92 }93 94 }90 } 91 92 } 95 93 96 94 class RSSItem { … … 116 114 117 115 if (isset($options['date'])) { 118 $this->pubDate = date("D, d M Y H:i:s ", ((strtotime($options['date'])) ? strtotime($options['date']) : $options['date']))."GMT";116 $this->pubDate = date("D, d M Y H:i:s O", ((strtotime($options['date'])) ? strtotime($options['date']) : $options['date'])); 119 117 } 120 118 … … 134 132 } 135 133 136 function out() {137 $out = "<item>\n";134 public function out() { 135 $out = "<item>\n"; 138 136 $out .= "<title>".$this->title."</title>\n"; 139 137 $out .= "<link>".$this->link."</link>\n"; 140 138 $out .= "<description>".$this->description."</description>\n"; 141 $out .= "<pubDate>".((empty($this->pubDate)) ? date("D, d M Y H:i:s \G\M\T") : $this->pubDate)."</pubDate>\n";139 $out .= "<pubDate>".((empty($this->pubDate)) ? date("D, d M Y H:i:s O") : $this->pubDate)."</pubDate>\n"; 142 140 143 141 if (!empty($this->attachment)) { 144 $out .= "<enclosure url='{$this->attachment}' length='{$this->length}' type='{$this->mimetype}' />";142 $out .= "<enclosure url='{$this->attachment}' length='{$this->length}' type='{$this->mimetype}' />"; 145 143 } 146 144 147 $this->guid = (empty($this->guid)) ? $this->guid : $this->link;145 $this->guid = (empty($this->guid)) ? $this->link : $this->guid; 148 146 149 147 $out .= "<guid>".$this->guid."</guid>\n"; … … 154 152 155 153 return $out."</item>\n"; 156 }157 158 154 } 159 155 156 } 157 160 158 ?>