2
0

Rss.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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_Feed
  17. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id$
  20. */
  21. /**
  22. * @see Zend_Feed_Entry_Abstract
  23. */
  24. require_once 'Zend/Feed/Entry/Abstract.php';
  25. /**
  26. * Concrete class for working with RSS items.
  27. *
  28. * @category Zend
  29. * @package Zend_Feed
  30. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. */
  33. class Zend_Feed_Entry_Rss extends Zend_Feed_Entry_Abstract
  34. {
  35. /**
  36. * Root XML element for RSS items.
  37. *
  38. * @var string
  39. */
  40. protected $_rootElement = 'item';
  41. /**
  42. * Overwrites parent::_get method to enable read access
  43. * to content:encoded element.
  44. *
  45. * @param string $var The property to access.
  46. * @return mixed
  47. */
  48. public function __get($var)
  49. {
  50. switch ($var) {
  51. case 'content':
  52. $prefix = $this->_element->lookupPrefix('http://purl.org/rss/1.0/modules/content/');
  53. return parent::__get("$prefix:encoded");
  54. default:
  55. return parent::__get($var);
  56. }
  57. }
  58. /**
  59. * Overwrites parent::_set method to enable write access
  60. * to content:encoded element.
  61. *
  62. * @param string $var The property to change.
  63. * @param string $val The property's new value.
  64. * @return void
  65. */
  66. public function __set($var, $value)
  67. {
  68. switch ($var) {
  69. case 'content':
  70. parent::__set('content:encoded', $value);
  71. break;
  72. default:
  73. parent::__set($var, $value);
  74. }
  75. }
  76. /**
  77. * Overwrites parent::_isset method to enable access
  78. * to content:encoded element.
  79. *
  80. * @param string $var
  81. * @return boolean
  82. */
  83. public function __isset($var)
  84. {
  85. switch ($var) {
  86. case 'content':
  87. // don't use other callback to prevent invalid returned value
  88. return $this->content() !== null;
  89. default:
  90. return parent::__isset($var);
  91. }
  92. }
  93. /**
  94. * Overwrites parent::_call method to enable read access
  95. * to content:encoded element.
  96. * Please note that method-style write access is not currently supported
  97. * by parent method, consequently this method doesn't as well.
  98. *
  99. * @param string $var The element to get the string value of.
  100. * @param mixed $unused This parameter is not used.
  101. * @return mixed The node's value, null, or an array of nodes.
  102. */
  103. public function __call($var, $unused)
  104. {
  105. switch ($var) {
  106. case 'content':
  107. $prefix = $this->_element->lookupPrefix('http://purl.org/rss/1.0/modules/content/');
  108. return parent::__call("$prefix:encoded", $unused);
  109. default:
  110. return parent::__call($var, $unused);
  111. }
  112. }
  113. }