From 249c93a228245c71853542814857ca0045e43052 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 7 Dec 2018 16:00:11 +0300 Subject: initial for js templates --- classes/feeds.php | 74 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 34 deletions(-) (limited to 'classes/feeds.php') diff --git a/classes/feeds.php b/classes/feeds.php index 080d9e80c..aab770fc0 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -230,7 +230,7 @@ class Feeds extends Handler_Protected { } } - $reply['content'] = ''; + $reply['content'] = []; $headlines_count = 0; @@ -240,32 +240,33 @@ class Feeds extends Handler_Protected { 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); - - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { - $line = $p->hook_query_headlines($line, 250, false); - } + if (!get_pref('SHOW_CONTENT_PREVIEW')) { + $line["content_preview"] = null; + } else { + $line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250); - if (get_pref('SHOW_CONTENT_PREVIEW')) { - $content_preview = $line["content_preview"]; - } + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { + $line = $p->hook_query_headlines($line, 250, false); + } + } $id = $line["id"]; - $feed_id = $line["feed_id"]; - $label_cache = $line["label_cache"]; - $labels = false; // normalize archived feed - if ($feed_id === null) { - $feed_id = 0; + if ($line['feed_id'] === null) { + $line['feed_id'] = 0; $line["feed_title"] = __("Archived articles"); } + $feed_id = $line["feed_id"]; - $mouseover_attrs = "onmouseover='Article.mouseIn($id)' onmouseout='Article.mouseOut($id)'"; + //$mouseover_attrs = "onmouseover='Article.mouseIn($id)' onmouseout='Article.mouseOut($id)'"; + + $label_cache = $line["label_cache"]; + $labels = false; if ($label_cache) { $label_cache = json_decode($label_cache, true); @@ -284,6 +285,9 @@ class Feeds extends Handler_Protected { $labels_str .= Article::format_article_labels($labels); $labels_str .= ""; + $line["labels"] = $labels_str; + unset($line["label_cache"]); + if (count($topmost_article_ids) < 3) { array_push($topmost_article_ids, $id); } @@ -296,35 +300,33 @@ class Feeds extends Handler_Protected { } $class .= $line["marked"] ? " marked" : ""; - $marked_pic = "star"; + //$marked_pic = "star"; - $class .= $line["published"] ? " published" : ""; - $published_pic = "rss_feed"; + //$class .= $line["published"] ? " published" : ""; + //$published_pic = "rss_feed"; - $updated_fmt = make_local_datetime($line["updated"], false, false, false, true); - $date_entered_fmt = T_sprintf("Imported at %s", + $line["updated"] = make_local_datetime($line["updated"], false, false, false, true); + $line['imported'] = T_sprintf("Imported at %s", make_local_datetime($line["date_entered"], false)); $score = $line["score"]; - $score_pic = "" . - get_score_pic($score) . ""; - $score_class = get_score_class($score); + $line["score_pic"] = get_score_pic($score); + $line["score_class"] = get_score_class($score); - $entry_author = $line["author"]; + //$entry_author = $line["author"]; - if ($entry_author) { + /* if ($entry_author) { $entry_author = " — $entry_author"; - } + } */ if (feeds::feedHasIcon($feed_id)) { - $feed_icon_img = "\"\""; + $line['feed_icon'] = "\"\""; } else { - $feed_icon_img = "rss_feed"; + $line['feed_icon'] = "rss_feed"; } - $entry_site_url = $line["site_url"]; + //$entry_site_url = $line["site_url"]; //setting feed headline background color, needs to change text color based on dark/light $fav_color = $line['favicon_avg_color']; @@ -335,9 +337,13 @@ class Feeds extends Handler_Protected { if (!isset($rgba_cache[$feed_id])) { $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color)); } + + $line['favicon_avg_color_rgba'] = $rgba_cache[$feed_id]; } - if (!get_pref('COMBINED_DISPLAY_MODE')) { + array_push($reply['content'], $line); + + /* if (!get_pref('COMBINED_DISPLAY_MODE')) { if ($vfeed_group_enabled) { if ($feed_id != $vgroup_last_feed) { @@ -413,7 +419,7 @@ class Feeds extends Handler_Protected { $reply['content'] .= ""; $reply['content'] .= ""; - } else { + } else { // HL if ($line["tag_cache"]) $tags = explode(",", $line["tag_cache"]); @@ -628,7 +634,7 @@ class Feeds extends Handler_Protected { } $reply['content'] .= $tmp_content; - } + } // end html */ ++$lnum; } -- cgit v1.2.3