comparison vendor/zendframework/zend-feed/src/Reader/Extension/CreativeCommons/Entry.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
4 *
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
9
10 namespace Zend\Feed\Reader\Extension\CreativeCommons;
11
12 use Zend\Feed\Reader\Extension;
13
14 class Entry extends Extension\AbstractEntry
15 {
16 /**
17 * Get the entry license
18 *
19 * @param int $index
20 * @return string|null
21 */
22 public function getLicense($index = 0)
23 {
24 $licenses = $this->getLicenses();
25
26 if (isset($licenses[$index])) {
27 return $licenses[$index];
28 }
29
30 return;
31 }
32
33 /**
34 * Get the entry licenses
35 *
36 * @return array
37 */
38 public function getLicenses()
39 {
40 $name = 'licenses';
41 if (array_key_exists($name, $this->data)) {
42 return $this->data[$name];
43 }
44
45 $licenses = [];
46 $list = $this->xpath->evaluate($this->getXpathPrefix() . '//cc:license');
47
48 if ($list->length) {
49 foreach ($list as $license) {
50 $licenses[] = $license->nodeValue;
51 }
52
53 $licenses = array_unique($licenses);
54 } else {
55 $cc = new Feed();
56 $licenses = $cc->getLicenses();
57 }
58
59 $this->data[$name] = $licenses;
60
61 return $this->data[$name];
62 }
63
64 /**
65 * Register Creative Commons namespaces
66 *
67 */
68 protected function registerNamespaces()
69 {
70 $this->xpath->registerNamespace('cc', 'http://backend.userland.com/creativeCommonsRssModule');
71 }
72 }