| 26 |
|
|
| 27 |
|
|
| 28 |
Changelog: |
Changelog: |
| 29 |
|
13-04-2006 Neil Thompson (neilt) |
| 30 |
|
added functionality for Atom 1.0 |
| 31 |
|
|
| 32 |
v1.7.2 10-11-04 |
v1.7.2 10-11-04 |
| 33 |
license changed to LGPL |
license changed to LGPL |
| 149 |
} |
} |
| 150 |
|
|
| 151 |
// valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated), |
// valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated), |
| 152 |
// MBOX, OPML, ATOM, ATOM0.3, HTML, JS |
// MBOX, OPML, ATOM1.0, HTML, JS |
| 153 |
echo $rss->saveFeed("RSS1.0", "news/feed.xml"); |
echo $rss->saveFeed("RSS1.0", "news/feed.xml"); |
| 154 |
|
|
| 155 |
|
|
| 372 |
break; |
break; |
| 373 |
|
|
| 374 |
case "ATOM": |
case "ATOM": |
| 375 |
// fall through: always the latest ATOM version |
// fall through |
| 376 |
|
|
| 377 |
case "ATOM0.3": |
case "ATOM1.0": |
| 378 |
$this->_feed = new AtomCreator03(); |
$this->_feed = new AtomCreator10(); |
| 379 |
break; |
break; |
| 380 |
|
|
| 381 |
case "HTML": |
case "HTML": |
| 407 |
* |
* |
| 408 |
* @see FeedCreator::addItem() |
* @see FeedCreator::addItem() |
| 409 |
* @param string format format the feed should comply to. Valid values are: |
* @param string format format the feed should comply to. Valid values are: |
| 410 |
* "PIE0.1", "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM0.3", "HTML", "JS" |
* "PIE0.1", "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM1.0", "HTML", "JS" |
| 411 |
* @return string the contents of the feed. |
* @return string the contents of the feed. |
| 412 |
*/ |
*/ |
| 413 |
function createFeed($format = "RSS0.91") { |
function createFeed($format = "RSS0.91") { |
| 423 |
* @since 1.4 |
* @since 1.4 |
| 424 |
* |
* |
| 425 |
* @param string format format the feed should comply to. Valid values are: |
* @param string format format the feed should comply to. Valid values are: |
| 426 |
* "PIE0.1" (deprecated), "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM", "ATOM0.3", "HTML", "JS" |
* "PIE0.1" (deprecated), "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM1.0", "HTML", "JS" |
| 427 |
* @param string filename optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). |
* @param string filename optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). |
| 428 |
* @param boolean displayContents optional send the content of the file or not. If true, the file will be sent in the body of the response. |
* @param boolean displayContents optional send the content of the file or not. If true, the file will be sent in the body of the response. |
| 429 |
*/ |
*/ |
| 441 |
* (web fetching, for example). |
* (web fetching, for example). |
| 442 |
* |
* |
| 443 |
* @param string format format the feed should comply to. Valid values are: |
* @param string format format the feed should comply to. Valid values are: |
| 444 |
* "PIE0.1" (deprecated), "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM0.3". |
* "PIE0.1" (deprecated), "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM1.0". |
| 445 |
* @param filename string optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). |
* @param filename string optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). |
| 446 |
* @param timeout int optional the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour) |
* @param timeout int optional the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour) |
| 447 |
*/ |
*/ |
| 1080 |
|
|
| 1081 |
|
|
| 1082 |
/** |
/** |
| 1083 |
|
* DEPRICATED |
| 1084 |
|
* |
| 1085 |
|
* |
| 1086 |
* AtomCreator03 is a FeedCreator that implements the atom specification, |
* AtomCreator03 is a FeedCreator that implements the atom specification, |
| 1087 |
* as in http://www.intertwingly.net/wiki/pie/FrontPage. |
* as in http://www.intertwingly.net/wiki/pie/FrontPage. |
| 1088 |
* Please note that just by using AtomCreator03 you won't automatically |
* Please note that just by using AtomCreator03 you won't automatically |
| 1158 |
} |
} |
| 1159 |
} |
} |
| 1160 |
|
|
| 1161 |
|
/** |
| 1162 |
|
* AtomCreator10 is a FeedCreator that implements the atom specification, |
| 1163 |
|
* as in http://www.atomenabled.org/ |
| 1164 |
|
* @author neil.thompson <nthompson@mambo-foundation.org> |
| 1165 |
|
*/ |
| 1166 |
|
class AtomCreator10 extends FeedCreator { |
| 1167 |
|
|
| 1168 |
|
function AtomCreator10() { |
| 1169 |
|
$this->contentType = "application/atom+xml"; |
| 1170 |
|
$this->encoding = "utf-8"; |
| 1171 |
|
} |
| 1172 |
|
|
| 1173 |
|
function createFeed() { |
| 1174 |
|
|
| 1175 |
|
$now = new FeedDate(); |
| 1176 |
|
|
| 1177 |
|
$feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; |
| 1178 |
|
$feed.= $this->_createGeneratorComment(); |
| 1179 |
|
$feed.= $this->_createStylesheetReferences(); |
| 1180 |
|
$feed.= "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n"; |
| 1181 |
|
$feed.= " <title type=\"text\">".htmlspecialchars($this->title)."</title>\n"; |
| 1182 |
|
$feed.= " <subtitle>".htmlspecialchars($this->description)."</subtitle>\n"; |
| 1183 |
|
$feed.= " <link rel=\"alternate\" type=\"text/html\" hreflang=\"en\" href=\"".htmlspecialchars($this->link)."\"/>\n"; |
| 1184 |
|
$feed.= " <link rel=\"self\" type=\"application/atom+xml\" hreflang=\"en\" href=\"".htmlspecialchars($this->link)."/index2.php?option=com_rss&feed=ATOM1.0&no_html=1\"/>\n"; |
| 1185 |
|
$feed.= " <id>".htmlspecialchars($this->link)."/</id>\n"; |
| 1186 |
|
$feed.= " <updated>".htmlspecialchars($now->iso8601())."</updated>\n"; |
| 1187 |
|
|
| 1188 |
|
if ($this->editor!="") { |
| 1189 |
|
$feed.= " <rights>".$this->editor; |
| 1190 |
|
if ($this->editorEmail!="") { |
| 1191 |
|
$feed.= $this->editorEmail; |
| 1192 |
|
} |
| 1193 |
|
$feed.= " </rights>\n"; |
| 1194 |
|
} |
| 1195 |
|
|
| 1196 |
|
$feed.= " <generator>".FEEDCREATOR_VERSION."</generator>\n"; |
| 1197 |
|
|
| 1198 |
|
$feed.= $this->_createAdditionalElements($this->additionalElements, " "); |
| 1199 |
|
|
| 1200 |
|
for ($i=0;$i<count($this->items);$i++) { |
| 1201 |
|
|
| 1202 |
|
$this->items[$i]->created = time(); |
| 1203 |
|
$itemDate = new FeedDate($this->items[$i]->created); |
| 1204 |
|
|
| 1205 |
|
$feed.= " <entry>\n"; |
| 1206 |
|
$feed.= " <title>".htmlspecialchars(strip_tags($this->items[$i]->title))."</title>\n"; |
| 1207 |
|
$feed.= " <link rel=\"self\" type=\"application/atom+xml\" href=\"".htmlspecialchars($this->items[$i]->link)."\"/>\n"; |
| 1208 |
|
$feed.= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->items[$i]->link)."\"/>\n"; |
| 1209 |
|
$feed.= " <updated>".htmlspecialchars($itemDate->iso8601())."</updated>\n"; |
| 1210 |
|
$feed.= " <id>".htmlspecialchars($this->items[$i]->link)."</id>\n"; |
| 1211 |
|
$feed.= " <author>\n"; |
| 1212 |
|
if ($this->items[$i]->author!="") { |
| 1213 |
|
$feed.= " <name>".htmlspecialchars($this->items[$i]->author)."</name>\n"; |
| 1214 |
|
}else{ |
| 1215 |
|
$feed.= " <name>".htmlspecialchars($this->link)."</name>\n"; |
| 1216 |
|
} |
| 1217 |
|
$feed.= " </author>\n"; |
| 1218 |
|
|
| 1219 |
|
if ($this->items[$i]->description!="") { |
| 1220 |
|
$feed.= " <summary type=\"html\">".htmlspecialchars($this->items[$i]->description)."</summary>\n"; |
| 1221 |
|
} |
| 1222 |
|
$feed.= " </entry>\n"; |
| 1223 |
|
|
| 1224 |
|
} |
| 1225 |
|
|
| 1226 |
|
$feed.= "</feed>\n"; |
| 1227 |
|
return $feed; |
| 1228 |
|
} |
| 1229 |
|
} |
| 1230 |
|
|
| 1231 |
|
|
| 1232 |
/** |
/** |
| 1233 |
* MBOXCreator is a FeedCreator that implements the mbox format |
* MBOXCreator is a FeedCreator that implements the mbox format |
| 1465 |
} |
} |
| 1466 |
if ($this->getDescription()) { |
if ($this->getDescription()) { |
| 1467 |
$feedArray[] = "<div class='".$this->stylePrefix."description'>". |
$feedArray[] = "<div class='".$this->stylePrefix."description'>". |
| 1468 |
str_replace("]]>", "", str_replace("<![CDATA[", "", $this->getDescription())). |
str_replace("</XMLCDATA>", "", str_replace("<![CDATA[", "", $this->getDescription())). |
| 1469 |
"</div>"; |
"</div>"; |
| 1470 |
} |
} |
| 1471 |
|
|