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

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