1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 13:35:56 +00:00

Merge branch 'pullreq-store-language' of tkappe/tt-rss into master

This commit is contained in:
fox
2018-08-12 15:45:11 +00:00
committed by Gogs
5 changed files with 27 additions and 4 deletions

View File

@@ -11,5 +11,6 @@ abstract class FeedItem {
abstract function get_categories(); abstract function get_categories();
abstract function get_enclosures(); abstract function get_enclosures();
abstract function get_author(); abstract function get_author();
abstract function get_language();
} }

View File

@@ -1,5 +1,6 @@
<?php <?php
class FeedItem_Atom extends FeedItem_Common { class FeedItem_Atom extends FeedItem_Common {
const NS_XML = "http://www.w3.org/XML/1998/namespace";
function get_id() { function get_id() {
$id = $this->elem->getElementsByTagName("id")->item(0); $id = $this->elem->getElementsByTagName("id")->item(0);
@@ -197,4 +198,14 @@ class FeedItem_Atom extends FeedItem_Common {
return $encs; return $encs;
} }
function get_language() {
$lang = $this->elem->getAttributeNS(self::NS_XML, "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");
}
}
} }

View File

@@ -189,4 +189,14 @@ class FeedItem_RSS extends FeedItem_Common {
return $encs; return $encs;
} }
function get_language() {
$languages = $this->doc->getElementsByTagName('language');
if (count($languages) == 0) {
return "";
}
return $languages[0]->textContent;
}
} }

View File

@@ -637,8 +637,11 @@ class RSSUtils {
$entry_link = rewrite_relative_url($site_url, $item->get_link()); $entry_link = rewrite_relative_url($site_url, $item->get_link());
$entry_language = mb_substr(trim($item->get_language()), 0, 2);
_debug("title $entry_title", $debug_enabled); _debug("title $entry_title", $debug_enabled);
_debug("link $entry_link", $debug_enabled); _debug("link $entry_link", $debug_enabled);
_debug("language $entry_language", $debug_enabled);
if (!$entry_title) $entry_title = date("Y-m-d H:i:s", $entry_timestamp);; if (!$entry_title) $entry_title = date("Y-m-d H:i:s", $entry_timestamp);;
@@ -694,7 +697,6 @@ class RSSUtils {
$base_entry_id = $row["id"]; $base_entry_id = $row["id"];
$entry_stored_hash = $row["content_hash"]; $entry_stored_hash = $row["content_hash"];
$article_labels = Article::get_article_labels($base_entry_id, $owner_uid); $article_labels = Article::get_article_labels($base_entry_id, $owner_uid);
$entry_language = $row["lang"];
$existing_tags = Article::get_article_tags($base_entry_id, $owner_uid); $existing_tags = Article::get_article_tags($base_entry_id, $owner_uid);
$entry_tags = array_unique(array_merge($entry_tags, $existing_tags)); $entry_tags = array_unique(array_merge($entry_tags, $existing_tags));
@@ -702,7 +704,6 @@ class RSSUtils {
$base_entry_id = false; $base_entry_id = false;
$entry_stored_hash = ""; $entry_stored_hash = "";
$article_labels = array(); $article_labels = array();
$entry_language = "";
} }
$article = array("owner_uid" => $owner_uid, // read only $article = array("owner_uid" => $owner_uid, // read only