source: trunk/www.guidonia.net/wp/wp-content/plugins/webtv/Drivers/Zend/Gdata/Media/Extension/MediaThumbnail.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:thumbnail 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_MediaThumbnail extends Zend_Gdata_Extension
38{
39
40 protected $_rootElement = 'thumbnail';
41 protected $_rootNamespace = 'media';
42
43 /**
44 * @var string
45 */
46 protected $_url = null;
47
48 /**
49 * @var int
50 */
51 protected $_width = null;
52
53 /**
54 * @var int
55 */
56 protected $_height = null;
57
58 /**
59 * @var string
60 */
61 protected $_time = null;
62
63 /**
64 * Constructs a new MediaThumbnail element
65 *
66 * @param string $url
67 * @param int $width
68 * @param int $height
69 * @param string $time
70 */
71 public function __construct($url = null, $width = null, $height = null,
72 $time = null)
73 {
74 $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
75 parent::__construct();
76 $this->_url = $url;
77 $this->_width = $width;
78 $this->_height = $height;
79 $this->_time = $time ;
80 }
81
82 /**
83 * Retrieves a DOMElement which corresponds to this element and all
84 * child properties. This is used to build an entry back into a DOM
85 * and eventually XML text for sending to the server upon updates, or
86 * for application storage/persistence.
87 *
88 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
89 * @return DOMElement The DOMElement representing this element and all
90 * child properties.
91 */
92 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
93 {
94 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
95 if ($this->_url !== null) {
96 $element->setAttribute('url', $this->_url);
97 }
98 if ($this->_width !== null) {
99 $element->setAttribute('width', $this->_width);
100 }
101 if ($this->_height !== null) {
102 $element->setAttribute('height', $this->_height);
103 }
104 if ($this->_time !== null) {
105 $element->setAttribute('time', $this->_time);
106 }
107 return $element;
108 }
109
110 /**
111 * Given a DOMNode representing an attribute, tries to map the data into
112 * instance members. If no mapping is defined, the name and value are
113 * stored in an array.
114 *
115 * @param DOMNode $attribute The DOMNode attribute needed to be handled
116 */
117 protected function takeAttributeFromDOM($attribute)
118 {
119 switch ($attribute->localName) {
120 case 'url':
121 $this->_url = $attribute->nodeValue;
122 break;
123 case 'width':
124 $this->_width = $attribute->nodeValue;
125 break;
126 case 'height':
127 $this->_height = $attribute->nodeValue;
128 break;
129 case 'time':
130 $this->_time = $attribute->nodeValue;
131 break;
132 default:
133 parent::takeAttributeFromDOM($attribute);
134 }
135 }
136
137 /**
138 * @return string
139 */
140 public function getUrl()
141 {
142 return $this->_url;
143 }
144
145 /**
146 * @param string $value
147 * @return Zend_Gdata_Media_Extension_MediaThumbnail Provides a fluent interface
148 */
149 public function setUrl($value)
150 {
151 $this->_url = $value;
152 return $this;
153 }
154
155 /**
156 * @return int
157 */
158 public function getWidth()
159 {
160 return $this->_width;
161 }
162
163 /**
164 * @param int $value
165 * @return Zend_Gdata_Media_Extension_MediaThumbnail Provides a fluent interface
166 */
167 public function setWidth($value)
168 {
169 $this->_width = $value;
170 return $this;
171 }
172
173 /**
174 * @return int
175 */
176 public function getHeight()
177 {
178 return $this->_height;
179 }
180
181 /**
182 * @param int $value
183 * @return Zend_Gdata_Media_Extension_MediaThumbnail Provides a fluent interface
184 */
185 public function setHeight($value)
186 {
187 $this->_height = $value;
188 return $this;
189 }
190
191 /**
192 * @return string
193 */
194 public function getTime()
195 {
196 return $this->_time;
197 }
198
199 /**
200 * @param string $value
201 * @return Zend_Gdata_Media_Extension_MediaThumbnail Provides a fluent interface
202 */
203 public function setTime($value)
204 {
205 $this->_time = $value;
206 return $this;
207 }
208
209}
Note: See TracBrowser for help on using the repository browser.