1: <?php
2: /**
3: * Portions Copyright 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
4: * Copyright 2007-2012 Horde LLC (http://www.horde.org/)
5: *
6: * @category Horde
7: * @package Feed
8: */
9:
10: /**
11: * RSS channel class
12: *
13: * The Horde_Feed_Rss class is a concrete subclass of Horde_Feed_Base
14: * meant for representing RSS channels. It does not add any methods to
15: * its parent, just provides a classname to check against with the
16: * instanceof operator, and expects to be handling RSS-formatted data
17: * instead of Atom.
18: *
19: * @category Horde
20: * @package Feed
21: */
22: class Horde_Feed_Rss extends Horde_Feed_Base
23: {
24: /**
25: * The classname for individual channel elements.
26: * @var string
27: */
28: protected $_listItemClassName = 'Horde_Feed_Entry_Rss';
29:
30: /**
31: * The default namespace for RSS channels.
32: * @var string
33: */
34: protected $_defaultNamespace = 'rss';
35:
36: /**
37: * The XML string for an "empty" RSS feed.
38: * @var string
39: */
40: protected $_emptyXml = '<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel></channel></rss>';
41:
42: /**
43: * Cache the individual feed elements so they don't need to be searched for
44: * on every operation.
45: * @return array
46: */
47: protected function _buildListItemCache()
48: {
49: $items = array();
50: foreach ($this->_element->childNodes as $child) {
51: if ($child->localName == 'item') {
52: $items[] = $child;
53: }
54: }
55:
56: // Brute-force search for <item> elements if we haven't found any so
57: // far.
58: if (!count($items)) {
59: foreach ($this->_element->ownerDocument->getElementsByTagName('item') as $child) {
60: $items[] = $child;
61: }
62: }
63:
64: return $items;
65: }
66:
67: }
68: