Browse Source

simplify media:content xpath

Andrew Dolgov 7 years ago
parent
commit
6bf61bdc63
2 changed files with 2 additions and 26 deletions
  1. 1 13
      classes/feeditem/atom.php
  2. 1 13
      classes/feeditem/rss.php

+ 1 - 13
classes/feeditem/atom.php

@@ -137,19 +137,7 @@ class FeedItem_Atom extends FeedItem_Common {
 			}
 		}
 
-		$enclosures = $this->xpath->query("media:content", $this->elem);
-
-		foreach ($enclosures as $enclosure) {
-			$enc = new FeedEnclosure();
-
-			$enc->type = $enclosure->getAttribute("type");
-			$enc->link = $enclosure->getAttribute("url");
-			$enc->length = $enclosure->getAttribute("length");
-
-			array_push($encs, $enc);
-		}
-
-		$enclosures = $this->xpath->query("media:group/media:content", $this->elem);
+		$enclosures = $this->xpath->query("media:content | media:group/media:content", $this->elem);
 
 		foreach ($enclosures as $enclosure) {
 			$enc = new FeedEnclosure();

+ 1 - 13
classes/feeditem/rss.php

@@ -112,19 +112,7 @@ class FeedItem_RSS extends FeedItem_Common {
 			array_push($encs, $enc);
 		}
 
-		$enclosures = $this->xpath->query("media:content", $this->elem);
-
-		foreach ($enclosures as $enclosure) {
-			$enc = new FeedEnclosure();
-
-			$enc->type = $enclosure->getAttribute("type");
-			$enc->link = $enclosure->getAttribute("url");
-			$enc->length = $enclosure->getAttribute("length");
-
-			array_push($encs, $enc);
-		}
-
-		$enclosures = $this->xpath->query("media:group/media:content", $this->elem);
+		$enclosures = $this->xpath->query("media:content | media:group/media:content", $this->elem);
 
 		foreach ($enclosures as $enclosure) {
 			$enc = new FeedEnclosure();