File indexing completed on 2025-01-19 05:21:05
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Feed_Reader 0017 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0018 * @license http://framework.zend.com/license/new-bsd New BSD License 0019 * @version $Id$ 0020 */ 0021 0022 /** 0023 * @see Zend_Feed_Reader_Extension_FeedAbstract 0024 */ 0025 // require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php'; 0026 0027 /** 0028 * @category Zend 0029 * @package Zend_Feed_Reader 0030 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0031 * @license http://framework.zend.com/license/new-bsd New BSD License 0032 */ 0033 class Zend_Feed_Reader_Extension_Podcast_Feed extends Zend_Feed_Reader_Extension_FeedAbstract 0034 { 0035 /** 0036 * Get the entry author 0037 * 0038 * @return string 0039 */ 0040 public function getCastAuthor() 0041 { 0042 if (isset($this->_data['author'])) { 0043 return $this->_data['author']; 0044 } 0045 0046 $author = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:author)'); 0047 0048 if (!$author) { 0049 $author = null; 0050 } 0051 0052 $this->_data['author'] = $author; 0053 0054 return $this->_data['author']; 0055 } 0056 0057 /** 0058 * Get the entry block 0059 * 0060 * @return string 0061 */ 0062 public function getBlock() 0063 { 0064 if (isset($this->_data['block'])) { 0065 return $this->_data['block']; 0066 } 0067 0068 $block = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:block)'); 0069 0070 if (!$block) { 0071 $block = null; 0072 } 0073 0074 $this->_data['block'] = $block; 0075 0076 return $this->_data['block']; 0077 } 0078 0079 /** 0080 * Get the entry category 0081 * 0082 * @return string 0083 */ 0084 public function getCategories() 0085 { 0086 if (isset($this->_data['categories'])) { 0087 return $this->_data['categories']; 0088 } 0089 0090 $categoryList = $this->_xpath->query($this->getXpathPrefix() . '/itunes:category'); 0091 0092 $categories = array(); 0093 0094 if ($categoryList->length > 0) { 0095 foreach ($categoryList as $node) { 0096 $children = null; 0097 0098 if ($node->childNodes->length > 0) { 0099 $children = array(); 0100 0101 foreach ($node->childNodes as $childNode) { 0102 if (!($childNode instanceof DOMText)) { 0103 $children[$childNode->getAttribute('text')] = null; 0104 } 0105 } 0106 } 0107 0108 $categories[$node->getAttribute('text')] = $children; 0109 } 0110 } 0111 0112 0113 if (!$categories) { 0114 $categories = null; 0115 } 0116 0117 $this->_data['categories'] = $categories; 0118 0119 return $this->_data['categories']; 0120 } 0121 0122 /** 0123 * Get the entry explicit 0124 * 0125 * @return string 0126 */ 0127 public function getExplicit() 0128 { 0129 if (isset($this->_data['explicit'])) { 0130 return $this->_data['explicit']; 0131 } 0132 0133 $explicit = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:explicit)'); 0134 0135 if (!$explicit) { 0136 $explicit = null; 0137 } 0138 0139 $this->_data['explicit'] = $explicit; 0140 0141 return $this->_data['explicit']; 0142 } 0143 0144 /** 0145 * Get the entry image 0146 * 0147 * @return string 0148 */ 0149 public function getImage() 0150 { 0151 if (isset($this->_data['image'])) { 0152 return $this->_data['image']; 0153 } 0154 0155 $image = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:image/@href)'); 0156 0157 if (!$image) { 0158 $image = null; 0159 } 0160 0161 $this->_data['image'] = $image; 0162 0163 return $this->_data['image']; 0164 } 0165 0166 /** 0167 * Get the entry keywords 0168 * 0169 * @return string 0170 */ 0171 public function getKeywords() 0172 { 0173 if (isset($this->_data['keywords'])) { 0174 return $this->_data['keywords']; 0175 } 0176 0177 $keywords = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:keywords)'); 0178 0179 if (!$keywords) { 0180 $keywords = null; 0181 } 0182 0183 $this->_data['keywords'] = $keywords; 0184 0185 return $this->_data['keywords']; 0186 } 0187 0188 /** 0189 * Get the entry's new feed url 0190 * 0191 * @return string 0192 */ 0193 public function getNewFeedUrl() 0194 { 0195 if (isset($this->_data['new-feed-url'])) { 0196 return $this->_data['new-feed-url']; 0197 } 0198 0199 $newFeedUrl = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:new-feed-url)'); 0200 0201 if (!$newFeedUrl) { 0202 $newFeedUrl = null; 0203 } 0204 0205 $this->_data['new-feed-url'] = $newFeedUrl; 0206 0207 return $this->_data['new-feed-url']; 0208 } 0209 0210 /** 0211 * Get the entry owner 0212 * 0213 * @return string 0214 */ 0215 public function getOwner() 0216 { 0217 if (isset($this->_data['owner'])) { 0218 return $this->_data['owner']; 0219 } 0220 0221 $owner = null; 0222 0223 $email = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:owner/itunes:email)'); 0224 $name = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:owner/itunes:name)'); 0225 0226 if (!empty($email)) { 0227 $owner = $email . (empty($name) ? '' : ' (' . $name . ')'); 0228 } else if (!empty($name)) { 0229 $owner = $name; 0230 } 0231 0232 if (!$owner) { 0233 $owner = null; 0234 } 0235 0236 $this->_data['owner'] = $owner; 0237 0238 return $this->_data['owner']; 0239 } 0240 0241 /** 0242 * Get the entry subtitle 0243 * 0244 * @return string 0245 */ 0246 public function getSubtitle() 0247 { 0248 if (isset($this->_data['subtitle'])) { 0249 return $this->_data['subtitle']; 0250 } 0251 0252 $subtitle = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:subtitle)'); 0253 0254 if (!$subtitle) { 0255 $subtitle = null; 0256 } 0257 0258 $this->_data['subtitle'] = $subtitle; 0259 0260 return $this->_data['subtitle']; 0261 } 0262 0263 /** 0264 * Get the entry summary 0265 * 0266 * @return string 0267 */ 0268 public function getSummary() 0269 { 0270 if (isset($this->_data['summary'])) { 0271 return $this->_data['summary']; 0272 } 0273 0274 $summary = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:summary)'); 0275 0276 if (!$summary) { 0277 $summary = null; 0278 } 0279 0280 $this->_data['summary'] = $summary; 0281 0282 return $this->_data['summary']; 0283 } 0284 0285 /** 0286 * Register iTunes namespace 0287 * 0288 */ 0289 protected function _registerNamespaces() 0290 { 0291 $this->_xpath->registerNamespace('itunes', 'http://www.itunes.com/dtds/podcast-1.0.dtd'); 0292 } 0293 }