drop BACKEND_RSS_TYPE from update_rss_feed, support detection of dc:subject as tags in Atom feeds

This commit is contained in:
Andrew Dolgov 2006-12-25 08:53:57 +01:00
parent 8fd2dc95ba
commit be832a1a56
1 changed files with 98 additions and 79 deletions

View File

@ -488,91 +488,98 @@
foreach ($iterator as $item) {
if (RSS_BACKEND_TYPE == "magpie") {
$entry_guid = $item["id"];
if (!$entry_guid) $entry_guid = $item["guid"];
if (!$entry_guid) $entry_guid = $item["link"];
if (!$entry_guid) $entry_guid = make_guid_from_title($item["title"]);
$entry_guid = $item["id"];
if (!$entry_guid) $entry_guid = $item["guid"];
if (!$entry_guid) $entry_guid = $item["link"];
if (!$entry_guid) $entry_guid = make_guid_from_title($item["title"]);
if (!$entry_guid) continue;
$entry_timestamp = "";
$rss_2_date = $item['pubdate'];
$rss_1_date = $item['dc']['date'];
$atom_date = $item['issued'];
if (!$atom_date) $atom_date = $item['updated'];
if (!$entry_guid) continue;
$entry_timestamp = "";
$rss_2_date = $item['pubdate'];
$rss_1_date = $item['dc']['date'];
$atom_date = $item['issued'];
if (!$atom_date) $atom_date = $item['updated'];
if ($atom_date != "") $entry_timestamp = parse_w3cdtf($atom_date);
if ($rss_1_date != "") $entry_timestamp = parse_w3cdtf($rss_1_date);
if ($rss_2_date != "") $entry_timestamp = strtotime($rss_2_date);
if ($atom_date != "") $entry_timestamp = parse_w3cdtf($atom_date);
if ($rss_1_date != "") $entry_timestamp = parse_w3cdtf($rss_1_date);
if ($rss_2_date != "") $entry_timestamp = strtotime($rss_2_date);
if ($entry_timestamp == "") {
$entry_timestamp = time();
$no_orig_date = 'true';
} else {
$no_orig_date = 'false';
}
$entry_timestamp_fmt = strftime("%Y/%m/%d %H:%M:%S", $entry_timestamp);
$entry_title = trim(strip_tags($item["title"]));
// strange Magpie workaround
$entry_link = $item["link_"];
if (!$entry_link) $entry_link = $item["link"];
if (!$entry_title) continue;
if ($entry_timestamp == "") {
$entry_timestamp = time();
$no_orig_date = 'true';
} else {
$no_orig_date = 'false';
}
$entry_timestamp_fmt = strftime("%Y/%m/%d %H:%M:%S", $entry_timestamp);
$entry_title = trim(strip_tags($item["title"]));
// strange Magpie workaround
$entry_link = $item["link_"];
if (!$entry_link) $entry_link = $item["link"];
if (!$entry_title) continue;
# if (!$entry_link) continue;
$entry_link = strip_tags($entry_link);
$entry_link = strip_tags($entry_link);
$entry_content = $item["content:escaped"];
if (!$entry_content) $entry_content = $item["content:encoded"];
if (!$entry_content) $entry_content = $item["content"];
if (!$entry_content) $entry_content = $item["atom_content"];
if (!$entry_content) $entry_content = $item["summary"];
if (!$entry_content) $entry_content = $item["description"];
// if (!$entry_content) continue;
// WTF
if (is_array($entry_content)) {
$entry_content = $entry_content["encoded"];
if (!$entry_content) $entry_content = $entry_content["escaped"];
}
// print_r($item);
// print_r(htmlspecialchars($entry_content));
// print "<br>";
$entry_content_unescaped = $entry_content;
$content_hash = "SHA1:" . sha1(strip_tags($entry_content));
$entry_comments = strip_tags($item["comments"]);
$entry_content = $item["content:escaped"];
$entry_author = db_escape_string(strip_tags($item['dc']['creator']));
if (!$entry_content) $entry_content = $item["content:encoded"];
if (!$entry_content) $entry_content = $item["content"];
if (!$entry_content) $entry_content = $item["atom_content"];
if (!$entry_content) $entry_content = $item["summary"];
if (!$entry_content) $entry_content = $item["description"];
if (!$entry_author) {
$entry_author = db_escape_string(strip_tags($item['author']));
}
// if (!$entry_content) continue;
$entry_guid = db_escape_string(strip_tags($entry_guid));
$result = db_query($link, "SELECT id FROM ttrss_entries
WHERE guid = '$entry_guid'");
$entry_content = db_escape_string($entry_content);
$entry_title = db_escape_string($entry_title);
$entry_link = db_escape_string($entry_link);
$entry_comments = db_escape_string($entry_comments);
$num_comments = db_escape_string($item["slash"]["comments"]);
if (!$num_comments) $num_comments = 0;
// WTF
if (is_array($entry_content)) {
$entry_content = $entry_content["encoded"];
if (!$entry_content) $entry_content = $entry_content["escaped"];
}
// print_r($item);
// print_r(htmlspecialchars($entry_content));
// print "<br>";
$entry_content_unescaped = $entry_content;
$content_hash = "SHA1:" . sha1(strip_tags($entry_content));
$entry_comments = strip_tags($item["comments"]);
$entry_author = db_escape_string(strip_tags($item['dc']['creator']));
if (!$entry_author) {
$entry_author = db_escape_string(strip_tags($item['author']));
}
$entry_guid = db_escape_string(strip_tags($entry_guid));
$result = db_query($link, "SELECT id FROM ttrss_entries
WHERE guid = '$entry_guid'");
$entry_content = db_escape_string($entry_content);
$entry_title = db_escape_string($entry_title);
$entry_link = db_escape_string($entry_link);
$entry_comments = db_escape_string($entry_comments);
$num_comments = db_escape_string($item["slash"]["comments"]);
if (!$num_comments) $num_comments = 0;
$dc_subject = $item['dc']['subject'];
$subject_tags = false;
if (is_array($dc_subject)) {
$subject_tags = $dc_subject;
} else if ($dc_subject) {
$subject_tags = array($dc_subject);
}
# sanitize content
@ -761,8 +768,16 @@
$manual_tags = trim_array(split(",", $filter_param));
foreach ($manual_tags as $tag) {
if (!preg_match("/^[0-9]*$/", $tag) && $tag != '') {
foreach ($manual_tags as $tag) {
if (tag_is_valid($tag)) {
array_push($entry_tags, $tag);
}
}
}
if ($subject_tags) {
foreach ($subject_tags as $tag) {
if (tag_is_valid($tag)) {
array_push($entry_tags, $tag);
}
}
@ -3112,4 +3127,8 @@
return $tmp;
}
function tag_is_valid($tag) {
return ($tag !='' && !preg_match("/^[0-9]*$/", $tag));
}
?>