From 891e36f57e2e3955a4f13019e8fdc58fce826434 Mon Sep 17 00:00:00 2001 From: justauser Date: Thu, 27 Jun 2013 11:18:23 -0400 Subject: Changes to add a new hook: HOOK_QUERY_HEADLINES. An example is provided. --- classes/api.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index 23866072f..139a486ee 100644 --- a/classes/api.php +++ b/classes/api.php @@ -636,8 +636,13 @@ class API extends Handler { $feed_title = $qfh_ret[1]; $headlines = array(); - + while ($line = db_fetch_assoc($result)) { + + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { + $line = $p->hook_query_headlines($line, 100, true); + } + $is_updated = ($line["last_read"] == "" && ($line["unread"] != "t" && $line["unread"] != "1")); @@ -664,24 +669,27 @@ class API extends Handler { $headline_row['attachments'] = get_article_enclosures( $line['id']); - if ($show_excerpt) { - $excerpt = truncate_string(strip_tags($line["content_preview"]), 100); + if ($show_excerpt ){ + if(isset($line["modified_preview"])) + $excerpt = strip_tags($line["content_preview"]); + else + $excerpt = truncate_string(strip_tags($line["content_preview"]), 100); $headline_row["excerpt"] = $excerpt; } if ($show_content) { if ($line["cached_content"] != "") { - $line["content_preview"] =& $line["cached_content"]; + $line["content"] =& $line["cached_content"]; } if ($sanitize_content) { $headline_row["content"] = sanitize( - $line["content_preview"], + $line["content"], sql_bool_to_bool($line['hide_images']), false, $line["site_url"]); } else { - $headline_row["content"] = $line["content_preview"]; + $headline_row["content"] = $line["content"]; } } @@ -699,6 +707,7 @@ class API extends Handler { $headline_row["always_display_attachments"] = sql_bool_to_bool($line["always_display_enclosures"]); $headline_row["author"] = $line["author"]; + $headline_row["score"] = (int)$line["score"]; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) { -- cgit v1.2.3-54-g00ecf From 67631438353273ea260be518e627bc25500e01f2 Mon Sep 17 00:00:00 2001 From: justauser Date: Fri, 28 Jun 2013 10:46:45 -0400 Subject: Changed the implementation of HOOK_QUERY_HEADLINES to deal with issue Fox raised --- classes/api.php | 11 +++-------- classes/feeds.php | 15 +++++---------- classes/handler/public.php | 14 ++++---------- classes/pref/filters.php | 9 +++------ 4 files changed, 15 insertions(+), 34 deletions(-) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index 139a486ee..aa092df78 100644 --- a/classes/api.php +++ b/classes/api.php @@ -638,7 +638,7 @@ class API extends Handler { $headlines = array(); while ($line = db_fetch_assoc($result)) { - + $line["content_preview"] = truncate_string(strip_tags($line["content_preview"]), 100); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { $line = $p->hook_query_headlines($line, 100, true); } @@ -669,13 +669,8 @@ class API extends Handler { $headline_row['attachments'] = get_article_enclosures( $line['id']); - if ($show_excerpt ){ - if(isset($line["modified_preview"])) - $excerpt = strip_tags($line["content_preview"]); - else - $excerpt = truncate_string(strip_tags($line["content_preview"]), 100); - $headline_row["excerpt"] = $excerpt; - } + if (!$show_excerpt ) + $headline_row["excerpt"] = $ine["content_preview"]; if ($show_content) { diff --git a/classes/feeds.php b/classes/feeds.php index b0447fd25..44af9ae0b 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -286,8 +286,9 @@ class Feeds extends Handler_Protected { if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info); $expand_cdm = get_pref('CDM_EXPANDED'); - + while ($line = $this->dbh->fetch_assoc($result)) { + $line["content_preview"] = "— " . truncate_string(strip_tags($line["content_preview"]),250); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { $line = $p->hook_query_headlines($line, 250); } @@ -364,11 +365,7 @@ class Feeds extends Handler_Protected { make_local_datetime($line["date_entered"], false)); if (get_pref('SHOW_CONTENT_PREVIEW') ) { - if(isset($line["modified_preview"])) - $content_preview = " — " . strip_tags($line["content_preview"]); - else - $content_preview = " — " . truncate_string(strip_tags($line["content_preview"]), - 250); + $content_preview = $line["content_preview"]; } $score = $line["score"]; @@ -461,9 +458,7 @@ class Feeds extends Handler_Protected { truncate_string($line["title"], 200); if (get_pref('SHOW_CONTENT_PREVIEW')) { - if ($content_preview) { - $reply['content'] .= "$content_preview"; - } + $reply['content'] .= "" . $line["content_preview"] . ""; } $reply['content'] .= ""; @@ -580,7 +575,7 @@ class Feeds extends Handler_Protected { else $excerpt_hidden = "style=\"display : none\""; - $reply['content'] .= "$content_preview"; + $reply['content'] .= "" . $line["content_preview"] . ""; $reply['content'] .= ""; diff --git a/classes/handler/public.php b/classes/handler/public.php index 825ea5e2e..08f35e212 100644 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -85,7 +85,7 @@ class Handler_Public extends Handler { } $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true); - + $line["content_preview"] = truncate_string(strip_tags($line["content_preview"]), 100, '...'); while ($line = $this->dbh->fetch_assoc($result)) { foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { $line = $p->hook_query_headlines($line); @@ -94,11 +94,7 @@ class Handler_Public extends Handler { $tpl->setVariable('ARTICLE_ID', htmlspecialchars($line['link']), true); $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true); $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true); - if(isset($line["modified_preview"])) - $tpl->setVariable('ARTICLE_EXCERPT', strip_tags($line["content_preview"]), true); - else - $tpl->setVariable('ARTICLE_EXCERPT', - truncate_string(strip_tags($line["content_preview"]), 100, '...'), true); + $tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true); $content = sanitize($line["content"], false, $owner_uid); @@ -170,6 +166,7 @@ class Handler_Public extends Handler { $feed['articles'] = array(); while ($line = $this->dbh->fetch_assoc($result)) { + $line["content_preview"]] = truncate_string(strip_tags($line["content_preview"]), 100, '...'); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { $line = $p->hook_query_headlines($line, 100); } @@ -178,10 +175,7 @@ class Handler_Public extends Handler { $article['id'] = $line['link']; $article['link'] = $line['link']; $article['title'] = $line['title']; - if(isset($line["modified_preview"])) - $article['excerpt'] = strip_tags($line["content_preview"]); - else - $article['excerpt'] = truncate_string(strip_tags($line["content_preview"]), 100, '...'); + $article['excerpt'] = $line["content_preview"]; $article['content'] = sanitize($line["content"], false, $owner_uid); $article['updated'] = date('c', strtotime($line["updated"])); diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 63318033e..5d19a5556 100644 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -95,7 +95,7 @@ class Pref_Filters extends Handler_Protected { print "
"; print ""; - + $line["content_preview"] = strip_tags($line["content_preview"]), 100, '...'); while ($line = $this->dbh->fetch_assoc($result)) { foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { $line = $p->hook_query_headlines($line, 100); @@ -104,10 +104,7 @@ class Pref_Filters extends Handler_Protected { $entry_timestamp = strtotime($line["updated"]); $entry_tags = get_article_tags($line["id"], $_SESSION["uid"]); - if(isset($line["modified_preview"])) - $content_preview = strip_tags($line["content_preview"]); - else - $content_preview = truncate_string(strip_tags($line["content_preview"]), 100, '...'); + $content_preview = $line["content_preview"]; if ($line["feed_title"]) $feed_title = $line["feed_title"]; @@ -123,7 +120,7 @@ class Pref_Filters extends Handler_Protected { print " ("; print "" . $feed_title . ""; print "): "; - print "" . $content_preview . ""; + print "" . $line["content_preview"] . ""; print " " . mb_substr($line["date_entered"], 0, 16); print ""; -- cgit v1.2.3-54-g00ecf From e9687f67e0196c063536c8e7770094129a42f2ef Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 6 Jul 2013 12:03:01 +0400 Subject: date_reverse view mode: take scoring into account --- classes/api.php | 2 +- classes/feeds.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index 23866072f..334f5fdc9 100644 --- a/classes/api.php +++ b/classes/api.php @@ -203,7 +203,7 @@ class API extends Handler { $override_order = false; switch ($_REQUEST["order_by"]) { case "date_reverse": - $override_order = "date_entered, updated"; + $override_order = "score DESC, date_entered, updated"; break; case "feed_dates": $override_order = "updated DESC"; diff --git a/classes/feeds.php b/classes/feeds.php index 33f239ee6..aeadcf257 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -863,7 +863,7 @@ class Feeds extends Handler_Protected { $override_order = "ttrss_entries.title"; break; case "date_reverse": - $override_order = "date_entered, updated"; + $override_order = "score DESC, date_entered, updated"; break; case "feed_dates": $override_order = "updated DESC"; -- cgit v1.2.3-54-g00ecf From 4f2a2ca945f61437cfe9ed1e395e5461c4f55511 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 10 Jul 2013 16:44:36 +0400 Subject: api: fix typo --- classes/api.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index b3f4ebc2a..03fb6eab1 100644 --- a/classes/api.php +++ b/classes/api.php @@ -636,13 +636,13 @@ class API extends Handler { $feed_title = $qfh_ret[1]; $headlines = array(); - + while ($line = db_fetch_assoc($result)) { $line["content_preview"] = truncate_string(strip_tags($line["content_preview"]), 100); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { $line = $p->hook_query_headlines($line, 100, true); } - + $is_updated = ($line["last_read"] == "" && ($line["unread"] != "t" && $line["unread"] != "1")); @@ -665,12 +665,12 @@ class API extends Handler { "tags" => $tags, ); - if ($include_attachments) - $headline_row['attachments'] = get_article_enclosures( - $line['id']); + if ($include_attachments) + $headline_row['attachments'] = get_article_enclosures( + $line['id']); - if (!$show_excerpt ) - $headline_row["excerpt"] = $ine["content_preview"]; + if (!$show_excerpt) + $headline_row["excerpt"] = $line["content_preview"]; if ($show_content) { @@ -702,7 +702,7 @@ class API extends Handler { $headline_row["always_display_attachments"] = sql_bool_to_bool($line["always_display_enclosures"]); $headline_row["author"] = $line["author"]; - + $headline_row["score"] = (int)$line["score"]; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) { -- cgit v1.2.3-54-g00ecf From c052e25a8b256c14fb439b33a410898212d1e708 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 10 Jul 2013 16:55:55 +0400 Subject: remove unused cached_content --- classes/api.php | 8 ++------ include/functions.php | 5 ++--- include/rssfuncs.php | 2 -- 3 files changed, 4 insertions(+), 11 deletions(-) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index 03fb6eab1..c1f4aa9fa 100644 --- a/classes/api.php +++ b/classes/api.php @@ -309,7 +309,7 @@ class API extends Handler { if ($article_id) { - $query = "SELECT id,title,link,content,cached_content,feed_id,comments,int_id, + $query = "SELECT id,title,link,content,feed_id,comments,int_id, marked,unread,published,score, ".SUBSTRING_FOR_DATE."(updated,1,16) as updated, author,(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title @@ -338,7 +338,7 @@ class API extends Handler { "comments" => $line["comments"], "author" => $line["author"], "updated" => (int) strtotime($line["updated"]), - "content" => $line["cached_content"] != "" ? $line["cached_content"] : $line["content"], + "content" => $line["content"], "feed_id" => $line["feed_id"], "attachments" => $attachments, "score" => (int)$line["score"], @@ -674,10 +674,6 @@ class API extends Handler { if ($show_content) { - if ($line["cached_content"] != "") { - $line["content"] =& $line["cached_content"]; - } - if ($sanitize_content) { $headline_row["content"] = sanitize( $line["content"], diff --git a/include/functions.php b/include/functions.php index 8c25d9008..d71f81ac4 100644 --- a/include/functions.php +++ b/include/functions.php @@ -2579,7 +2579,7 @@ } - $content_query_part = "content, content AS content_preview, cached_content, "; + $content_query_part = "content, content AS content_preview, "; if (is_numeric($feed)) { @@ -3104,8 +3104,7 @@ tag_cache, author, orig_feed_id, - note, - cached_content + note FROM ttrss_entries,ttrss_user_entries WHERE id = '$id' AND ref_id = id AND owner_uid = $owner_uid"); diff --git a/include/rssfuncs.php b/include/rssfuncs.php index e2837a3b5..cfb0e7a46 100644 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -671,7 +671,6 @@ updated, content, content_hash, - cached_content, no_orig_date, date_updated, date_entered, @@ -686,7 +685,6 @@ '$entry_timestamp_fmt', '$entry_content', '$content_hash', - '', $no_orig_date, NOW(), '$date_feed_processed', -- cgit v1.2.3-54-g00ecf From 891d033c97e61253a19758379c20916a7bdd2c67 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 28 Jul 2013 23:37:19 +0400 Subject: api: getLabels: return converted label ids --- classes/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index c1f4aa9fa..e9ffc63dd 100644 --- a/classes/api.php +++ b/classes/api.php @@ -430,7 +430,7 @@ class API extends Handler { } array_push($rv, array( - "id" => (int)$line['id'], + "id" => (int)label_to_feed_id($line['id']), "caption" => $line['caption'], "fg_color" => $line['fg_color'], "bg_color" => $line['bg_color'], -- cgit v1.2.3-54-g00ecf From d208abc933e7f1499189a219d5c6f36ba585719f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 2 Aug 2013 14:41:01 +0400 Subject: api: pass article id to sanitize --- classes/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index e9ffc63dd..4330b3dc6 100644 --- a/classes/api.php +++ b/classes/api.php @@ -678,7 +678,7 @@ class API extends Handler { $headline_row["content"] = sanitize( $line["content"], sql_bool_to_bool($line['hide_images']), - false, $line["site_url"]); + false, $line["site_url"], false, $line["id"]); } else { $headline_row["content"] = $line["content"]; } -- cgit v1.2.3-54-g00ecf From 64595782ff0c3cd131b2c59bf7f246c3f285311b Mon Sep 17 00:00:00 2001 From: Matt Haley Date: Sun, 4 Aug 2013 10:41:29 -0700 Subject: API should return excerpt when asked --- classes/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index 4330b3dc6..bbbcbb5a8 100644 --- a/classes/api.php +++ b/classes/api.php @@ -669,7 +669,7 @@ class API extends Handler { $headline_row['attachments'] = get_article_enclosures( $line['id']); - if (!$show_excerpt) + if ($show_excerpt) $headline_row["excerpt"] = $line["content_preview"]; if ($show_content) { -- cgit v1.2.3-54-g00ecf From 788cf0a1b1a8a7fc3561bc8eb3347ce204f2120f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 12 Oct 2013 09:55:35 +0400 Subject: api: fix setArticleLabel expecting wrong format for label_id --- classes/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index bbbcbb5a8..b62a8b5fd 100644 --- a/classes/api.php +++ b/classes/api.php @@ -447,7 +447,7 @@ class API extends Handler { $assign = (bool) $this->dbh->escape_string($_REQUEST['assign']) == "true"; $label = $this->dbh->escape_string(label_find_caption( - $label_id, $_SESSION["uid"])); + feed_to_label_id($label_id), $_SESSION["uid"])); $num_updated = 0; -- cgit v1.2.3-54-g00ecf From 273c33e512b034bec1a392d41050cadc8522aff0 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 9 Nov 2013 16:42:41 +0400 Subject: api: allow sorting headlines by title --- classes/api.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index b62a8b5fd..aaa6bb9f6 100644 --- a/classes/api.php +++ b/classes/api.php @@ -202,6 +202,9 @@ class API extends Handler { $override_order = false; switch ($_REQUEST["order_by"]) { + case "title": + $override_order = "ttrss_entries.title"; + break; case "date_reverse": $override_order = "score DESC, date_entered, updated"; break; -- cgit v1.2.3-54-g00ecf From 21bb3c064afe1ec043a45ad0a6026ddd9e75f152 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 23 Nov 2013 20:22:02 +0400 Subject: api: add note support for getHeadlines/getArticle (bump api version) --- classes/api.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index aaa6bb9f6..0b5757a6b 100644 --- a/classes/api.php +++ b/classes/api.php @@ -2,7 +2,7 @@ class API extends Handler { - const API_LEVEL = 7; + const API_LEVEL = 8; const STATUS_OK = 0; const STATUS_ERR = 1; @@ -313,7 +313,7 @@ class API extends Handler { if ($article_id) { $query = "SELECT id,title,link,content,feed_id,comments,int_id, - marked,unread,published,score, + marked,unread,published,score,note, ".SUBSTRING_FOR_DATE."(updated,1,16) as updated, author,(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title FROM ttrss_entries,ttrss_user_entries @@ -345,7 +345,8 @@ class API extends Handler { "feed_id" => $line["feed_id"], "attachments" => $attachments, "score" => (int)$line["score"], - "feed_title" => $line["feed_title"] + "feed_title" => $line["feed_title"], + "note" => $line["note"] ); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) { @@ -703,6 +704,7 @@ class API extends Handler { $headline_row["author"] = $line["author"]; $headline_row["score"] = (int)$line["score"]; + $headline_row["note"] = $line["note"]; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) { $headline_row = $p->hook_render_article_api(array("headline" => $headline_row)); -- cgit v1.2.3-54-g00ecf From 25237aea4371cfa3096e525aed25c432ca067190 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 27 Nov 2013 21:54:27 +0400 Subject: api: fix getLabels never returning existing checked labels correctly --- classes/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index 0b5757a6b..e3fcc8d3d 100644 --- a/classes/api.php +++ b/classes/api.php @@ -427,7 +427,7 @@ class API extends Handler { $checked = false; foreach ($article_labels as $al) { - if ($al[0] == $line['id']) { + if (feed_to_label_id($al[0]) == $line['id']) { $checked = true; break; } -- cgit v1.2.3-54-g00ecf From bf5bcb8e272feb19103d601d29f17cb9917e95c3 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 29 Nov 2013 13:54:30 +0400 Subject: queryFeedHeadlines: remove obsolete content_preview --- classes/api.php | 2 +- classes/feeds.php | 2 +- classes/handler/public.php | 2 +- classes/pref/filters.php | 2 +- include/functions.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index e3fcc8d3d..8e279521a 100644 --- a/classes/api.php +++ b/classes/api.php @@ -642,7 +642,7 @@ class API extends Handler { $headlines = array(); while ($line = db_fetch_assoc($result)) { - $line["content_preview"] = truncate_string(strip_tags($line["content_preview"]), 100); + $line["content_preview"] = truncate_string(strip_tags($line["content"]), 100); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { $line = $p->hook_query_headlines($line, 100, true); } diff --git a/classes/feeds.php b/classes/feeds.php index 2c17a2257..5fc75cb2f 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -292,7 +292,7 @@ class Feeds extends Handler_Protected { $expand_cdm = get_pref('CDM_EXPANDED'); while ($line = $this->dbh->fetch_assoc($result)) { - $line["content_preview"] = "— " . truncate_string(strip_tags($line["content_preview"]), 250); + $line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { $line = $p->hook_query_headlines($line, 250, false); diff --git a/classes/handler/public.php b/classes/handler/public.php index 86e58fd68..037e6bf0f 100644 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -91,7 +91,7 @@ class Handler_Public extends Handler { $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true); while ($line = $this->dbh->fetch_assoc($result)) { - $line["content_preview"] = truncate_string(strip_tags($line["content_preview"]), 100, '...'); + $line["content_preview"] = truncate_string(strip_tags($line["content"]), 100, '...'); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { $line = $p->hook_query_headlines($line); diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 87e63cc2d..43da6d04d 100644 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -97,7 +97,7 @@ class Pref_Filters extends Handler_Protected { print "
"; while ($line = $this->dbh->fetch_assoc($result)) { - $line["content_preview"] = truncate_string(strip_tags($line["content_preview"]), 100, '...'); + $line["content_preview"] = truncate_string(strip_tags($line["content"]), 100, '...'); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { $line = $p->hook_query_headlines($line, 100); diff --git a/include/functions.php b/include/functions.php index 28a51b232..f7e910ad3 100644 --- a/include/functions.php +++ b/include/functions.php @@ -2651,7 +2651,7 @@ } - $content_query_part = "content, content AS content_preview, "; + $content_query_part = "content, "; if (is_numeric($feed)) { -- cgit v1.2.3-54-g00ecf From 429ff9afb03b079b76c4a9080994ce05dd104515 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 4 Dec 2013 01:30:54 +0400 Subject: api: add article language to getArticle/getHeadlines --- classes/api.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index 8e279521a..0306eff94 100644 --- a/classes/api.php +++ b/classes/api.php @@ -313,7 +313,7 @@ class API extends Handler { if ($article_id) { $query = "SELECT id,title,link,content,feed_id,comments,int_id, - marked,unread,published,score,note, + marked,unread,published,score,note,lang, ".SUBSTRING_FOR_DATE."(updated,1,16) as updated, author,(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title FROM ttrss_entries,ttrss_user_entries @@ -346,7 +346,8 @@ class API extends Handler { "attachments" => $attachments, "score" => (int)$line["score"], "feed_title" => $line["feed_title"], - "note" => $line["note"] + "note" => $line["note"], + "lang" => $line["lang"] ); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) { @@ -705,6 +706,7 @@ class API extends Handler { $headline_row["score"] = (int)$line["score"]; $headline_row["note"] = $line["note"]; + $headline_row["lang"] = $line["lang"]; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) { $headline_row = $p->hook_render_article_api(array("headline" => $headline_row)); -- cgit v1.2.3-54-g00ecf From 1d3cbe31c317397b90afa3bcbf79e394fa4667d8 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 24 Jan 2014 15:33:16 +0400 Subject: api: fix getFeeds returning some ids in string format --- classes/api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index 0306eff94..a9216c58b 100644 --- a/classes/api.php +++ b/classes/api.php @@ -516,7 +516,7 @@ class API extends Handler { if ($unread || !$unread_only) { $row = array( - "id" => $cv["id"], + "id" => (int) $cv["id"], "title" => $cv["description"], "unread" => $cv["counter"], "cat_id" => -2, @@ -562,7 +562,7 @@ class API extends Handler { if ($unread || !$unread_only) { $row = array( - "id" => $line["id"], + "id" => (int) $line["id"], "title" => $line["title"], "unread" => $unread, "is_cat" => true, -- cgit v1.2.3-54-g00ecf From a2108ee96d308e2359ebd132417d8c042c8b0a58 Mon Sep 17 00:00:00 2001 From: Dave Zaikos Date: Fri, 24 Jan 2014 19:19:10 -0500 Subject: Added syslog reporting for failed API login attempts. --- classes/api.php | 1 + 1 file changed, 1 insertion(+) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index a9216c58b..6bcb92152 100644 --- a/classes/api.php +++ b/classes/api.php @@ -77,6 +77,7 @@ class API extends Handler { $this->wrap(self::STATUS_OK, array("session_id" => session_id(), "api_level" => self::API_LEVEL)); } else { // else we are not logged in + user_error("Failed login attempt for $login from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING); $this->wrap(self::STATUS_ERR, array("error" => "LOGIN_ERROR")); } } else { -- cgit v1.2.3-54-g00ecf From 4baa1afa430aa87c49cc02e111c6b3de8491d1a3 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 16 Oct 2014 09:53:54 +0400 Subject: add force_update to api getHeadlines; bump api version to 9 --- classes/api.php | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index 6bcb92152..97f17cc74 100644 --- a/classes/api.php +++ b/classes/api.php @@ -2,7 +2,7 @@ class API extends Handler { - const API_LEVEL = 8; + const API_LEVEL = 9; const STATUS_OK = 0; const STATUS_ERR = 1; @@ -200,6 +200,7 @@ class API extends Handler { $include_nested = sql_bool_to_bool($_REQUEST["include_nested"]); $sanitize_content = !isset($_REQUEST["sanitize"]) || sql_bool_to_bool($_REQUEST["sanitize"]); + $force_update = sql_bool_to_bool($_REQUEST["force_update"]); $override_order = false; switch ($_REQUEST["order_by"]) { @@ -222,7 +223,7 @@ class API extends Handler { $headlines = $this->api_get_headlines($feed_id, $limit, $offset, $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $override_order, $include_attachments, $since_id, $search, $search_mode, - $include_nested, $sanitize_content); + $include_nested, $sanitize_content, $force_update); $this->wrap(self::STATUS_OK, $headlines); } else { @@ -632,7 +633,28 @@ class API extends Handler { $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order, $include_attachments, $since_id, $search = "", $search_mode = "", - $include_nested = false, $sanitize_content = true) { + $include_nested = false, $sanitize_content = true, $force_update = false) { + + if ($force_update && $feed_id > 0 && is_numeric($feed_id)) { + // Update the feed if required with some basic flood control + + $result = db_query( + "SELECT cache_images,".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated + FROM ttrss_feeds WHERE id = '$feed_id'"); + + 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")); + + if (!$cache_images && time() - $last_updated > 120) { + include "rssfuncs.php"; + update_rss_feed($feed_id, true, true); + } else { + db_query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01' + WHERE id = '$feed_id'"); + } + } + } $qfh_ret = queryFeedHeadlines($feed_id, $limit, $view_mode, $is_cat, $search, $search_mode, -- cgit v1.2.3-54-g00ecf From f71a669b7dc9e2048cfea02f39ab4ef8cde4178a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 27 Oct 2014 22:07:20 +0300 Subject: api: handle uncached labels the way main headlines function does it --- classes/api.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index 97f17cc74..730e20ab9 100644 --- a/classes/api.php +++ b/classes/api.php @@ -675,7 +675,22 @@ class API extends Handler { ($line["unread"] != "t" && $line["unread"] != "1")); $tags = explode(",", $line["tag_cache"]); - $labels = json_decode($line["label_cache"], true); + + $label_cache = $line["label_cache"]; + $labels = false; + + if ($label_cache) { + $label_cache = json_decode($label_cache, true); + + if ($label_cache) { + if ($label_cache["no-labels"] == 1) + $labels = array(); + else + $labels = $label_cache; + } + } + + if (!is_array($labels)) $labels = get_article_labels($line["id"]); //if (!$tags) $tags = get_article_tags($line["id"]); //if (!$labels) $labels = get_article_labels($line["id"]); -- cgit v1.2.3-54-g00ecf