12 * obtain it through the world-wide-web, please send an email |
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. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Feed_Reader |
16 * @package Zend_Feed_Reader |
17 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
17 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @version $Id: Entry.php 23170 2010-10-19 18:29:24Z mabe $ |
19 * @version $Id: Entry.php 24593 2012-01-05 20:35:02Z matthew $ |
20 */ |
20 */ |
21 |
21 |
22 /** |
22 /** |
23 * @see Zend_Feed_Reader |
23 * @see Zend_Feed_Reader |
24 */ |
24 */ |
50 require_once 'Zend/Feed/Reader/Feed/Atom/Source.php'; |
50 require_once 'Zend/Feed/Reader/Feed/Atom/Source.php'; |
51 |
51 |
52 /** |
52 /** |
53 * @category Zend |
53 * @category Zend |
54 * @package Zend_Feed_Reader |
54 * @package Zend_Feed_Reader |
55 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
55 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
56 * @license http://framework.zend.com/license/new-bsd New BSD License |
56 * @license http://framework.zend.com/license/new-bsd New BSD License |
57 */ |
57 */ |
58 class Zend_Feed_Reader_Extension_Atom_Entry |
58 class Zend_Feed_Reader_Extension_Atom_Entry |
59 extends Zend_Feed_Reader_Extension_EntryAbstract |
59 extends Zend_Feed_Reader_Extension_EntryAbstract |
60 { |
60 { |
125 public function getContent() |
125 public function getContent() |
126 { |
126 { |
127 if (array_key_exists('content', $this->_data)) { |
127 if (array_key_exists('content', $this->_data)) { |
128 return $this->_data['content']; |
128 return $this->_data['content']; |
129 } |
129 } |
130 |
130 |
131 $content = null; |
131 $content = null; |
132 |
132 |
133 $el = $this->getXpath()->query($this->getXpathPrefix() . '/atom:content'); |
133 $el = $this->getXpath()->query($this->getXpathPrefix() . '/atom:content'); |
134 if($el->length > 0) { |
134 if($el->length > 0) { |
135 $el = $el->item(0); |
135 $el = $el->item(0); |
136 $type = $el->getAttribute('type'); |
136 $type = $el->getAttribute('type'); |
137 switch ($type) { |
137 switch ($type) { |
156 $d->lookupPrefix('http://www.w3.org/1999/xhtml') |
156 $d->lookupPrefix('http://www.w3.org/1999/xhtml') |
157 ); |
157 ); |
158 break; |
158 break; |
159 } |
159 } |
160 } |
160 } |
161 |
161 |
162 //var_dump($content); exit; |
162 //var_dump($content); exit; |
163 |
163 |
164 if (!$content) { |
164 if (!$content) { |
165 $content = $this->getDescription(); |
165 $content = $this->getDescription(); |
166 } |
166 } |
167 |
167 |
168 $this->_data['content'] = trim($content); |
168 $this->_data['content'] = trim($content); |
169 |
169 |
170 return $this->_data['content']; |
170 return $this->_data['content']; |
171 } |
171 } |
172 |
172 |
173 /** |
173 /** |
174 * Parse out XHTML to remove the namespacing |
174 * Parse out XHTML to remove the namespacing |
175 */ |
175 */ |
176 protected function _collectXhtml($xhtml, $prefix) |
176 protected function _collectXhtml($xhtml, $prefix) |
177 { |
177 { |
549 |
549 |
550 $this->_data['categories'] = $categoryCollection; |
550 $this->_data['categories'] = $categoryCollection; |
551 |
551 |
552 return $this->_data['categories']; |
552 return $this->_data['categories']; |
553 } |
553 } |
554 |
554 |
555 /** |
555 /** |
556 * Get source feed metadata from the entry |
556 * Get source feed metadata from the entry |
557 * |
557 * |
558 * @return Zend_Feed_Reader_Feed_Atom_Source|null |
558 * @return Zend_Feed_Reader_Feed_Atom_Source|null |
559 */ |
559 */ |
560 public function getSource() |
560 public function getSource() |
561 { |
561 { |
562 if (array_key_exists('source', $this->_data)) { |
562 if (array_key_exists('source', $this->_data)) { |
563 return $this->_data['source']; |
563 return $this->_data['source']; |
564 } |
564 } |
565 |
565 |
566 $source = null; |
566 $source = null; |
567 // TODO: Investigate why _getAtomType() fails here. Is it even needed? |
567 // TODO: Investigate why _getAtomType() fails here. Is it even needed? |
568 if ($this->getType() == Zend_Feed_Reader::TYPE_ATOM_10) { |
568 if ($this->getType() == Zend_Feed_Reader::TYPE_ATOM_10) { |
569 $list = $this->getXpath()->query($this->getXpathPrefix() . '/atom:source[1]'); |
569 $list = $this->getXpath()->query($this->getXpathPrefix() . '/atom:source[1]'); |
570 if ($list->length) { |
570 if ($list->length) { |
571 $element = $list->item(0); |
571 $element = $list->item(0); |
572 $source = new Zend_Feed_Reader_Feed_Atom_Source($element, $this->getXpathPrefix()); |
572 $source = new Zend_Feed_Reader_Feed_Atom_Source($element, $this->getXpathPrefix()); |
573 } |
573 } |
574 } |
574 } |
575 |
575 |
576 $this->_data['source'] = $source; |
576 $this->_data['source'] = $source; |
577 return $this->_data['source']; |
577 return $this->_data['source']; |
578 } |
578 } |
579 |
579 |
580 /** |
580 /** |
581 * Attempt to absolutise the URI, i.e. if a relative URI apply the |
581 * Attempt to absolutise the URI, i.e. if a relative URI apply the |
582 * xml:base value as a prefix to turn into an absolute URI. |
582 * xml:base value as a prefix to turn into an absolute URI. |
605 $author = array(); |
605 $author = array(); |
606 |
606 |
607 $emailNode = $element->getElementsByTagName('email'); |
607 $emailNode = $element->getElementsByTagName('email'); |
608 $nameNode = $element->getElementsByTagName('name'); |
608 $nameNode = $element->getElementsByTagName('name'); |
609 $uriNode = $element->getElementsByTagName('uri'); |
609 $uriNode = $element->getElementsByTagName('uri'); |
610 |
610 |
611 if ($emailNode->length && strlen($emailNode->item(0)->nodeValue) > 0) { |
611 if ($emailNode->length && strlen($emailNode->item(0)->nodeValue) > 0) { |
612 $author['email'] = $emailNode->item(0)->nodeValue; |
612 $author['email'] = $emailNode->item(0)->nodeValue; |
613 } |
613 } |
614 |
614 |
615 if ($nameNode->length && strlen($nameNode->item(0)->nodeValue) > 0) { |
615 if ($nameNode->length && strlen($nameNode->item(0)->nodeValue) > 0) { |