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_CreativeCommons_Feed
0034     extends Zend_Feed_Reader_Extension_FeedAbstract
0035 {
0036     /**
0037      * Get the entry license
0038      *
0039      * @return string|null
0040      */
0041     public function getLicense($index = 0)
0042     {
0043         $licenses = $this->getLicenses();
0044 
0045         if (isset($licenses[$index])) {
0046             return $licenses[$index];
0047         }
0048 
0049         return null;
0050     }
0051 
0052     /**
0053      * Get the entry licenses
0054      *
0055      * @return array
0056      */
0057     public function getLicenses()
0058     {
0059         $name = 'licenses';
0060         if (array_key_exists($name, $this->_data)) {
0061             return $this->_data[$name];
0062         }
0063 
0064         $licenses = array();
0065         $list = $this->_xpath->evaluate('channel/cc:license');
0066 
0067         if ($list->length) {
0068             foreach ($list as $license) {
0069                 $licenses[] = $license->nodeValue;
0070             }
0071 
0072             $licenses = array_unique($licenses);
0073         }
0074 
0075         $this->_data[$name] = $licenses;
0076 
0077         return $this->_data[$name];
0078     }
0079 
0080     /**
0081      * Register Creative Commons namespaces
0082      *
0083      * @return void
0084      */
0085     protected function _registerNamespaces()
0086     {
0087         $this->_xpath->registerNamespace('cc', 'http://backend.userland.com/creativeCommonsRssModule');
0088     }
0089 }