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

## Source for file feed.php

Documentation is available at feed.php

1. <?php
2. /**
3. *
4. * Licensed to the Apache Software Foundation (ASF) under one
5. * or more contributor license agreements. See the NOTICE file
6. * distributed with this work for additional information
7. * regarding copyright ownership. The ASF licenses this file
8. * to you under the Apache License, Version 2.0 (the
9. * "License"); you may not use this file except in compliance
10. * with the License. You may obtain a copy of the License at
11. *
12. * http://www.apache.org/licenses/LICENSE-2.0
13. *
14. * Unless required by applicable law or agreed to in writing,
15. * software distributed under the License is distributed on an
16. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17. * KIND, either express or implied. See the License for the
18. * specific language governing permissions and limitations
19. * under the License.
20. *
21. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
22. * @version //autogentag//
23. * @filesource
24. * @package MvcFeedTiein
25. */
27. /**
28. * The view handler that uses XML feeds to render result objects.
29. *
30. * @package MvcFeedTiein
31. * @version //autogentag//
32. * @mainclass
33. */
34. class ezcMvcFeedViewHandler implements ezcMvcViewHandler
35. {
36. /**
37. * Contains the zone name.
38. *
39. * @var string
40. */
41. protected $zoneName ;
43. /**
44. * Contains the decorator.
45. *
46. * @var ezcMvcFeedDecorator
47. */
48. protected $decorator ;
50. /**
51. * Contains the result after process() has been called.
52. *
53. * @var mixed
54. */
55. protected $result ;
57. /**
58. * Contains the variables that will be available in the template.
59. *
60. * @var array(mixed)
61. */
62. protected $variables = array();
64. /**
65. * Contains the embedded feed object.
66. *
67. * @var ezcFeed
68. */
69. public $feed ;
71. /**
72. * Contains the embedded feed type.
73. *
74. * @var string
75. */
76. protected $feedType ;
78. /**
79. * Creates a new view handler, where $zoneName is the name of the block and
80. * $decorator is the object implementing decorating methods for the feed
81. * and feed items.
82. *
83. * @param string $zoneName
84. * @param ezcMvcFeedDecorator $decorator
85. */
86. public function __construct ( $zoneName, $decorator = null, $feedType = 'rss2' )
87. {
88. $this-> zoneName = $zoneName;
89. $this-> decorator = $decorator;
90. $this-> feed = new ezcFeed ;
91. $this-> feedType = $feedType;
92. }
94. /**
95. * Adds a variable to the template, which can then be used for rendering
96. * the view.
97. *
98. * @param string $name
99. * @param mixed $value
100. */
101. public function send ( $name, $value )
102. {
103. $this-> variables [$name] = $value;
104. }
106. /**
107. * Processes the template with the variables added by the send() method.
108. * The result of this action should be retrievable through the getResult() method.
109. *
110. * @param mixed $last
111. */
112. public function process ( $last )
113. {
114. $feed = new ezcFeed ;
115. $this-> decorator ->decorateFeed( $feed );
117. foreach ( $this-> variables [$this-> decorator ->getItemVariable()] as $itemData )
118. {
119. $item = $feed->add( 'item' );
120. $this-> decorator ->decorateFeedItem( $item, $itemData );
121. }
122. $this-> result = $feed->generate( $this-> feedType );
123. }
125. /**
126. * Returns the value of the property $name.
127. *
128. * @throws ezcBasePropertyNotFoundException if the property does not exist.
129. * @param string $name
130. * @return mixed
131. * @ignore
132. */
133. public function __get( $name )
134. {
135. return $this-> variables [$name];
136. }
138. /**
139. * Returns true if the property $name is set, otherwise false.
140. *
141. * @param string $name
142. * @return bool
143. * @ignore
144. */
145. public function __isset( $name )
146. {
147. return array_key_exists ( $name, $this-> variables );
148. }
150. /**
151. * Returns the name of the template, as set in the constructor.
152. *
153. * @return string
154. */
155. public function getName ()
156. {
157. return $this-> zoneName ;
158. }
160. /**
161. * Returns the result of the process() method.
162. *
163. * @return mixed
164. */
165. public function getResult ()
166. {
167. return $this-> result ;
168. }
169. }
170. ?>

Documentation generated by phpDocumentor 1.4.3