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-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_App_Extension
|
---|
25 | */
|
---|
26 | require_once 'Zend/Gdata/App/Extension.php';
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Represents the YouTube specific media:credit element
|
---|
30 | *
|
---|
31 | * @category Zend
|
---|
32 | * @package Zend_Gdata
|
---|
33 | * @subpackage Media
|
---|
34 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
35 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
36 | */
|
---|
37 | class Zend_Gdata_YouTube_Extension_MediaCredit extends Zend_Gdata_Extension
|
---|
38 | {
|
---|
39 |
|
---|
40 | protected $_rootElement = 'credit';
|
---|
41 | protected $_rootNamespace = 'media';
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * @var string
|
---|
45 | */
|
---|
46 | protected $_role = null;
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * @var string
|
---|
50 | */
|
---|
51 | protected $_scheme = null;
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * Represents the value of the yt:type attribute.
|
---|
55 | *
|
---|
56 | * Set to 'partner' if the uploader of this video is a YouTube
|
---|
57 | * partner.
|
---|
58 | *
|
---|
59 | * @var string
|
---|
60 | */
|
---|
61 | protected $_yttype = null;
|
---|
62 |
|
---|
63 | /**
|
---|
64 | * Creates an individual MediaCredit object.
|
---|
65 | *
|
---|
66 | * @param string $text
|
---|
67 | * @param string $role
|
---|
68 | * @param string $scheme
|
---|
69 | */
|
---|
70 | public function __construct($text = null, $role = null, $scheme = null,
|
---|
71 | $yttype = null)
|
---|
72 | {
|
---|
73 | $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
|
---|
74 | parent::__construct();
|
---|
75 | $this->_text = $text;
|
---|
76 | $this->_role = $role;
|
---|
77 | $this->_scheme = $scheme;
|
---|
78 | $this->_yttype = $yttype;
|
---|
79 | }
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * Retrieves a DOMElement which corresponds to this element and all
|
---|
83 | * child properties. This is used to build an entry back into a DOM
|
---|
84 | * and eventually XML text for sending to the server upon updates, or
|
---|
85 | * for application storage/persistence.
|
---|
86 | *
|
---|
87 | * @param DOMDocument $doc The DOMDocument used to construct DOMElements
|
---|
88 | * @return DOMElement The DOMElement representing this element and all
|
---|
89 | * child properties.
|
---|
90 | */
|
---|
91 | public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
|
---|
92 | {
|
---|
93 | $element = parent::getDOM($doc, $majorVersion, $minorVersion);
|
---|
94 | if ($this->_role !== null) {
|
---|
95 | $element->setAttribute('role', $this->_role);
|
---|
96 | }
|
---|
97 | if ($this->_scheme !== null) {
|
---|
98 | $element->setAttribute('scheme', $this->_scheme);
|
---|
99 | }
|
---|
100 | if ($this->_yttype !== null) {
|
---|
101 | $element->setAttributeNS('http://gdata.youtube.com/schemas/2007',
|
---|
102 | 'yt:type', $this->_yttype);
|
---|
103 | }
|
---|
104 | return $element;
|
---|
105 | }
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * Given a DOMNode representing an attribute, tries to map the data into
|
---|
109 | * instance members. If no mapping is defined, the name and value are
|
---|
110 | * stored in an array.
|
---|
111 | *
|
---|
112 | * @param DOMNode $attribute The DOMNode attribute needed to be handled
|
---|
113 | */
|
---|
114 | protected function takeAttributeFromDOM($attribute)
|
---|
115 | {
|
---|
116 | switch ($attribute->localName) {
|
---|
117 | case 'role':
|
---|
118 | $this->_role = $attribute->nodeValue;
|
---|
119 | break;
|
---|
120 | case 'scheme':
|
---|
121 | $this->_scheme = $attribute->nodeValue;
|
---|
122 | break;
|
---|
123 | case 'type':
|
---|
124 | $this->_yttype = $attribute->nodeValue;
|
---|
125 | break;
|
---|
126 | default:
|
---|
127 | parent::takeAttributeFromDOM($attribute);
|
---|
128 | }
|
---|
129 | }
|
---|
130 |
|
---|
131 | /**
|
---|
132 | * @return string
|
---|
133 | */
|
---|
134 | public function getRole()
|
---|
135 | {
|
---|
136 | return $this->_role;
|
---|
137 | }
|
---|
138 |
|
---|
139 | /**
|
---|
140 | * @param string $value
|
---|
141 | * @return Zend_Gdata_Media_Extension_MediaCredit Provides a fluent
|
---|
142 | * interface
|
---|
143 | */
|
---|
144 | public function setRole($value)
|
---|
145 | {
|
---|
146 | $this->_role = $value;
|
---|
147 | return $this;
|
---|
148 | }
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * @return string
|
---|
152 | */
|
---|
153 | public function getScheme()
|
---|
154 | {
|
---|
155 | return $this->_scheme;
|
---|
156 | }
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * @param string $value
|
---|
160 | * @return Zend_Gdata_Media_Extension_MediaCredit Provides a fluent
|
---|
161 | * interface
|
---|
162 | */
|
---|
163 | public function setScheme($value)
|
---|
164 | {
|
---|
165 | $this->_scheme = $value;
|
---|
166 | return $this;
|
---|
167 | }
|
---|
168 |
|
---|
169 | /**
|
---|
170 | * @return string
|
---|
171 | */
|
---|
172 | public function getYTtype()
|
---|
173 | {
|
---|
174 | return $this->_yttype;
|
---|
175 | }
|
---|
176 |
|
---|
177 | /**
|
---|
178 | * @param string $value
|
---|
179 | * @return Zend_Gdata_Media_Extension_MediaCredit Provides a fluent
|
---|
180 | * interface
|
---|
181 | */
|
---|
182 | public function setYTtype($value)
|
---|
183 | {
|
---|
184 | $this->_yttype = $value;
|
---|
185 | return $this;
|
---|
186 | }
|
---|
187 |
|
---|
188 | } |
---|