diff options
Diffstat (limited to 'classes/feeds.php')
-rwxr-xr-x | classes/feeds.php | 528 |
1 files changed, 123 insertions, 405 deletions
diff --git a/classes/feeds.php b/classes/feeds.php index d9c772c9c..a79a1ebd2 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -28,8 +28,6 @@ class Feeds extends Handler_Protected { $rss_link = htmlspecialchars(get_self_url_prefix() . "/public.php?op=rss&id=$feed_id$cat_q$search_q"); - $error_class = $error ? "error" : ""; - $reply .= "<span class='left'>"; $reply .= "<a href=\"#\" @@ -37,25 +35,20 @@ class Feeds extends Handler_Protected { onclick=\"App.displayDlg('".__("Show as feed")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\"> <i class='icon-syndicate material-icons'>rss_feed</i></a>"; - $reply .= "<span id='feed_title' class='$error_class'>"; + $reply .= "<span id='feed_title'>"; if ($feed_site_url) { - $last_updated = T_sprintf("Last updated: %s", - $feed_last_updated); + $last_updated = T_sprintf("Last updated: %s", $feed_last_updated); - $target = "target=\"_blank\""; - $reply .= "<a title=\"$last_updated\" $target href=\"$feed_site_url\">". + $reply .= "<a title=\"$last_updated\" target='_blank' href=\"$feed_site_url\">". truncate_string(strip_tags($feed_title), 30)."</a>"; - - if ($error) { - $error = htmlspecialchars($error); - $reply .= " <img title=\"$error\" src='images/error.png' alt='error' class=\"noborder\">"; - } - } else { $reply .= strip_tags($feed_title); } + if ($error) + $reply .= " <i title=\"" . htmlspecialchars($error) . "\" class='material-icons icon-error'>error</i>"; + $reply .= "</span></span>"; $reply .= "<span class=\"right\">"; @@ -120,18 +113,14 @@ class Feeds extends Handler_Protected { } private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, - $offset, $vgr_last_feed = false, - $override_order = false, $include_children = false, $check_first_id = false, - $skip_first_id_check = false) { + $offset, $override_order = false, $include_children = false, $check_first_id = false, + $skip_first_id_check = false, $order_by = false) { $disable_cache = false; $reply = array(); $rgba_cache = array(); - - $timing_info = microtime(true); - $topmost_article_ids = array(); if (!$offset) $offset = 0; @@ -168,8 +157,6 @@ class Feeds extends Handler_Protected { $disable_cache = true; } - if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info); - if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) { $handler = PluginHost::getInstance()->get_feed_handler( PluginHost::feed_to_pfeed_id($feed)); @@ -185,7 +172,8 @@ class Feeds extends Handler_Protected { "owner_uid" => $_SESSION["uid"], "filter" => false, "since_id" => 0, - "include_children" => $include_children); + "include_children" => $include_children, + "order_by" => $order_by); $qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed), $options); @@ -204,7 +192,8 @@ class Feeds extends Handler_Protected { "offset" => $offset, "include_children" => $include_children, "check_first_id" => $check_first_id, - "skip_first_id_check" => $skip_first_id_check + "skip_first_id_check" => $skip_first_id_check, + "order_by" => $order_by ); $qfh_ret = $this->queryFeedHeadlines($params); @@ -212,8 +201,6 @@ class Feeds extends Handler_Protected { $vfeed_group_enabled = get_pref("VFEED_GROUP_BY_FEED") && $feed != -6; - if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info); - $result = $qfh_ret[0]; // this could be either a PDO query result or a -1 if first id changed $feed_title = $qfh_ret[1]; $feed_site_url = $qfh_ret[2]; @@ -223,8 +210,7 @@ class Feeds extends Handler_Protected { $highlight_words = $qfh_ret[5]; $reply['first_id'] = $qfh_ret[6]; $reply['search_query'] = [$search, $search_language]; - - $vgroup_last_feed = $vgr_last_feed; + $reply['vfeed_group_enabled'] = $vfeed_group_enabled; $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url, $feed_title, @@ -237,37 +223,45 @@ class Feeds extends Handler_Protected { } } - $reply['content'] = ''; + $reply['content'] = []; $headlines_count = 0; - $lnum = $offset; - $num_unread = 0; - if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info); - if (is_object($result)) { - - while ($line = $result->fetch()) { + while ($line = $result->fetch(PDO::FETCH_ASSOC)) { ++$headlines_count; - $line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250); + if (!get_pref('SHOW_CONTENT_PREVIEW')) { + $line["content_preview"] = ""; + } else { + $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); + } + } + + $id = $line["id"]; - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { - $line = $p->hook_query_headlines($line, 250, false); + // frontend doesn't expect pdo returning booleans as strings on mysql + if (DB_TYPE == "mysql") { + foreach (["unread", "marked", "published"] as $k) { + $line[$k] = $line[$k] === "1"; + } } - if (get_pref('SHOW_CONTENT_PREVIEW')) { - $content_preview = $line["content_preview"]; + // normalize archived feed + if ($line['feed_id'] === null) { + $line['feed_id'] = 0; + $line["feed_title"] = __("Archived articles"); } - $id = $line["id"]; $feed_id = $line["feed_id"]; + $label_cache = $line["label_cache"]; $labels = false; - $mouseover_attrs = "onmouseover='Article.mouseIn($id)' onmouseout='Article.mouseOut($id)'"; - if ($label_cache) { $label_cache = json_decode($label_cache, true); @@ -285,372 +279,112 @@ class Feeds extends Handler_Protected { $labels_str .= Article::format_article_labels($labels); $labels_str .= "</span>"; + $line["labels"] = $labels_str; + if (count($topmost_article_ids) < 3) { array_push($topmost_article_ids, $id); } - $class = ""; - - if ($line["unread"]) { - $class .= " Unread"; - ++$num_unread; - } - - $class .= $line["marked"] ? " marked" : ""; - $marked_pic = "<i class=\"marked-pic marked-$id material-icons\" onclick='Headlines.toggleMark($id)'>star</i>"; + if (!$line["feed_title"]) $line["feed_title"] = ""; - $class .= $line["published"] ? " published" : ""; - $published_pic = "<i class=\"pub-pic pub-$id material-icons\" onclick='Headlines.togglePub($id)'>rss_feed</i>"; + $line["buttons_left"] = ""; + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { + $line["buttons_left"] .= $p->hook_article_left_button($line); + } - $updated_fmt = make_local_datetime($line["updated"], false, false, false, true); - $date_entered_fmt = T_sprintf("Imported at %s", - make_local_datetime($line["date_entered"], false)); - - $score = $line["score"]; + $line["buttons"] = ""; + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) { + $line["buttons"] .= $p->hook_article_button($line); + } - $score_pic = "images/" . get_score_pic($score); + $line["content"] = sanitize($line["content"], + $line['hide_images'], false, $line["site_url"], $highlight_words, $line["id"]); - $score_pic = "<img class='score-pic' score='$score' onclick='Article.setScore($id, this)' src=\"$score_pic\" - title=\"$score\">"; + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) { + $line = $p->hook_render_article_cdm($line); + } - if ($score > 500) { - $hlc_suffix = "high"; - } else if ($score < -100) { - $hlc_suffix = "low"; - } else { - $hlc_suffix = ""; - } + $line['content'] = rewrite_cached_urls($line['content']); - $entry_author = $line["author"]; + if ($line['note']) + $line['note'] = Article::format_article_note($id, $line['note']); + else + $line['note'] = ""; - if ($entry_author) { - $entry_author = " — $entry_author"; - } + if (!get_pref("CDM_EXPANDED")) { + $line["cdm_excerpt"] = "<span class='collapse'> + <i class='material-icons' onclick='return Article.cdmUnsetActive(event)' + title=\"" . __("Collapse article") . "\">remove_circle</i></span>"; - if (feeds::feedHasIcon($feed_id)) { - $feed_icon_img = "<img class=\"icon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">"; - } else { - $feed_icon_img = "<i class='icon-syndicate material-icons'>rss_feed</i>"; - } + if (get_pref('SHOW_CONTENT_PREVIEW')) { + $line["cdm_excerpt"] .= "<span class='excerpt'>" . $line["content_preview"] . "</span>"; + } + } - $entry_site_url = $line["site_url"]; + $line["enclosures"] = Article::format_article_enclosures($id, $line["always_display_enclosures"], + $line["content"], $line["hide_images"]); - //setting feed headline background color, needs to change text color based on dark/light - $fav_color = $line['favicon_avg_color']; + if ($line["orig_feed_id"]) { - require_once "colors.php"; + $ofgh = $this->pdo->prepare("SELECT * FROM ttrss_archived_feeds + WHERE id = ? AND owner_uid = ?"); + $ofgh->execute([$line["orig_feed_id"], $_SESSION['uid']]); - if ($fav_color && $fav_color != 'fail') { - if (!isset($rgba_cache[$feed_id])) { - $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color)); - } - } + if ($tmp_line = $ofgh->fetch()) { + $line["orig_feed"] = [ $tmp_line["title"], $tmp_line["site_url"], $tmp_line["feed_url"] ]; + } + } - if (!get_pref('COMBINED_DISPLAY_MODE')) { + $line["updated_long"] = make_local_datetime($line["updated"],true); + $line["updated"] = make_local_datetime($line["updated"], false, false, false, true); - if ($vfeed_group_enabled) { - if ($feed_id != $vgroup_last_feed && $line["feed_title"]) { - $vgroup_last_feed = $feed_id; - - $vf_catchup_link = "<a class='catchup' onclick='Feeds.catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>"; - - $reply['content'] .= "<div data-feed-id='$feed_id' class='feed-title'>". - "<div style='float : right'>$feed_icon_img</div>". - "<a class='title' href=\"#\" onclick=\"Feeds.open({feed:$feed_id})\">". - $line["feed_title"]."</a> - $vf_catchup_link</div>"; - - - } - } - - $reply['content'] .= "<div class='hl $class' data-orig-feed-id='$feed_id' data-article-id='$id' id='RROW-$id' $mouseover_attrs>"; - - $reply['content'] .= "<div class='left'>"; - - $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\" - type=\"checkbox\" onclick=\"Headlines.onRowChecked(this)\" - class='rchk'>"; - - $reply['content'] .= "$marked_pic"; - $reply['content'] .= "$published_pic"; - - $reply['content'] .= "</div>"; - - $reply['content'] .= "<div onclick='return Headlines.click(event, $id)' - class=\"title\"><span data-article-id=\"$id\" class='hl-content hlMenuAttach $hlc_suffix'>"; - $reply['content'] .= "<a class=\"title $hlc_suffix\" - href=\"" . htmlspecialchars($line["link"]) . "\" - onclick=\"\">" . - truncate_string($line["title"], 200); - - if (get_pref('SHOW_CONTENT_PREVIEW')) { - $reply['content'] .= "<span class=\"preview\">" . $line["content_preview"] . "</span>"; - } - - $reply['content'] .= "</a></span>"; - - $reply['content'] .= $labels_str; - - $reply['content'] .= "</div>"; - - if (!$vfeed_group_enabled) { - if (@$line["feed_title"]) { - $rgba = @$rgba_cache[$feed_id]; - - $reply['content'] .= "<span class=\"feed\"><a style=\"background : rgba($rgba, 0.3)\" href=\"#\" onclick=\"Feeds.open({feed:$feed_id})\">". - truncate_string($line["feed_title"],30)."</a></span>"; - } - } - - - $reply['content'] .= "<span class=\"updated\">"; - - $reply['content'] .= "<div title='$date_entered_fmt'>$updated_fmt</div> - </span>"; - - $reply['content'] .= "<div class=\"right\">"; + $line['imported'] = T_sprintf("Imported at %s", + make_local_datetime($line["date_entered"], false)); - $reply['content'] .= $score_pic; + $score = $line["score"]; - if ($line["feed_title"] && !$vfeed_group_enabled) { + $line["score_pic"] = get_score_pic($score); + $line["score_class"] = get_score_class($score); - $reply['content'] .= "<span onclick=\"Feeds.open({feed:$feed_id})\" - style=\"cursor : pointer\" - title=\"".htmlspecialchars($line['feed_title'])."\"> - $feed_icon_img</span>"; - } + if ($line["tag_cache"]) + $tags = explode(",", $line["tag_cache"]); + else + $tags = false; - $reply['content'] .= "</div>"; - $reply['content'] .= "</div>"; + $line["tags_str"] = Article::format_tags_string($tags, $id); + if (feeds::feedHasIcon($feed_id)) { + $line['feed_icon'] = "<img class=\"icon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">"; } else { + $line['feed_icon'] = "<i class='icon-no-feed material-icons'>rss_feed</i>"; + } - if ($line["tag_cache"]) - $tags = explode(",", $line["tag_cache"]); - else - $tags = false; - - $line["content"] = sanitize($line["content"], - $line['hide_images'], false, $entry_site_url, $highlight_words, $line["id"]); - - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) { - $line = $p->hook_render_article_cdm($line); - } - - $line['content'] = rewrite_cached_urls($line['content']); - - if ($vfeed_group_enabled && $line["feed_title"]) { - if ($feed_id != $vgroup_last_feed) { - - $vgroup_last_feed = $feed_id; - - $vf_catchup_link = "<a class='catchup' onclick='Feeds.catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>"; - - $feed_icon_src = Feeds::getFeedIcon($feed_id); - $feed_icon_img = "<img class=\"icon\" src=\"$feed_icon_src\">"; - - $reply['content'] .= "<div data-feed-id='$feed_id' class='feed-title'>". - "<div style=\"float : right\">$feed_icon_img</div>". - "<a href=\"#\" class='title' onclick=\"Feeds.open({feed:$feed_id})\">". - $line["feed_title"]."</a> $vf_catchup_link</div>"; - - } - } - - $content_encoded = htmlspecialchars($line["content"]); - - $expanded_class = get_pref("CDM_EXPANDED") ? "expanded" : "expandable"; - $tmp_content = "<div class=\"cdm $expanded_class $hlc_suffix $class\" - id=\"RROW-$id\" data-content=\"$content_encoded\" data-article-id='$id' data-orig-feed-id='$feed_id' $mouseover_attrs>"; - - $tmp_content .= "<div class=\"header\">"; - $tmp_content .= "<div class=\"left\">"; - - $tmp_content .= "<input dojoType=\"dijit.form.CheckBox\" - type=\"checkbox\" onclick=\"Headlines.onRowChecked(this)\" - class='rchk'>"; - - $tmp_content .= "$marked_pic"; - $tmp_content .= "$published_pic"; - - $tmp_content .= "</div>"; - - if ($highlight_words && count($highlight_words) > 0) { - foreach ($highlight_words as $word) { - $word = preg_quote($word, "/"); - - $line["title"] = preg_replace("/($word)/i", - "<span class=\"highlight\">$1</span>", $line["title"]); - } - } - - // data-article-id included for context menu - $tmp_content .= "<span - onclick=\"return Headlines.click(event, $id);\" - data-article-id=\"$id\" - class=\"titleWrap hlMenuAttach $hlc_suffix\"> - <a class=\"title $hlc_suffix\" - title=\"".htmlspecialchars($line["title"])."\" - target=\"_blank\" rel=\"noopener noreferrer\" href=\"". - htmlspecialchars($line["link"])."\">". - $line["title"] . - "</a> <span class=\"author\">$entry_author</span>"; - - $tmp_content .= $labels_str; - - if (!get_pref("CDM_EXPANDED")) { - $tmp_content .= "<span class='collapse'> - <img src=\"images/collapse.png\" onclick=\"return Article.cdmUnsetActive(event)\" - title=\"" . __("Collapse article") . "\"/></span>"; - - if (get_pref('SHOW_CONTENT_PREVIEW')) { - $tmp_content .= "<span class='excerpt'>" . $line["content_preview"] . "</span>"; - } - } - - $tmp_content .= "</span>"; - - if (!$vfeed_group_enabled) { - if (@$line["feed_title"]) { - $rgba = @$rgba_cache[$feed_id]; - - $tmp_content .= "<div class=\"feed\"> - <a href=\"#\" style=\"background-color: rgba($rgba,0.3)\" - onclick=\"Feeds.open({feed:$feed_id})\">". - truncate_string($line["feed_title"],30)."</a> - </div>"; - } - } - - $tmp_content .= "<span class='updated' title='$date_entered_fmt'>$updated_fmt</span>"; - - $tmp_content .= "<div class='right'>"; - $tmp_content .= "$score_pic"; - - if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) { - $tmp_content .= "<span style=\"cursor : pointer\" - title=\"".htmlspecialchars($line["feed_title"])."\" - onclick=\"Feeds.open({feed:$feed_id})\">$feed_icon_img</span>"; - } - $tmp_content .= "</div>"; //score wrapper2 - - $tmp_content .= "</div>"; //header - - $tmp_content .= "<div class=\"content\" onclick=\"return Headlines.click(event, $id, true);\">"; - - $tmp_content .= "<div id=\"POSTNOTE-$id\">"; - if ($line['note']) { - $tmp_content .= Article::format_article_note($id, $line['note']); - } - $tmp_content .= "</div>"; //POSTNOTE - - if (!$line['lang']) $line['lang'] = 'en'; - - // this is filled from RROW data-content - $tmp_content .= "<div class=\"content-inner\" lang=\"".$line['lang']."\"> - <img src='images/indicator_white.gif'> - </div>"; - $tmp_content .= "<div class=\"intermediate\">"; - - if ($line["orig_feed_id"]) { - - $ofgh = $this->pdo->prepare("SELECT * FROM ttrss_archived_feeds - WHERE id = ? AND owner_uid = ?"); - $ofgh->execute([$line["orig_feed_id"], $_SESSION['uid']]); - - if ($tmp_line = $ofgh->fetch()) { - - $tmp_content .= "<div clear='both'>"; - $tmp_content .= __("Originally from:"); - - $tmp_content .= " "; - - $tmp_content .= "<a target='_blank' rel='noopener noreferrer' - href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" . - $tmp_line['title'] . "</a>"; - - $tmp_content .= " "; - - $tmp_content .= "<a target='_blank' rel='noopener noreferrer' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>"; - - $tmp_content .= "</div>"; - } - } - - - $always_display_enclosures = $line["always_display_enclosures"]; - $tmp_content .= Article::format_article_enclosures($id, $always_display_enclosures, - $line["content"], $line["hide_images"]); - - $tmp_content .= "</div>"; // cdmIntermediate - - $tmp_content .= "<div class=\"footer\" onclick=\"event.stopPropagation()\">"; - - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { - $tmp_content .= $p->hook_article_left_button($line); - } - - $tags_str = Article::format_tags_string($tags, $id); - - $tmp_content .= "<div class='left'>"; - - $tmp_content .= "<img src='images/tag.png' alt='Tags' title='Tags'> - <span id=\"ATSTR-$id\">$tags_str</span> - <a title=\"".__('Edit tags for this article')."\" - href=\"#\" onclick=\"Article.editTags($id)\">(+)</a>"; - - $num_comments = (int) $line["num_comments"]; - $entry_comments = ""; - - if ($num_comments > 0) { - if ($line["comments"]) { - $comments_url = htmlspecialchars($line["comments"]); - } else { - $comments_url = htmlspecialchars($line["link"]); - } - $entry_comments = "<a class=\"comments\" - target='_blank' rel='noopener noreferrer' href=\"$comments_url\">$num_comments ". - _ngettext("comment", "comments", $num_comments)."</a>"; - - } else { - if ($line["comments"] && $line["link"] != $line["comments"]) { - $entry_comments = "<a class=\"comments\" target='_blank' rel='noopener noreferrer' href=\"".htmlspecialchars($line["comments"])."\">".__("comments")."</a>"; - } - } - - if ($entry_comments) $tmp_content .= " ($entry_comments)"; + //setting feed headline background color, needs to change text color based on dark/light + $fav_color = $line['favicon_avg_color']; - $tmp_content .= "</div>"; - $tmp_content .= "<div class='right'>"; + require_once "colors.php"; - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) { - $tmp_content .= $p->hook_article_button($line); + if ($fav_color && $fav_color != 'fail') { + if (!isset($rgba_cache[$feed_id])) { + $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color)) . ",0.3"; } - $tmp_content .= "</div>"; // buttons + $line['favicon_avg_color_rgba'] = $rgba_cache[$feed_id]; + } - $tmp_content .= "</div>"; // cdm footer - $tmp_content .= "</div>"; // cdmContent - $tmp_content .= "</div>"; // RROW.cdm + /* we don't need those */ - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FORMAT_ARTICLE_CDM) as $p) { - $tmp_content = $p->hook_format_article_cdm($tmp_content, $line); - } + foreach (["date_entered", "guid", "last_published", "last_marked", "tag_cache", "favicon_avg_color", "uuid", "label_cache"] as $k) + unset($line[$k]); - $reply['content'] .= $tmp_content; - } - - ++$lnum; + array_push($reply['content'], $line); } } - if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info); - if (!$headlines_count) { - if (!is_numeric($result)) { + if (is_object($result)) { switch ($view_mode) { case "unread": @@ -704,10 +438,7 @@ class Feeds extends Handler_Protected { } } - if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info); - - return array($topmost_article_ids, $headlines_count, $feed, $disable_cache, - $vgroup_last_feed, $reply); + return array($topmost_article_ids, $headlines_count, $feed, $disable_cache, $reply); } function catchupAll() { @@ -719,12 +450,8 @@ class Feeds extends Handler_Protected { } function view() { - $timing_info = microtime(true); - $reply = array(); - if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info); - $feed = $_REQUEST["feed"]; $method = $_REQUEST["m"]; $view_mode = $_REQUEST["view_mode"]; @@ -732,7 +459,6 @@ class Feeds extends Handler_Protected { @$cat_view = $_REQUEST["cat"] == "true"; @$next_unread_feed = $_REQUEST["nuf"]; @$offset = $_REQUEST["skip"]; - @$vgroup_last_feed = $_REQUEST["vgrlf"]; $order_by = $_REQUEST["order_by"]; $check_first_id = $_REQUEST["fid"]; @@ -798,7 +524,7 @@ class Feeds extends Handler_Protected { $sth->execute([$feed, $_SESSION['uid']]); } - $reply['headlines'] = array(); + $reply['headlines'] = []; $override_order = false; $skip_first_id_check = false; @@ -816,22 +542,13 @@ class Feeds extends Handler_Protected { break; } - if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info); - $ret = $this->format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, $offset, - $vgroup_last_feed, $override_order, true, $check_first_id, $skip_first_id_check); + $override_order, true, $check_first_id, $skip_first_id_check, $order_by); - //$topmost_article_ids = $ret[0]; $headlines_count = $ret[1]; - /* $returned_feed = $ret[2]; */ $disable_cache = $ret[3]; - $vgroup_last_feed = $ret[4]; - - //$reply['headlines']['content'] =& $ret[5]['content']; - //$reply['headlines']['toolbar'] =& $ret[5]['toolbar']; - - $reply['headlines'] = $ret[5]; + $reply['headlines'] = $ret[4]; if (!$next_unread_feed) $reply['headlines']['id'] = $feed; @@ -840,14 +557,10 @@ class Feeds extends Handler_Protected { $reply['headlines']['is_cat'] = (bool) $cat_view; - if ($_REQUEST["debug"]) $timing_info = print_checkpoint("05", $timing_info); - - $reply['headlines-info'] = array("count" => (int) $headlines_count, - "vgroup_last_feed" => $vgroup_last_feed, - "disable_cache" => (bool) $disable_cache); - - if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info); + $reply['headlines-info'] = ["count" => (int) $headlines_count, + "disable_cache" => (bool) $disable_cache]; + // this is parsed by handleRpcJson() on first viewfeed() to set cdm expanded, etc $reply['runtime-info'] = make_runtime_info(); print json_encode($reply); @@ -890,7 +603,6 @@ class Feeds extends Handler_Protected { $reply['headlines']['content'] .= "</span></p>"; $reply['headlines-info'] = array("count" => 0, - "vgroup_last_feed" => '', "unread" => 0, "disable_cache" => true); @@ -907,7 +619,6 @@ class Feeds extends Handler_Protected { $reply['headlines']['content'] = "<div class='whiteBox'>". $error . "</div>"; $reply['headlines-info'] = array("count" => 0, - "vgroup_last_feed" => '', "unread" => 0, "disable_cache" => true); @@ -1501,17 +1212,17 @@ class Feeds extends Handler_Protected { return "rss_feed"; break; case -3: - return "new_releases"; + return "whatshot"; break; case -4: return "inbox"; break; case -6: - return "cached"; + return "restore"; break; default: if ($id < LABEL_BASE_INDEX) { - return "images/label.png"; + return "label"; } else { $icon = self::getIconFile($id); @@ -1722,6 +1433,7 @@ class Feeds extends Handler_Protected { $start_ts = isset($params["start_ts"]) ? $params["start_ts"] : false; $check_first_id = isset($params["check_first_id"]) ? $params["check_first_id"] : false; $skip_first_id_check = isset($params["skip_first_id_check"]) ? $params["skip_first_id_check"] : false; + $order_by = isset($params["order_by"]) ? $params["order_by"] : false; $ext_tables_part = ""; $limit_query_part = ""; @@ -1951,10 +1663,12 @@ class Feeds extends Handler_Protected { if (is_numeric($feed)) { // proper override_order applied above if ($vfeed_query_part && !$ignore_vfeed_group && get_pref('VFEED_GROUP_BY_FEED', $owner_uid)) { + $yyiw_desc = $order_by == "date_reverse" ? "" : "desc"; + if (!$override_order) { - $order_by = "ttrss_feeds.title, ".$order_by; + $order_by = "yyiw $yyiw_desc, ttrss_feeds.title, ".$order_by; } else { - $order_by = "ttrss_feeds.title, ".$override_order; + $order_by = "yyiw $yyiw_desc, ttrss_feeds.title, ".$override_order; } } @@ -1984,8 +1698,10 @@ class Feeds extends Handler_Protected { if (DB_TYPE == "pgsql") { $sanity_interval_qpart = "date_entered >= NOW() - INTERVAL '1 hour' AND"; + $yyiw_qpart = "to_char(date_entered, 'IYYY-IW') AS yyiw"; } else { $sanity_interval_qpart = "date_entered >= DATE_SUB(NOW(), INTERVAL 1 hour) AND"; + $yyiw_qpart = "date_format(date_entered, '%Y-%u') AS yyiw"; } if (!$search && !$skip_first_id_check) { @@ -1993,6 +1709,7 @@ class Feeds extends Handler_Protected { $query = "SELECT DISTINCT ttrss_feeds.title, date_entered, + $yyiw_qpart, guid, ttrss_entries.id, ttrss_entries.title, @@ -2031,6 +1748,7 @@ class Feeds extends Handler_Protected { $query = "SELECT DISTINCT date_entered, + $yyiw_qpart, guid, ttrss_entries.id,ttrss_entries.title, updated, |