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/handler/public.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'classes/handler/public.php') diff --git a/classes/handler/public.php b/classes/handler/public.php index f05beafd2..825ea5e2e 100644 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -87,14 +87,20 @@ class Handler_Public extends Handler { $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true); while ($line = $this->dbh->fetch_assoc($result)) { + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { + $line = $p->hook_query_headlines($line); + } $tpl->setVariable('ARTICLE_ID', htmlspecialchars($line['link']), true); $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true); $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true); - $tpl->setVariable('ARTICLE_EXCERPT', - truncate_string(strip_tags($line["content_preview"]), 100, '...'), true); + if(isset($line["modified_preview"])) + $tpl->setVariable('ARTICLE_EXCERPT', strip_tags($line["content_preview"]), true); + else + $tpl->setVariable('ARTICLE_EXCERPT', + truncate_string(strip_tags($line["content_preview"]), 100, '...'), true); - $content = sanitize($line["content_preview"], false, $owner_uid); + $content = sanitize($line["content"], false, $owner_uid); if ($line['note']) { $content = "
Article note: " . $line['note'] . "
" . @@ -164,13 +170,19 @@ class Handler_Public extends Handler { $feed['articles'] = array(); while ($line = $this->dbh->fetch_assoc($result)) { + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { + $line = $p->hook_query_headlines($line, 100); + } $article = array(); $article['id'] = $line['link']; $article['link'] = $line['link']; $article['title'] = $line['title']; - $article['excerpt'] = truncate_string(strip_tags($line["content_preview"]), 100, '...'); - $article['content'] = sanitize($line["content_preview"], false, $owner_uid); + if(isset($line["modified_preview"])) + $article['excerpt'] = strip_tags($line["content_preview"]); + else + $article['excerpt'] = truncate_string(strip_tags($line["content_preview"]), 100, '...'); + $article['content'] = sanitize($line["content"], false, $owner_uid); $article['updated'] = date('c', strtotime($line["updated"])); if ($line['note']) $article['note'] = $line['note']; -- 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/handler/public.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'classes/handler/public.php') diff --git a/classes/handler/public.php b/classes/handler/public.php index 825ea5e2e..08f35e212 100644 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -85,7 +85,7 @@ class Handler_Public extends Handler { } $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true); - + $line["content_preview"] = truncate_string(strip_tags($line["content_preview"]), 100, '...'); while ($line = $this->dbh->fetch_assoc($result)) { foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { $line = $p->hook_query_headlines($line); @@ -94,11 +94,7 @@ class Handler_Public extends Handler { $tpl->setVariable('ARTICLE_ID', htmlspecialchars($line['link']), true); $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true); $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true); - if(isset($line["modified_preview"])) - $tpl->setVariable('ARTICLE_EXCERPT', strip_tags($line["content_preview"]), true); - else - $tpl->setVariable('ARTICLE_EXCERPT', - truncate_string(strip_tags($line["content_preview"]), 100, '...'), true); + $tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true); $content = sanitize($line["content"], false, $owner_uid); @@ -170,6 +166,7 @@ class Handler_Public extends Handler { $feed['articles'] = array(); while ($line = $this->dbh->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); } @@ -178,10 +175,7 @@ class Handler_Public extends Handler { $article['id'] = $line['link']; $article['link'] = $line['link']; $article['title'] = $line['title']; - if(isset($line["modified_preview"])) - $article['excerpt'] = strip_tags($line["content_preview"]); - else - $article['excerpt'] = truncate_string(strip_tags($line["content_preview"]), 100, '...'); + $article['excerpt'] = $line["content_preview"]; $article['content'] = sanitize($line["content"], false, $owner_uid); $article['updated'] = date('c', strtotime($line["updated"])); -- cgit v1.2.3 From 575a52874c8ebb0bcd5741009cc143389ea2279e Mon Sep 17 00:00:00 2001 From: justauser Date: Sat, 29 Jun 2013 03:11:38 -0400 Subject: fixed a typo --- classes/handler/public.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes/handler/public.php') diff --git a/classes/handler/public.php b/classes/handler/public.php index 08f35e212..810f4c034 100644 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -166,7 +166,7 @@ class Handler_Public extends Handler { $feed['articles'] = array(); while ($line = $this->dbh->fetch_assoc($result)) { - $line["content_preview"]] = truncate_string(strip_tags($line["content_preview"]), 100, '...'); + $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); } -- cgit v1.2.3