summaryrefslogtreecommitdiff
path: root/classes/feeditem
diff options
context:
space:
mode:
authorTobias KappĂ© <[email protected]>2018-08-12 16:17:13 +0100
committerTobias KappĂ© <[email protected]>2018-08-12 16:17:13 +0100
commita377d5c981471f86c0d0c121be799aa0868e220e (patch)
tree10cbaf3e8e1a7a1e51ee17cfbbcc7a559ce48263 /classes/feeditem
parent3bbaf902abe70e28645dcd1bba20705e8db4676b (diff)
Determine language for atom entry without a loop.
Diffstat (limited to 'classes/feeditem')
-rw-r--r--classes/feeditem/atom.php14
1 files changed, 8 insertions, 6 deletions
diff --git a/classes/feeditem/atom.php b/classes/feeditem/atom.php
index 6e7a904f8..ee5591757 100644
--- a/classes/feeditem/atom.php
+++ b/classes/feeditem/atom.php
@@ -1,5 +1,6 @@
<?php
class FeedItem_Atom extends FeedItem_Common {
+ const NS_XML = "http://www.w3.org/XML/1998/namespace";
function get_id() {
$id = $this->elem->getElementsByTagName("id")->item(0);
@@ -198,12 +199,13 @@ class FeedItem_Atom extends FeedItem_Common {
}
function get_language() {
- $elem = $this->elem;
- do {
- $lang = $elem->getAttributeNS("http://www.w3.org/XML/1998/namespace", "lang");
- $elem = $elem->parentNode;
- } while (empty($lang) && $elem instanceof DOMElement);
+ $lang = $this->elem->getAttributeNS(self::NS_XML, "lang");
- return $lang;
+ if (!empty($lang)) {
+ return $lang;
+ } else {
+ // Fall back to the language declared on the feed, if any.
+ return $this->doc->firstChild->getAttributeNS(self::NS_XML, "lang");
+ }
}
}