mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2026-01-07 16:09:14 +00:00
implement ttrss_feeds.cache_content
This commit is contained in:
@@ -280,7 +280,7 @@ class API extends Handler {
|
||||
|
||||
$article_id = join(",", array_filter(explode(",", db_escape_string($_REQUEST["article_id"])), is_numeric));
|
||||
|
||||
$query = "SELECT id,title,link,content,feed_id,comments,int_id,
|
||||
$query = "SELECT id,title,link,content,cached_content,feed_id,comments,int_id,
|
||||
marked,unread,published,
|
||||
".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
|
||||
author
|
||||
@@ -309,7 +309,7 @@ class API extends Handler {
|
||||
"comments" => $line["comments"],
|
||||
"author" => $line["author"],
|
||||
"updated" => strtotime($line["updated"]),
|
||||
"content" => $line["content"],
|
||||
"content" => $line["cached_content"] != "" ? $line["cached_content"] : $line["content"],
|
||||
"feed_id" => $line["feed_id"],
|
||||
"attachments" => $attachments
|
||||
);
|
||||
|
||||
@@ -158,16 +158,20 @@ class Feeds extends Handler_Protected {
|
||||
// Update the feed if required with some basic flood control
|
||||
|
||||
$result = db_query($this->link,
|
||||
"SELECT cache_images,".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
|
||||
"SELECT cache_images,cache_content,".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
|
||||
FROM ttrss_feeds WHERE id = '$feed'");
|
||||
|
||||
if (db_num_rows($result) != 0) {
|
||||
$last_updated = strtotime(db_fetch_result($result, 0, "last_updated"));
|
||||
$cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
|
||||
$cache_content = sql_bool_to_bool(db_fetch_result($result, 0, "cache_content"));
|
||||
|
||||
if (!$cache_images && time() - $last_updated > 120 || isset($_REQUEST['DevForceUpdate'])) {
|
||||
if (!$cache_images && !$cache_content && time() - $last_updated > 120 || isset($_REQUEST['DevForceUpdate'])) {
|
||||
include "rssfuncs.php";
|
||||
update_rss_feed($this->link, $feed, true, true);
|
||||
} else {
|
||||
db_query($this->link, "UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
|
||||
WHERE id = '$feed'");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,6 +238,7 @@ class Feeds extends Handler_Protected {
|
||||
$feed_title = $qfh_ret[1];
|
||||
$feed_site_url = $qfh_ret[2];
|
||||
$last_error = $qfh_ret[3];
|
||||
$cache_content = true;
|
||||
|
||||
$vgroup_last_feed = $vgr_last_feed;
|
||||
|
||||
@@ -627,6 +632,10 @@ class Feeds extends Handler_Protected {
|
||||
|
||||
$feed_site_url = $line["site_url"];
|
||||
|
||||
if ($cache_content && $line["cached_content"] != "") {
|
||||
$line["content_preview"] =& $line["cached_content"];
|
||||
}
|
||||
|
||||
$article_content = sanitize($this->link, $line["content_preview"],
|
||||
false, false, $feed_site_url);
|
||||
|
||||
|
||||
@@ -653,6 +653,19 @@ class Pref_Feeds extends Handler_Protected {
|
||||
$checked> <label for=\"cache_images\">".
|
||||
__('Cache images locally')."</label>";
|
||||
|
||||
$cache_content = sql_bool_to_bool(db_fetch_result($result, 0, "cache_content"));
|
||||
|
||||
if ($cache_content) {
|
||||
$checked = "checked=\"1\"";
|
||||
} else {
|
||||
$checked = "";
|
||||
}
|
||||
|
||||
print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"cache_content\"
|
||||
name=\"cache_content\"
|
||||
$checked> <label for=\"cache_content\">".
|
||||
__('Cache content locally')."</label>";
|
||||
|
||||
$mark_unread_on_update = sql_bool_to_bool(db_fetch_result($result, 0, "mark_unread_on_update"));
|
||||
|
||||
if ($mark_unread_on_update) {
|
||||
@@ -914,6 +927,8 @@ class Pref_Feeds extends Handler_Protected {
|
||||
db_escape_string($_POST["include_in_digest"]));
|
||||
$cache_images = checkbox_to_sql_bool(
|
||||
db_escape_string($_POST["cache_images"]));
|
||||
$cache_content = checkbox_to_sql_bool(
|
||||
db_escape_string($_POST["cache_content"]));
|
||||
$update_method = (int) db_escape_string($_POST["update_method"]);
|
||||
|
||||
$always_display_enclosures = checkbox_to_sql_bool(
|
||||
@@ -938,8 +953,6 @@ class Pref_Feeds extends Handler_Protected {
|
||||
$category_qpart_nocomma = "";
|
||||
}
|
||||
|
||||
$cache_images_qpart = "cache_images = $cache_images,";
|
||||
|
||||
if (!$batch) {
|
||||
|
||||
$result = db_query($this->link, "UPDATE ttrss_feeds SET
|
||||
@@ -951,7 +964,8 @@ class Pref_Feeds extends Handler_Protected {
|
||||
auth_pass = '$auth_pass',
|
||||
private = $private,
|
||||
rtl_content = $rtl_content,
|
||||
$cache_images_qpart
|
||||
cache_images = $cache_images,
|
||||
cache_content = $cache_content,
|
||||
include_in_digest = $include_in_digest,
|
||||
always_display_enclosures = $always_display_enclosures,
|
||||
mark_unread_on_update = $mark_unread_on_update,
|
||||
@@ -1023,6 +1037,10 @@ class Pref_Feeds extends Handler_Protected {
|
||||
$qpart = "cache_images = $cache_images";
|
||||
break;
|
||||
|
||||
case "cache_content":
|
||||
$qpart = "cache_content = $cache_content";
|
||||
break;
|
||||
|
||||
case "rtl_content":
|
||||
$qpart = "rtl_content = $rtl_content";
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user