/libraries/Zend/GData/Media/Extension/MediaContent.php

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