aboutsummaryrefslogtreecommitdiffstats
path: root/include/items.php
diff options
context:
space:
mode:
authorPaolo Tacconi <p.tacconi@giunti.it>2014-09-25 08:44:07 +0200
committerPaolo Tacconi <p.tacconi@giunti.it>2014-09-25 08:44:07 +0200
commit6324a07dd8b17db5da0ce66c99fb69e2f3ec49e1 (patch)
tree89e81409add34df97f633515181790d6aed4c726 /include/items.php
parent7da97c198182f8f6f4286e16d80de205431d81bb (diff)
parent92c723d37cd8ded2183d3334eb51e740170e191b (diff)
downloadvolse-hubzilla-6324a07dd8b17db5da0ce66c99fb69e2f3ec49e1.tar.gz
volse-hubzilla-6324a07dd8b17db5da0ce66c99fb69e2f3ec49e1.tar.bz2
volse-hubzilla-6324a07dd8b17db5da0ce66c99fb69e2f3ec49e1.zip
Rebase from upstream
Diffstat (limited to 'include/items.php')
-rwxr-xr-xinclude/items.php66
1 files changed, 46 insertions, 20 deletions
diff --git a/include/items.php b/include/items.php
index 1fa833eb2..4d89606da 100755
--- a/include/items.php
+++ b/include/items.php
@@ -1418,16 +1418,23 @@ function get_atom_elements($feed,$item,&$author) {
if($found_author) {
$author['author_name'] = unxmlify($found_author->get_name());
$author['author_link'] = unxmlify($found_author->get_link());
+ $author['author_is_feed'] = false;
}
else {
$author['author_name'] = unxmlify($feed->get_title());
$author['author_link'] = unxmlify($feed->get_permalink());
+ $author['author_is_feed'] = true;
}
+ if(substr($author['author_link'],-1,1) == '/')
+ $author['author_link'] = substr($author['author_link'],0,-1);
+
$res['mid'] = base64url_encode(unxmlify($item->get_id()));
$res['title'] = unxmlify($item->get_title());
$res['body'] = unxmlify($item->get_content());
$res['plink'] = unxmlify($item->get_link(0));
+ $res['item_flags'] = ITEM_RSS;
+
// removing the content of the title if its identically to the body
// This helps with auto generated titles e.g. from tumblr
@@ -1488,8 +1495,10 @@ function get_atom_elements($feed,$item,&$author) {
if($rawauthor && $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) {
$base = $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'];
foreach($base as $link) {
- if($link['attribs']['']['rel'] === 'alternate' && (! $author['author_link']))
+ if($link['attribs']['']['rel'] === 'alternate' && (! $author['author_link'])) {
$author['author_link'] = unxmlify($link['attribs']['']['href']);
+ $author['author_is_feed'] = true;
+ }
if(! $author['author_photo']) {
if($link['attribs']['']['rel'] === 'photo' || $link['attribs']['']['rel'] === 'avatar')
$author['author_photo'] = unxmlify($link['attribs']['']['href']);
@@ -1576,6 +1585,28 @@ function get_atom_elements($feed,$item,&$author) {
$res['body'] = escape_tags($res['body']);
}
+ if($res['plink'] && $res['title']) {
+ $res['body'] = '#^[url=' . $res['plink'] . ']' . $res['title'] . '[/url]' . "\n\n" . $res['body'];
+ $terms = array();
+ $terms[] = array(
+ 'otype' => TERM_OBJ_POST,
+ 'type' => TERM_BOOKMARK,
+ 'url' => $res['plink'],
+ 'term' => $res['title'],
+ );
+ }
+ elseif($res['plink']) {
+ $res['body'] = '#^[url]' . $res['plink'] . '[/url]' . "\n\n" . $res['body'];
+ $terms = array();
+ $terms[] = array(
+ 'otype' => TERM_OBJ_POST,
+ 'type' => TERM_BOOKMARK,
+ 'url' => $res['plink'],
+ 'term' => $res['plink'],
+ );
+ }
+
+
$private = $item->get_item_tags(NAMESPACE_DFRN,'private');
if($private && intval($private[0]['data']) > 0)
$res['item_private'] = ((intval($private[0]['data'])) ? 1 : 0);
@@ -1664,7 +1695,8 @@ function get_atom_elements($feed,$item,&$author) {
$cats = $item->get_categories();
if($cats) {
- $terms = array();
+ if(is_null($terms))
+ $terms = array();
foreach($cats as $cat) {
$term = $cat->get_term();
if(! $term)
@@ -1689,9 +1721,11 @@ function get_atom_elements($feed,$item,&$author) {
);
}
}
- $res['term'] = $terms;
}
+ if(! is_null($terms))
+ $res['term'] = $terms;
+
$attach = $item->get_enclosures();
if($attach) {
$res['attach'] = array();
@@ -1791,6 +1825,7 @@ function get_atom_elements($feed,$item,&$author) {
call_hooks('parse_atom', $arr);
logger('get_atom_elements: author: ' . print_r($author,true),LOGGER_DATA);
+
logger('get_atom_elements: ' . print_r($res,true),LOGGER_DATA);
return $res;
@@ -2469,18 +2504,10 @@ function store_diaspora_comment_sig($datarray, $channel, $parent_item, $post_id)
return;
}
- $body = $datarray['body'];
- if(array_key_exists('item_flags',$datarray) && ($datarray['item_flags'] & ITEM_OBSCURED)) {
- $key = get_config('system','prvkey');
- if($datarray['body'])
- $body = crypto_unencapsulate(json_decode($datarray['body'],true),$key);
- }
-
- logger('mod_item: storing diaspora comment signature',LOGGER_DEBUG);
-
require_once('include/bb2diaspora.php');
+ $signed_body = bb2diaspora_itembody($datarray);
- $signed_body = html_entity_decode(bb2diaspora($body));
+ logger('mod_item: storing diaspora comment signature',LOGGER_DEBUG);
$diaspora_handle = $channel['channel_address'] . '@' . get_app()->get_hostname();
@@ -3203,7 +3230,6 @@ function mail_store($arr) {
}
-
/**
*
* consume_feed - process atom feed and update anything/everything we might need to update
@@ -3321,11 +3347,11 @@ function consume_feed($xml,$importer,&$contact,$pass = 0) {
$author = array();
$datarray = get_atom_elements($feed,$item,$author);
- if(! x($author,'author_name'))
+ if((! x($author,'author_name')) || ($author['author_is_feed']))
$author['author_name'] = $contact['xchan_name'];
- if(! x($author,'author_link'))
+ if((! x($author,'author_link')) || ($author['author_is_feed']))
$author['author_link'] = $contact['xchan_url'];
- if(! x($author,'author_photo'))
+ if((! x($author,'author_photo'))|| ($author['author_is_feed']))
$author['author_photo'] = $contact['xchan_photo_m'];
$datarray['author_xchan'] = '';
@@ -3384,11 +3410,11 @@ function consume_feed($xml,$importer,&$contact,$pass = 0) {
$datarray = get_atom_elements($feed,$item,$author);
if(is_array($contact)) {
- if(! x($author,'author_name'))
+ if((! x($author,'author_name')) || ($author['author_is_feed']))
$author['author_name'] = $contact['xchan_name'];
- if(! x($author,'author_link'))
+ if((! x($author,'author_link')) || ($author['author_is_feed']))
$author['author_link'] = $contact['xchan_url'];
- if(! x($author,'author_photo'))
+ if((! x($author,'author_photo'))|| ($author['author_is_feed']))
$author['author_photo'] = $contact['xchan_photo_m'];
}