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 0024 */ 0025 // require_once 'Zend/Feed/Reader.php'; 0026 0027 /** 0028 * @see Zend_Feed_Reader_Extension_EntryAbstract 0029 */ 0030 // require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; 0031 0032 /** 0033 * @category Zend 0034 * @package Zend_Feed_Reader 0035 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0036 * @license http://framework.zend.com/license/new-bsd New BSD License 0037 */ 0038 class Zend_Feed_Reader_Extension_Slash_Entry 0039 extends Zend_Feed_Reader_Extension_EntryAbstract 0040 { 0041 /** 0042 * Get the entry section 0043 * 0044 * @return string|null 0045 */ 0046 public function getSection() 0047 { 0048 return $this->_getData('section'); 0049 } 0050 0051 /** 0052 * Get the entry department 0053 * 0054 * @return string|null 0055 */ 0056 public function getDepartment() 0057 { 0058 return $this->_getData('department'); 0059 } 0060 0061 /** 0062 * Get the entry hit_parade 0063 * 0064 * @return array 0065 */ 0066 public function getHitParade() 0067 { 0068 $name = 'hit_parade'; 0069 0070 if (isset($this->_data[$name])) { 0071 return $this->_data[$name]; 0072 } 0073 0074 $stringParade = $this->_getData($name); 0075 $hitParade = array(); 0076 0077 if (!empty($stringParade)) { 0078 $stringParade = explode(',', $stringParade); 0079 0080 foreach ($stringParade as $hit) 0081 $hitParade[] = $hit + 0; //cast to integer 0082 } 0083 0084 $this->_data[$name] = $hitParade; 0085 return $hitParade; 0086 } 0087 0088 /** 0089 * Get the entry comments 0090 * 0091 * @return int 0092 */ 0093 public function getCommentCount() 0094 { 0095 $name = 'comments'; 0096 0097 if (isset($this->_data[$name])) { 0098 return $this->_data[$name]; 0099 } 0100 0101 $comments = $this->_getData($name, 'string'); 0102 0103 if (!$comments) { 0104 $this->_data[$name] = null; 0105 return $this->_data[$name]; 0106 } 0107 0108 return $comments; 0109 } 0110 0111 /** 0112 * Get the entry data specified by name 0113 * @param string $name 0114 * @param string $type 0115 * 0116 * @return mixed|null 0117 */ 0118 protected function _getData($name, $type = 'string') 0119 { 0120 if (array_key_exists($name, $this->_data)) { 0121 return $this->_data[$name]; 0122 } 0123 0124 $data = $this->_xpath->evaluate($type . '(' . $this->getXpathPrefix() . '/slash10:' . $name . ')'); 0125 0126 if (!$data) { 0127 $data = null; 0128 } 0129 0130 $this->_data[$name] = $data; 0131 0132 return $data; 0133 } 0134 0135 /** 0136 * Register Slash namespaces 0137 * 0138 * @return void 0139 */ 0140 protected function _registerNamespaces() 0141 { 0142 $this->_xpath->registerNamespace('slash10', 'http://purl.org/rss/1.0/modules/slash/'); 0143 } 0144 }