]> git.mxchange.org Git - friendica.git/commitdiff
fetch further information: it is now possible to define a blacklist for keywords...
authorMichael Vogel <icarus@dabo.de>
Wed, 29 Oct 2014 23:24:23 +0000 (00:24 +0100)
committerMichael Vogel <icarus@dabo.de>
Wed, 29 Oct 2014 23:24:23 +0000 (00:24 +0100)
boot.php
include/dbstructure.php
include/items.php
mod/contacts.php
update.php
view/templates/contact_edit.tpl

index 7a959a09ae9f630c311d7b6aa3b44175a92e6c7a..cde1220a5e7dc4ccc92fdf1c664c80649f346950 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -18,7 +18,7 @@ define ( 'FRIENDICA_PLATFORM',     'Friendica');
 define ( 'FRIENDICA_CODENAME', 'Ginger');
 define ( 'FRIENDICA_VERSION',      '3.3' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.23'    );
-define ( 'DB_UPDATE_VERSION',      1173      );
+define ( 'DB_UPDATE_VERSION',      1174      );
 define ( 'EOL',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
 
index 75623c01c82bdca578a2a1194ed91fb604d8d14a..c05bd3796afaccde39e35bbb20e6639f25c91533 100644 (file)
@@ -462,6 +462,7 @@ function db_definition() {
                                        "bd" => array("type" => "date", "not null" => "1"),
                                        "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
                                        "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
+                                       "ffi_keyword_blacklist" => array("type" => "mediumtext", "not null" => "1"),
                                        ),
                        "indexes" => array(
                                        "PRIMARY" => array("id"),
index 3171e4f936cd76f5c52c914acc2c05d33e29360e..c24bd6b55e299d78051041b8c034a79bd5ae5858 100644 (file)
@@ -872,7 +872,7 @@ function get_atom_elements($feed, $item, $contact = array()) {
        }
 
        if (isset($contact["network"]) AND ($contact["network"] == NETWORK_FEED) AND $contact['fetch_further_information']) {
-               $res["body"] = $res["title"].add_page_info($res['plink'], false, "", ($contact['fetch_further_information'] == 2));
+               $res["body"] = $res["title"].add_page_info($res['plink'], false, "", ($contact['fetch_further_information'] == 2), $contact['ffi_keyword_blacklist']);
                $res["title"] = "";
                $res["object-type"] = ACTIVITY_OBJ_BOOKMARK;
        } elseif (isset($contact["network"]) AND ($contact["network"] == NETWORK_OSTATUS))
@@ -929,7 +929,7 @@ function add_page_info_data($data) {
        return("\n[class=type-".$data["type"]."]".$text."[/class]".$hashtags);
 }
 
-function add_page_info($url, $no_photos = false, $photo = "", $keywords = false) {
+function add_page_info($url, $no_photos = false, $photo = "", $keywords = false, $keyword_blacklist = "") {
        require_once("mod/parse_url.php");
 
        $data = parseurl_getsiteinfo($url, true);
@@ -939,6 +939,16 @@ function add_page_info($url, $no_photos = false, $photo = "", $keywords = false)
        if (!$keywords AND isset($data["keywords"]))
                unset($data["keywords"]);
 
+       if (($keyword_blacklist != "") AND isset($data["keywords"])) {
+               $list = explode(",", $keyword_blacklist);
+               foreach ($list AS $keyword) {
+                       $keyword = trim($keyword);
+                       $index = array_search($keyword, $data["keywords"]);
+                       if ($index !== false)
+                               unset($data["keywords"][$index]);
+               }
+       }
+
        $text = add_page_info_data($data);
 
        return($text);
index 51ff4ed4bc1fc481dcc646ceb5ae34c76873e06d..fbab84f562ad51d8bfa4b3f4ea3668a0f9f43230 100644 (file)
@@ -160,6 +160,8 @@ function contacts_post(&$a) {
 
        $fetch_further_information = intval($_POST['fetch_further_information']);
 
+       $ffi_keyword_blacklist = fix_mce_lf(escape_tags(trim($_POST['ffi_keyword_blacklist'])));
+
        $priority = intval($_POST['poll']);
        if($priority > 5 || $priority < 0)
                $priority = 0;
@@ -167,13 +169,15 @@ function contacts_post(&$a) {
        $info = fix_mce_lf(escape_tags(trim($_POST['info'])));
 
        $r = q("UPDATE `contact` SET `profile-id` = %d, `priority` = %d , `info` = '%s',
-               `hidden` = %d, `notify_new_posts` = %d, `fetch_further_information` = %d WHERE `id` = %d AND `uid` = %d",
+               `hidden` = %d, `notify_new_posts` = %d, `fetch_further_information` = %d,
+               `ffi_keyword_blacklist` = '%s' WHERE `id` = %d AND `uid` = %d",
                intval($profile_id),
                intval($priority),
                dbesc($info),
                intval($hidden),
                intval($notify),
                intval($fetch_further_information),
+               dbesc($ffi_keyword_blacklist),
                intval($contact_id),
                intval(local_user())
        );
@@ -388,7 +392,7 @@ function contacts_content(&$a) {
                                $dir_icon = 'images/larrow.gif';
                                $relation_text = t('You are sharing with %s');
                                break;
-       
+
                        case CONTACT_IS_SHARING;
                                $dir_icon = 'images/rarrow.gif';
                                $relation_text = t('%s is sharing with you');
@@ -504,6 +508,8 @@ function contacts_content(&$a) {
                        '$notify' => array('notify', t('Notification for new posts'), ($contact['notify_new_posts'] == 1), t('Send a notification of every new post of this contact')),
                        '$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'))),
+                       '$ffi_keyword_blacklist' => $contact['ffi_keyword_blacklist'],
+                       '$ffi_keyword_blacklist' => array('ffi_keyword_blacklist', t('Blacklisted keywords'), $contact['ffi_keyword_blacklist'], t('Comma separated list of keywords that should not be converted to hashtags, when "Fetch information and keywords" is selected')),
                        '$photo' => $contact['photo'],
                        '$name' => $contact['name'],
                        '$dir_icon' => $dir_icon,
index 0d4863a3ff6ece28582a3b53380f45297dfd557a..51b532d88d2de234c82809fbf5d76c235bd5443e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-define( 'UPDATE_VERSION' , 1173 );
+define( 'UPDATE_VERSION' , 1174 );
 
 /**
  *
index 133912bc94c988a68abbcf286f21545fcb05b477..9b57f17417281f9ca5742bd7d5dde3e7e26237fb 100644 (file)
@@ -67,6 +67,7 @@
        <div id="contact-edit-end" ></div>
        {{include file="field_checkbox.tpl" field=$notify}}
        {{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}}
        {{include file="field_checkbox.tpl" field=$hidden}}
 
 <div id="contact-edit-info-wrapper">