From 3cb906c420579617e742f6bd1d22cda748893443 Mon Sep 17 00:00:00 2001
From: Michael <heluecht@pirati.ca>
Date: Sat, 25 Nov 2017 11:59:20 +0000
Subject: [PATCH] Issue 3911: Fetch keywords for feeds

---
 include/feed.php                           | 5 ++++-
 mod/contacts.php                           | 2 +-
 view/templates/contact_edit.tpl            | 3 +--
 view/theme/frio/templates/contact_edit.tpl | 2 +-
 view/theme/vier/templates/contact_edit.tpl | 2 +-
 5 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/feed.php b/include/feed.php
index 22deff535a..0be6a5781c 100644
--- a/include/feed.php
+++ b/include/feed.php
@@ -344,7 +344,7 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
 			$item["title"] = '';
 		}
 
-		if ($contact["fetch_further_information"]) {
+		if (!empty($contact["fetch_further_information"]) && ($contact["fetch_further_information"] < 3)) {
 			$preview = "";
 
 			// Handle enclosures and treat them as preview picture
@@ -384,6 +384,9 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
 			if (!strstr($item["body"], '[url') && ($item['plink'] != '')) {
 				$item["body"] .= "[hr][url]".$item['plink']."[/url]";
 			}
+			if ($contact["fetch_further_information"] == 3) {
+				$item["tag"] = add_page_keywords($item["plink"], false, $preview, true, $contact["ffi_keyword_blacklist"]);
+			}
 		}
 
 		if (!$simulate) {
diff --git a/mod/contacts.php b/mod/contacts.php
index 1859c2aa60..d294f6518d 100644
--- a/mod/contacts.php
+++ b/mod/contacts.php
@@ -577,7 +577,7 @@ function contacts_content(App $a) {
 
 		if ($contact['network'] == NETWORK_FEED) {
 			$fetch_further_information = array('fetch_further_information', t('Fetch further information for feeds'), $contact['fetch_further_information'], t('Fetch further information for feeds'),
-									array('0'=>t('Disabled'), '1'=>t('Fetch information'), '2'=>t('Fetch information and keywords')));
+									array('0' => t('Disabled'), '1' => t('Fetch information'), '3' => t('Fetch keywords'), '2' => t('Fetch information and keywords')));
 		}
 		if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2)))
 			$poll_interval = contact_poll_interval($contact['priority'],(! $poll_enabled));
diff --git a/view/templates/contact_edit.tpl b/view/templates/contact_edit.tpl
index bad1b63c35..4493161899 100644
--- a/view/templates/contact_edit.tpl
+++ b/view/templates/contact_edit.tpl
@@ -1,4 +1,3 @@
-
 <div id="contact-edit-wrapper" >
 
 	{{* Insert Tab-Nav *}}
@@ -71,7 +70,7 @@
 					{{include file="field_checkbox.tpl" field=$notify}}
 					{{if $fetch_further_information}}
 						{{include file="field_select.tpl" field=$fetch_further_information}}
-						{{if $fetch_further_information.2 == 2 }} {{include file="field_textarea.tpl" field=$ffi_keyword_blacklist}} {{/if}}
+						{{if $fetch_further_information.2 == 2 || $fetch_further_information.2 == 3}} {{include file="field_textarea.tpl" field=$ffi_keyword_blacklist}} {{/if}}
 					{{/if}}
 					{{include file="field_checkbox.tpl" field=$hidden}}
 
diff --git a/view/theme/frio/templates/contact_edit.tpl b/view/theme/frio/templates/contact_edit.tpl
index 540aebef54..52f3fc545e 100644
--- a/view/theme/frio/templates/contact_edit.tpl
+++ b/view/theme/frio/templates/contact_edit.tpl
@@ -134,7 +134,7 @@
 								{{include file="field_checkbox.tpl" field=$notify}}
 								{{if $fetch_further_information}}
 									{{include file="field_select.tpl" field=$fetch_further_information}}
-									{{if $fetch_further_information.2 == 2 }} {{include file="field_textarea.tpl" field=$ffi_keyword_blacklist}} {{/if}}
+									{{if $fetch_further_information.2 == 2 || $fetch_further_information.2 == 3}} {{include file="field_textarea.tpl" field=$ffi_keyword_blacklist}} {{/if}}
 								{{/if}}
 								{{include file="field_checkbox.tpl" field=$hidden}}
 
diff --git a/view/theme/vier/templates/contact_edit.tpl b/view/theme/vier/templates/contact_edit.tpl
index f4f85d611b..9dc11a31c2 100644
--- a/view/theme/vier/templates/contact_edit.tpl
+++ b/view/theme/vier/templates/contact_edit.tpl
@@ -71,7 +71,7 @@
 					{{include file="field_checkbox.tpl" field=$notify}}
 					{{if $fetch_further_information}}
 						{{include file="field_select.tpl" field=$fetch_further_information}}
-						{{if $fetch_further_information.2 == 2 }} {{include file="field_textarea.tpl" field=$ffi_keyword_blacklist}} {{/if}}
+						{{if $fetch_further_information.2 == 2 || $fetch_further_information.2 == 3}} {{include file="field_textarea.tpl" field=$ffi_keyword_blacklist}} {{/if}}
 					{{/if}}
 					{{include file="field_checkbox.tpl" field=$hidden}}
 
-- 
2.39.5