PageRenderTime 38ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/zf2/vendor/Zend/GData/Media/Extension/MediaContent.php

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