## Apache Zeta Components Manual :: File Source for entry.php

## Source for file entry.php

Documentation is available at entry.php

1. <?php
2. /**
3. * File containing the ezcFeedEntryElement class.
4. *
5. * Licensed to the Apache Software Foundation (ASF) under one
6. * or more contributor license agreements. See the NOTICE file
7. * distributed with this work for additional information
8. * regarding copyright ownership. The ASF licenses this file
9. * to you under the Apache License, Version 2.0 (the
10. * "License"); you may not use this file except in compliance
11. * with the License. You may obtain a copy of the License at
12. *
13. * http://www.apache.org/licenses/LICENSE-2.0
14. *
15. * Unless required by applicable law or agreed to in writing,
16. * software distributed under the License is distributed on an
17. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18. * KIND, either express or implied. See the License for the
19. * specific language governing permissions and limitations
20. * under the License.
21. *
22. * @package Feed
23. * @version //autogentag//
24. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
25. * @filesource
26. */
28. /**
29. * Class defining a feed entry.
30. *
31. * @property array(ezcFeedPersonElement) $author
32. * The authors of the entry. Equivalents:
33. * ATOM-author (required, multiple),
34. * RSS1-none,
35. * RSS2-author (optional, recommended, single).
36. * @property array(ezcFeedCategoryElement) $category
37. * The categories of the entry. Equivalents:
38. * ATOM-author (optional, multiple),
39. * RSS1-none,
40. * RSS2-category (optional, multiple).
41. * @property ezcFeedTextElement $comments
42. * The comments of the entry. Equivalents:
43. * ATOM-none,
44. * RSS1-none,
45. * RSS2-author (optional, single).
46. * @property ezcFeedContentElement $content
47. * The complex text content of the entry. Equivalents:
48. * ATOM-content (optional, single),
49. * RSS1-none,
50. * RSS2-none.
51. * @property array(ezcFeedPersonElement) $contributor
52. * The contributors of the entry. Equivalents:
53. * ATOM-contributor (optional, not recommended, multiple),
54. * RSS1-none,
55. * RSS2-none.
56. * @property ezcFeedTextElement $copyright
57. * The copyright of the entry. Equivalents:
58. * ATOM-rights (optional, single),
59. * RSS1-none,
60. * RSS2-none.
61. * @property ezcFeedTextElement $description
62. * The description of the entry. Equivalents:
63. * ATOM-summary (required, single),
64. * RSS1-description (required, single),
65. * RSS2-description (required, single).
66. * @property array(ezcFeedEnclosureElement) $enclosure
67. * The enclosures of the entry. Equivalents:
68. * ATOM-link@rel="enclosure" (optional, multiple),
69. * RSS1-none,
70. * RSS2-enclosure (optional, single).
71. * @property ezcFeedTextElement $id
72. * The id of the entry. Equivalents:
73. * ATOM-id (required, single),
74. * RSS1-about (required, single),
75. * RSS2-guid (optional, single).
76. * @property array(ezcFeedLinkElement) $link
77. * The links of the entry. Equivalents:
78. * ATOM-link (required, multiple),
79. * RSS1-link (required, single),
80. * RSS2-link (required, single).
81. * @property ezcFeedDateElement $published
82. * The published date of the entry. Equivalents:
83. * ATOM-published (optional, single),
84. * RSS1-none,
85. * RSS2-pubDate (optional, single).
86. * @property ezcFeedTextElement $title
87. * The title of the entry. Equivalents:
88. * ATOM-title (required, single),
89. * RSS1-title (required, single),
90. * RSS2-title (required, single).
91. * @property ezcFeedDateElement $updated
92. * The updated date of the entry. Equivalents:
93. * ATOM-updated (required, single),
94. * RSS1-none,
95. * RSS2-none.
96. * @property ezcFeedSourceElement $source
97. * The source of the entry. Equivalents:
98. * ATOM-source (optional, not recommended, single),
99. * RSS1-none,
100. * RSS2-source (optional, not recommended, single).
101. * @property ezcFeedTextElement $language
102. * The language of the entry. Equivalents:
103. * ATOM-source (optional, not recommended, single ),
104. * RSS1-none,
105. * RSS2-none.
106. *
107. * @package Feed
108. * @version //autogentag//
109. * @mainclass
110. */
111. class ezcFeedEntryElement extends ezcFeedElement
112. {
113. /**
114. * Holds the modules used by this feed item.
115. *
116. * @var array(string=>ezcFeedModule)
117. */
118. private $modules = array();
120. /**
121. * Sets the property $name to $value.
122. *
123. * @param string $name The property name
124. * @param mixed $value The property value
125. * @ignore
126. */
127. public function __set( $name, $value )
128. {
129. switch ( $name )
130. {
131. case 'title':
132. case 'description':
133. case 'comments':
134. case 'copyright':
135. case 'language':
136. $element = $this-> add ( $name );
137. $element->text = $value;
138. break;
140. case 'content':
141. $element = $this-> add ( $name );
142. $element->text = $value;
143. break;
145. case 'author':
146. case 'contributor':
147. $element = $this-> add ( $name );
148. $element->name = $value;
149. break;
151. case 'updated':
152. case 'published':
153. $element = $this-> add ( $name );
154. $element->date = $value;
155. break;
157. case 'id':
158. $element = $this-> add ( $name );
159. $element->id = $value;
160. break;
162. case 'link':
163. $element = $this-> add ( $name );
164. $element->href = $value;
165. break;
167. case 'enclosure':
168. $element = $this-> add ( $name );
169. $element->url = $value;
170. break;
172. case 'source':
173. $element = $this-> add ( $name );
174. $element->source = $value;
175. break;
177. default:
178. $supportedModules = ezcFeed :: getSupportedModules ();
179. if ( isset( $supportedModules[$name] ) )
180. {
181. $this->modules[$name] = $value;
182. }
183. break;
184. }
185. }
187. /**
188. * Returns the value of property $name.
189. *
190. * @throws ezcFeedUndefinedModuleException
191. * if trying to fetch a module not defined yet
192. *
193. * @param string $name The property name
194. * @return mixed
195. * @ignore
196. */
197. public function __get( $name )
198. {
199. switch ( $name )
200. {
201. case 'author':
202. case 'category':
203. case 'comments':
204. case 'content':
205. case 'contributor':
206. case 'copyright':
207. case 'description':
208. case 'enclosure':
209. case 'id':
210. case 'link':
211. case 'published':
212. case 'title':
213. case 'updated':
214. case 'source':
215. case 'language':
216. if ( isset( $this-> properties [$name] ) )
217. {
218. return $this-> properties [$name];
219. }
220. break;
222. default:
223. $supportedModules = ezcFeed :: getSupportedModules ();
224. if ( isset( $supportedModules[$name] ) )
225. {
226. if ( isset( $this->$name ) )
227. {
228. return $this->modules[$name];
229. }
230. else
231. {
232. throw new ezcFeedUndefinedModuleException ( $name );
233. }
234. }
235. break;
236. }
237. }
239. /**
240. * Returns if the property $name is set.
241. *
242. * @param string $name The property name
243. * @return bool
244. * @ignore
245. */
246. public function __isset( $name )
247. {
248. switch ( $name )
249. {
250. case 'author':
251. case 'category':
252. case 'comments':
253. case 'content':
254. case 'contributor':
255. case 'copyright':
256. case 'description':
257. case 'enclosure':
258. case 'id':
259. case 'link':
260. case 'published':
261. case 'title':
262. case 'updated':
263. case 'source':
264. case 'language':
265. return isset( $this-> properties [$name] );
267. default:
268. $supportedModules = ezcFeed :: getSupportedModules ();
269. if ( isset( $supportedModules[$name] ) )
270. {
271. return isset( $this->modules[$name] );
272. }
273. }
274. }
276. /**
277. * Adds a new element with name $name to the feed item and returns it.
278. *
279. * Example:
280. * <code>
281. * // $item is an ezcFeedEntryElement object
282. * $link = $item->add( 'link' );
283. * $link->href = 'http://ez.no/';
284. * </code>
285. *
286. * @throws ezcFeedUnsupportedElementException
287. * if the element $name is not supported
288. *
289. * @apichange All items are not encoded at all, in future versions this
290. * should be done in one of the ways as described in
291. * http://issues.ez.no/14093
292. *
293. * @param string $name The name of the element to add
294. * @return ezcFeedElement
295. */
296. public function add ( $name )
297. {
298. switch ( $name )
299. {
300. case 'author':
301. case 'contributor':
302. $element = new ezcFeedPersonElement ();
303. $this-> properties [$name][] = $element;
304. break;
306. case 'id':
307. $element = new ezcFeedIdElement ();
308. $this-> properties [$name] = $element;
309. break;
311. case 'category':
312. $element = new ezcFeedCategoryElement ();
313. $this-> properties [$name][] = $element;
314. break;
316. case 'title':
317. case 'description':
318. case 'comments':
319. case 'copyright':
320. case 'language':
321. $element = new ezcFeedTextElement ();
322. $this-> properties [$name] = $element;
323. break;
325. case 'content':
326. $element = new ezcFeedContentElement ();
327. $this-> properties [$name] = $element;
328. break;
330. case 'updated':
331. case 'published':
332. $element = new ezcFeedDateElement ();
333. $this-> properties [$name] = $element;
334. break;
336. case 'link':
337. $element = new ezcFeedLinkElement ();
338. $this-> properties [$name][] = $element;
339. break;
341. case 'enclosure':
342. $element = new ezcFeedEnclosureElement ();
343. $this-> properties [$name][] = $element;
344. break;
346. case 'source':
347. $element = new ezcFeedSourceElement ();
348. $this-> properties [$name] = $element;
349. break;
351. default:
352. throw new ezcFeedUnsupportedElementException ( $name );
353. }
355. return $element;
356. }
358. /**
359. * Adds a new module to this item and returns it.
360. *
361. * @param string $name The name of the module to add
362. * @return ezcFeedModule
363. */
364. public function addModule ( $name )
365. {
366. $this->$name = ezcFeedModule :: create ( $name, 'item' );
367. return $this->$name;
368. }
370. /**
371. * Returns true if the module $name is loaded, false otherwise.
372. *
373. * @param string $name The name of the module to check if loaded for this item
374. * @return bool
375. */
376. public function hasModule ( $name )
377. {
378. return isset( $this->modules[$name] );
379. }
381. /**
382. * Returns an array with all the modules defined for this feed item.
383. *
384. * @return array(ezcFeedModule)
385. */
386. public function getModules ()
387. {
388. return $this->modules;
389. }
390. }
391. ?>

Documentation generated by phpDocumentor 1.4.3