Category.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 App
  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_App_Extension
  24. */
  25. require_once 'Zend/Gdata/App/Extension.php';
  26. /**
  27. * Represents the atom:category element
  28. *
  29. * @category Zend
  30. * @package Zend_Gdata
  31. * @subpackage App
  32. * @copyright Copyright (c) 2005-2015 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_App_Extension_Category extends Zend_Gdata_App_Extension
  36. {
  37. protected $_rootElement = 'category';
  38. protected $_term = null;
  39. protected $_scheme = null;
  40. protected $_label = null;
  41. public function __construct($term = null, $scheme = null, $label=null)
  42. {
  43. parent::__construct();
  44. $this->_term = $term;
  45. $this->_scheme = $scheme;
  46. $this->_label = $label;
  47. }
  48. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  49. {
  50. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  51. if ($this->_term !== null) {
  52. $element->setAttribute('term', $this->_term);
  53. }
  54. if ($this->_scheme !== null) {
  55. $element->setAttribute('scheme', $this->_scheme);
  56. }
  57. if ($this->_label !== null) {
  58. $element->setAttribute('label', $this->_label);
  59. }
  60. return $element;
  61. }
  62. protected function takeAttributeFromDOM($attribute)
  63. {
  64. switch ($attribute->localName) {
  65. case 'term':
  66. $this->_term = $attribute->nodeValue;
  67. break;
  68. case 'scheme':
  69. $this->_scheme = $attribute->nodeValue;
  70. break;
  71. case 'label':
  72. $this->_label = $attribute->nodeValue;
  73. break;
  74. default:
  75. parent::takeAttributeFromDOM($attribute);
  76. }
  77. }
  78. /**
  79. * @return string|null
  80. */
  81. public function getTerm()
  82. {
  83. return $this->_term;
  84. }
  85. /**
  86. * @param string|null $value
  87. * @return Zend_Gdata_App_Extension_Category Provides a fluent interface
  88. */
  89. public function setTerm($value)
  90. {
  91. $this->_term = $value;
  92. return $this;
  93. }
  94. /**
  95. * @return string|null
  96. */
  97. public function getScheme()
  98. {
  99. return $this->_scheme;
  100. }
  101. /**
  102. * @param string|null $value
  103. * @return Zend_Gdata_App_Extension_Category Provides a fluent interface
  104. */
  105. public function setScheme($value)
  106. {
  107. $this->_scheme = $value;
  108. return $this;
  109. }
  110. /**
  111. * @return string|null
  112. */
  113. public function getLabel()
  114. {
  115. return $this->_label;
  116. }
  117. /**
  118. * @param string|null $value
  119. * @return Zend_Gdata_App_Extension_Category Provides a fluent interface
  120. */
  121. public function setLabel($value)
  122. {
  123. $this->_label = $value;
  124. return $this;
  125. }
  126. }