Zend_Feed_Writer.xml 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.feed.writer">
  4. <title>Zend_Feed_Writer</title>
  5. <sect2 id="zend.feed.writer.introduction">
  6. <title>Introduction</title>
  7. <para>
  8. <classname>Zend_Feed_Writer</classname> is the sibling component to
  9. <classname>Zend_Feed_Reader</classname> responsible for generating feeds for output. It
  10. supports the Atom 1.0 specification (<acronym>RFC</acronym> 4287) and
  11. <acronym>RSS</acronym> 2.0 as specified by the <acronym>RSS</acronym> Advisory Board
  12. (<acronym>RSS</acronym> 2.0.11). It does not deviate from these standards. It does,
  13. however, offer a simple Extension system which allows for any extension and module for
  14. either of these two specifications to be implemented if they are not provided out of the
  15. box.
  16. </para>
  17. <para>
  18. In many ways, <classname>Zend_Feed_Writer</classname> is the inverse of
  19. <classname>Zend_Feed_Reader</classname>. Where <classname>Zend_Feed_Reader</classname>
  20. focuses on providing an easy to use architecture fronted by getter methods,
  21. <classname>Zend_Feed_Writer</classname> is fronted by similarly named setters or
  22. mutators. This ensures the <acronym>API</acronym> won't pose a learning curve to anyone
  23. familiar with <classname>Zend_Feed_Reader</classname>.
  24. </para>
  25. <para>
  26. As a result of this design, the rest may even be obvious. Behind the scenes, data set on
  27. any <classname>Zend_Feed_Writer</classname> Data Container object is translated at
  28. render time onto a DOMDocument object using the necessary feed elements. For each
  29. supported feed type there is both an Atom 1.0 and <acronym>RSS</acronym> 2.0 renderer.
  30. Using a DOMDocument class rather than a templating solution has numerous advantages,
  31. the most obvious being the ability to export the DOMDocument for
  32. additional processing and relying on <acronym>PHP</acronym> <acronym>DOM</acronym> for
  33. correct and valid rendering.
  34. </para>
  35. <para>
  36. As with <classname>Zend_Feed_Reader</classname>, <classname>Zend_Feed_Writer</classname>
  37. is a standalone replacement for <classname>Zend_Feed</classname>'s Builder architecture
  38. and is not compatible with those classes.
  39. </para>
  40. </sect2>
  41. <sect2 id="zend.feed.writer.architecture">
  42. <title>Architecture</title>
  43. <para>
  44. The architecture of <classname>Zend_Feed_Writer</classname> is very simple. It has two
  45. core sets of classes: data containers and renderers.
  46. </para>
  47. <para>
  48. The containers include the <classname>Zend_Feed_Writer_Feed</classname> and
  49. <classname>Zend_Feed_Writer_Entry</classname> classes. The Entry classes can be attached
  50. to any Feed class. The sole purpose of these containers is to collect data about the
  51. feed to generate using a simple interface of setter methods. These methods perform some
  52. data validity testing. For example, it will validate any passed <acronym>URI</acronym>s,
  53. dates, etc. These checks are not tied to any of the feed standards definitions. The
  54. container objects also contain methods to allow for fast rendering and export of the
  55. final feed, and these can be reused at will.
  56. </para>
  57. <para>
  58. In addition to the main data container classes, there are two additional Atom 2.0
  59. specific classes. <classname>Zend_Feed_Writer_Source</classname> and
  60. <classname>Zend_Feed_Writer_Deleted</classname>. The former implements Atom 2.0 source
  61. elements which carry source feed metadata for a specific entry within an aggregate feed
  62. (i.e. the current feed is not the entry's original source). The latter implements the
  63. Atom Tombstones <acronym>RFC</acronym> allowing feeds to carry references to entries
  64. which have been deleted.
  65. </para>
  66. <para>
  67. While there are two main data container types, there are four renderers - two matching
  68. container renderers per supported feed type. Each renderer accepts a container, and
  69. based on its content attempts to generate valid feed markup. If the renderer is unable
  70. to generate valid feed markup, perhaps due to the container missing an obligatory data
  71. point, it will report this by throwing an <classname>Exception</classname>. While it is
  72. possible to ignore <classname>Exception</classname>s, this removes the default safeguard
  73. of ensuring you have sufficient data set to render a wholly valid feed.
  74. </para>
  75. <para>
  76. To explain this more clearly, you may construct a set of data containers for a feed
  77. where there is a Feed container, into which has been added some Entry containers and a
  78. Deleted container. This forms a data hierarchy resembling a normal feed. When rendering
  79. is performed, this hierarchy has its pieces passed to relevant renderers and the partial
  80. feeds (all DOMDocuments) are then pieced together to create a complete feed. In the case
  81. of Source or Deleted (Tomestone) containers, these are rendered only for Atom 2.0 and
  82. ignored for <acronym>RSS</acronym>.
  83. </para>
  84. <para>
  85. Due to the system being divided between data containers and renderers, it can make
  86. Extensions somewhat interesting. A typical Extension offering namespaced feed and entry
  87. level elements, must itself reflect the exact same architecture, i.e. offer feed and
  88. entry level data containers, and matching renderers. There is, fortunately, no complex
  89. integration work required since all Extension classes are simply registered and
  90. automatically used by the core classes. We'll meet Extensions in more detail at the end
  91. of this section.
  92. </para>
  93. </sect2>
  94. <sect2 id="zend.feed.writer.getting.started">
  95. <title>Getting Started</title>
  96. <para>
  97. Using <classname>Zend_Feed_Writer</classname> is as simple as setting data and
  98. triggering the renderer. Here is an example to generate a minimal Atom 1.0 feed.
  99. As this demonstrates, each feed or entry uses a separate data container.
  100. </para>
  101. <programlisting language="php"><![CDATA[
  102. /**
  103. * Create the parent feed
  104. */
  105. $feed = new Zend_Feed_Writer_Feed;
  106. $feed->setTitle('Paddy\'s Blog');
  107. $feed->setLink('http://www.example.com');
  108. $feed->setFeedLink('http://www.example.com/atom', 'atom');
  109. $feed->addAuthor(array(
  110. 'name' => 'Paddy',
  111. 'email' => 'paddy@example.com',
  112. 'uri' => 'http://www.example.com',
  113. ));
  114. $feed->setDateModified(time());
  115. $feed->addHub('http://pubsubhubbub.appspot.com/');
  116. /**
  117. * Add one or more entries. Note that entries must
  118. * be manually added once created.
  119. */
  120. $entry = $feed->createEntry();
  121. $entry->setTitle('All Your Base Are Belong To Us');
  122. $entry->setLink('http://www.example.com/all-your-base-are-belong-to-us');
  123. $entry->addAuthor(array(
  124. 'name' => 'Paddy',
  125. 'email' => 'paddy@example.com',
  126. 'uri' => 'http://www.example.com',
  127. ));
  128. $entry->setDateModified(time());
  129. $entry->setDateCreated(time());
  130. $entry->setDescription('Exposing the difficultly of porting games to English.');
  131. $entry->setContent(
  132. 'I am not writing the article. The example is long enough as is ;).'
  133. );
  134. $feed->addEntry($entry);
  135. /**
  136. * Render the resulting feed to Atom 1.0 and assign to $out.
  137. * You can substitute "atom" with "rss" to generate an RSS 2.0 feed.
  138. */
  139. $out = $feed->export('atom');
  140. ]]></programlisting>
  141. <para>
  142. The output rendered should be as follows:
  143. </para>
  144. <programlisting language="xml"><![CDATA[
  145. <?xml version="1.0" encoding="utf-8"?>
  146. <feed xmlns="http://www.w3.org/2005/Atom">
  147. <title type="text">Paddy's Blog</title>
  148. <subtitle type="text">Writing about PC Games since 176 BC.</subtitle>
  149. <updated>2009-12-14T20:28:18+00:00</updated>
  150. <generator uri="http://framework.zend.com" version="1.10.0alpha">
  151. Zend_Feed_Writer
  152. </generator>
  153. <link rel="alternate" type="text/html" href="http://www.example.com"/>
  154. <link rel="self" type="application/atom+xml"
  155. href="http://www.example.com/atom"/>
  156. <id>http://www.example.com</id>
  157. <author>
  158. <name>Paddy</name>
  159. <email>paddy@example.com</email>
  160. <uri>http://www.example.com</uri>
  161. </author>
  162. <link rel="hub" href="http://pubsubhubbub.appspot.com/"/>
  163. <entry>
  164. <title type="html"><![CDATA[All Your Base Are Belong To
  165. Us]]]]><![CDATA[></title>
  166. <summary type="html">
  167. <![CDATA[Exposing the difficultly of porting games to
  168. English.]]]]><![CDATA[>
  169. </summary>
  170. <published>2009-12-14T20:28:18+00:00</published>
  171. <updated>2009-12-14T20:28:18+00:00</updated>
  172. <link rel="alternate" type="text/html"
  173. href="http://www.example.com/all-your-base-are-belong-to-us"/>
  174. <id>http://www.example.com/all-your-base-are-belong-to-us</id>
  175. <author>
  176. <name>Paddy</name>
  177. <email>paddy@example.com</email>
  178. <uri>http://www.example.com</uri>
  179. </author>
  180. <content type="html">
  181. <![CDATA[I am not writing the article.
  182. The example is long enough as is ;).]]]]><![CDATA[>
  183. </content>
  184. </entry>
  185. </feed>
  186. ]]></programlisting>
  187. <para>
  188. This is a perfectly valid Atom 1.0 example. It should be noted that omitting an
  189. obligatory point of data, such as a title, will trigger an
  190. <classname>Exception</classname> when rendering as Atom 1.0. This will differ for
  191. <acronym>RSS</acronym> 2.0 since a title may be omitted so long as a description is
  192. present. This gives rise to Exceptions that differ between the two standards depending
  193. on the renderer in use. By design, <classname>Zend_Feed_Writer</classname> will not
  194. render an invalid feed for either standard unless the end-user deliberately elects to
  195. ignore all Exceptions. This built in safeguard was added to ensure users without
  196. in-depth knowledge of the relevant specifications have a bit less to worry about.
  197. </para>
  198. </sect2>
  199. <sect2 id="zend.feed.writer.setting.feed.data.points">
  200. <title>Setting Feed Data Points</title>
  201. <para>
  202. Before you can render a feed, you must first setup the data necessary for
  203. the feed being rendered. This utilises a simple setter style <acronym>API</acronym>
  204. which doubles as an initial method for validating the data being set. By design, the
  205. <acronym>API</acronym> closely matches that for <classname>Zend_Feed_Reader</classname>
  206. to avoid undue confusion and uncertainty.
  207. </para>
  208. <note>
  209. <para>Users have commented that the lack of a simple array based notation for input data
  210. gives rise to lengthy tracts of code. This will be addressed in a future release.</para>
  211. </note>
  212. <para>
  213. <classname>Zend_Feed_Writer</classname> offers this <acronym>API</acronym> via its data
  214. container classes <classname>Zend_Feed_Writer_Feed</classname> and
  215. <classname>Zend_Feed_Writer_Entry</classname> (not to mention the Atom 2.0 specific
  216. and Extension classes). These classes merely store
  217. all feed data in a type-agnostic manner, meaning you may reuse any data
  218. container with any renderer without requiring additional work. Both classes
  219. are also amenable to Extensions, meaning that an Extension may define its own
  220. container classes which are registered to the base container classes as extensions, and
  221. are checked when any method call triggers the base container's
  222. <methodname>__call()</methodname> method.
  223. </para>
  224. <para>
  225. Here's a summary of the Core <acronym>API</acronym> for Feeds. You should note it
  226. comprises not only the basic <acronym>RSS</acronym> and Atom standards, but also
  227. accounts for a number of included Extensions bundled with
  228. <classname>Zend_Feed_Writer</classname>. The naming of these
  229. Extension sourced methods remain fairly generic - all Extension
  230. methods operate at the same level as the Core <acronym>API</acronym> though we do allow
  231. you to retrieve any specific Extension object separately if required.
  232. </para>
  233. <para>
  234. The Feed Level <acronym>API</acronym> for data is contained in
  235. <classname>Zend_Feed_Writer_Feed</classname>. In addition to the <acronym>API</acronym>
  236. detailed below, the class also implements the <classname>Countable</classname> and
  237. <classname>Iterator</classname> interfaces.
  238. </para>
  239. <table>
  240. <title>Feed Level API Methods</title>
  241. <tgroup cols="2">
  242. <tbody>
  243. <row>
  244. <entry><methodname>setId()</methodname></entry>
  245. <entry>
  246. Set a unique ID associated with this feed. For Atom 1.0
  247. this is an atom:id element, whereas for <acronym>RSS</acronym> 2.0 it
  248. is added as a guid element. These are optional so long as a link is
  249. added, i.e. the link is set as the ID.
  250. </entry>
  251. </row>
  252. <row>
  253. <entry><methodname>setTitle()</methodname></entry>
  254. <entry>Set the title of the feed.</entry>
  255. </row>
  256. <row>
  257. <entry><methodname>setDescription()</methodname></entry>
  258. <entry>Set the text description of the feed.</entry>
  259. </row>
  260. <row>
  261. <entry><methodname>setLink()</methodname></entry>
  262. <entry>
  263. Set a <acronym>URI</acronym> to the <acronym>HTML</acronym> website
  264. containing the same or
  265. similar information as this feed (i.e. if the feed is from a blog,
  266. it should provide the blog's <acronym>URI</acronym> where the
  267. <acronym>HTML</acronym> version of the entries can be read).
  268. </entry>
  269. </row>
  270. <row>
  271. <entry><methodname>setFeedLinks()</methodname></entry>
  272. <entry>
  273. Add a link to an <acronym>XML</acronym> feed, whether the feed being
  274. generated or an alternate <acronym>URI</acronym> pointing to the same
  275. feed but in a different format. At a minimum, it is recommended to
  276. include a link to the feed being generated so it has an identifiable
  277. final <acronym>URI</acronym> allowing a client to track its location
  278. changes without necessitating constant redirects. The parameter is an
  279. array of arrays, where each sub-array contains the keys "type" and
  280. "uri". The type should be one of "atom", "rss", or "rdf".
  281. </entry>
  282. </row>
  283. <row>
  284. <entry><methodname>addAuthors()</methodname></entry>
  285. <entry>
  286. Sets the data for authors. The parameter is an array of arrays
  287. where each sub-array may contain the keys "name", "email" and
  288. "uri". The "uri" value is only applicable for Atom feeds since
  289. <acronym>RSS</acronym> contains no facility to show it. For
  290. <acronym>RSS</acronym> 2.0, rendering will create two elements - an
  291. author element containing the email reference with the name in brackets,
  292. and a Dublin Core creator element only containing the name.
  293. </entry>
  294. </row>
  295. <row>
  296. <entry><methodname>addAuthor()</methodname></entry>
  297. <entry>
  298. Sets the data for a single author following the same
  299. array format as described above for a single sub-array.
  300. </entry>
  301. </row>
  302. <row>
  303. <entry><methodname>setDateCreated()</methodname></entry>
  304. <entry>
  305. Sets the date on which this feed was created. Generally
  306. only applicable to Atom where it represents the date the resource
  307. described by an Atom 1.0 document was created. The expected parameter
  308. may be a <acronym>UNIX</acronym> timestamp or a
  309. <classname>Zend_Date</classname> object.
  310. </entry>
  311. </row>
  312. <row>
  313. <entry><methodname>setDateModified()</methodname></entry>
  314. <entry>
  315. Sets the date on which this feed was last modified. The expected
  316. parameter may be a <acronym>UNIX</acronym> timestamp or a
  317. <classname>Zend_Date</classname> object.
  318. </entry>
  319. </row>
  320. <row>
  321. <entry><methodname>setLastBuildDate()</methodname></entry>
  322. <entry>
  323. Sets the date on which this feed was last build. The expected
  324. parameter may be a <acronym>UNIX</acronym> timestamp or a
  325. <classname>Zend_Date</classname> object. This will only be
  326. rendered for <acronym>RSS</acronym> 2.0 feeds and is automatically
  327. rendered as the current date by default when not explicity set.
  328. </entry>
  329. </row>
  330. <row>
  331. <entry><methodname>setLanguage()</methodname></entry>
  332. <entry>
  333. Sets the language of the feed. This will be omitted unless set.
  334. </entry>
  335. </row>
  336. <row>
  337. <entry><methodname>setGenerator()</methodname></entry>
  338. <entry>
  339. Allows the setting of a generator. The parameter should be an
  340. array containing the keys "name", "version" and "uri". If omitted
  341. a default generator will be added referencing
  342. <classname>Zend_Feed_Writer</classname>, the current Zend Framework
  343. version and the Framework's <acronym>URI</acronym>.
  344. </entry>
  345. </row>
  346. <row>
  347. <entry><methodname>setCopyright()</methodname></entry>
  348. <entry>Sets a copyright notice associated with the feed.</entry>
  349. </row>
  350. <row>
  351. <entry><methodname>addHubs()</methodname></entry>
  352. <entry>
  353. Accepts an array of Pubsubhubbub Hub Endpoints to be rendered in
  354. the feed as Atom links so that PuSH Subscribers may subscribe to
  355. your feed. Note that you must implement a Pubsubhubbub Publisher in
  356. order for real-time updates to be enabled. A Publisher may be
  357. implemented using
  358. <classname>Zend_Feed_Pubsubhubbub_Publisher</classname>.
  359. The method <methodname>addHub()</methodname> allows adding
  360. a single hub at a time.
  361. </entry>
  362. </row>
  363. <row>
  364. <entry><methodname>addCategories()</methodname></entry>
  365. <entry>
  366. Accepts an array of categories for rendering, where each element is
  367. itself an array whose possible keys include "term", "label" and
  368. "scheme". The "term" is a typically a category name suitable for
  369. inclusion in a <acronym>URI</acronym>. The "label" may be a human
  370. readable category name supporting special characters (it is
  371. <acronym>HTML</acronym> encoded during rendering) and is a required key.
  372. The "scheme" (called the domain in <acronym>RSS</acronym>) is optional
  373. but must be a valid <acronym>URI</acronym>. The method
  374. <methodname>addCategory()</methodname> allows adding a single category
  375. at a time.
  376. </entry>
  377. </row>
  378. <row>
  379. <entry><methodname>setImage()</methodname></entry>
  380. <entry>
  381. Accepts an array of image metadata for an <acronym>RSS</acronym> image
  382. or Atom logo. Atom 1.0 only requires a <acronym>URI</acronym>.
  383. <acronym>RSS</acronym> 2.0 requires a <acronym>URI</acronym>,
  384. <acronym>HTML</acronym> link, and an image title. <acronym>RSS</acronym>
  385. 2.0 optionally may send a width, height and image description. The array
  386. parameter may contain these using the keys: <property>uri</property>,
  387. <property>link</property>, <property>title</property>,
  388. <property>description</property>, <property>height</property> and
  389. <property>width</property>. The <acronym>RSS</acronym> 2.0
  390. <acronym>HTML</acronym> link should point to the feed source's
  391. <acronym>HTML</acronym> page.
  392. </entry>
  393. </row>
  394. <row>
  395. <entry><methodname>createEntry()</methodname></entry>
  396. <entry>
  397. Returns a new instance of
  398. <classname>Zend_Feed_Writer_Entry</classname>. This is the Entry level
  399. data container. New entries are not automatically assigned to the
  400. current feed, so you must explicitly call
  401. <methodname>addEntry()</methodname> to add the entry for rendering.
  402. </entry>
  403. </row>
  404. <row>
  405. <entry><methodname>addEntry()</methodname></entry>
  406. <entry>
  407. Adds an instance of <classname>Zend_Feed_Writer_Entry</classname>
  408. to the current feed container for rendering.
  409. </entry>
  410. </row>
  411. <row>
  412. <entry><methodname>createTombstone()</methodname></entry>
  413. <entry>
  414. Returns a new instance of
  415. <classname>Zend_Feed_Writer_Deleted</classname>. This is the Atom 2.0
  416. Tombstone level data container. New entries are not automatically
  417. assigned to the current feed, so you must explicitly call
  418. <methodname>addTombstone()</methodname> to add the deleted entry for
  419. rendering.
  420. </entry>
  421. </row>
  422. <row>
  423. <entry><methodname>addTombstone()</methodname></entry>
  424. <entry>
  425. Adds an instance of <classname>Zend_Feed_Writer_Deleted</classname> to
  426. the current feed container for rendering.
  427. </entry>
  428. </row>
  429. <row>
  430. <entry><methodname>removeEntry()</methodname></entry>
  431. <entry>
  432. Accepts a parameter indicating an array index of the entry to remove
  433. from the feed.
  434. </entry>
  435. </row>
  436. <row>
  437. <entry><methodname>export()</methodname></entry>
  438. <entry>
  439. Exports the entire data hierarchy to an <acronym>XML</acronym> feed. The
  440. method has two parameters. The first is the feed type, one of "atom"
  441. or "rss". The second is an optional boolean to set whether
  442. Exceptions are thrown. The default is <constant>TRUE</constant>.
  443. </entry>
  444. </row>
  445. </tbody>
  446. </tgroup>
  447. </table>
  448. <note>
  449. <para>
  450. In addition to these setters, there are also matching getters to retrieve data from
  451. the Entry data container. For example, <methodname>setImage()</methodname> is
  452. matched with a <methodname>getImage()</methodname> method.
  453. </para>
  454. </note>
  455. <!-- remaining feed stuff -->
  456. </sect2>
  457. <sect2 id="zend.feed.writer.setting.entry.data.points">
  458. <title>Setting Entry Data Points</title>
  459. <para>
  460. Here's a summary of the Core <acronym>API</acronym> for Entries and Items. You should
  461. note it comprises not only the basic <acronym>RSS</acronym> and Atom standards, but
  462. also accounts for a number of included Extensions bundled with
  463. <classname>Zend_Feed_Writer</classname>. The naming of these
  464. Extension sourced methods remain fairly generic - all Extension
  465. methods operate at the same level as the Core <acronym>API</acronym> though we do allow
  466. you to retrieve any specific Extension object separately if required.
  467. </para>
  468. <para>
  469. The Entry Level <acronym>API</acronym> for data is contained in
  470. <classname>Zend_Feed_Writer_Entry</classname>.
  471. </para>
  472. <table>
  473. <title>Entry Level API Methods</title>
  474. <tgroup cols="2">
  475. <tbody>
  476. <row>
  477. <entry><methodname>setId()</methodname></entry>
  478. <entry>
  479. Set a unique ID associated with this entry. For Atom 1.0
  480. this is an atom:id element, whereas for <acronym>RSS</acronym> 2.0 it is
  481. added as a guid element. These are optional so long as a link is
  482. added, i.e. the link is set as the ID.
  483. </entry>
  484. </row>
  485. <row>
  486. <entry><methodname>setTitle()</methodname></entry>
  487. <entry>Set the title of the entry.</entry>
  488. </row>
  489. <row>
  490. <entry><methodname>setDescription()</methodname></entry>
  491. <entry>Set the text description of the entry.</entry>
  492. </row>
  493. <row>
  494. <entry><methodname>setContent()</methodname></entry>
  495. <entry>Set the content of the entry.</entry>
  496. </row>
  497. <row>
  498. <entry><methodname>setLink()</methodname></entry>
  499. <entry>
  500. Set a <acronym>URI</acronym> to the <acronym>HTML</acronym> website
  501. containing the same or
  502. similar information as this entry (i.e. if the feed is from a blog,
  503. it should provide the blog article's <acronym>URI</acronym> where the
  504. <acronym>HTML</acronym> version of the entry can be read).
  505. </entry>
  506. </row>
  507. <row>
  508. <entry><methodname>addAuthors()</methodname></entry>
  509. <entry>
  510. Sets the data for authors. The parameter is an array of arrays
  511. where each sub-array may contain the keys "name", "email" and
  512. "uri". The "uri" value is only applicable for Atom feeds since
  513. <acronym>RSS</acronym> contains no facility to show it. For
  514. <acronym>RSS</acronym> 2.0, rendering will create two elements - an
  515. author element containing the email reference with the name in brackets,
  516. and a Dublin Core creator element only containing the name.
  517. </entry>
  518. </row>
  519. <row>
  520. <entry><methodname>addAuthor()</methodname></entry>
  521. <entry>
  522. Sets the data for a single author following the same
  523. format as described above for a single sub-array.
  524. </entry>
  525. </row>
  526. <row>
  527. <entry><methodname>setDateCreated()</methodname></entry>
  528. <entry>
  529. Sets the date on which this feed was created. Generally
  530. only applicable to Atom where it represents the date the resource
  531. described by an Atom 1.0 document was created. The expected parameter
  532. may be a <acronym>UNIX</acronym> timestamp or a
  533. <classname>Zend_Date</classname> object. If omitted, the date
  534. used will be the current date and time.
  535. </entry>
  536. </row>
  537. <row>
  538. <entry><methodname>setDateModified()</methodname></entry>
  539. <entry>
  540. Sets the date on which this feed was last modified. The expected
  541. parameter may be a <acronym>UNIX</acronym> timestamp or a
  542. <classname>Zend_Date</classname> object. If omitted, the date
  543. used will be the current date and time.
  544. </entry>
  545. </row>
  546. <row>
  547. <entry><methodname>setCopyright()</methodname></entry>
  548. <entry>Sets a copyright notice associated with the feed.</entry>
  549. </row>
  550. <row>
  551. <entry><methodname>addCategories()</methodname></entry>
  552. <entry>
  553. Accepts an array of categories for rendering, where each element is
  554. itself an array whose possible keys include "term", "label" and
  555. "scheme". The "term" is a typically a category name suitable for
  556. inclusion in a <acronym>URI</acronym>. The "label" may be a human
  557. readable category name supporting special characters (it is encoded
  558. during rendering) and is a required key. The "scheme" (called the domain
  559. in <acronym>RSS</acronym>) is optional but must be a valid
  560. <acronym>URI</acronym>. The method
  561. <methodname>addCategory()</methodname> allows adding a single category
  562. at a time.
  563. </entry>
  564. </row>
  565. <row>
  566. <entry><methodname>setCommentCount()</methodname></entry>
  567. <entry>
  568. Sets the number of comments associated with this entry. Rendering
  569. differs between <acronym>RSS</acronym> and Atom 2.0 depending
  570. on the element or attribute needed.
  571. </entry>
  572. </row>
  573. <row>
  574. <entry><methodname>setEnclosure()</methodname></entry>
  575. <entry>
  576. Adds an enclosure to the entry. The array parameter may contain the
  577. keys 'uri', 'type' and 'length'. Only 'uri' is required for Atom, though the
  578. others must also be provided or <acronym>RSS</acronym> rendering
  579. (where they are required) will throw an Exception.
  580. </entry>
  581. </row>
  582. <row>
  583. <entry><methodname>setCommentLink()</methodname></entry>
  584. <entry>
  585. Seta a link to a <acronym>HTML</acronym> page containing comments
  586. associated with this entry.
  587. </entry>
  588. </row>
  589. <row>
  590. <entry><methodname>setCommentFeedLink()</methodname></entry>
  591. <entry>
  592. Sets a link to a <acronym>XML</acronym> feed containing comments
  593. associated with this entry. The parameter is an array containing the
  594. keys "uri" and "type", where the type is one of "rdf", "rss" or "atom".
  595. </entry>
  596. </row>
  597. <row>
  598. <entry><methodname>setCommentFeedLinks()</methodname></entry>
  599. <entry>
  600. Same as <methodname>setCommentFeedLink()</methodname> except it
  601. accepts an array of arrays, where each subarray contains the
  602. expected parameters of <methodname>setCommentFeedLink()</methodname>.
  603. </entry>
  604. </row>
  605. <row>
  606. <entry><methodname>setEncoding()</methodname></entry>
  607. <entry>
  608. Sets the encoding of entry text. This will default to
  609. <acronym>UTF-8</acronym> which is the preferred encoding.
  610. </entry>
  611. </row>
  612. </tbody>
  613. </tgroup>
  614. </table>
  615. <note>
  616. <para>
  617. In addition to these setters, there are also matching getters to retrieve data from
  618. the Entry data container.
  619. </para>
  620. </note>
  621. </sect2>
  622. </sect1>