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 Media |
---|
19 | * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
---|
20 | * @license http://framework.zend.com/license/new-bsd New BSD License |
---|
21 | * @version $Id: MediaContent.php 24594 2012-01-05 21:27:01Z matthew $ |
---|
22 | */ |
---|
23 | |
---|
24 | /** |
---|
25 | * @see Zend_Gdata_Extension |
---|
26 | */ |
---|
27 | require_once 'Zend/Gdata/Extension.php'; |
---|
28 | |
---|
29 | /** |
---|
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. |
---|
34 | * |
---|
35 | * @category Zend |
---|
36 | * @package Zend_Gdata |
---|
37 | * @subpackage Media |
---|
38 | * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
---|
39 | * @license http://framework.zend.com/license/new-bsd New BSD License |
---|
40 | */ |
---|
41 | class Zend_Gdata_Media_Extension_MediaContent extends Zend_Gdata_Extension |
---|
42 | { |
---|
43 | protected $_rootElement = 'content'; |
---|
44 | protected $_rootNamespace = 'media'; |
---|
45 | |
---|
46 | /** |
---|
47 | * @var string |
---|
48 | */ |
---|
49 | protected $_url = null; |
---|
50 | |
---|
51 | /** |
---|
52 | * @var int |
---|
53 | */ |
---|
54 | protected $_fileSize = null; |
---|
55 | |
---|
56 | /** |
---|
57 | * @var string |
---|
58 | */ |
---|
59 | protected $_type = null; |
---|
60 | |
---|
61 | /** |
---|
62 | * @var string |
---|
63 | */ |
---|
64 | protected $_medium = null; |
---|
65 | |
---|
66 | /** |
---|
67 | * @var string |
---|
68 | */ |
---|
69 | protected $_isDefault = null; |
---|
70 | |
---|
71 | /** |
---|
72 | * @var string |
---|
73 | */ |
---|
74 | protected $_expression = null; |
---|
75 | |
---|
76 | /** |
---|
77 | * @var int |
---|
78 | */ |
---|
79 | protected $_bitrate = null; |
---|
80 | |
---|
81 | /** |
---|
82 | * @var int |
---|
83 | */ |
---|
84 | protected $_framerate = null; |
---|
85 | |
---|
86 | /** |
---|
87 | * @var int |
---|
88 | */ |
---|
89 | protected $_samplingrate = null; |
---|
90 | |
---|
91 | /** |
---|
92 | * @var int |
---|
93 | */ |
---|
94 | protected $_channels = null; |
---|
95 | |
---|
96 | /** |
---|
97 | * @var int |
---|
98 | */ |
---|
99 | protected $_duration = null; |
---|
100 | |
---|
101 | /** |
---|
102 | * @var int |
---|
103 | */ |
---|
104 | protected $_height = null; |
---|
105 | |
---|
106 | /** |
---|
107 | * @var int |
---|
108 | */ |
---|
109 | protected $_width = null; |
---|
110 | |
---|
111 | /** |
---|
112 | * @var string |
---|
113 | */ |
---|
114 | protected $_lang = null; |
---|
115 | |
---|
116 | /** |
---|
117 | * Creates an individual MediaContent object. |
---|
118 | */ |
---|
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, |
---|
123 | $lang = null) |
---|
124 | { |
---|
125 | $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces); |
---|
126 | parent::__construct(); |
---|
127 | $this->_url = $url; |
---|
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; |
---|
141 | } |
---|
142 | |
---|
143 | |
---|
144 | /** |
---|
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. |
---|
149 | * |
---|
150 | * @param DOMDocument $doc The DOMDocument used to construct DOMElements |
---|
151 | * @return DOMElement The DOMElement representing this element and all |
---|
152 | * child properties. |
---|
153 | */ |
---|
154 | public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) |
---|
155 | { |
---|
156 | $element = parent::getDOM($doc, $majorVersion, $minorVersion); |
---|
157 | if ($this->_url !== null) { |
---|
158 | $element->setAttribute('url', $this->_url); |
---|
159 | } |
---|
160 | if ($this->_fileSize !== null) { |
---|
161 | $element->setAttribute('fileSize', $this->_fileSize); |
---|
162 | } |
---|
163 | if ($this->_type !== null) { |
---|
164 | $element->setAttribute('type', $this->_type); |
---|
165 | } |
---|
166 | if ($this->_medium !== null) { |
---|
167 | $element->setAttribute('medium', $this->_medium); |
---|
168 | } |
---|
169 | if ($this->_isDefault !== null) { |
---|
170 | $element->setAttribute('isDefault', $this->_isDefault); |
---|
171 | } |
---|
172 | if ($this->_expression !== null) { |
---|
173 | $element->setAttribute('expression', $this->_expression); |
---|
174 | } |
---|
175 | if ($this->_bitrate !== null) { |
---|
176 | $element->setAttribute('bitrate', $this->_bitrate); |
---|
177 | } |
---|
178 | if ($this->_framerate !== null) { |
---|
179 | $element->setAttribute('framerate', $this->_framerate); |
---|
180 | } |
---|
181 | if ($this->_samplingrate !== null) { |
---|
182 | $element->setAttribute('samplingrate', $this->_samplingrate); |
---|
183 | } |
---|
184 | if ($this->_channels !== null) { |
---|
185 | $element->setAttribute('channels', $this->_channels); |
---|
186 | } |
---|
187 | if ($this->_duration !== null) { |
---|
188 | $element->setAttribute('duration', $this->_duration); |
---|
189 | } |
---|
190 | if ($this->_height !== null) { |
---|
191 | $element->setAttribute('height', $this->_height); |
---|
192 | } |
---|
193 | if ($this->_width !== null) { |
---|
194 | $element->setAttribute('width', $this->_width); |
---|
195 | } |
---|
196 | if ($this->_lang !== null) { |
---|
197 | $element->setAttribute('lang', $this->_lang); |
---|
198 | } |
---|
199 | return $element; |
---|
200 | } |
---|
201 | |
---|
202 | /** |
---|
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. |
---|
206 | * |
---|
207 | * @param DOMNode $attribute The DOMNode attribute needed to be handled |
---|
208 | */ |
---|
209 | protected function takeAttributeFromDOM($attribute) |
---|
210 | { |
---|
211 | switch ($attribute->localName) { |
---|
212 | case 'url': |
---|
213 | $this->_url = $attribute->nodeValue; |
---|
214 | break; |
---|
215 | case 'fileSize': |
---|
216 | $this->_fileSize = $attribute->nodeValue; |
---|
217 | break; |
---|
218 | case 'type': |
---|
219 | $this->_type = $attribute->nodeValue; |
---|
220 | break; |
---|
221 | case 'medium': |
---|
222 | $this->_medium = $attribute->nodeValue; |
---|
223 | break; |
---|
224 | case 'isDefault': |
---|
225 | $this->_isDefault = $attribute->nodeValue; |
---|
226 | break; |
---|
227 | case 'expression': |
---|
228 | $this->_expression = $attribute->nodeValue; |
---|
229 | break; |
---|
230 | case 'bitrate': |
---|
231 | $this->_bitrate = $attribute->nodeValue; |
---|
232 | break; |
---|
233 | case 'framerate': |
---|
234 | $this->_framerate = $attribute->nodeValue; |
---|
235 | break; |
---|
236 | case 'samplingrate': |
---|
237 | $this->_samplingrate = $attribute->nodeValue; |
---|
238 | break; |
---|
239 | case 'channels': |
---|
240 | $this->_channels = $attribute->nodeValue; |
---|
241 | break; |
---|
242 | case 'duration': |
---|
243 | $this->_duration = $attribute->nodeValue; |
---|
244 | break; |
---|
245 | case 'height': |
---|
246 | $this->_height = $attribute->nodeValue; |
---|
247 | break; |
---|
248 | case 'width': |
---|
249 | $this->_width = $attribute->nodeValue; |
---|
250 | break; |
---|
251 | case 'lang': |
---|
252 | $this->_lang = $attribute->nodeValue; |
---|
253 | break; |
---|
254 | default: |
---|
255 | parent::takeAttributeFromDOM($attribute); |
---|
256 | } |
---|
257 | } |
---|
258 | |
---|
259 | /** |
---|
260 | * Returns the URL representing this MediaContent object |
---|
261 | * |
---|
262 | * @return string The URL representing this MediaContent object. |
---|
263 | */ |
---|
264 | public function __toString() |
---|
265 | { |
---|
266 | return $this->getUrl(); |
---|
267 | } |
---|
268 | |
---|
269 | /** |
---|
270 | * @return string The direct URL to the media object |
---|
271 | */ |
---|
272 | public function getUrl() |
---|
273 | { |
---|
274 | return $this->_url; |
---|
275 | } |
---|
276 | |
---|
277 | /** |
---|
278 | * @param string $value The direct URL to the media object |
---|
279 | * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface |
---|
280 | */ |
---|
281 | public function setUrl($value) |
---|
282 | { |
---|
283 | $this->_url = $value; |
---|
284 | return $this; |
---|
285 | } |
---|
286 | |
---|
287 | /** |
---|
288 | * @return int The size of the media in bytes |
---|
289 | */ |
---|
290 | public function getFileSize() |
---|
291 | { |
---|
292 | return $this->_fileSize; |
---|
293 | } |
---|
294 | |
---|
295 | /** |
---|
296 | * @param int $value |
---|
297 | * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface |
---|
298 | */ |
---|
299 | public function setFileSize($value) |
---|
300 | { |
---|
301 | $this->_fileSize = $value; |
---|
302 | return $this; |
---|
303 | } |
---|
304 | |
---|
305 | /** |
---|
306 | * @return string |
---|
307 | */ |
---|
308 | public function getType() |
---|
309 | { |
---|
310 | return $this->_type; |
---|
311 | } |
---|
312 | |
---|
313 | /** |
---|
314 | * @param string $value |
---|
315 | * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface |
---|
316 | */ |
---|
317 | public function setType($value) |
---|
318 | { |
---|
319 | $this->_type = $value; |
---|
320 | return $this; |
---|
321 | } |
---|
322 | |
---|
323 | /** |
---|
324 | * @return string |
---|
325 | */ |
---|
326 | public function getMedium() |
---|
327 | { |
---|
328 | return $this->_medium; |
---|
329 | } |
---|
330 | |
---|
331 | /** |
---|
332 | * @param string $value |
---|
333 | * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface |
---|
334 | */ |
---|
335 | public function setMedium($value) |
---|
336 | { |
---|
337 | $this->_medium = $value; |
---|
338 | return $this; |
---|
339 | } |
---|
340 | |
---|
341 | /** |
---|
342 | * @return bool |
---|
343 | */ |
---|
344 | public function getIsDefault() |
---|
345 | { |
---|
346 | return $this->_isDefault; |
---|
347 | } |
---|
348 | |
---|
349 | /** |
---|
350 | * @param bool $value |
---|
351 | * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface |
---|
352 | */ |
---|
353 | public function setIsDefault($value) |
---|
354 | { |
---|
355 | $this->_isDefault = $value; |
---|
356 | return $this; |
---|
357 | } |
---|
358 | |
---|
359 | /** |
---|
360 | * @return string |
---|
361 | */ |
---|
362 | public function getExpression() |
---|
363 | { |
---|
364 | return $this->_expression; |
---|
365 | } |
---|
366 | |
---|
367 | /** |
---|
368 | * @param string |
---|
369 | * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface |
---|
370 | */ |
---|
371 | public function setExpression($value) |
---|
372 | { |
---|
373 | $this->_expression = $value; |
---|
374 | return $this; |
---|
375 | } |
---|
376 | |
---|
377 | /** |
---|
378 | * @return int |
---|
379 | */ |
---|
380 | public function getBitrate() |
---|
381 | { |
---|
382 | return $this->_bitrate; |
---|
383 | } |
---|
384 | |
---|
385 | /** |
---|
386 | * @param int |
---|
387 | * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface |
---|
388 | */ |
---|
389 | public function setBitrate($value) |
---|
390 | { |
---|
391 | $this->_bitrate = $value; |
---|
392 | return $this; |
---|
393 | } |
---|
394 | |
---|
395 | /** |
---|
396 | * @return int |
---|
397 | */ |
---|
398 | public function getFramerate() |
---|
399 | { |
---|
400 | return $this->_framerate; |
---|
401 | } |
---|
402 | |
---|
403 | /** |
---|
404 | * @param int |
---|
405 | * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface |
---|
406 | */ |
---|
407 | public function setFramerate($value) |
---|
408 | { |
---|
409 | $this->_framerate = $value; |
---|
410 | return $this; |
---|
411 | } |
---|
412 | |
---|
413 | /** |
---|
414 | * @return int |
---|
415 | */ |
---|
416 | public function getSamplingrate() |
---|
417 | { |
---|
418 | return $this->_samplingrate; |
---|
419 | } |
---|
420 | |
---|
421 | /** |
---|
422 | * @param int |
---|
423 | * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface |
---|
424 | */ |
---|
425 | public function setSamplingrate($value) |
---|
426 | { |
---|
427 | $this->_samplingrate = $value; |
---|
428 | return $this; |
---|
429 | } |
---|
430 | |
---|
431 | /** |
---|
432 | * @return int |
---|
433 | */ |
---|
434 | public function getChannels() |
---|
435 | { |
---|
436 | return $this->_channels; |
---|
437 | } |
---|
438 | |
---|
439 | /** |
---|
440 | * @param int |
---|
441 | * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface |
---|
442 | */ |
---|
443 | public function setChannels($value) |
---|
444 | { |
---|
445 | $this->_channels = $value; |
---|
446 | return $this; |
---|
447 | } |
---|
448 | |
---|
449 | /** |
---|
450 | * @return int |
---|
451 | */ |
---|
452 | public function getDuration() |
---|
453 | { |
---|
454 | return $this->_duration; |
---|
455 | } |
---|
456 | |
---|
457 | /** |
---|
458 | * |
---|
459 | * @param int |
---|
460 | * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface |
---|
461 | */ |
---|
462 | public function setDuration($value) |
---|
463 | { |
---|
464 | $this->_duration = $value; |
---|
465 | return $this; |
---|
466 | } |
---|
467 | |
---|
468 | /** |
---|
469 | * @return int |
---|
470 | */ |
---|
471 | public function getHeight() |
---|
472 | { |
---|
473 | return $this->_height; |
---|
474 | } |
---|
475 | |
---|
476 | /** |
---|
477 | * @param int |
---|
478 | * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface |
---|
479 | */ |
---|
480 | public function setHeight($value) |
---|
481 | { |
---|
482 | $this->_height = $value; |
---|
483 | return $this; |
---|
484 | } |
---|
485 | |
---|
486 | /** |
---|
487 | * @return int |
---|
488 | */ |
---|
489 | public function getWidth() |
---|
490 | { |
---|
491 | return $this->_width; |
---|
492 | } |
---|
493 | |
---|
494 | /** |
---|
495 | * @param int |
---|
496 | * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface |
---|
497 | */ |
---|
498 | public function setWidth($value) |
---|
499 | { |
---|
500 | $this->_width = $value; |
---|
501 | return $this; |
---|
502 | } |
---|
503 | |
---|
504 | /** |
---|
505 | * @return string |
---|
506 | */ |
---|
507 | public function getLang() |
---|
508 | { |
---|
509 | return $this->_lang; |
---|
510 | } |
---|
511 | |
---|
512 | /** |
---|
513 | * @param string |
---|
514 | * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface |
---|
515 | */ |
---|
516 | public function setLang($value) |
---|
517 | { |
---|
518 | $this->_lang = $value; |
---|
519 | return $this; |
---|
520 | } |
---|
521 | |
---|
522 | } |
---|