From ac4c1383ae3b1af7be056b1f75c8125b272b0e5f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 13 Jul 2015 01:19:52 +0300 Subject: bring cdmFeedTitle style in line with the rest of the UI send headline rows as separate JSON objects --- classes/feeds.php | 161 +++++++++++++++++++++++++++++------------------------- 1 file changed, 86 insertions(+), 75 deletions(-) (limited to 'classes/feeds.php') diff --git a/classes/feeds.php b/classes/feeds.php index 9608290ca..089c3e713 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -307,7 +307,11 @@ class Feeds extends Handler_Protected { $expand_cdm = get_pref('CDM_EXPANDED'); + $reply['content'] = array(); + while ($line = $this->dbh->fetch_assoc($result)) { + $headline_row = ''; + $line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { @@ -448,76 +452,79 @@ class Feeds extends Handler_Protected { $vf_catchup_link = "".__('mark feed as read').""; - $reply['content'] .= "
". + $feed_title_row = "
". "
$feed_icon_img
". - "". $line["feed_title"]." + "". + $line["feed_title"]." $vf_catchup_link
"; + array_push($reply['content'], array('id' => 0, 'kind' => 'feed_title', 'html' => $feed_title_row)); + } } $mouseover_attrs = "onmouseover='postMouseIn(event, $id)' onmouseout='postMouseOut($id)'"; - $reply['content'] .= "
"; + $headline_row .= "
"; - $reply['content'] .= "
"; + $headline_row .= "
"; - $reply['content'] .= ""; - $reply['content'] .= "$marked_pic"; - $reply['content'] .= "$published_pic"; + $headline_row .= "$marked_pic"; + $headline_row .= "$published_pic"; - $reply['content'] .= "
"; + $headline_row .= "
"; - $reply['content'] .= "
"; - $reply['content'] .= "" . truncate_string($line["title"], 200); if (get_pref('SHOW_CONTENT_PREVIEW')) { - $reply['content'] .= "" . $line["content_preview"] . ""; + $headline_row .= "" . $line["content_preview"] . ""; } - $reply['content'] .= ""; + $headline_row .= ""; - $reply['content'] .= $labels_str; + $headline_row .= $labels_str; - $reply['content'] .= "
"; + $headline_row .= "
"; if (!$vfeed_group_enabled) { if (@$line["feed_title"]) { $rgba = @$rgba_cache[$feed_id]; - $reply['content'] .= "". + $headline_row .= "". truncate_string($line["feed_title"],30).""; } } - $reply['content'] .= ""; + $headline_row .= ""; - $reply['content'] .= "
$updated_fmt
+ $headline_row .= "
$updated_fmt
"; - $reply['content'] .= "
"; + $headline_row .= "
"; - $reply['content'] .= $score_pic; + $headline_row .= $score_pic; if ($line["feed_title"] && !$vfeed_group_enabled) { - $reply['content'] .= " $feed_icon_img"; } - $reply['content'] .= "
"; - $reply['content'] .= "
"; + $headline_row .= "
"; + $headline_row .= "
"; } else { @@ -551,10 +558,12 @@ class Feeds extends Handler_Protected { //$feed_icon_img = "\"\""; } - $reply['content'] .= "
". + $feed_title_row = "
". "
$feed_icon_img
". "". $line["feed_title"]." $vf_catchup_link
"; + + array_push($reply['content'], array('id' => 0, 'kind' => 'feed_title', 'html' => $feed_title_row)); } } @@ -563,20 +572,20 @@ class Feeds extends Handler_Protected { $expanded_class = $expand_cdm ? "expanded" : "expandable"; - $reply['content'] .= "
"; - $reply['content'] .= "
"; - $reply['content'] .= "
"; + $headline_row .= "
"; + $headline_row .= "
"; - $reply['content'] .= ""; - $reply['content'] .= "$marked_pic"; - $reply['content'] .= "$published_pic"; + $headline_row .= "$marked_pic"; + $headline_row .= "$published_pic"; - $reply['content'] .= "
"; + $headline_row .= "
"; if ($highlight_words && count($highlight_words > 0)) { foreach ($highlight_words as $word) { @@ -585,7 +594,7 @@ class Feeds extends Handler_Protected { } } - $reply['content'] .= " $entry_author"; - $reply['content'] .= $labels_str; + $headline_row .= $labels_str; - $reply['content'] .= ""; + $headline_row .= ""; if (!$vfeed_group_enabled) { if (@$line["feed_title"]) { $rgba = @$rgba_cache[$feed_id]; - $reply['content'] .= "
+ $headline_row .= "
". truncate_string($line["feed_title"],30)." @@ -622,34 +631,34 @@ class Feeds extends Handler_Protected { } } - $reply['content'] .= " + $headline_row .= " $updated_fmt"; - $reply['content'] .= "
"; - $reply['content'] .= "$score_pic"; + $headline_row .= "
"; + $headline_row .= "$score_pic"; if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) { - $reply['content'] .= "$feed_icon_img"; } - $reply['content'] .= "
"; + $headline_row .= "
"; - $reply['content'] .= "
"; + $headline_row .= "
"; - $reply['content'] .= "
"; - $reply['content'] .= "
"; + $headline_row .= "
"; if ($line['note']) { - $reply['content'] .= format_article_note($id, $line['note']); + $headline_row .= format_article_note($id, $line['note']); } - $reply['content'] .= "
"; + $headline_row .= "
"; if (!$line['lang']) $line['lang'] = 'en'; - $reply['content'] .= "
"; + $headline_row .= "
"; if ($line["orig_feed_id"]) { @@ -658,54 +667,54 @@ class Feeds extends Handler_Protected { if ($this->dbh->num_rows($tmp_result) != 0) { - $reply['content'] .= "
"; - $reply['content'] .= __("Originally from:"); + $headline_row .= "
"; + $headline_row .= __("Originally from:"); - $reply['content'] .= " "; + $headline_row .= " "; $tmp_line = $this->dbh->fetch_assoc($tmp_result); - $reply['content'] .= "" . $tmp_line['title'] . ""; - $reply['content'] .= " "; + $headline_row .= " "; - $reply['content'] .= ""; - $reply['content'] .= ""; + $headline_row .= ""; + $headline_row .= ""; - $reply['content'] .= "
"; + $headline_row .= "
"; } } - $reply['content'] .= ""; + $headline_row .= ""; // if (!$expand_cdm) { - $reply['content'] .= ""; - $reply['content'] .= htmlspecialchars($line["content"]); - $reply['content'] .= ""; + $headline_row .= htmlspecialchars($line["content"]); + $headline_row .= ""; + $headline_row .= "
"; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { - $reply['content'] .= $p->hook_article_left_button($line); + $headline_row .= $p->hook_article_left_button($line); } $tags_str = format_tags_string($tags, $id); - $reply['content'] .= "Tags + $headline_row .= "Tags $tags_str (+)"; @@ -729,26 +738,28 @@ class Feeds extends Handler_Protected { } } - if ($entry_comments) $reply['content'] .= " ($entry_comments)"; + if ($entry_comments) $headline_row .= " ($entry_comments)"; - $reply['content'] .= "
"; + $headline_row .= "
"; -// $reply['content'] .= "$marked_pic"; -// $reply['content'] .= "$published_pic"; +// $headline_row .= "$marked_pic"; +// $headline_row .= "$published_pic"; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) { - $reply['content'] .= $p->hook_article_button($line); + $headline_row .= $p->hook_article_button($line); } - $reply['content'] .= "
"; - $reply['content'] .= "
"; + $headline_row .= "
"; + $headline_row .= "
"; - $reply['content'] .= "
"; + $headline_row .= "
"; - $reply['content'] .= "
"; + $headline_row .= "
"; } + array_push($reply['content'], array("id" => (int)$line['id'], 'html' => $headline_row)); + ++$lnum; } -- cgit v1.2.3-54-g00ecf