/Zend/Gdata/Media/Extension/MediaContent.php

https://github.com/ftaiolivista/Zend-Framework-Namespaced- · PHP · 527 lines · 271 code · 52 blank · 204 comment · 15 complexity · 62055d003aa7ec76dd26b05219bc37c2 MD5 · raw file

  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Gdata
  17. * @subpackage Media
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: MediaContent.php 20096 2010-01-06 02:05:09Z bkarwin $
  21. */
  22. /**
  23. * @namespace
  24. */
  25. namespace Zend\Gdata\Media\Extension;
  26. /**
  27. * @see Zend_Gdata_Extension
  28. */
  29. require_once 'Zend/Gdata/Extension.php';
  30. /**
  31. * Represents the media:content element of Media RSS.
  32. * Represents media objects. Multiple media objects representing
  33. * the same content can be represented using a
  34. * media:group (Zend_Gdata_Media_Extension_MediaGroup) element.
  35. *
  36. * @category Zend
  37. * @package Zend_Gdata
  38. * @subpackage Media
  39. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  40. * @license http://framework.zend.com/license/new-bsd New BSD License
  41. */
  42. class MediaContent extends \Zend\Gdata\Extension\Extension
  43. {
  44. protected $_rootElement = 'content';
  45. protected $_rootNamespace = 'media';
  46. /**
  47. * @var string
  48. */
  49. protected $_url = null;
  50. /**
  51. * @var int
  52. */
  53. protected $_fileSize = null;
  54. /**
  55. * @var string
  56. */
  57. protected $_type = null;
  58. /**
  59. * @var string
  60. */
  61. protected $_medium = null;
  62. /**
  63. * @var string
  64. */
  65. protected $_isDefault = null;
  66. /**
  67. * @var string
  68. */
  69. protected $_expression = null;
  70. /**
  71. * @var int
  72. */
  73. protected $_bitrate = null;
  74. /**
  75. * @var int
  76. */
  77. protected $_framerate = null;
  78. /**
  79. * @var int
  80. */
  81. protected $_samplingrate = null;
  82. /**
  83. * @var int
  84. */
  85. protected $_channels = null;
  86. /**
  87. * @var int
  88. */
  89. protected $_duration = null;
  90. /**
  91. * @var int
  92. */
  93. protected $_height = null;
  94. /**
  95. * @var int
  96. */
  97. protected $_width = null;
  98. /**
  99. * @var string
  100. */
  101. protected $_lang = null;
  102. /**
  103. * Creates an individual MediaContent object.
  104. */
  105. public function __construct($url = null, $fileSize = null, $type = null,
  106. $medium = null, $isDefault = null, $expression = null,
  107. $bitrate = null, $framerate = null, $samplingrate = null,
  108. $channels = null, $duration = null, $height = null, $width = null,
  109. $lang = null)
  110. {
  111. $this->registerAllNamespaces(\Zend\Gdata\Media\Media::$namespaces);
  112. parent::__construct();
  113. $this->_url = $url;
  114. $this->_fileSize = $fileSize;
  115. $this->_type = $type;
  116. $this->_medium = $medium;
  117. $this->_isDefault = $isDefault;
  118. $this->_expression = $expression;
  119. $this->_bitrate = $bitrate;
  120. $this->_framerate = $framerate;
  121. $this->_samplingrate = $samplingrate;
  122. $this->_channels = $channels;
  123. $this->_duration = $duration;
  124. $this->_height = $height;
  125. $this->_width = $width;
  126. $this->_lang = $lang;
  127. }
  128. /**
  129. * Retrieves a DOMElement which corresponds to this element and all
  130. * child properties. This is used to build an entry back into a DOM
  131. * and eventually XML text for sending to the server upon updates, or
  132. * for application storage/persistence.
  133. *
  134. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  135. * @return DOMElement The DOMElement representing this element and all
  136. * child properties.
  137. */
  138. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  139. {
  140. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  141. if ($this->_url !== null) {
  142. $element->setAttribute('url', $this->_url);
  143. }
  144. if ($this->_fileSize !== null) {
  145. $element->setAttribute('fileSize', $this->_fileSize);
  146. }
  147. if ($this->_type !== null) {
  148. $element->setAttribute('type', $this->_type);
  149. }
  150. if ($this->_medium !== null) {
  151. $element->setAttribute('medium', $this->_medium);
  152. }
  153. if ($this->_isDefault !== null) {
  154. $element->setAttribute('isDefault', $this->_isDefault);
  155. }
  156. if ($this->_expression !== null) {
  157. $element->setAttribute('expression', $this->_expression);
  158. }
  159. if ($this->_bitrate !== null) {
  160. $element->setAttribute('bitrate', $this->_bitrate);
  161. }
  162. if ($this->_framerate !== null) {
  163. $element->setAttribute('framerate', $this->_framerate);
  164. }
  165. if ($this->_samplingrate !== null) {
  166. $element->setAttribute('samplingrate', $this->_samplingrate);
  167. }
  168. if ($this->_channels !== null) {
  169. $element->setAttribute('channels', $this->_channels);
  170. }
  171. if ($this->_duration !== null) {
  172. $element->setAttribute('duration', $this->_duration);
  173. }
  174. if ($this->_height !== null) {
  175. $element->setAttribute('height', $this->_height);
  176. }
  177. if ($this->_width !== null) {
  178. $element->setAttribute('width', $this->_width);
  179. }
  180. if ($this->_lang !== null) {
  181. $element->setAttribute('lang', $this->_lang);
  182. }
  183. return $element;
  184. }
  185. /**
  186. * Given a DOMNode representing an attribute, tries to map the data into
  187. * instance members. If no mapping is defined, the name and value are
  188. * stored in an array.
  189. *
  190. * @param DOMNode $attribute The DOMNode attribute needed to be handled
  191. */
  192. protected function takeAttributeFromDOM($attribute)
  193. {
  194. switch ($attribute->localName) {
  195. case 'url':
  196. $this->_url = $attribute->nodeValue;
  197. break;
  198. case 'fileSize':
  199. $this->_fileSize = $attribute->nodeValue;
  200. break;
  201. case 'type':
  202. $this->_type = $attribute->nodeValue;
  203. break;
  204. case 'medium':
  205. $this->_medium = $attribute->nodeValue;
  206. break;
  207. case 'isDefault':
  208. $this->_isDefault = $attribute->nodeValue;
  209. break;
  210. case 'expression':
  211. $this->_expression = $attribute->nodeValue;
  212. break;
  213. case 'bitrate':
  214. $this->_bitrate = $attribute->nodeValue;
  215. break;
  216. case 'framerate':
  217. $this->_framerate = $attribute->nodeValue;
  218. break;
  219. case 'samplingrate':
  220. $this->_samplingrate = $attribute->nodeValue;
  221. break;
  222. case 'channels':
  223. $this->_channels = $attribute->nodeValue;
  224. break;
  225. case 'duration':
  226. $this->_duration = $attribute->nodeValue;
  227. break;
  228. case 'height':
  229. $this->_height = $attribute->nodeValue;
  230. break;
  231. case 'width':
  232. $this->_width = $attribute->nodeValue;
  233. break;
  234. case 'lang':
  235. $this->_lang = $attribute->nodeValue;
  236. break;
  237. default:
  238. parent::takeAttributeFromDOM($attribute);
  239. }
  240. }
  241. /**
  242. * Returns the URL representing this MediaContent object
  243. *
  244. * @return string The URL representing this MediaContent object.
  245. */
  246. public function __toString()
  247. {
  248. return $this->getUrl();
  249. }
  250. /**
  251. * @return string The direct URL to the media object
  252. */
  253. public function getUrl()
  254. {
  255. return $this->_url;
  256. }
  257. /**
  258. * @param string $value The direct URL to the media object
  259. * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
  260. */
  261. public function setUrl($value)
  262. {
  263. $this->_url = $value;
  264. return $this;
  265. }
  266. /**
  267. * @return int The size of the media in bytes
  268. */
  269. public function getFileSize()
  270. {
  271. return $this->_fileSize;
  272. }
  273. /**
  274. * @param int $value
  275. * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
  276. */
  277. public function setFileSize($value)
  278. {
  279. $this->_fileSize = $value;
  280. return $this;
  281. }
  282. /**
  283. * @return string
  284. */
  285. public function getType()
  286. {
  287. return $this->_type;
  288. }
  289. /**
  290. * @param string $value
  291. * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
  292. */
  293. public function setType($value)
  294. {
  295. $this->_type = $value;
  296. return $this;
  297. }
  298. /**
  299. * @return string
  300. */
  301. public function getMedium()
  302. {
  303. return $this->_medium;
  304. }
  305. /**
  306. * @param string $value
  307. * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
  308. */
  309. public function setMedium($value)
  310. {
  311. $this->_medium = $value;
  312. return $this;
  313. }
  314. /**
  315. * @return bool
  316. */
  317. public function getIsDefault()
  318. {
  319. return $this->_isDefault;
  320. }
  321. /**
  322. * @param bool $value
  323. * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
  324. */
  325. public function setIsDefault($value)
  326. {
  327. $this->_isDefault = $value;
  328. return $this;
  329. }
  330. /**
  331. * @return string
  332. */
  333. public function getExpression()
  334. {
  335. return $this->_expression;
  336. }
  337. /**
  338. * @param string
  339. * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
  340. */
  341. public function setExpression($value)
  342. {
  343. $this->_expression = $value;
  344. return $this;
  345. }
  346. /**
  347. * @return int
  348. */
  349. public function getBitrate()
  350. {
  351. return $this->_bitrate;
  352. }
  353. /**
  354. * @param int
  355. * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
  356. */
  357. public function setBitrate($value)
  358. {
  359. $this->_bitrate = $value;
  360. return $this;
  361. }
  362. /**
  363. * @return int
  364. */
  365. public function getFramerate()
  366. {
  367. return $this->_framerate;
  368. }
  369. /**
  370. * @param int
  371. * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
  372. */
  373. public function setFramerate($value)
  374. {
  375. $this->_framerate = $value;
  376. return $this;
  377. }
  378. /**
  379. * @return int
  380. */
  381. public function getSamplingrate()
  382. {
  383. return $this->_samplingrate;
  384. }
  385. /**
  386. * @param int
  387. * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
  388. */
  389. public function setSamplingrate($value)
  390. {
  391. $this->_samplingrate = $value;
  392. return $this;
  393. }
  394. /**
  395. * @return int
  396. */
  397. public function getChannels()
  398. {
  399. return $this->_channels;
  400. }
  401. /**
  402. * @param int
  403. * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
  404. */
  405. public function setChannels($value)
  406. {
  407. $this->_channels = $value;
  408. return $this;
  409. }
  410. /**
  411. * @return int
  412. */
  413. public function getDuration()
  414. {
  415. return $this->_duration;
  416. }
  417. /**
  418. *
  419. * @param int
  420. * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
  421. */
  422. public function setDuration($value)
  423. {
  424. $this->_duration = $value;
  425. return $this;
  426. }
  427. /**
  428. * @return int
  429. */
  430. public function getHeight()
  431. {
  432. return $this->_height;
  433. }
  434. /**
  435. * @param int
  436. * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
  437. */
  438. public function setHeight($value)
  439. {
  440. $this->_height = $value;
  441. return $this;
  442. }
  443. /**
  444. * @return int
  445. */
  446. public function getWidth()
  447. {
  448. return $this->_width;
  449. }
  450. /**
  451. * @param int
  452. * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
  453. */
  454. public function setWidth($value)
  455. {
  456. $this->_width = $value;
  457. return $this;
  458. }
  459. /**
  460. * @return string
  461. */
  462. public function getLang()
  463. {
  464. return $this->_lang;
  465. }
  466. /**
  467. * @param string
  468. * @return Zend_Gdata_Media_Extension_MediaContent Provides a fluent interface
  469. */
  470. public function setLang($value)
  471. {
  472. $this->_lang = $value;
  473. return $this;
  474. }
  475. }