2
0

Category.php 3.4 KB

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