aboutsummaryrefslogtreecommitdiffstats
path: root/include/items.php
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-04-06 19:41:16 -0700
committerFriendika <info@friendika.com>2011-04-06 19:42:35 -0700
commit6728a11ee38e890a0ce9b8b6d96dba98a7238129 (patch)
tree5396ee3aabb61f9d7ca399073606f5f27b599079 /include/items.php
parent9c77c57b74312a92eada9b84f68addece7a3a27c (diff)
downloadvolse-hubzilla-6728a11ee38e890a0ce9b8b6d96dba98a7238129.tar.gz
volse-hubzilla-6728a11ee38e890a0ce9b8b6d96dba98a7238129.tar.bz2
volse-hubzilla-6728a11ee38e890a0ce9b8b6d96dba98a7238129.zip
support feed attachments/enclosures, and fix for bug #30
Diffstat (limited to 'include/items.php')
-rw-r--r--include/items.php47
1 files changed, 46 insertions, 1 deletions
diff --git a/include/items.php b/include/items.php
index b17eadba2..501f2f944 100644
--- a/include/items.php
+++ b/include/items.php
@@ -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) {