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 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 +++-------- 1 file changed, 3 insertions(+), 8 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) { -- cgit v1.2.3