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

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 3.6 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 YouTube
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_Media_Extension_MediaContent
25 */
26require_once 'Zend/Gdata/Media/Extension/MediaContent.php';
27
28/**
29 * Represents the media:content element of Media RSS.
30 * Represents media objects. Multiple media objects representing
31 * the same content can be represented using a
32 * media:group (Zend_Gdata_Media_Extension_MediaGroup) element.
33 *
34 * @category Zend
35 * @package Zend_Gdata
36 * @subpackage YouTube
37 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
38 * @license http://framework.zend.com/license/new-bsd New BSD License
39 */
40class Zend_Gdata_YouTube_Extension_MediaContent extends Zend_Gdata_Media_Extension_MediaContent
41{
42 protected $_rootElement = 'content';
43 protected $_rootNamespace = 'media';
44
45 /*
46 * Format of the video
47 * Optional.
48 *
49 * @var int
50 */
51 protected $_format = null;
52
53
54 function __construct() {
55 $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
56 parent::__construct();
57 }
58
59 /**
60 * Retrieves a DOMElement which corresponds to this element and all
61 * child properties. This is used to build an entry back into a DOM
62 * and eventually XML text for sending to the server upon updates, or
63 * for application storage/persistence.
64 *
65 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
66 * @return DOMElement The DOMElement representing this element and all
67 * child properties.
68 */
69 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
70 {
71 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
72 if ($this->_format!= null) {
73 $element->setAttributeNS($this->lookupNamespace('yt'), 'yt:format', $this->_format);
74 }
75 return $element;
76 }
77
78 /**
79 * Given a DOMNode representing an attribute, tries to map the data into
80 * instance members. If no mapping is defined, the name and value are
81 * stored in an array.
82 *
83 * @param DOMNode $attribute The DOMNode attribute needed to be handled
84 */
85 protected function takeAttributeFromDOM($attribute)
86 {
87 $absoluteAttrName = $attribute->namespaceURI . ':' . $attribute->localName;
88 if ($absoluteAttrName == $this->lookupNamespace('yt') . ':' . 'format') {
89 $this->_format = $attribute->nodeValue;
90 } else {
91 parent::takeAttributeFromDOM($attribute);
92 }
93 }
94
95 /**
96 * Returns the format of the media
97 * Optional.
98 *
99 * @return int The format of the media
100 */
101 public function getFormat()
102 {
103 return $this->_format;
104 }
105
106 /**
107 * Sets the format of the media
108 *
109 * @param int $value Format of the media
110 * @return Zend_Gdata_YouTube_Extension_MediaContent Provides a fluent interface
111 *
112 */
113 public function setFormat($value)
114 {
115 $this->_format = $value;
116 return $this;
117 }
118
119}
Note: See TracBrowser for help on using the repository browser.