aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2010-11-03 16:48:21 -0700
committerFriendika <info@friendika.com>2010-11-03 16:48:21 -0700
commita985ad4a5407c3cbc0d0a3919e19ddd99bf108af (patch)
tree8d4cc4b5e0cd4d452c571ea41e8f32e81127b028
parent98a508532f0f3ea35748fa650aa3cad5e929e3de (diff)
downloadvolse-hubzilla-a985ad4a5407c3cbc0d0a3919e19ddd99bf108af.tar.gz
volse-hubzilla-a985ad4a5407c3cbc0d0a3919e19ddd99bf108af.tar.bz2
volse-hubzilla-a985ad4a5407c3cbc0d0a3919e19ddd99bf108af.zip
add activity target to items, allow multiple link relations
-rw-r--r--boot.php3
-rw-r--r--database.sql2
-rw-r--r--include/items.php104
-rw-r--r--mod/photos.php34
-rw-r--r--update.php7
5 files changed, 138 insertions, 12 deletions
diff --git a/boot.php b/boot.php
index 5837f14d3..60fccc0ea 100644
--- a/boot.php
+++ b/boot.php
@@ -2,7 +2,7 @@
set_time_limit(0);
-define ( 'BUILD_ID', 1013 );
+define ( 'BUILD_ID', 1014 );
define ( 'DFRN_PROTOCOL_VERSION', '2.0' );
define ( 'EOL', "<br />\r\n" );
@@ -61,6 +61,7 @@ define ( 'NAMESPACE_THREAD' , 'http://purl.org/syndication/thread/1.0' )
define ( 'NAMESPACE_TOMB' , 'http://purl.org/atompub/tombstones/1.0' );
define ( 'NAMESPACE_ACTIVITY', 'http://activitystrea.ms/spec/1.0/' );
define ( 'NAMESPACE_ACTIVITY_SCHEMA', 'http://activitystrea.ms/schema/1.0/' );
+define ( 'NAMESPACE_MEDIA', 'http://purl.org/syndication/atommedia' );
define ( 'NAMESPACE_SALMON_ME', 'http://salmon-protocol.org/ns/magic-env' );
define ( 'NAMESPACE_OSTATUSSUB', 'http://ostatus.org/schema/1.0/subscribe' );
define ( 'NAMESPACE_GEORSS', 'http://www.georss.org/georss' );
diff --git a/database.sql b/database.sql
index 5b8141f7a..33f1e7949 100644
--- a/database.sql
+++ b/database.sql
@@ -174,6 +174,8 @@ CREATE TABLE IF NOT EXISTS `item` (
`verb` char(255) NOT NULL,
`object-type` char(255) NOT NULL,
`object` text NOT NULL,
+ `target-type` char(255) NOT NULL,
+ `target` text NOT NULL,
`resource-id` char(255) NOT NULL,
`tag` mediumtext NOT NULL,
`inform` mediumtext NOT NULL,
diff --git a/include/items.php b/include/items.php
index da85ed331..b016fa180 100644
--- a/include/items.php
+++ b/include/items.php
@@ -188,7 +188,7 @@ function construct_verb($item) {
return ACTIVITY_POST;
}
-function construct_activity($item) {
+function construct_activity_object($item) {
if($item['object']) {
$o = '<as:object>' . "\r\n";
@@ -197,8 +197,12 @@ function construct_activity($item) {
$o .= '<as:object-type>' . xmlify($r->type) . '</as:object-type>' . "\r\n";
if($r->id)
$o .= '<id>' . xmlify($r->id) . '</id>' . "\r\n";
- if($r->link)
- $o .= '<link rel="alternate" type="text/html" href="' . xmlify($r->link) . '" />' . "\r\n";
+ if($r->link) {
+ if(substr($r->link,0,1) === '&')
+ $o .= unxmlify($r->link);
+ else
+ $o .= '<link rel="alternate" type="text/html" href="' . xmlify($r->link) . '" />' . "\r\n";
+ }
if($r->title)
$o .= '<title>' . xmlify($r->title) . '</title>' . "\r\n";
if($r->content)
@@ -210,6 +214,32 @@ function construct_activity($item) {
return '';
}
+function construct_activity_target($item) {
+
+ if($item['target']) {
+ $o = '<as:target>' . "\r\n";
+ $r = @simplexml_load_string($item['target']);
+ if($r->type)
+ $o .= '<as:object-type>' . xmlify($r->type) . '</as:object-type>' . "\r\n";
+ if($r->id)
+ $o .= '<id>' . xmlify($r->id) . '</id>' . "\r\n";
+ if($r->link) {
+ if(substr($r->link,0,1) === '&')
+ $o .= unxmlify($r->link);
+ else
+ $o .= '<link rel="alternate" type="text/html" href="' . xmlify($r->link) . '" />' . "\r\n";
+ }
+ if($r->title)
+ $o .= '<title>' . xmlify($r->title) . '</title>' . "\r\n";
+ if($r->content)
+ $o .= '<content type="html" >' . xmlify(bbcode($r->content)) . '</content>' . "\r\n";
+ $o .= '</as:target>' . "\r\n";
+ return $o;
+ }
+
+ return '';
+}
+
@@ -391,9 +421,8 @@ function get_atom_elements($feed,$item) {
}
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
$res['object'] .= '<id>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n";
-
- if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'][0]['attribs']['']['rel'] === 'alternate')
- $res['object'] .= '<link>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'][0]['attribs']['']['href'] . '</link>' . "\n";
+ if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'])
+ $res['target'] .= '<link>' . encode_rel_links($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n";
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'])
$res['object'] .= '<title>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n";
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) {
@@ -419,9 +448,67 @@ function get_atom_elements($feed,$item) {
$res['object'] .= '</object>' . "\n";
}
+ $rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'target');
+
+ if($rawobj) {
+ $res['target'] = '<target>' . "\n";
+ if($rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
+ $res['target'] .= '<type>' . $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n";
+ }
+ if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
+ $res['target'] .= '<id>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n";
+
+ if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'])
+ $res['target'] .= '<link>' . encode_rel_links($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n";
+ if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'])
+ $res['target'] .= '<title>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n";
+ if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) {
+ $body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data'];
+ if(! $body)
+ $body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data'];
+ if(strpos($body,'<')) {
+
+ $body = preg_replace('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s',
+ '[youtube]$1[/youtube]', $body);
+
+ $config = HTMLPurifier_Config::createDefault();
+ $config->set('Cache.DefinitionImpl', null);
+
+ $purifier = new HTMLPurifier($config);
+ $body = $purifier->purify($body);
+ }
+
+ $body = html2bbcode($body);
+ $res['target'] .= '<content>' . $body . '</content>' . "\n";
+ }
+
+ $res['target'] .= '</target>' . "\n";
+ }
+
return $res;
}
+function encode_rel_links($links) {
+ $o = '';
+ if(! ((is_array($links)) && (count($links))))
+ return $o;
+ foreach($links as $link) {
+ $o .= '<link ';
+ if($link['attribs']['']['rel'])
+ $o .= 'rel="' . $link['attribs']['']['rel'] . '" ';
+ if($link['attribs']['']['type'])
+ $o .= 'type="' . $link['attribs']['']['type'] . '" ';
+ if($link['attribs']['']['href'])
+ $o .= 'type="' . $link['attribs']['']['href'] . '" ';
+ if($link['attribs'][NAMESPACE_MEDIA]['width'])
+ $o .= 'media:width="' . $link['attribs'][NAMESPACE_MEDIA]['width'] . '" ';
+ if($link['attribs'][NAMESPACE_MEDIA]['height'])
+ $o .= 'media:height="' . $link['attribs'][NAMESPACE_MEDIA]['height'] . '" ';
+ $o .= ' />' . "\n" ;
+ }
+ return xmlify($o);
+}
+
function item_store($arr) {
if($arr['gravity'])
@@ -1050,9 +1137,12 @@ function atom_entry($item,$type,$author,$owner,$comment = false) {
$verb = construct_verb($item);
$o .= '<as:verb>' . xmlify($verb) . '</as:verb>' . "\r\n";
- $actobj = construct_activity($item);
+ $actobj = construct_activity_object($item);
if(strlen($actobj))
$o .= $actobj;
+ $actarg = construct_activity_target($item);
+ if(strlen($actarg))
+ $o .= $actarg;
$mentioned = get_mentions($item);
if($mentioned)
diff --git a/mod/photos.php b/mod/photos.php
index 8d2805fde..298bc9907 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -259,6 +259,7 @@ function photos_post(&$a) {
if($x !== '@' && $x !== '#')
$rawtags = '#' . $rawtags;
+ $taginfo = array();
$tags = get_tags($rawtags);
if(count($tags)) {
@@ -273,12 +274,14 @@ function photos_post(&$a) {
if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page')
$profile = $link['@attributes']['href'];
if($link['@attributes']['rel'] === 'salmon') {
+ $salmon = '$url:' . str_replace(',','%sc',$link['@attributes']['href']);
if(strlen($inform))
$inform .= ',';
- $inform .= 'url:' . str_replace(',','%2c',$link['@attributes']['href']);
+ $inform .= $salmon;
}
}
}
+ $taginfo[] = array($newname,$profile,$salmon);
}
else {
$newname = $name;
@@ -297,12 +300,14 @@ function photos_post(&$a) {
}
if(count($r)) {
$profile = $r[0]['url'];
+ $notify = 'cid:' . $r[0]['id'];
if(strlen($inform))
$inform .= ',';
- $inform .= 'cid:' . $r[0]['id'];
+ $inform .= $notify;
}
}
if($profile) {
+ $taginfo[] = array($newname,$profile,$notify);
if(strlen($str_tags))
$str_tags .= ',';
$profile = str_replace(',','%2c',$profile);
@@ -330,13 +335,36 @@ function photos_post(&$a) {
intval($item_id),
intval(local_user())
);
+
+ if(count($taginfo)) {
+ foreach($taginfo as $tagged) {
+// $slap = create_photo_tag(local_user(),$item_id, $tagged);
+
+
+//
+ }
+ // call notifier on new tag activity
+ }
+
+// $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
+
+// $proc_debug = get_config('system','proc_debug');
+
+ // send the notification upstream/downstream as the case may be
+
+// if($i[0]['visible'])
+// proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" $proc_debug & ",
+// array(),$foo));
+
+
+
}
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
return; // NOTREACHED
}
-
+ // default post action - upload a photo
if(! x($_FILES,'userfile'))
killme();
diff --git a/update.php b/update.php
index 9c5caa0b5..68367343d 100644
--- a/update.php
+++ b/update.php
@@ -96,4 +96,9 @@ function update_1011() {
function update_1012() {
q("ALTER TABLE `item` ADD `inform` MEDIUMTEXT NOT NULL AFTER `tag` ");
-} \ No newline at end of file
+}
+
+function update_1013() {
+ q("ALTER TABLE `item` ADD `target-type` CHAR( 255 ) NOT NULL
+ AFTER `object` , ADD `target` TEXT NOT NULL AFTER `target-type`");
+} \ No newline at end of file