2
0

Comments.php 3.0 KB

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