source: trunk/www.guidonia.net/wp/wp-content/plugins/webtv/Drivers/Zend/Gdata/Extension/Rating.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 6.7 KB
Line 
1<?php
2
3/**
4 * Zend Framework
5 *
6 * LICENSE
7 *
8 * This source file is subject to the new BSD license that is bundled
9 * with this package in the file LICENSE.txt.
10 * It is also available through the world-wide-web at this URL:
11 * http://framework.zend.com/license/new-bsd
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@zend.com so we can send you a copy immediately.
15 *
16 * @category Zend
17 * @package Zend_Gdata
18 * @subpackage Gdata
19 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
21 */
22
23/**
24 * @see Zend_Gdata_Extension
25 */
26require_once 'Zend/Gdata/Extension.php';
27
28/**
29 * Implements the gd:rating element
30 *
31 *
32 * @category Zend
33 * @package Zend_Gdata
34 * @subpackage Gdata
35 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
36 * @license http://framework.zend.com/license/new-bsd New BSD License
37 */
38class Zend_Gdata_Extension_Rating extends Zend_Gdata_Extension
39{
40
41 protected $_rootElement = 'rating';
42 protected $_min = null;
43 protected $_max = null;
44 protected $_numRaters = null;
45 protected $_average = null;
46 protected $_value = null;
47
48 /**
49 * Constructs a new Zend_Gdata_Extension_Rating object.
50 *
51 * @param integer $average (optional) Average rating.
52 * @param integer $min (optional) Minimum rating.
53 * @param integer $max (optional) Maximum rating.
54 * @param integer $numRaters (optional) Number of raters.
55 * @param integer $value (optional) The value of the rating.
56 */
57 public function __construct($average = null, $min = null,
58 $max = null, $numRaters = null, $value = null)
59 {
60 parent::__construct();
61 $this->_average = $average;
62 $this->_min = $min;
63 $this->_max = $max;
64 $this->_numRaters = $numRaters;
65 $this->_value = $value;
66 }
67
68 /**
69 * Retrieves a DOMElement which corresponds to this element and all
70 * child properties. This is used to build an entry back into a DOM
71 * and eventually XML text for sending to the server upon updates, or
72 * for application storage/persistence.
73 *
74 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
75 * @return DOMElement The DOMElement representing this element and all
76 * child properties.
77 */
78 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
79 {
80 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
81 if ($this->_min !== null) {
82 $element->setAttribute('min', $this->_min);
83 }
84 if ($this->_max !== null) {
85 $element->setAttribute('max', $this->_max);
86 }
87 if ($this->_numRaters !== null) {
88 $element->setAttribute('numRaters', $this->_numRaters);
89 }
90 if ($this->_average !== null) {
91 $element->setAttribute('average', $this->_average);
92 }
93 if ($this->_value !== null) {
94 $element->setAttribute('value', $this->_value);
95 }
96
97 return $element;
98 }
99
100 /**
101 * Given a DOMNode representing an attribute, tries to map the data into
102 * instance members. If no mapping is defined, the name and value are
103 * stored in an array.
104 *
105 * @param DOMNode $attribute The DOMNode attribute needed to be handled
106 */
107 protected function takeAttributeFromDOM($attribute)
108 {
109 switch ($attribute->localName) {
110 case 'min':
111 $this->_min = $attribute->nodeValue;
112 break;
113 case 'max':
114 $this->_max = $attribute->nodeValue;
115 break;
116 case 'numRaters':
117 $this->_numRaters = $attribute->nodeValue;
118 break;
119 case 'average':
120 $this->_average = $attribute->nodeValue;
121 break;
122 case 'value':
123 $this->_value = $attribute->nodeValue;
124 default:
125 parent::takeAttributeFromDOM($attribute);
126 }
127 }
128
129 /**
130 * Get the value for this element's min attribute.
131 *
132 * @return integer The requested attribute.
133 */
134 public function getMin()
135 {
136 return $this->_min;
137 }
138
139 /**
140 * Set the value for this element's min attribute.
141 *
142 * @param bool $value The desired value for this attribute.
143 * @return Zend_Gdata_Extension_Rating The element being modified.
144 */
145 public function setMin($value)
146 {
147 $this->_min = $value;
148 return $this;
149 }
150
151 /**
152 * Get the value for this element's numRaters attribute.
153 *
154 * @return integer The requested attribute.
155 */
156 public function getNumRaters()
157 {
158 return $this->_numRaters;
159 }
160
161 /**
162 * Set the value for this element's numRaters attribute.
163 *
164 * @param bool $value The desired value for this attribute.
165 * @return Zend_Gdata_Extension_Rating The element being modified.
166 */
167 public function setNumRaters($value)
168 {
169 $this->_numRaters = $value;
170 return $this;
171 }
172
173 /**
174 * Get the value for this element's average attribute.
175 *
176 * @return integer The requested attribute.
177 */
178 public function getAverage()
179 {
180 return $this->_average;
181 }
182
183 /**
184 * Set the value for this element's average attribute.
185 *
186 * @param bool $value The desired value for this attribute.
187 * @return Zend_Gdata_Extension_Rating The element being modified.
188 */
189 public function setAverage($value)
190 {
191 $this->_average = $value;
192 return $this;
193 }
194
195 /**
196 * Get the value for this element's max attribute.
197 *
198 * @return integer The requested attribute.
199 */
200 public function getMax()
201 {
202 return $this->_max;
203 }
204
205 /**
206 * Set the value for this element's max attribute.
207 *
208 * @param bool $value The desired value for this attribute.
209 * @return Zend_Gdata_Extension_Rating The element being modified.
210 */
211 public function setMax($value)
212 {
213 $this->_max = $value;
214 return $this;
215 }
216
217 /**
218 * Get the value for this element's value attribute.
219 *
220 * @return integer The requested attribute.
221 */
222 public function getValue()
223 {
224 return $this->_value;
225 }
226
227 /**
228 * Set the value for this element's value attribute.
229 *
230 * @param bool $value The desired value for this attribute.
231 * @return Zend_Gdata_Extension_Rating The element being modified.
232 */
233 public function setValue($value)
234 {
235 $this->_value = $value;
236 return $this;
237 }
238
239}
Note: See TracBrowser for help on using the repository browser.