Merge pull request #4052 from annando/issue-3911

Issue 3911: Now the categories are really fetched
This commit is contained in:
Tobias Diekershoff 2017-12-12 08:06:23 +01:00 committed by GitHub
commit 3a1a320dd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 3 deletions

View File

@ -1,5 +1,7 @@
<?php
use Friendica\Database\DBM;
use Friendica\Core\System;
require_once("include/html2bbcode.php");
require_once("include/items.php");
@ -320,6 +322,18 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
$item["attach"] .= '[attach]href="'.$href.'" length="'.$length.'" type="'.$type.'"[/attach]';
}
$tags = '';
$categories = $xpath->query("category", $entry);
foreach ($categories AS $category) {
$hashtag = $category->nodeValue;
if ($tags != '') {
$tags .= ', ';
}
$taglink = "#[url=" . System::baseUrl() . "/search?tag=" . rawurlencode($hashtag) . "]" . $hashtag . "[/url]";
$tags .= $taglink;
}
$body = trim($xpath->evaluate('atom:content/text()', $entry)->item(0)->nodeValue);
if ($body == "") {
@ -381,12 +395,17 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
$item["object-type"] = ACTIVITY_OBJ_BOOKMARK;
unset($item["attach"]);
} else {
if ($contact["fetch_further_information"] == 3) {
if (!empty($tags)) {
$item["tag"] = $tags;
} else {
$item["tag"] = add_page_keywords($item["plink"], false, $preview, true, $contact["ffi_keyword_blacklist"]);
}
$item["body"] .= "\n".$item['tag'];
}
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) {