MediaContent.php 12 KB

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