MediaContent.php 12 KB

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