From 6728a11ee38e890a0ce9b8b6d96dba98a7238129 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 6 Apr 2011 19:41:16 -0700 Subject: [PATCH] support feed attachments/enclosures, and fix for bug #30 --- boot.php | 4 ++-- database.sql | 1 + include/items.php | 47 ++++++++++++++++++++++++++++++++++++++++++++- mod/register.php | 2 +- update.php | 4 ++++ util/messages.po | 2 +- util/strings.php | 2 +- view/fr/messages.po | 2 +- view/fr/strings.php | 2 +- view/it/messages.po | 2 +- view/it/strings.php | 2 +- view/sv/strings.php | 2 +- 12 files changed, 61 insertions(+), 11 deletions(-) diff --git a/boot.php b/boot.php index f8a8c9f939..858eb19a83 100644 --- a/boot.php +++ b/boot.php @@ -2,9 +2,9 @@ set_time_limit(0); -define ( 'FRIENDIKA_VERSION', '2.1.940' ); +define ( 'FRIENDIKA_VERSION', '2.1.941' ); define ( 'DFRN_PROTOCOL_VERSION', '2.2' ); -define ( 'DB_UPDATE_VERSION', 1046 ); +define ( 'DB_UPDATE_VERSION', 1047 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/database.sql b/database.sql index 5e5d3eefac..eb6eebc4a7 100644 --- a/database.sql +++ b/database.sql @@ -184,6 +184,7 @@ CREATE TABLE IF NOT EXISTS `item` ( `plink` char(255) NOT NULL, `resource-id` char(255) NOT NULL, `tag` mediumtext NOT NULL, + `attach` mediumtext NOT NULL, `inform` mediumtext NOT NULL, `location` char(255) NOT NULL, `coord` char(255) NOT NULL, diff --git a/include/items.php b/include/items.php index b17eadba28..501f2f9447 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[] = '' . $title . ''; + } + $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('|\(.+?)|',$item['attach'],$matches); + if($cnt) { + $ret .= 'strings['Invalid OpenID url'] = 'Invalid OpenID url'; $a->strings['Please enter the required information.'] = 'Please enter the required information.'; $a->strings['Please use a shorter name.'] = 'Please use a shorter name.'; $a->strings['Name too short.'] = 'Name too short.'; -$a->strings["That doesn\'t appear to be your full \x28First Last\x29 name."] = "That doesn\'t appear to be your full \x28First Last\x29 name."; +$a->strings["That doesn't appear to be your full \x28First Last\x29 name."] = "That doesn't appear to be your full \x28First Last\x29 name."; $a->strings['Your email domain is not among those allowed on this site.'] = 'Your email domain is not among those allowed on this site.'; $a->strings['Not a valid email address.'] = 'Not a valid email address.'; $a->strings['Cannot use that email.'] = 'Cannot use that email.'; diff --git a/view/fr/messages.po b/view/fr/messages.po index c0cb2789d0..573ab32aaf 100644 --- a/view/fr/messages.po +++ b/view/fr/messages.po @@ -940,7 +940,7 @@ msgstr "Nom trop court." #: ../../mod/register.php:89 #, fuzzy -msgid "That doesn\\'t appear to be your full (First Last) name." +msgid "That doesn't appear to be your full (First Last) name." msgstr "Ceci ne semble pas être votre nom complet (Prénom Nom)." #: ../../mod/register.php:92 diff --git a/view/fr/strings.php b/view/fr/strings.php index 5a6ae50274..0062a24b59 100644 --- a/view/fr/strings.php +++ b/view/fr/strings.php @@ -192,7 +192,7 @@ $a->strings["Invalid OpenID url"] = "Adresse OpenID invalide"; $a->strings["Please enter the required information."] = "Entrez les informations requises."; $a->strings["Please use a shorter name."] = "Utilisez un nom plus court."; $a->strings["Name too short."] = "Nom trop court."; -$a->strings["That doesn\\'t appear to be your full (First Last) name."] = "Ceci ne semble pas être votre nom complet (Prénom Nom)."; +$a->strings["That doesn't appear to be your full (First Last) name."] = "Ceci ne semble pas être votre nom complet (Prénom Nom)."; $a->strings["Your email domain is not among those allowed on this site."] = "Votre domaine de courriel n'est pas autorisé sur ce site."; $a->strings["Not a valid email address."] = "Ceci n'est pas une adresse courriel valide."; $a->strings["Cannot use that email."] = "Impossible d'utiliser ce courriel."; diff --git a/view/it/messages.po b/view/it/messages.po index 97dd746c7c..4337e7965f 100644 --- a/view/it/messages.po +++ b/view/it/messages.po @@ -1107,7 +1107,7 @@ msgid "Name too short." msgstr "Il Nome è troppo corto." #: ../../mod/register.php:89 -msgid "That doesn\\'t appear to be your full (First Last) name." +msgid "That doesn't appear to be your full (First Last) name." msgstr "Questo non sembra essere il tuo nome completo (Nome Cognome)." #: ../../mod/register.php:92 diff --git a/view/it/strings.php b/view/it/strings.php index 57dad37fe8..544c815c12 100644 --- a/view/it/strings.php +++ b/view/it/strings.php @@ -231,7 +231,7 @@ $a->strings["Invalid OpenID url"] = "Url OpenID non valido"; $a->strings["Please enter the required information."] = "Inserisci le informazioni richieste."; $a->strings["Please use a shorter name."] = "Usa un nome più corto."; $a->strings["Name too short."] = "Il Nome è troppo corto."; -$a->strings["That doesn\\'t appear to be your full (First Last) name."] = "Questo non sembra essere il tuo nome completo (Nome Cognome)."; +$a->strings["That doesn't appear to be your full (First Last) name."] = "Questo non sembra essere il tuo nome completo (Nome Cognome)."; $a->strings["Your email domain is not among those allowed on this site."] = "Il dominio della tua email non è tra quelli autorizzati su questo sito."; $a->strings["Not a valid email address."] = "Indirizzo email invaildo."; $a->strings["Cannot use that email."] = "Questa email non si puo' usare."; diff --git a/view/sv/strings.php b/view/sv/strings.php index df1b34465b..c20bc3293d 100644 --- a/view/sv/strings.php +++ b/view/sv/strings.php @@ -393,7 +393,7 @@ $a->strings['Invalid OpenID url'] = 'Ogiltig OpenID-URL'; $a->strings['Please enter the required information.'] = 'Fyll i alla obligatoriska fält.'; $a->strings['Please use a shorter name.'] = 'Välj ett kortare namn.'; $a->strings['Name too short.'] = 'Namnet är för kort.'; -$a->strings["That doesn\'t appear to be your full \x28First Last\x29 name."] = "Du verkar inte ha angett ditt fullständiga namn."; +$a->strings["That doesn't appear to be your full \x28First Last\x29 name."] = "Du verkar inte ha angett ditt fullständiga namn."; $a->strings['Your email domain is not among those allowed on this site.'] = 'Din e-postdomän är inte tillåten på den här webbplatsen.'; $a->strings['Not a valid email address.'] = 'Ogiltig e-postadress.'; $a->strings['Cannot use that email.'] = 'Otillåten e-postadress.';