mirror of
https://github.com/friendica/friendica
synced 2025-04-25 05:10:11 +00:00
support feed attachments/enclosures, and fix for bug #30
This commit is contained in:
parent
9c77c57b74
commit
6728a11ee3
12 changed files with 61 additions and 11 deletions
|
@ -468,11 +468,34 @@ function get_atom_elements($feed,$item) {
|
|||
if($scheme && $term && stristr($scheme,'X-DFRN:'))
|
||||
$tag_arr[] = substr($scheme,7,1) . '[url=' . unxmlify(substr($scheme,9)) . ']' . unxmlify($term) . '[/url]';
|
||||
elseif($term)
|
||||
$tag_arr[] = $term;
|
||||
$tag_arr[] = notags(trim($term));
|
||||
}
|
||||
$res['tag'] = implode(',', $tag_arr);
|
||||
}
|
||||
|
||||
$attach = $item->get_enclosures();
|
||||
if($attach) {
|
||||
$att_arr = array();
|
||||
foreach($attach as $att) {
|
||||
$len = intval($att->get_length());
|
||||
$link = str_replace(',','%2D', notags(trim($att->get_link())));
|
||||
$title = str_replace(',','%2D',notags(trim($att->get_title())));
|
||||
$type = notags(trim($att->get_type()));
|
||||
if((! $link) || (strpos($link,'http') !== 0))
|
||||
continue;
|
||||
|
||||
if(! $title)
|
||||
$title = ' ';
|
||||
if(! $type)
|
||||
$type = 'application/octet-stream';
|
||||
|
||||
// this isn't legal html - there is no size in an 'a' tag, remember to strip it before display
|
||||
|
||||
$att_arr[] = '<a href="' . $link . '" size="' . $len . '" type="' . $type . '">' . $title . '</a>';
|
||||
}
|
||||
$res['attach'] = implode(',', $att_arr);
|
||||
}
|
||||
|
||||
$rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'object');
|
||||
|
||||
if($rawobj) {
|
||||
|
@ -1526,6 +1549,8 @@ function atom_entry($item,$type,$author,$owner,$comment = false) {
|
|||
}
|
||||
}
|
||||
|
||||
$o .= item_getfeedattach($item);
|
||||
|
||||
$mentioned = get_mentions($item);
|
||||
if($mentioned)
|
||||
$o .= $mentioned;
|
||||
|
@ -1558,6 +1583,26 @@ function item_getfeedtags($item) {
|
|||
return $ret;
|
||||
}
|
||||
|
||||
function item_getfeedattach($item) {
|
||||
$ret = array();
|
||||
$arr = explode(',',$item['attach']);
|
||||
if(count($arr)) {
|
||||
foreach($arr as $r) {
|
||||
$matches = false;
|
||||
$cnt = preg_match('|\<a href=\"(.+?)\" size=\"(.+?)\" type=\"(.+?)\" >(.+?)</a>|',$item['attach'],$matches);
|
||||
if($cnt) {
|
||||
$ret .= '<link href="' . $matches[1] . '" type="' . $matches[3] . '" ';
|
||||
if(intval($matches[2]))
|
||||
$ret .= 'size="' . intval($matches[2]) . '" ';
|
||||
if($matches[4] !== ' ')
|
||||
$ret .= 'title="' . $matches[4] . '" ';
|
||||
$ret .= ' />' . "\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function item_expire($uid,$days) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue