/library/Zend/Gdata/Media/Extension/MediaDescription.php

https://bitbucket.org/hamidrezas/melobit · PHP · 116 lines · 42 code · 11 blank · 63 comment · 2 complexity · 4e7585bc0dfe2e979280706a7c800bf9 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. * @version $Id: MediaDescription.php 24594 2012-01-05 21:27:01Z matthew $
  21. */
  22. /**
  23. * @see Zend_Gdata_App_Extension
  24. */
  25. require_once 'Zend/Gdata/App/Extension.php';
  26. /**
  27. * Represents the media:description element
  28. *
  29. * @category Zend
  30. * @package Zend_Gdata
  31. * @subpackage Media
  32. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. class Zend_Gdata_Media_Extension_MediaDescription extends Zend_Gdata_Extension
  36. {
  37. protected $_rootElement = 'description';
  38. protected $_rootNamespace = 'media';
  39. /**
  40. * @var string
  41. */
  42. protected $_type = null;
  43. /**
  44. * @param string $text
  45. * @param string $type
  46. */
  47. public function __construct($text = null, $type = null)
  48. {
  49. $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
  50. parent::__construct();
  51. $this->_type = $type;
  52. $this->_text = $text;
  53. }
  54. /**
  55. * Retrieves a DOMElement which corresponds to this element and all
  56. * child properties. This is used to build an entry back into a DOM
  57. * and eventually XML text for sending to the server upon updates, or
  58. * for application storage/persistence.
  59. *
  60. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  61. * @return DOMElement The DOMElement representing this element and all
  62. * child properties.
  63. */
  64. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  65. {
  66. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  67. if ($this->_type !== null) {
  68. $element->setAttribute('type', $this->_type);
  69. }
  70. return $element;
  71. }
  72. /**
  73. * Given a DOMNode representing an attribute, tries to map the data into
  74. * instance members. If no mapping is defined, the name and value are
  75. * stored in an array.
  76. *
  77. * @param DOMNode $attribute The DOMNode attribute needed to be handled
  78. */
  79. protected function takeAttributeFromDOM($attribute)
  80. {
  81. switch ($attribute->localName) {
  82. case 'type':
  83. $this->_type = $attribute->nodeValue;
  84. break;
  85. default:
  86. parent::takeAttributeFromDOM($attribute);
  87. }
  88. }
  89. /**
  90. * @return string
  91. */
  92. public function getType()
  93. {
  94. return $this->_type;
  95. }
  96. /**
  97. * @param string $value
  98. * @return Zend_Gdata_Media_Extension_MediaDescription Provides a fluent interface
  99. */
  100. public function setType($value)
  101. {
  102. $this->_type = $value;
  103. return $this;
  104. }
  105. }