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_Extension
|
---|
25 | */
|
---|
26 | require_once 'Zend/Gdata/Extension.php';
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Represents the yt:state element used by the YouTube data API
|
---|
30 | *
|
---|
31 | * @category Zend
|
---|
32 | * @package Zend_Gdata
|
---|
33 | * @subpackage YouTube
|
---|
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_State extends Zend_Gdata_Extension
|
---|
38 | {
|
---|
39 |
|
---|
40 | protected $_rootNamespace = 'yt';
|
---|
41 | protected $_rootElement = 'state';
|
---|
42 | protected $_name = null;
|
---|
43 | protected $_reasonCode = null;
|
---|
44 | protected $_helpUrl = null;
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * Constructs a new Zend_Gdata_YouTube_Extension_State object.
|
---|
48 | *
|
---|
49 | * @param string $explanation(optional) The explanation of this state
|
---|
50 | * @param string $name(optional) The name value
|
---|
51 | * @param string $reasonCode(optional) The reasonCode value
|
---|
52 | * @param string $helpUrl(optional) The helpUrl value
|
---|
53 | */
|
---|
54 | public function __construct($explanation = null, $name = null,
|
---|
55 | $reasonCode = null, $helpUrl = null)
|
---|
56 | {
|
---|
57 | $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
|
---|
58 | parent::__construct();
|
---|
59 | $this->_text = $explanation;
|
---|
60 | $this->_name = $name;
|
---|
61 | $this->_reasonCode = $reasonCode;
|
---|
62 | $this->_helpUrl = $reasonCode;
|
---|
63 | }
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Retrieves a DOMElement which corresponds to this element and all
|
---|
67 | * child properties. This is used to build an entry back into a DOM
|
---|
68 | * and eventually XML text for sending to the server upon updates, or
|
---|
69 | * for application storage/persistence.
|
---|
70 | *
|
---|
71 | * @param DOMDocument $doc The DOMDocument used to construct DOMElements
|
---|
72 | * @return DOMElement The DOMElement representing this element and all
|
---|
73 | * child properties.
|
---|
74 | */
|
---|
75 | public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
|
---|
76 | {
|
---|
77 | $element = parent::getDOM($doc, $majorVersion, $minorVersion);
|
---|
78 | if ($this->_name !== null) {
|
---|
79 | $element->setAttribute('name', $this->_name);
|
---|
80 | }
|
---|
81 | if ($this->_reasonCode !== null) {
|
---|
82 | $element->setAttribute('reasonCode', $this->_reasonCode);
|
---|
83 | }
|
---|
84 | if ($this->_helpUrl !== null) {
|
---|
85 | $element->setAttribute('helpUrl', $this->_helpUrl);
|
---|
86 | }
|
---|
87 | return $element;
|
---|
88 | }
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * Given a DOMNode representing an attribute, tries to map the data into
|
---|
92 | * instance members. If no mapping is defined, the name and valueare
|
---|
93 | * stored in an array.
|
---|
94 | * TODO: Convert attributes to proper types
|
---|
95 | *
|
---|
96 | * @param DOMNode $attribute The DOMNode attribute needed to be handled
|
---|
97 | */
|
---|
98 | protected function takeAttributeFromDOM($attribute)
|
---|
99 | {
|
---|
100 | switch ($attribute->localName) {
|
---|
101 | case 'name':
|
---|
102 | $this->_name = $attribute->nodeValue;
|
---|
103 | break;
|
---|
104 | case 'reasonCode':
|
---|
105 | $this->_reasonCode = $attribute->nodeValue;
|
---|
106 | break;
|
---|
107 | case 'helpUrl':
|
---|
108 | $this->_helpUrl = $attribute->nodeValue;
|
---|
109 | break;
|
---|
110 | default:
|
---|
111 | parent::takeAttributeFromDOM($attribute);
|
---|
112 | }
|
---|
113 | }
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * Get the value for this element's name attribute.
|
---|
117 | *
|
---|
118 | * @return int The value associated with this attribute.
|
---|
119 | */
|
---|
120 | public function getName()
|
---|
121 | {
|
---|
122 | return $this->_name;
|
---|
123 | }
|
---|
124 |
|
---|
125 | /**
|
---|
126 | * Set the value for this element's name attribute.
|
---|
127 | *
|
---|
128 | * @param int $value The desired value for this attribute.
|
---|
129 | * @return Zend_Gdata_YouTube_Extension_State The element being modified.
|
---|
130 | */
|
---|
131 | public function setName($value)
|
---|
132 | {
|
---|
133 | $this->_name = $value;
|
---|
134 | return $this;
|
---|
135 | }
|
---|
136 |
|
---|
137 | /**
|
---|
138 | * Get the value for this element's reasonCode attribute.
|
---|
139 | *
|
---|
140 | * @return int The value associated with this attribute.
|
---|
141 | */
|
---|
142 | public function getReasonCode()
|
---|
143 | {
|
---|
144 | return $this->_reasonCode;
|
---|
145 | }
|
---|
146 |
|
---|
147 | /**
|
---|
148 | * Set the value for this element's reasonCode attribute.
|
---|
149 | *
|
---|
150 | * @param int $value The desired value for this attribute.
|
---|
151 | * @return Zend_Gdata_YouTube_Extension_State The element being modified.
|
---|
152 | */
|
---|
153 | public function setReasonCode($value)
|
---|
154 | {
|
---|
155 | $this->_reasonCode = $value;
|
---|
156 | return $this;
|
---|
157 | }
|
---|
158 |
|
---|
159 | /**
|
---|
160 | * Get the value for this element's helpUrl attribute.
|
---|
161 | *
|
---|
162 | * @return int The value associated with this attribute.
|
---|
163 | */
|
---|
164 | public function getHelpUrl()
|
---|
165 | {
|
---|
166 | return $this->_helpUrl;
|
---|
167 | }
|
---|
168 |
|
---|
169 | /**
|
---|
170 | * Set the value for this element's helpUrl attribute.
|
---|
171 | *
|
---|
172 | * @param int $value The desired value for this attribute.
|
---|
173 | * @return Zend_Gdata_YouTube_Extension_State The element being modified.
|
---|
174 | */
|
---|
175 | public function setHelpUrl($value)
|
---|
176 | {
|
---|
177 | $this->_helpUrl = $value;
|
---|
178 | return $this;
|
---|
179 | }
|
---|
180 |
|
---|
181 | /**
|
---|
182 | * Magic toString method allows using this directly via echo
|
---|
183 | * Works best in PHP >= 4.2.0
|
---|
184 | *
|
---|
185 | * @return string
|
---|
186 | */
|
---|
187 | public function __toString()
|
---|
188 | {
|
---|
189 | return $this->_text;
|
---|
190 | }
|
---|
191 |
|
---|
192 | }
|
---|