annotate vendor/zendframework/zend-feed/src/Reader/Extension/GooglePlayPodcast/Feed.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents c2387f117808
children
rev   line source
Chris@16 1 <?php
Chris@16 2 /**
Chris@16 3 * @see https://github.com/zendframework/zend-feed for the canonical source repository
Chris@16 4 * @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
Chris@16 5 * @license https://github.com/zendframework/zend-feed/blob/master/LICENSE.md New BSD License
Chris@16 6 */
Chris@16 7
Chris@16 8 namespace Zend\Feed\Reader\Extension\GooglePlayPodcast;
Chris@16 9
Chris@16 10 use DOMText;
Chris@16 11 use Zend\Feed\Reader\Extension;
Chris@16 12
Chris@16 13 class Feed extends Extension\AbstractFeed
Chris@16 14 {
Chris@16 15 /**
Chris@16 16 * Get the entry author
Chris@16 17 *
Chris@16 18 * @return string
Chris@16 19 */
Chris@16 20 public function getPlayPodcastAuthor()
Chris@16 21 {
Chris@16 22 if (isset($this->data['author'])) {
Chris@16 23 return $this->data['author'];
Chris@16 24 }
Chris@16 25
Chris@16 26 $author = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/googleplay:author)');
Chris@16 27
Chris@16 28 if (! $author) {
Chris@16 29 $author = null;
Chris@16 30 }
Chris@16 31
Chris@16 32 $this->data['author'] = $author;
Chris@16 33
Chris@16 34 return $this->data['author'];
Chris@16 35 }
Chris@16 36
Chris@16 37 /**
Chris@16 38 * Get the entry block
Chris@16 39 *
Chris@16 40 * @return string
Chris@16 41 */
Chris@16 42 public function getPlayPodcastBlock()
Chris@16 43 {
Chris@16 44 if (isset($this->data['block'])) {
Chris@16 45 return $this->data['block'];
Chris@16 46 }
Chris@16 47
Chris@16 48 $block = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/googleplay:block)');
Chris@16 49
Chris@16 50 if (! $block) {
Chris@16 51 $block = null;
Chris@16 52 }
Chris@16 53
Chris@16 54 $this->data['block'] = $block;
Chris@16 55
Chris@16 56 return $this->data['block'];
Chris@16 57 }
Chris@16 58
Chris@16 59 /**
Chris@16 60 * Get the entry category
Chris@16 61 *
Chris@16 62 * @return array|null
Chris@16 63 */
Chris@16 64 public function getPlayPodcastCategories()
Chris@16 65 {
Chris@16 66 if (isset($this->data['categories'])) {
Chris@16 67 return $this->data['categories'];
Chris@16 68 }
Chris@16 69
Chris@16 70 $categoryList = $this->xpath->query($this->getXpathPrefix() . '/googleplay:category');
Chris@16 71
Chris@16 72 $categories = [];
Chris@16 73
Chris@16 74 if ($categoryList->length > 0) {
Chris@16 75 foreach ($categoryList as $node) {
Chris@16 76 $children = null;
Chris@16 77
Chris@16 78 if ($node->childNodes->length > 0) {
Chris@16 79 $children = [];
Chris@16 80
Chris@16 81 foreach ($node->childNodes as $childNode) {
Chris@16 82 if (! ($childNode instanceof DOMText)) {
Chris@16 83 $children[$childNode->getAttribute('text')] = null;
Chris@16 84 }
Chris@16 85 }
Chris@16 86 }
Chris@16 87
Chris@16 88 $categories[$node->getAttribute('text')] = $children;
Chris@16 89 }
Chris@16 90 }
Chris@16 91
Chris@16 92 if (! $categories) {
Chris@16 93 $categories = null;
Chris@16 94 }
Chris@16 95
Chris@16 96 $this->data['categories'] = $categories;
Chris@16 97
Chris@16 98 return $this->data['categories'];
Chris@16 99 }
Chris@16 100
Chris@16 101 /**
Chris@16 102 * Get the entry explicit
Chris@16 103 *
Chris@16 104 * @return string
Chris@16 105 */
Chris@16 106 public function getPlayPodcastExplicit()
Chris@16 107 {
Chris@16 108 if (isset($this->data['explicit'])) {
Chris@16 109 return $this->data['explicit'];
Chris@16 110 }
Chris@16 111
Chris@16 112 $explicit = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/googleplay:explicit)');
Chris@16 113
Chris@16 114 if (! $explicit) {
Chris@16 115 $explicit = null;
Chris@16 116 }
Chris@16 117
Chris@16 118 $this->data['explicit'] = $explicit;
Chris@16 119
Chris@16 120 return $this->data['explicit'];
Chris@16 121 }
Chris@16 122
Chris@16 123 /**
Chris@16 124 * Get the feed/podcast image
Chris@16 125 *
Chris@16 126 * @return string
Chris@16 127 */
Chris@16 128 public function getPlayPodcastImage()
Chris@16 129 {
Chris@16 130 if (isset($this->data['image'])) {
Chris@16 131 return $this->data['image'];
Chris@16 132 }
Chris@16 133
Chris@16 134 $image = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/googleplay:image/@href)');
Chris@16 135
Chris@16 136 if (! $image) {
Chris@16 137 $image = null;
Chris@16 138 }
Chris@16 139
Chris@16 140 $this->data['image'] = $image;
Chris@16 141
Chris@16 142 return $this->data['image'];
Chris@16 143 }
Chris@16 144
Chris@16 145 /**
Chris@16 146 * Get the entry description
Chris@16 147 *
Chris@16 148 * @return string
Chris@16 149 */
Chris@16 150 public function getPlayPodcastDescription()
Chris@16 151 {
Chris@16 152 if (isset($this->data['description'])) {
Chris@16 153 return $this->data['description'];
Chris@16 154 }
Chris@16 155
Chris@16 156 $description = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/googleplay:description)');
Chris@16 157
Chris@16 158 if (! $description) {
Chris@16 159 $description = null;
Chris@16 160 }
Chris@16 161
Chris@16 162 $this->data['description'] = $description;
Chris@16 163
Chris@16 164 return $this->data['description'];
Chris@16 165 }
Chris@16 166
Chris@16 167 /**
Chris@16 168 * Register googleplay namespace
Chris@16 169 *
Chris@16 170 */
Chris@16 171 protected function registerNamespaces()
Chris@16 172 {
Chris@16 173 $this->xpath->registerNamespace('googleplay', 'http://www.google.com/schemas/play-podcasts/1.0');
Chris@16 174 }
Chris@16 175 }