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.
19 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
25 * @see Zend_Gdata_Extension
27 require_once 'Zend/Gdata/Extension.php';
30 * Represents the media:content element of Media RSS.
31 * Represents media objects. Multiple media objects representing
32 * the same content can be represented using a
33 * media:group (Zend_Gdata_Media_Extension_MediaGroup) element.
38 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
39 * @license http://framework.zend.com/license/new-bsd New BSD License
41 class Zend_Gdata_Media_Extension_MediaContent extends Zend_Gdata_Extension
43 protected $_rootElement = 'content';
44 protected $_rootNamespace = 'media';
49 protected $_url = null;
54 protected $_fileSize = null;
59 protected $_type = null;
64 protected $_medium = null;
69 protected $_isDefault = null;
74 protected $_expression = null;
79 protected $_bitrate = null;
84 protected $_framerate = null;
89 protected $_samplingrate = null;
94 protected $_channels = null;
99 protected $_duration = null;
104 protected $_height = null;
109 protected $_width = null;
114 protected $_lang = null;
117 * Creates an individual MediaContent object.
119 public function __construct($url = null, $fileSize = null, $type = null,
120 $medium = null, $isDefault = null, $expression = null,
121 $bitrate = null, $framerate = null, $samplingrate = null,
122 $channels = null, $duration = null, $height = null, $width = null,
125 $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
126 parent::__construct();
128 $this->_fileSize = $fileSize;
129 $this->_type = $type;
130 $this->_medium = $medium;
131 $this->_isDefault = $isDefault;
132 $this->_expression = $expression;
133 $this->_bitrate = $bitrate;
134 $this->_framerate = $framerate;
135 $this->_samplingrate = $samplingrate;
136 $this->_channels = $channels;
137 $this->_duration = $duration;
138 $this->_height = $height;
139 $this->_width = $width;
140 $this->_lang = $lang;
145 * Retrieves a DOMElement which corresponds to this element and all
146 * child properties. This is used to build an entry back into a DOM
147 * and eventually XML text for sending to the server upon updates, or
148 * for application storage/persistence.
150 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
151 * @return DOMElement The DOMElement representing this element and all
154 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
156 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
157 if ($this->_url !== null) {
158 $element->setAttribute('url', $this->_url);
160 if ($this->_fileSize !== null) {
161 $element->setAttribute('fileSize', $this->_fileSize);
163 if ($this->_type !== null) {
164 $element->setAttribute('type', $this->_type);
166 if ($this->_medium !== null) {
167 $element->setAttribute('medium', $this->_medium);
169 if ($this->_isDefault !== null) {
170 $element->setAttribute('isDefault', $this->_isDefault);
172 if ($this->_expression !== null) {
173 $element->setAttribute('expression', $this->_expression);
175 if ($this->_bitrate !== null) {
176 $element->setAttribute('bitrate', $this->_bitrate);
178 if ($this->_framerate !== null) {
179 $element->setAttribute('framerate', $this->_framerate);
181 if ($this->_samplingrate !== null) {
182 $element->setAttribute('samplingrate', $this->_samplingrate);
184 if ($this->_channels !== null) {
185 $element->setAttribute('channels', $this->_channels);
187 if ($this->_duration !== null) {
188 $element->setAttribute('duration', $this->_duration);
190 if ($this->_height !== null) {
191 $element->setAttribute('height', $this->_height);
193 if ($this->_width !== null) {
194 $element->setAttribute('width', $this->_width);
196 if ($this->_lang !== null) {
197 $element->setAttribute('lang', $this->_lang);
203 * Given a DOMNode representing an attribute, tries to map the data into
204 * instance members. If no mapping is defined, the name and value are
205 * stored in an array.
207 * @param DOMNode $attribute The DOMNode attribute needed to be handled
209 protected function takeAttributeFromDOM($attribute)
211 switch ($attribute->localName) {
213 $this->_url = $attribute->nodeValue;
216 $this->_fileSize = $attribute->nodeValue;
219 $this->_type = $attribute->nodeValue;
222 $this->_medium = $attribute->nodeValue;
225 $this->_isDefault = $attribute->nodeValue;
228 $this->_expression = $attribute->nodeValue;
231 $this->_bitrate = $attribute->nodeValue;
234 $this->_framerate = $attribute->nodeValue;
237 $this->_samplingrate = $attribute->nodeValue;
240 $this->_channels = $attribute->nodeValue;
243 $this->_duration = $attribute->nodeValue;
246 $this->_height = $attribute->nodeValue;
249 $this->_width = $attribute->nodeValue;
252 $this->_lang = $attribute->nodeValue;
255 parent::takeAttributeFromDOM($attribute);
260 * Returns the URL representing this MediaContent object
262 * @return string The URL representing this MediaContent object.
264 public function __toString()
266 return $this->getUrl();
270 * @return string The direct URL to the media object
272 public function getUrl()
278 * @param string $value The direct URL to the media object
279 * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
281 public function setUrl($value)
283 $this->_url = $value;
288 * @return int The size of the media in bytes
290 public function getFileSize()
292 return $this->_fileSize;
297 * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
299 public function setFileSize($value)
301 $this->_fileSize = $value;
308 public function getType()
314 * @param string $value
315 * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
317 public function setType($value)
319 $this->_type = $value;
326 public function getMedium()
328 return $this->_medium;
332 * @param string $value
333 * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
335 public function setMedium($value)
337 $this->_medium = $value;
344 public function getIsDefault()
346 return $this->_isDefault;
351 * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
353 public function setIsDefault($value)
355 $this->_isDefault = $value;
362 public function getExpression()
364 return $this->_expression;
369 * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
371 public function setExpression($value)
373 $this->_expression = $value;
380 public function getBitrate()
382 return $this->_bitrate;
387 * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
389 public function setBitrate($value)
391 $this->_bitrate = $value;
398 public function getFramerate()
400 return $this->_framerate;
405 * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
407 public function setFramerate($value)
409 $this->_framerate = $value;
416 public function getSamplingrate()
418 return $this->_samplingrate;
423 * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
425 public function setSamplingrate($value)
427 $this->_samplingrate = $value;
434 public function getChannels()
436 return $this->_channels;
441 * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
443 public function setChannels($value)
445 $this->_channels = $value;
452 public function getDuration()
454 return $this->_duration;
460 * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
462 public function setDuration($value)
464 $this->_duration = $value;
471 public function getHeight()
473 return $this->_height;
478 * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
480 public function setHeight($value)
482 $this->_height = $value;
489 public function getWidth()
491 return $this->_width;
496 * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
498 public function setWidth($value)
500 $this->_width = $value;
507 public function getLang()
514 * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
516 public function setLang($value)
518 $this->_lang = $value;