|
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-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
19 * @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
20 */ |
|
21 |
|
22 /** |
|
23 * @see Zend_Feed_Reader_Extension_EntryAbstract |
|
24 */ |
|
25 require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; |
|
26 |
|
27 /** |
|
28 * @see Zend_Feed_Reader_Extension_CreativeCommons_Feed |
|
29 */ |
|
30 require_once 'Zend/Feed/Reader/Extension/CreativeCommons/Feed.php'; |
|
31 |
|
32 /** |
|
33 * @category Zend |
|
34 * @package Zend_Feed_Reader |
|
35 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
36 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
37 */ |
|
38 class Zend_Feed_Reader_Extension_CreativeCommons_Entry extends Zend_Feed_Reader_Extension_EntryAbstract |
|
39 { |
|
40 /** |
|
41 * Get the entry license |
|
42 * |
|
43 * @return string|null |
|
44 */ |
|
45 public function getLicense($index = 0) |
|
46 { |
|
47 $licenses = $this->getLicenses(); |
|
48 |
|
49 if (isset($licenses[$index])) { |
|
50 return $licenses[$index]; |
|
51 } |
|
52 |
|
53 return null; |
|
54 } |
|
55 |
|
56 /** |
|
57 * Get the entry licenses |
|
58 * |
|
59 * @return array |
|
60 */ |
|
61 public function getLicenses() |
|
62 { |
|
63 $name = 'licenses'; |
|
64 if (array_key_exists($name, $this->_data)) { |
|
65 return $this->_data[$name]; |
|
66 } |
|
67 |
|
68 $licenses = array(); |
|
69 $list = $this->_xpath->evaluate($this->getXpathPrefix() . '//cc:license'); |
|
70 |
|
71 if ($list->length) { |
|
72 foreach ($list as $license) { |
|
73 $licenses[] = $license->nodeValue; |
|
74 } |
|
75 |
|
76 $licenses = array_unique($licenses); |
|
77 } else { |
|
78 $cc = new Zend_Feed_Reader_Extension_CreativeCommons_Feed( |
|
79 $this->_domDocument, $this->_data['type'], $this->_xpath |
|
80 ); |
|
81 $licenses = $cc->getLicenses(); |
|
82 } |
|
83 |
|
84 $this->_data[$name] = $licenses; |
|
85 |
|
86 return $this->_data[$name]; |
|
87 } |
|
88 |
|
89 /** |
|
90 * Register Creative Commons namespaces |
|
91 * |
|
92 */ |
|
93 protected function _registerNamespaces() |
|
94 { |
|
95 $this->_xpath->registerNamespace('cc', 'http://backend.userland.com/creativeCommonsRssModule'); |
|
96 } |
|
97 } |