Review.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 Books
  18. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc.
  19. * (http://www.zend.com)
  20. * @license http://framework.zend.com/license/new-bsd New BSD License
  21. */
  22. /**
  23. * @see Zend_Gdata_Extension
  24. */
  25. require_once 'Zend/Gdata/Extension.php';
  26. /**
  27. * User-provided review
  28. *
  29. * @category Zend
  30. * @package Zend_Gdata
  31. * @subpackage Books
  32. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc.
  33. * (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. */
  36. class Zend_Gdata_Books_Extension_Review extends Zend_Gdata_Extension
  37. {
  38. protected $_rootNamespace = 'gbs';
  39. protected $_rootElement = 'review';
  40. protected $_lang = null;
  41. protected $_type = null;
  42. /**
  43. * Constructor for Zend_Gdata_Books_Extension_Review which
  44. * User-provided review
  45. *
  46. * @param string|null $lang Review language.
  47. * @param string|null $type Type of text construct (typically text, html,
  48. * or xhtml).
  49. * @param string|null $value Text content of the review.
  50. */
  51. public function __construct($lang = null, $type = null, $value = null)
  52. {
  53. $this->registerAllNamespaces(Zend_Gdata_Books::$namespaces);
  54. parent::__construct();
  55. $this->_lang = $lang;
  56. $this->_type = $type;
  57. $this->_text = $value;
  58. }
  59. /**
  60. * Retrieves DOMElement which corresponds to this element and all
  61. * child properties. This is used to build this object back into a DOM
  62. * and eventually XML text for sending to the server upon updates, or
  63. * for application storage/persistance.
  64. *
  65. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  66. * @return DOMElement The DOMElement representing this element and all
  67. * child properties.
  68. */
  69. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  70. {
  71. $element = parent::getDOM($doc);
  72. if ($this->_lang !== null) {
  73. $element->setAttribute('lang', $this->_lang);
  74. }
  75. if ($this->_type !== null) {
  76. $element->setAttribute('type', $this->_type);
  77. }
  78. return $element;
  79. }
  80. /**
  81. * Extracts XML attributes from the DOM and converts them to the
  82. * appropriate object members.
  83. *
  84. * @param DOMNode $attribute The DOMNode attribute to be handled.
  85. */
  86. protected function takeAttributeFromDOM($attribute)
  87. {
  88. switch ($attribute->localName) {
  89. case 'lang':
  90. $this->_lang = $attribute->nodeValue;
  91. break;
  92. case 'type':
  93. $this->_type = $attribute->nodeValue;
  94. break;
  95. default:
  96. parent::takeAttributeFromDOM($attribute);
  97. }
  98. }
  99. /**
  100. * Returns the language of link title
  101. *
  102. * @return string The lang
  103. */
  104. public function getLang()
  105. {
  106. return $this->_lang;
  107. }
  108. /**
  109. * Returns the type of text construct (typically 'text', 'html' or 'xhtml')
  110. *
  111. * @return string The type
  112. */
  113. public function getType()
  114. {
  115. return $this->_type;
  116. }
  117. /**
  118. * Sets the language of link title
  119. *
  120. * @param string $lang language of link title
  121. * @return Zend_Gdata_Books_Extension_Review Provides a fluent interface
  122. */
  123. public function setLang($lang)
  124. {
  125. $this->_lang = $lang;
  126. return $this;
  127. }
  128. /**
  129. * Sets the type of text construct (typically 'text', 'html' or 'xhtml')
  130. *
  131. * @param string $type type of text construct (typically 'text', 'html' or 'xhtml')
  132. * @return Zend_Gdata_Books_Extension_Review Provides a fluent interface
  133. */
  134. public function setType($type)
  135. {
  136. $this->_type = $type;
  137. return $this;
  138. }
  139. }