Entry.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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_Reader
  17. * @copyright Copyright (c) 2005-2012 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_Reader
  23. */
  24. require_once 'Zend/Feed/Reader.php';
  25. /**
  26. * @see Zend_Feed_Reader_Extension_EntryAbstract
  27. */
  28. require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php';
  29. /**
  30. * @category Zend
  31. * @package Zend_Feed_Reader
  32. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. class Zend_Feed_Reader_Extension_Podcast_Entry extends Zend_Feed_Reader_Extension_EntryAbstract
  36. {
  37. /**
  38. * Get the entry author
  39. *
  40. * @return string
  41. */
  42. public function getCastAuthor()
  43. {
  44. if (isset($this->_data['author'])) {
  45. return $this->_data['author'];
  46. }
  47. $author = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:author)');
  48. if (!$author) {
  49. $author = null;
  50. }
  51. $this->_data['author'] = $author;
  52. return $this->_data['author'];
  53. }
  54. /**
  55. * Get the entry block
  56. *
  57. * @return string
  58. */
  59. public function getBlock()
  60. {
  61. if (isset($this->_data['block'])) {
  62. return $this->_data['block'];
  63. }
  64. $block = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:block)');
  65. if (!$block) {
  66. $block = null;
  67. }
  68. $this->_data['block'] = $block;
  69. return $this->_data['block'];
  70. }
  71. /**
  72. * Get the entry duration
  73. *
  74. * @return string
  75. */
  76. public function getDuration()
  77. {
  78. if (isset($this->_data['duration'])) {
  79. return $this->_data['duration'];
  80. }
  81. $duration = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:duration)');
  82. if (!$duration) {
  83. $duration = null;
  84. }
  85. $this->_data['duration'] = $duration;
  86. return $this->_data['duration'];
  87. }
  88. /**
  89. * Get the entry explicit
  90. *
  91. * @return string
  92. */
  93. public function getExplicit()
  94. {
  95. if (isset($this->_data['explicit'])) {
  96. return $this->_data['explicit'];
  97. }
  98. $explicit = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:explicit)');
  99. if (!$explicit) {
  100. $explicit = null;
  101. }
  102. $this->_data['explicit'] = $explicit;
  103. return $this->_data['explicit'];
  104. }
  105. /**
  106. * Get the entry keywords
  107. *
  108. * @return string
  109. */
  110. public function getKeywords()
  111. {
  112. if (isset($this->_data['keywords'])) {
  113. return $this->_data['keywords'];
  114. }
  115. $keywords = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:keywords)');
  116. if (!$keywords) {
  117. $keywords = null;
  118. }
  119. $this->_data['keywords'] = $keywords;
  120. return $this->_data['keywords'];
  121. }
  122. /**
  123. * Get the entry subtitle
  124. *
  125. * @return string
  126. */
  127. public function getSubtitle()
  128. {
  129. if (isset($this->_data['subtitle'])) {
  130. return $this->_data['subtitle'];
  131. }
  132. $subtitle = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:subtitle)');
  133. if (!$subtitle) {
  134. $subtitle = null;
  135. }
  136. $this->_data['subtitle'] = $subtitle;
  137. return $this->_data['subtitle'];
  138. }
  139. /**
  140. * Get the entry summary
  141. *
  142. * @return string
  143. */
  144. public function getSummary()
  145. {
  146. if (isset($this->_data['summary'])) {
  147. return $this->_data['summary'];
  148. }
  149. $summary = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:summary)');
  150. if (!$summary) {
  151. $summary = null;
  152. }
  153. $this->_data['summary'] = $summary;
  154. return $this->_data['summary'];
  155. }
  156. /**
  157. * Register iTunes namespace
  158. *
  159. */
  160. protected function _registerNamespaces()
  161. {
  162. $this->_xpath->registerNamespace('itunes', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
  163. }
  164. }