more merging
This commit is contained in:
parent
7d694dca07
commit
1acc5ceb5f
@ -1149,7 +1149,7 @@ class Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($act->obj['type'] === 'Note' && $s['attach']) {
|
if($act->obj['type'] === 'Note' && $s['attach']) {
|
||||||
$s['body'] .= self::bb_attach($s['attach']);
|
$s['body'] .= self::bb_attach($s['attach'],$s['body']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// we will need a hook here to extract magnet links e.g. peertube
|
// we will need a hook here to extract magnet links e.g. peertube
|
||||||
@ -1651,7 +1651,7 @@ class Activity {
|
|||||||
$body .= self::bb_content($content,'content');
|
$body .= self::bb_content($content,'content');
|
||||||
|
|
||||||
if($act->obj['type'] === 'Note' && $s['attach']) {
|
if($act->obj['type'] === 'Note' && $s['attach']) {
|
||||||
$body .= self::bb_attach($s['attach']);
|
$body .= self::bb_attach($s['attach'],$body);
|
||||||
}
|
}
|
||||||
|
|
||||||
$body .= "[/share]";
|
$body .= "[/share]";
|
||||||
@ -1829,19 +1829,26 @@ class Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static function bb_attach($attach) {
|
|
||||||
|
static function bb_attach($attach,$body) {
|
||||||
|
|
||||||
$ret = false;
|
$ret = false;
|
||||||
|
|
||||||
foreach($attach as $a) {
|
foreach($attach as $a) {
|
||||||
if(strpos($a['type'],'image') !== false) {
|
if(strpos($a['type'],'image') !== false) {
|
||||||
$ret .= "\n\n" . '[img]' . $a['href'] . '[/img]';
|
if(self::media_not_in_body($a['href'],$body)) {
|
||||||
|
$ret .= "\n\n" . '[img]' . $a['href'] . '[/img]';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(array_key_exists('type',$a) && strpos($a['type'], 'video') === 0) {
|
if(array_key_exists('type',$a) && strpos($a['type'], 'video') === 0) {
|
||||||
$ret .= "\n\n" . '[video]' . $a['href'] . '[/video]';
|
if(self::media_not_in_body($a['href'],$body)) {
|
||||||
|
$ret .= "\n\n" . '[video]' . $a['href'] . '[/video]';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(array_key_exists('type',$a) && strpos($a['type'], 'audio') === 0) {
|
if(array_key_exists('type',$a) && strpos($a['type'], 'audio') === 0) {
|
||||||
$ret .= "\n\n" . '[audio]' . $a['href'] . '[/audio]';
|
if(self::media_not_in_body($a['href'],$body)) {
|
||||||
|
$ret .= "\n\n" . '[audio]' . $a['href'] . '[/audio]';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1849,16 +1856,31 @@ class Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// check for the existence of existing media link in body
|
||||||
|
|
||||||
|
static function media_not_in_body($s,$body) {
|
||||||
|
|
||||||
|
if((strpos($body,']' . $s . '[/img]') === false) &&
|
||||||
|
(strpos($body,']' . $s . '[/zmg]') === false) &&
|
||||||
|
(strpos($body,']' . $s . '[/video]') === false) &&
|
||||||
|
(strpos($body,']' . $s . '[/audio]') === false)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static function bb_content($content,$field) {
|
static function bb_content($content,$field) {
|
||||||
|
|
||||||
require_once('include/html2bbcode.php');
|
require_once('include/html2bbcode.php');
|
||||||
|
require_once('include/event.php');
|
||||||
$ret = false;
|
$ret = false;
|
||||||
|
|
||||||
if(is_array($content[$field])) {
|
if(is_array($content[$field])) {
|
||||||
foreach($content[$field] as $k => $v) {
|
foreach($content[$field] as $k => $v) {
|
||||||
$ret .= '[language=' . $k . ']' . html2bbcode($v) . '[/language]';
|
$ret .= html2bbcode($v);
|
||||||
|
// save this for auto-translate or dynamic filtering
|
||||||
|
// $ret .= '[language=' . $k . ']' . html2bbcode($v) . '[/language]';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1869,6 +1891,9 @@ class Activity {
|
|||||||
$ret = html2bbcode($content[$field]);
|
$ret = html2bbcode($content[$field]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if($field === 'content' && $content['event'] && (! strpos($ret,'[event'))) {
|
||||||
|
$ret .= format_event_bbcode($content['event']);
|
||||||
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
@ -1877,21 +1902,52 @@ class Activity {
|
|||||||
static function get_content($act) {
|
static function get_content($act) {
|
||||||
|
|
||||||
$content = [];
|
$content = [];
|
||||||
if (! $act) {
|
$event = null;
|
||||||
|
|
||||||
|
if ((! $act) || (! is_array($act))) {
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($act['type'] === 'Event') {
|
||||||
|
$adjust = false;
|
||||||
|
$event = [];
|
||||||
|
$event['event_hash'] = $act['id'];
|
||||||
|
if(array_key_exists('startTime',$act) && strpos($act['startTime'],-1,1) === 'Z') {
|
||||||
|
$adjust = true;
|
||||||
|
$event['adjust'] = 1;
|
||||||
|
$event['dtstart'] = datetime_convert('UTC','UTC',$event['startTime'] . (($adjust) ? '' : 'Z'));
|
||||||
|
}
|
||||||
|
if(array_key_exists('endTime',$act)) {
|
||||||
|
$event['dtend'] = datetime_convert('UTC','UTC',$event['endTime'] . (($adjust) ? '' : 'Z'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$event['nofinish'] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ([ 'name', 'summary', 'content' ] as $a) {
|
foreach ([ 'name', 'summary', 'content' ] as $a) {
|
||||||
if (($x = self::get_textfield($act,$a)) !== false) {
|
if (($x = self::get_textfield($act,$a)) !== false) {
|
||||||
$content[$a] = $x;
|
$content[$a] = $x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($event) {
|
||||||
|
$event['summary'] = html2bbcode($content['summary']);
|
||||||
|
$event['description'] = html2bbcode($content['content']);
|
||||||
|
if($event['summary'] && $event['dtstart']) {
|
||||||
|
$content['event'] = $event;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (array_key_exists('source',$act) && array_key_exists('mediaType',$act['source'])) {
|
if (array_key_exists('source',$act) && array_key_exists('mediaType',$act['source'])) {
|
||||||
if ($act['source']['mediaType'] === 'text/bbcode') {
|
if ($act['source']['mediaType'] === 'text/bbcode') {
|
||||||
$content['bbcode'] = purify_html($act['source']['content']);
|
$content['bbcode'] = purify_html($act['source']['content']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1909,4 +1965,6 @@ class Activity {
|
|||||||
}
|
}
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user