MediaCategory.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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_App_Extension
  23. */
  24. require_once 'Zend/Gdata/App/Extension.php';
  25. /**
  26. * Represents the media:category element
  27. *
  28. * @category Zend
  29. * @package Zend_Gdata
  30. * @subpackage Media
  31. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. */
  34. class Zend_Gdata_Media_Extension_MediaCategory extends Zend_Gdata_Extension
  35. {
  36. protected $_rootElement = 'category';
  37. protected $_rootNamespace = 'media';
  38. /**
  39. * @var string
  40. */
  41. protected $_scheme = null;
  42. protected $_label = null;
  43. /**
  44. * Creates an individual MediaCategory object.
  45. *
  46. * @param string $text Indication of the type and content of the media
  47. * @param string $scheme URI that identifies the categorization scheme
  48. * @param string $label Human-readable label to be displayed in applications
  49. */
  50. public function __construct($text = null, $scheme = null, $label = null)
  51. {
  52. $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
  53. parent::__construct();
  54. $this->_text = $text;
  55. $this->_scheme = $scheme;
  56. $this->_label = $label;
  57. }
  58. /**
  59. * Retrieves a DOMElement which corresponds to this element and all
  60. * child properties. This is used to build an entry back into a DOM
  61. * and eventually XML text for sending to the server upon updates, or
  62. * for application storage/persistence.
  63. *
  64. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  65. * @return DOMElement The DOMElement representing this element and all
  66. * child properties.
  67. */
  68. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  69. {
  70. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  71. if ($this->_scheme !== null) {
  72. $element->setAttribute('scheme', $this->_scheme);
  73. }
  74. if ($this->_label !== null) {
  75. $element->setAttribute('label', $this->_label);
  76. }
  77. return $element;
  78. }
  79. /**
  80. * Given a DOMNode representing an attribute, tries to map the data into
  81. * instance members. If no mapping is defined, the name and value are
  82. * stored in an array.
  83. *
  84. * @param DOMNode $attribute The DOMNode attribute needed to be handled
  85. */
  86. protected function takeAttributeFromDOM($attribute)
  87. {
  88. switch ($attribute->localName) {
  89. case 'scheme':
  90. $this->_scheme = $attribute->nodeValue;
  91. break;
  92. case 'label':
  93. $this->_label = $attribute->nodeValue;
  94. break;
  95. default:
  96. parent::takeAttributeFromDOM($attribute);
  97. }
  98. }
  99. /**
  100. * Returns the URI that identifies the categorization scheme
  101. * Optional.
  102. *
  103. * @return string URI that identifies the categorization scheme
  104. */
  105. public function getScheme()
  106. {
  107. return $this->_scheme;
  108. }
  109. /**
  110. * @param string $value URI that identifies the categorization scheme
  111. * @return Zend_Gdata_Media_Extension_MediaCategory Provides a fluent interface
  112. */
  113. public function setScheme($value)
  114. {
  115. $this->_scheme = $value;
  116. return $this;
  117. }
  118. /**
  119. * @return string Human-readable label to be displayed in applications
  120. */
  121. public function getLabel()
  122. {
  123. return $this->_label;
  124. }
  125. /**
  126. * @param string $value Human-readable label to be displayed in applications
  127. * @return Zend_Gdata_Media_Extension_MediaCategory Provides a fluent interface
  128. */
  129. public function setLabel($value)
  130. {
  131. $this->_label = $value;
  132. return $this;
  133. }
  134. }