|
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-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
20 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
21 * @version $Id: MediaText.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
22 */ |
|
23 |
|
24 /** |
|
25 * @see Zend_Gdata_App_Extension |
|
26 */ |
|
27 require_once 'Zend/Gdata/App/Extension.php'; |
|
28 |
|
29 /** |
|
30 * Represents the media:text element |
|
31 * |
|
32 * @category Zend |
|
33 * @package Zend_Gdata |
|
34 * @subpackage Media |
|
35 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
36 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
37 */ |
|
38 class Zend_Gdata_Media_Extension_MediaText extends Zend_Gdata_Extension |
|
39 { |
|
40 |
|
41 protected $_rootElement = 'text'; |
|
42 protected $_rootNamespace = 'media'; |
|
43 |
|
44 /** |
|
45 * @var string |
|
46 */ |
|
47 protected $_type = null; |
|
48 |
|
49 /** |
|
50 * @var string |
|
51 */ |
|
52 protected $_lang = null; |
|
53 |
|
54 /** |
|
55 * @var string |
|
56 */ |
|
57 protected $_start = null; |
|
58 |
|
59 /** |
|
60 * @var string |
|
61 */ |
|
62 protected $_end = null; |
|
63 |
|
64 /** |
|
65 * Constructs a new MediaText element |
|
66 * |
|
67 * @param $text string |
|
68 * @param $type string |
|
69 * @param $lang string |
|
70 * @param $start string |
|
71 * @param $end string |
|
72 */ |
|
73 public function __construct($text = null, $type = null, $lang = null, |
|
74 $start = null, $end = null) |
|
75 { |
|
76 $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces); |
|
77 parent::__construct(); |
|
78 $this->_text = $text; |
|
79 $this->_type = $type; |
|
80 $this->_lang = $lang; |
|
81 $this->_start = $start; |
|
82 $this->_end = $end; |
|
83 } |
|
84 |
|
85 /** |
|
86 * Retrieves a DOMElement which corresponds to this element and all |
|
87 * child properties. This is used to build an entry back into a DOM |
|
88 * and eventually XML text for sending to the server upon updates, or |
|
89 * for application storage/persistence. |
|
90 * |
|
91 * @param DOMDocument $doc The DOMDocument used to construct DOMElements |
|
92 * @return DOMElement The DOMElement representing this element and all |
|
93 * child properties. |
|
94 */ |
|
95 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) |
|
96 { |
|
97 $element = parent::getDOM($doc, $majorVersion, $minorVersion); |
|
98 if ($this->_type !== null) { |
|
99 $element->setAttribute('type', $this->_type); |
|
100 } |
|
101 if ($this->_lang !== null) { |
|
102 $element->setAttribute('lang', $this->_lang); |
|
103 } |
|
104 if ($this->_start !== null) { |
|
105 $element->setAttribute('start', $this->_start); |
|
106 } |
|
107 if ($this->_end !== null) { |
|
108 $element->setAttribute('end', $this->_end); |
|
109 } |
|
110 return $element; |
|
111 } |
|
112 |
|
113 /** |
|
114 * Given a DOMNode representing an attribute, tries to map the data into |
|
115 * instance members. If no mapping is defined, the name and value are |
|
116 * stored in an array. |
|
117 * |
|
118 * @param DOMNode $attribute The DOMNode attribute needed to be handled |
|
119 */ |
|
120 protected function takeAttributeFromDOM($attribute) |
|
121 { |
|
122 switch ($attribute->localName) { |
|
123 case 'type': |
|
124 $this->_type = $attribute->nodeValue; |
|
125 break; |
|
126 case 'lang': |
|
127 $this->_lang = $attribute->nodeValue; |
|
128 break; |
|
129 case 'start': |
|
130 $this->_start = $attribute->nodeValue; |
|
131 break; |
|
132 case 'end': |
|
133 $this->_end = $attribute->nodeValue; |
|
134 break; |
|
135 default: |
|
136 parent::takeAttributeFromDOM($attribute); |
|
137 } |
|
138 } |
|
139 |
|
140 /** |
|
141 * @return string |
|
142 */ |
|
143 public function getType() |
|
144 { |
|
145 return $this->_type; |
|
146 } |
|
147 |
|
148 /** |
|
149 * @param string $value |
|
150 * @return Zend_Gdata_Media_Extension_MediaText Provides a fluent interface |
|
151 */ |
|
152 public function setType($value) |
|
153 { |
|
154 $this->_type = $value; |
|
155 return $this; |
|
156 } |
|
157 |
|
158 /** |
|
159 * @return string |
|
160 */ |
|
161 public function getLang() |
|
162 { |
|
163 return $this->_lang; |
|
164 } |
|
165 |
|
166 /** |
|
167 * @param string $value |
|
168 * @return Zend_Gdata_Media_Extension_MediaText Provides a fluent interface |
|
169 */ |
|
170 public function setLang($value) |
|
171 { |
|
172 $this->_lang = $value; |
|
173 return $this; |
|
174 } |
|
175 |
|
176 /** |
|
177 * @return string |
|
178 */ |
|
179 public function getStart() |
|
180 { |
|
181 return $this->_start; |
|
182 } |
|
183 |
|
184 /** |
|
185 * @param string $value |
|
186 * @return Zend_Gdata_Media_Extension_MediaText Provides a fluent interface |
|
187 */ |
|
188 public function setStart($value) |
|
189 { |
|
190 $this->_start = $value; |
|
191 return $this; |
|
192 } |
|
193 |
|
194 /** |
|
195 * @return string |
|
196 */ |
|
197 public function getEnd() |
|
198 { |
|
199 return $this->_end; |
|
200 } |
|
201 |
|
202 /** |
|
203 * @param string $value |
|
204 * @return Zend_Gdata_Media_Extension_MediaText Provides a fluent interface |
|
205 */ |
|
206 public function setEnd($value) |
|
207 { |
|
208 $this->_end = $value; |
|
209 return $this; |
|
210 } |
|
211 } |