Index: trunk/extensions/RSS/RSSData.php |
— | — | @@ -28,14 +28,12 @@ |
29 | 29 | $defaultNS = ""; |
30 | 30 | } |
31 | 31 | |
32 | | - $q = "/rss/channel/item"; |
33 | | - $q = preg_replace( '#(::|/\s*|\A)(?![/@].+?|[a-z\-]+::)#', '$1' . $defaultNS . '$2', $q ); |
34 | | - $items = $xpath->query( $q ); // is it an RSS feed ? |
| 32 | + // is it an RSS feed ? |
| 33 | + $items = $xpath->query( $this->namespacePrefixedQuery( "/rss/channel/item", $defaultNS ) ); |
35 | 34 | |
36 | 35 | if ( $items->length === 0 ) { |
37 | | - $q = "/feed/entry"; |
38 | | - $q = preg_replace( '#(::|/\s*|\A)(?![/@].+?|[a-z\-]+::)#', '$1' . $defaultNS . '$2', $q ); |
39 | | - $items = $xpath->query( $q ); // is it an ATOM feed ? |
| 36 | + // or is it an ATOM feed ? |
| 37 | + $items = $xpath->query( $this->namespacePrefixedQuery( "/feed/entry", $defaultNS ) ); |
40 | 38 | } |
41 | 39 | |
42 | 40 | if( $items->length !== 0 ) { |
— | — | @@ -63,6 +61,14 @@ |
64 | 62 | } |
65 | 63 | } |
66 | 64 | |
| 65 | + protected function namespacePrefixedQuery( $query, $namespace = "" ) { |
| 66 | + if ( $namespace !== "" ) { |
| 67 | + $ret = preg_replace( '#(::|/\s*|\A)(?![/@].+?|[a-z\-]+::)#', '$1' . $namespace . '$2', $query ); |
| 68 | + } else { |
| 69 | + $ret = $query; |
| 70 | + } |
| 71 | + return $ret; |
| 72 | + } |
67 | 73 | /** |
68 | 74 | * Return a string that will be used to map RSS elements that |
69 | 75 | * contain similar data (e.g. dc:date, date, and pubDate) to the |