From 911d4c0836cf6d1be53be5917739defc91277a7e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 9 Sep 2010 16:49:06 +0400 Subject: add experimental digest thingie --- functions.php | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) (limited to 'functions.php') diff --git a/functions.php b/functions.php index 05eb85909..78e0d4f18 100644 --- a/functions.php +++ b/functions.php @@ -6652,4 +6652,145 @@ return $rv; } + function api_get_feeds($link, $cat_id, $unread_only, $limit, $offset) { + if ($limit) { + $limit_qpart = "LIMIT $limit OFFSET $offset"; + } else { + $limit_qpart = ""; + } + + if (!$cat_id) { + $result = db_query($link, "SELECT + id, feed_url, cat_id, title, ". + SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated + FROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"] . + " ORDER BY cat_id, title " . $limit_qpart); + } else { + $result = db_query($link, "SELECT + id, feed_url, cat_id, title, ". + SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated + FROM ttrss_feeds WHERE + cat_id = '$cat_id' AND owner_uid = " . $_SESSION["uid"] . + " ORDER BY cat_id, title " . $limit_qpart); + } + + $feeds = array(); + + while ($line = db_fetch_assoc($result)) { + + $unread = getFeedUnread($link, $line["id"]); + + $has_icon = feed_has_icon($line['id']); + + if ($unread || !$unread_only) { + + $row = array( + "feed_url" => $line["feed_url"], + "title" => $line["title"], + "id" => (int)$line["id"], + "unread" => (int)$unread, + "has_icon" => $has_icon, + "cat_id" => (int)$line["cat_id"], + "last_updated" => strtotime($line["last_updated"]) + ); + + array_push($feeds, $row); + } + } + + /* Labels */ + + if (!$cat_id || $cat_id == -2) { + $counters = getLabelCounters($link, true); + + foreach (array_keys($counters) as $id) { + + $unread = $counters[$id]["counter"]; + + if ($unread || !$unread_only) { + + $row = array( + "id" => $id, + "title" => $counters[$id]["description"], + "unread" => $counters[$id]["counter"], + "cat_id" => -2, + ); + + array_push($feeds, $row); + } + } + } + + /* Virtual feeds */ + + if (!$cat_id || $cat_id == -1) { + foreach (array(-1, -2, -3, -4, 0) as $i) { + $unread = getFeedUnread($link, $i); + + if ($unread || !$unread_only) { + $title = getFeedTitle($link, $i); + + $row = array( + "id" => $i, + "title" => $title, + "unread" => $unread, + "cat_id" => -1, + ); + array_push($feeds, $row); + } + + } + } + return $feeds; + } + + function api_get_headlines($link, $feed_id, $limit, $offset, + $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order) { + + /* do not rely on params below */ + + $search = db_escape_string($_REQUEST["search"]); + $search_mode = db_escape_string($_REQUEST["search_mode"]); + $match_on = db_escape_string($_REQUEST["match_on"]); + + $qfh_ret = queryFeedHeadlines($link, $feed_id, $limit, + $view_mode, $is_cat, $search, $search_mode, $match_on, + $order, $offset); + + $result = $qfh_ret[0]; + $feed_title = $qfh_ret[1]; + + $headlines = array(); + + while ($line = db_fetch_assoc($result)) { + $is_updated = ($line["last_read"] == "" && + ($line["unread"] != "t" && $line["unread"] != "1")); + + $headline_row = array( + "id" => (int)$line["id"], + "unread" => sql_bool_to_bool($line["unread"]), + "marked" => sql_bool_to_bool($line["marked"]), + "updated" => strtotime($line["updated"]), + "is_updated" => $is_updated, + "title" => $line["title"], + "link" => $line["link"], + "feed_id" => $line["feed_id"], + "has_icon" => feed_has_icon($line["feed_id"]) + ); + + if ($show_excerpt) { + $excerpt = truncate_string(strip_tags($line["content_preview"]), 100); + $headline_row["excerpt"] = $excerpt; + } + + if ($show_content) { + $headline_row["content"] = $line["content_preview"]; + } + + array_push($headlines, $headline_row); + } + + return $headlines; + } + ?> -- cgit v1.2.3 From b41c254984df3fcb9fc7db4bb5218f2391e62164 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 9 Sep 2010 19:02:12 +0400 Subject: small digest page improvements --- functions.php | 88 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 46 insertions(+), 42 deletions(-) (limited to 'functions.php') diff --git a/functions.php b/functions.php index 78e0d4f18..ce1a06a62 100644 --- a/functions.php +++ b/functions.php @@ -6653,51 +6653,9 @@ } function api_get_feeds($link, $cat_id, $unread_only, $limit, $offset) { - if ($limit) { - $limit_qpart = "LIMIT $limit OFFSET $offset"; - } else { - $limit_qpart = ""; - } - - if (!$cat_id) { - $result = db_query($link, "SELECT - id, feed_url, cat_id, title, ". - SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated - FROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"] . - " ORDER BY cat_id, title " . $limit_qpart); - } else { - $result = db_query($link, "SELECT - id, feed_url, cat_id, title, ". - SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated - FROM ttrss_feeds WHERE - cat_id = '$cat_id' AND owner_uid = " . $_SESSION["uid"] . - " ORDER BY cat_id, title " . $limit_qpart); - } $feeds = array(); - while ($line = db_fetch_assoc($result)) { - - $unread = getFeedUnread($link, $line["id"]); - - $has_icon = feed_has_icon($line['id']); - - if ($unread || !$unread_only) { - - $row = array( - "feed_url" => $line["feed_url"], - "title" => $line["title"], - "id" => (int)$line["id"], - "unread" => (int)$unread, - "has_icon" => $has_icon, - "cat_id" => (int)$line["cat_id"], - "last_updated" => strtotime($line["last_updated"]) - ); - - array_push($feeds, $row); - } - } - /* Labels */ if (!$cat_id || $cat_id == -2) { @@ -6741,6 +6699,52 @@ } } + + /* Real feeds */ + + if ($limit) { + $limit_qpart = "LIMIT $limit OFFSET $offset"; + } else { + $limit_qpart = ""; + } + + if (!$cat_id) { + $result = db_query($link, "SELECT + id, feed_url, cat_id, title, ". + SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated + FROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"] . + " ORDER BY cat_id, title " . $limit_qpart); + } else { + $result = db_query($link, "SELECT + id, feed_url, cat_id, title, ". + SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated + FROM ttrss_feeds WHERE + cat_id = '$cat_id' AND owner_uid = " . $_SESSION["uid"] . + " ORDER BY cat_id, title " . $limit_qpart); + } + + while ($line = db_fetch_assoc($result)) { + + $unread = getFeedUnread($link, $line["id"]); + + $has_icon = feed_has_icon($line['id']); + + if ($unread || !$unread_only) { + + $row = array( + "feed_url" => $line["feed_url"], + "title" => $line["title"], + "id" => (int)$line["id"], + "unread" => (int)$unread, + "has_icon" => $has_icon, + "cat_id" => (int)$line["cat_id"], + "last_updated" => strtotime($line["last_updated"]) + ); + + array_push($feeds, $row); + } + } + return $feeds; } -- cgit v1.2.3 From d5d5632952914611c0ddf93959034aa1e7d87c21 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 11 Sep 2010 15:25:47 +0400 Subject: code cleanup --- functions.php | 1 - 1 file changed, 1 deletion(-) (limited to 'functions.php') diff --git a/functions.php b/functions.php index 735fd2c73..e53995335 100644 --- a/functions.php +++ b/functions.php @@ -6782,7 +6782,6 @@ "title" => $line["title"], "link" => $line["link"], "feed_id" => $line["feed_id"], - "has_icon" => feed_has_icon($line["feed_id"]) ); if ($show_excerpt) { -- cgit v1.2.3 From 9ed133e7a97e4ad591df2557646519a2f451adf3 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 12 Sep 2010 13:38:57 +0400 Subject: api: support published status in getHeadlines; digest: code cleanup --- functions.php | 1 + 1 file changed, 1 insertion(+) (limited to 'functions.php') diff --git a/functions.php b/functions.php index e53995335..2174460b4 100644 --- a/functions.php +++ b/functions.php @@ -6777,6 +6777,7 @@ "id" => (int)$line["id"], "unread" => sql_bool_to_bool($line["unread"]), "marked" => sql_bool_to_bool($line["marked"]), + "published" => sql_bool_to_bool($line["published"]), "updated" => strtotime($line["updated"]), "is_updated" => $is_updated, "title" => $line["title"], -- cgit v1.2.3 From 78ac6caf001402142951ec90e8d0a1dac02e433b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 12 Sep 2010 14:37:47 +0400 Subject: digest: support tags --- functions.php | 1 + 1 file changed, 1 insertion(+) (limited to 'functions.php') diff --git a/functions.php b/functions.php index 2174460b4..232ee7c1f 100644 --- a/functions.php +++ b/functions.php @@ -6783,6 +6783,7 @@ "title" => $line["title"], "link" => $line["link"], "feed_id" => $line["feed_id"], + "tags" => get_article_tags($link, $line["id"]), ); if ($show_excerpt) { -- cgit v1.2.3 From a16a62c02d36668877b81487f8e3e363e203a979 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 11 Oct 2010 11:24:29 +0400 Subject: outputHeadlinesList: properly handle always_display_enclosures when feed_id is null --- functions.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'functions.php') diff --git a/functions.php b/functions.php index cdbfa4cae..527e78f85 100644 --- a/functions.php +++ b/functions.php @@ -5520,7 +5520,9 @@ } $tmp_result = db_query($link, "SELECT always_display_enclosures FROM - ttrss_feeds WHERE id = ".$line['feed_id']." AND owner_uid = ".$_SESSION["uid"]); + ttrss_feeds WHERE id = ". + (($line['feed_id'] == null) ? $line['orig_feed_id'] : + $line['feed_id'])." AND owner_uid = ".$_SESSION["uid"]); $always_display_enclosures = db_fetch_result($tmp_result, 0, "always_display_enclosures"); -- cgit v1.2.3