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

## Source for file source.php

Documentation is available at source.php

1. <?php
2. /**
3. * File containing the ezcFeedSourceElement 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 source element.
30. *
31. * @property string $source
32. * The name of the source feed (RSS2 only).
33. * @property string $url
34. * The url of the source feed (RSS2 only).
35. * @property array(ezcFeedAuthorElement) $author
36. * The authors from the source feed (ATOM only).
37. * @property ezcFeedCategoryElement $category
38. * The categories from the source feed (ATOM only).
39. * @property array(ezcFeedAuthorElement) $contributor
40. * The contributors from the source feed (ATOM only).
41. * @property ezcFeedTextElement $copyright
42. * The copyright information from the source feed (ATOM only).
43. * @property ezcFeedTextElement $description
44. * The description from the source feed (ATOM only).
45. * @property ezcFeedGeneratorElement $generator
46. * The generator information from the source feed (ATOM only).
47. * @property ezcFeedImageElement $icon
48. * The icon from the source feed (ATOM only).
49. * @property ezcFeedIdElement $id
50. * The id from the source feed (ATOM only).
51. * @property ezcFeedImageElement $image
52. * The image from the source feed (ATOM only).
53. * @property array(ezcFeedLinkElement) $link
54. * The links from the source feed (ATOM only).
55. * @property ezcFeedTextElement $title
56. * The title from the source feed (ATOM only).
57. * @property ezcFeedDateElement $updated
58. * The date and time of the last update from the source feed (ATOM only).
59. *
60. * @package Feed
61. * @version //autogentag//
62. */
63. class ezcFeedSourceElement extends ezcFeedElement
64. {
65. /**
66. * The name of the source feed (RSS2 only).
67. *
68. * @var string
69. */
70. public $source ;
72. /**
73. * The url of the source feed (RSS2 only).
74. *
75. * @var string
76. */
77. public $url ;
79. /**
80. * Sets the property $name to $value.
81. *
82. * @param string $name The property name
83. * @param mixed $value The property value
84. * @ignore
85. */
86. public function __set( $name, $value )
87. {
88. switch ( $name )
89. {
90. case 'title':
91. case 'description':
92. case 'copyright':
93. $element = new ezcFeedTextElement ();
94. $element->text = $value;
95. $this-> properties [$name] = $element;
96. break;
98. case 'author':
99. case 'contributor':
100. $element = new ezcFeedPersonElement ();
101. $element->name = $value;
102. $this-> properties [$name] = $element;
103. break;
105. case 'updated':
106. $element = new ezcFeedDateElement ();
107. $element->date = $value;
108. $this-> properties [$name] = $element;
109. break;
111. case 'generator':
112. $element = new ezcFeedGeneratorElement ();
113. $element->name = $value;
114. $this-> properties [$name] = $element;
115. break;
117. case 'image':
118. case 'icon':
119. $element = new ezcFeedImageElement ();
120. $element->link = $value;
121. $this-> properties [$name] = $element;
122. break;
124. case 'id':
125. $element = new ezcFeedIdElement ();
126. $element->id = $value;
127. $this-> properties [$name] = $element;
128. break;
130. case 'link':
131. $element = new ezcFeedLinkElement ();
132. $element->href = $value;
133. $this-> properties [$name] = $element;
134. break;
136. case 'category':
137. $element = new ezcFeedCategoryElement ();
138. $element->term = $value;
139. $this-> properties [$name] = $element;
140. break;
142. default:
143. parent::__set( $name, $value );
144. break;
145. }
146. }
148. /**
149. * Returns the value of property $name.
150. *
151. * @param string $name The property name
152. * @return mixed
153. * @ignore
154. */
155. public function __get( $name )
156. {
157. switch ( $name )
158. {
159. case 'title':
160. case 'description':
161. case 'copyright':
162. case 'author':
163. case 'contributor':
164. case 'updated':
165. case 'generator':
166. case 'image':
167. case 'icon':
168. case 'id':
169. case 'link':
170. case 'category':
171. if ( isset( $this-> properties [$name] ) )
172. {
173. return $this-> properties [$name];
174. }
175. break;
177. default:
178. return parent::__get( $name );
179. break;
180. }
181. }
183. /**
184. * Returns if the property $name is set.
185. *
186. * @param string $name The property name
187. * @return bool
188. * @ignore
189. */
190. public function __isset( $name )
191. {
192. switch ( $name )
193. {
194. case 'title':
195. case 'description':
196. case 'copyright':
197. case 'author':
198. case 'contributor':
199. case 'updated':
200. case 'generator':
201. case 'image':
202. case 'icon':
203. case 'id':
204. case 'link':
205. case 'category':
206. return isset( $this-> properties [$name] );
208. default:
209. return parent::__isset( $name );
210. }
211. }
213. /**
214. * Adds a new element with name $name to the source element and returns it.
215. *
216. * Example:
217. * <code>
218. * // $source is an ezcFeedSourceElement object
219. * $link = $source->add( 'link' );
220. * $link->href = 'http://ez.no/';
221. * </code>
222. *
223. * @param string $name The name of the element to add
224. * @return ezcFeedElement
225. */
226. public function add ( $name )
227. {
228. switch ( $name )
229. {
230. case 'author':
231. case 'contributor':
232. $element = new ezcFeedPersonElement ();
233. $this-> properties [$name][] = $element;
234. break;
236. case 'id':
237. $element = new ezcFeedIdElement ();
238. $this-> properties [$name] = $element;
239. break;
241. case 'category':
242. $element = new ezcFeedCategoryElement ();
243. $this-> properties [$name][] = $element;
244. break;
246. case 'title':
247. case 'description':
248. case 'copyright':
249. $element = new ezcFeedTextElement ();
250. $this-> properties [$name] = $element;
251. break;
253. case 'generator':
254. $element = new ezcFeedGeneratorElement ();
255. $this-> properties [$name] = $element;
256. break;
258. case 'image':
259. case 'icon':
260. $element = new ezcFeedImageElement ();
261. $this-> properties [$name] = $element;
262. break;
264. case 'updated':
265. $element = new ezcFeedDateElement ();
266. $this-> properties [$name] = $element;
267. break;
269. case 'link':
270. $element = new ezcFeedLinkElement ();
271. $this-> properties [$name][] = $element;
272. break;
274. default:
275. throw new ezcFeedUnsupportedElementException ( $name );
276. }
278. return $element;
279. }
281. /**
282. * Returns the source attribute.
283. *
284. * @return string
285. */
286. public function __toString ()
287. {
288. return $this-> source . '';
289. }
290. }
291. ?>

Documentation generated by phpDocumentor 1.4.3