Review.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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-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_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-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_Books_Extension_Review extends Zend_Gdata_Extension
  36. {
  37. protected $_rootNamespace = 'gbs';
  38. protected $_rootElement = 'review';
  39. protected $_lang = null;
  40. protected $_type = null;
  41. /**
  42. * Constructor for Zend_Gdata_Books_Extension_Review which
  43. * User-provided review
  44. *
  45. * @param string|null $lang Review language.
  46. * @param string|null $type Type of text construct (typically text, html,
  47. * or xhtml).
  48. * @param string|null $value Text content of the review.
  49. */
  50. public function __construct($lang = null, $type = null, $value = null)
  51. {
  52. $this->registerAllNamespaces(Zend_Gdata_Books::$namespaces);
  53. parent::__construct();
  54. $this->_lang = $lang;
  55. $this->_type = $type;
  56. $this->_text = $value;
  57. }
  58. /**
  59. * Retrieves DOMElement which corresponds to this element and all
  60. * child properties. This is used to build this object back into a DOM
  61. * and eventually XML text for sending to the server upon updates, or
  62. * for application storage/persistance.
  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);
  71. if ($this->_lang !== null) {
  72. $element->setAttribute('lang', $this->_lang);
  73. }
  74. if ($this->_type !== null) {
  75. $element->setAttribute('type', $this->_type);
  76. }
  77. return $element;
  78. }
  79. /**
  80. * Extracts XML attributes from the DOM and converts them to the
  81. * appropriate object members.
  82. *
  83. * @param DOMNode $attribute The DOMNode attribute to be handled.
  84. */
  85. protected function takeAttributeFromDOM($attribute)
  86. {
  87. switch ($attribute->localName) {
  88. case 'lang':
  89. $this->_lang = $attribute->nodeValue;
  90. break;
  91. case 'type':
  92. $this->_type = $attribute->nodeValue;
  93. break;
  94. default:
  95. parent::takeAttributeFromDOM($attribute);
  96. }
  97. }
  98. /**
  99. * Returns the language of link title
  100. *
  101. * @return string The lang
  102. */
  103. public function getLang()
  104. {
  105. return $this->_lang;
  106. }
  107. /**
  108. * Returns the type of text construct (typically 'text', 'html' or 'xhtml')
  109. *
  110. * @return string The type
  111. */
  112. public function getType()
  113. {
  114. return $this->_type;
  115. }
  116. /**
  117. * Sets the language of link title
  118. *
  119. * @param string $lang language of link title
  120. * @return Zend_Gdata_Books_Extension_Review Provides a fluent interface
  121. */
  122. public function setLang($lang)
  123. {
  124. $this->_lang = $lang;
  125. return $this;
  126. }
  127. /**
  128. * Sets the type of text construct (typically 'text', 'html' or 'xhtml')
  129. *
  130. * @param string $type type of text construct (typically 'text', 'html' or 'xhtml')
  131. * @return Zend_Gdata_Books_Extension_Review Provides a fluent interface
  132. */
  133. public function setType($type)
  134. {
  135. $this->_type = $type;
  136. return $this;
  137. }
  138. }