]> git.mxchange.org Git - friendica.git/commitdiff
Creating hashtags from keywords of a feed, when additional data should be fetched.
authorMichael Vogel <icarus@dabo.de>
Fri, 3 Oct 2014 10:18:33 +0000 (12:18 +0200)
committerMichael Vogel <icarus@dabo.de>
Fri, 3 Oct 2014 10:18:33 +0000 (12:18 +0200)
include/items.php
mod/parse_url.php

index 8cbcc3e6e93f35427277dcee246a73248fe944ba..4d6d6dcb14824d677a57ea5db17edd74637d6b00 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']);
+               $res["body"] = $res["title"].add_page_info($res['plink'], false, "", true);
                $res["title"] = "";
                $res["object-type"] = ACTIVITY_OBJ_BOOKMARK;
        } elseif (isset($contact["network"]) AND ($contact["network"] == NETWORK_OSTATUS))
@@ -888,7 +888,7 @@ function get_atom_elements($feed, $item, $contact = array()) {
        return $res;
 }
 
-function add_page_info($url, $no_photos = false, $photo = "") {
+function add_page_info($url, $no_photos = false, $photo = "", $keywords = false) {
        require_once("mod/parse_url.php");
 
        $data = parseurl_getsiteinfo($url, true);
@@ -920,7 +920,12 @@ function add_page_info($url, $no_photos = false, $photo = "") {
        if (($data["type"] != "photo") AND is_string($data["text"]))
                $text .= "[quote]".$data["text"]."[/quote]";
 
-       return("\n[class=type-".$data["type"]."]".$text."[/class]");
+       $hashtags = "";
+       if ($keywords AND isset($data["keywords"]))
+               foreach ($data["keywords"] AS $keyword)
+                       $hashtags .= "#".str_replace(" ", "", $keyword)." ";
+
+       return("\n[class=type-".$data["type"]."]".$text."[/class]".$hashtags);
 }
 
 function add_page_info_to_body($body, $texturl = false, $no_photos = false) {
index c5f010ac117ad2fa7c1aea43a406639ba244c337..d314c6c67ff09190036ffb1753faeeb67f2e1329 100644 (file)
@@ -205,11 +205,23 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co
                                case "dc.description":
                                        $siteinfo["text"] = $attr["content"];
                                        break;
+                               case "keywords":
+                                       $keywords = explode(",", $attr["content"]);
+                                       break;
+                               case "news_keywords":
+                                       $keywords = explode(",", $attr["content"]);
+                                       break;
                        }
                if ($siteinfo["type"] == "summary")
                        $siteinfo["type"] = "link";
        }
 
+       if (isset($keywords)) {
+               $siteinfo["keywords"] = array();
+               foreach ($keywords as $keyword)
+                       $siteinfo["keywords"][] = trim($keyword);
+       }
+
        //$list = $xpath->query("head/meta[@property]");
        $list = $xpath->query("//meta[@property]");
        foreach ($list as $node) {