2
0

Comments.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 Gdata
  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_Extension
  23. */
  24. require_once 'Zend/Gdata/Extension.php';
  25. /**
  26. * @see Zend_Gdata_Extension_FeedLink
  27. */
  28. require_once 'Zend/Gdata/Extension/FeedLink.php';
  29. /**
  30. * Represents the gd:comments element
  31. *
  32. * @category Zend
  33. * @package Zend_Gdata
  34. * @subpackage Gdata
  35. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  36. * @license http://framework.zend.com/license/new-bsd New BSD License
  37. */
  38. class Zend_Gdata_Extension_Comments extends Zend_Gdata_Extension
  39. {
  40. protected $_rootElement = 'comments';
  41. protected $_rel = null;
  42. protected $_feedLink = null;
  43. public function __construct($rel = null, $feedLink = null)
  44. {
  45. parent::__construct();
  46. $this->_rel = $rel;
  47. $this->_feedLink = $feedLink;
  48. }
  49. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  50. {
  51. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  52. if ($this->_rel !== null) {
  53. $element->setAttribute('rel', $this->_rel);
  54. }
  55. if ($this->_feedLink !== null) {
  56. $element->appendChild($this->_feedLink->getDOM($element->ownerDocument));
  57. }
  58. return $element;
  59. }
  60. protected function takeChildFromDOM($child)
  61. {
  62. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  63. switch ($absoluteNodeName) {
  64. case $this->lookupNamespace('gd') . ':' . 'feedLink';
  65. $feedLink = new Zend_Gdata_Extension_FeedLink();
  66. $feedLink->transferFromDOM($child);
  67. $this->_feedLink = $feedLink;
  68. break;
  69. default:
  70. parent::takeChildFromDOM($child);
  71. break;
  72. }
  73. }
  74. protected function takeAttributeFromDOM($attribute)
  75. {
  76. switch ($attribute->localName) {
  77. case 'rel':
  78. $this->_rel = $attribute->nodeValue;
  79. break;
  80. default:
  81. parent::takeAttributeFromDOM($attribute);
  82. }
  83. }
  84. public function getRel()
  85. {
  86. return $this->_rel;
  87. }
  88. public function setRel($value)
  89. {
  90. $this->_rel = $value;
  91. return $this;
  92. }
  93. public function getFeedLink()
  94. {
  95. return $this->_feedLink;
  96. }
  97. public function setFeedLink($value)
  98. {
  99. $this->_feedLink = $value;
  100. return $this;
  101. }
  102. }