mirror of
https://github.com/friendica/friendica
synced 2024-11-18 17:43:41 +00:00
Merge branch 'friendica:develop' into mastodon-edit-title-spoiler-update
This commit is contained in:
commit
4fe278be7d
22 changed files with 625 additions and 491 deletions
|
@ -223,15 +223,13 @@ class Item
|
||||||
|
|
||||||
// select someone by nick in the current network
|
// select someone by nick in the current network
|
||||||
if (!DBA::isResult($contact) && ($network != '')) {
|
if (!DBA::isResult($contact) && ($network != '')) {
|
||||||
$condition = ["`nick` = ? AND `network` = ? AND `uid` = ?",
|
$condition = ['nick' => $name, 'network' => $network, 'uid' => $profile_uid];
|
||||||
$name, $network, $profile_uid];
|
|
||||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
// select someone by attag in the current network
|
// select someone by attag in the current network
|
||||||
if (!DBA::isResult($contact) && ($network != '')) {
|
if (!DBA::isResult($contact) && ($network != '')) {
|
||||||
$condition = ["`attag` = ? AND `network` = ? AND `uid` = ?",
|
$condition = ['attag' => $name, 'network' => $network, 'uid' => $profile_uid];
|
||||||
$name, $network, $profile_uid];
|
|
||||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,13 +241,13 @@ class Item
|
||||||
|
|
||||||
// select someone by nick in any network
|
// select someone by nick in any network
|
||||||
if (!DBA::isResult($contact)) {
|
if (!DBA::isResult($contact)) {
|
||||||
$condition = ["`nick` = ? AND `uid` = ?", $name, $profile_uid];
|
$condition = ['nick' => $name, 'uid' => $profile_uid];
|
||||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
// select someone by attag in any network
|
// select someone by attag in any network
|
||||||
if (!DBA::isResult($contact)) {
|
if (!DBA::isResult($contact)) {
|
||||||
$condition = ["`attag` = ? AND `uid` = ?", $name, $profile_uid];
|
$condition = ['attag' => $name, 'uid' => $profile_uid];
|
||||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +269,7 @@ class Item
|
||||||
$replaced = true;
|
$replaced = true;
|
||||||
// create profile link
|
// create profile link
|
||||||
$profile = str_replace(',', '%2c', $profile);
|
$profile = str_replace(',', '%2c', $profile);
|
||||||
$newtag = $tag_type.'[url=' . $profile . ']' . $newname . '[/url]';
|
$newtag = $tag_type . '[url=' . $profile . ']' . $newname . '[/url]';
|
||||||
$body = str_replace($tag_type . $name, $newtag, $body);
|
$body = str_replace($tag_type . $name, $newtag, $body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,8 +293,10 @@ class Item
|
||||||
$xmlhead = '<?xml version="1.0" encoding="UTF-8" ?>';
|
$xmlhead = '<?xml version="1.0" encoding="UTF-8" ?>';
|
||||||
|
|
||||||
if ($this->activity->match($item['verb'], Activity::TAG)) {
|
if ($this->activity->match($item['verb'], Activity::TAG)) {
|
||||||
$fields = ['author-id', 'author-link', 'author-name', 'author-network',
|
$fields = [
|
||||||
'verb', 'object-type', 'resource-id', 'body', 'plink'];
|
'author-id', 'author-link', 'author-name', 'author-network',
|
||||||
|
'verb', 'object-type', 'resource-id', 'body', 'plink'
|
||||||
|
];
|
||||||
$obj = Post::selectFirst($fields, ['uri' => $item['parent-uri']]);
|
$obj = Post::selectFirst($fields, ['uri' => $item['parent-uri']]);
|
||||||
if (!DBA::isResult($obj)) {
|
if (!DBA::isResult($obj)) {
|
||||||
$this->profiler->stopRecording();
|
$this->profiler->stopRecording();
|
||||||
|
@ -333,8 +333,8 @@ class Item
|
||||||
default:
|
default:
|
||||||
if ($obj['resource-id']) {
|
if ($obj['resource-id']) {
|
||||||
$post_type = $this->l10n->t('photo');
|
$post_type = $this->l10n->t('photo');
|
||||||
$m=[]; preg_match("/\[url=([^]]*)\]/", $obj['body'], $m);
|
preg_match("/\[url=([^]]*)\]/", $obj['body'], $matches);
|
||||||
$rr['plink'] = $m[1];
|
$rr['plink'] = $matches[1];
|
||||||
} else {
|
} else {
|
||||||
$post_type = $this->l10n->t('status');
|
$post_type = $this->l10n->t('status');
|
||||||
}
|
}
|
||||||
|
@ -433,7 +433,8 @@ class Item
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((($cid == 0) || ($rel == Contact::FOLLOWER)) &&
|
if ((($cid == 0) || ($rel == Contact::FOLLOWER)) &&
|
||||||
in_array($item['network'], Protocol::FEDERATED)) {
|
in_array($item['network'], Protocol::FEDERATED)
|
||||||
|
) {
|
||||||
$menu[$this->l10n->t('Connect/Follow')] = 'contact/follow?url=' . urlencode($item['author-link']) . '&auto=1';
|
$menu[$this->l10n->t('Connect/Follow')] = 'contact/follow?url=' . urlencode($item['author-link']) . '&auto=1';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -891,7 +892,7 @@ class Item
|
||||||
|
|
||||||
public function moveAttachmentsFromBodyToAttach(array $post): array
|
public function moveAttachmentsFromBodyToAttach(array $post): array
|
||||||
{
|
{
|
||||||
if (!preg_match_all('/(\[attachment\]([0-9]+)\[\/attachment\])/',$post['body'], $match)) {
|
if (!preg_match_all('/(\[attachment\]([0-9]+)\[\/attachment\])/', $post['body'], $match)) {
|
||||||
return $post;
|
return $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -903,11 +904,17 @@ class Item
|
||||||
if ($post['attach']) {
|
if ($post['attach']) {
|
||||||
$post['attach'] .= ',';
|
$post['attach'] .= ',';
|
||||||
}
|
}
|
||||||
$post['attach'] .= Post\Media::getAttachElement($this->baseURL . '/attach/' . $attachment['id'],
|
$post['attach'] .= Post\Media::getAttachElement(
|
||||||
$attachment['filesize'], $attachment['filetype'], $attachment['filename'] ?? '');
|
$this->baseURL . '/attach/' . $attachment['id'],
|
||||||
|
$attachment['filesize'],
|
||||||
|
$attachment['filetype'],
|
||||||
|
$attachment['filename'] ?? ''
|
||||||
|
);
|
||||||
|
|
||||||
$fields = ['allow_cid' => $post['allow_cid'], 'allow_gid' => $post['allow_gid'],
|
$fields = [
|
||||||
'deny_cid' => $post['deny_cid'], 'deny_gid' => $post['deny_gid']];
|
'allow_cid' => $post['allow_cid'], 'allow_gid' => $post['allow_gid'],
|
||||||
|
'deny_cid' => $post['deny_cid'], 'deny_gid' => $post['deny_gid']
|
||||||
|
];
|
||||||
$condition = ['id' => $attachment_id];
|
$condition = ['id' => $attachment_id];
|
||||||
Attach::update($fields, $condition);
|
Attach::update($fields, $condition);
|
||||||
}
|
}
|
||||||
|
@ -925,8 +932,9 @@ class Item
|
||||||
|
|
||||||
// embedded bookmark or attachment in post? set bookmark flag
|
// embedded bookmark or attachment in post? set bookmark flag
|
||||||
$data = BBCode::getAttachmentData($post['body']);
|
$data = BBCode::getAttachmentData($post['body']);
|
||||||
if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $post['body'], $match, PREG_SET_ORDER) || isset($data['type']))
|
if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $post['body'], $match, PREG_SET_ORDER) || !empty($data['type']))
|
||||||
&& ($post['post-type'] != ItemModel::PT_PERSONAL_NOTE)) {
|
&& ($post['post-type'] != ItemModel::PT_PERSONAL_NOTE)
|
||||||
|
) {
|
||||||
$post['post-type'] = ItemModel::PT_PAGE;
|
$post['post-type'] = ItemModel::PT_PAGE;
|
||||||
$post['object-type'] = Activity\ObjectType::BOOKMARK;
|
$post['object-type'] = Activity\ObjectType::BOOKMARK;
|
||||||
}
|
}
|
||||||
|
@ -934,16 +942,6 @@ class Item
|
||||||
// Setting the object type if not defined before
|
// Setting the object type if not defined before
|
||||||
if (empty($post['object-type'])) {
|
if (empty($post['object-type'])) {
|
||||||
$post['object-type'] = ($post['gravity'] == ItemModel::GRAVITY_PARENT) ? Activity\ObjectType::NOTE : Activity\ObjectType::COMMENT;
|
$post['object-type'] = ($post['gravity'] == ItemModel::GRAVITY_PARENT) ? Activity\ObjectType::NOTE : Activity\ObjectType::COMMENT;
|
||||||
|
|
||||||
$objectdata = BBCode::getAttachedData($post['body']);
|
|
||||||
|
|
||||||
if ($objectdata['type'] == 'link') {
|
|
||||||
$post['object-type'] = Activity\ObjectType::BOOKMARK;
|
|
||||||
} elseif ($objectdata['type'] == 'video') {
|
|
||||||
$post['object-type'] = Activity\ObjectType::VIDEO;
|
|
||||||
} elseif ($objectdata['type'] == 'photo') {
|
|
||||||
$post['object-type'] = Activity\ObjectType::IMAGE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $post;
|
return $post;
|
||||||
}
|
}
|
||||||
|
@ -1039,8 +1037,14 @@ class Item
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->emailer->send(new ItemCCEMail($this->app, $this->l10n, $this->baseURL,
|
$this->emailer->send(new ItemCCEMail(
|
||||||
$post, $address, $author['thumb'] ?? ''));
|
$this->app,
|
||||||
|
$this->l10n,
|
||||||
|
$this->baseURL,
|
||||||
|
$post,
|
||||||
|
$address,
|
||||||
|
$author['thumb'] ?? ''
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,77 +74,6 @@ class BBCode
|
||||||
const PREVIEW_LARGE = 2;
|
const PREVIEW_LARGE = 2;
|
||||||
const PREVIEW_SMALL = 3;
|
const PREVIEW_SMALL = 3;
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches attachment data that were generated the old way
|
|
||||||
*
|
|
||||||
* @param string $body Message body
|
|
||||||
* @return array
|
|
||||||
* 'type' -> Message type ('link', 'video', 'photo')
|
|
||||||
* 'text' -> Text before the shared message
|
|
||||||
* 'after' -> Text after the shared message
|
|
||||||
* 'image' -> Preview image of the message
|
|
||||||
* 'url' -> Url to the attached message
|
|
||||||
* 'title' -> Title of the attachment
|
|
||||||
* 'description' -> Description of the attachment
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
|
||||||
*/
|
|
||||||
private static function getOldAttachmentData(string $body): array
|
|
||||||
{
|
|
||||||
$post = [];
|
|
||||||
|
|
||||||
// Simplify image codes
|
|
||||||
$body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body);
|
|
||||||
|
|
||||||
if (preg_match_all("(\[class=(.*?)\](.*?)\[\/class\])ism", $body, $attached, PREG_SET_ORDER)) {
|
|
||||||
foreach ($attached as $data) {
|
|
||||||
if (!in_array($data[1], ['type-link', 'type-video', 'type-photo'])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$post['type'] = substr($data[1], 5);
|
|
||||||
|
|
||||||
$pos = strpos($body, $data[0]);
|
|
||||||
if ($pos > 0) {
|
|
||||||
$post['text'] = trim(substr($body, 0, $pos));
|
|
||||||
$post['after'] = trim(substr($body, $pos + strlen($data[0])));
|
|
||||||
} else {
|
|
||||||
$post['text'] = trim(str_replace($data[0], '', $body));
|
|
||||||
$post['after'] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$attacheddata = $data[2];
|
|
||||||
|
|
||||||
if (preg_match("/\[img\](.*?)\[\/img\]/ism", $attacheddata, $matches)) {
|
|
||||||
|
|
||||||
$picturedata = Images::getInfoFromURLCached($matches[1]);
|
|
||||||
|
|
||||||
if ($picturedata) {
|
|
||||||
if (($picturedata[0] >= 500) && ($picturedata[0] >= $picturedata[1])) {
|
|
||||||
$post['image'] = $matches[1];
|
|
||||||
} else {
|
|
||||||
$post['preview'] = $matches[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (preg_match("/\[bookmark\=(.*?)\](.*?)\[\/bookmark\]/ism", $attacheddata, $matches)) {
|
|
||||||
$post['url'] = $matches[1];
|
|
||||||
$post['title'] = $matches[2];
|
|
||||||
}
|
|
||||||
if (!empty($post['url']) && (in_array($post['type'], ['link', 'video']))
|
|
||||||
&& preg_match("/\[url\=(.*?)\](.*?)\[\/url\]/ism", $attacheddata, $matches)) {
|
|
||||||
$post['url'] = $matches[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search for description
|
|
||||||
if (preg_match("/\[quote\](.*?)\[\/quote\]/ism", $attacheddata, $matches)) {
|
|
||||||
$post['description'] = $matches[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $post;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches attachment data that were generated with the "attachment" element
|
* Fetches attachment data that were generated with the "attachment" element
|
||||||
*
|
*
|
||||||
|
@ -178,7 +107,7 @@ class BBCode
|
||||||
|
|
||||||
if (!preg_match("/(.*)\[attachment(.*?)\](.*?)\[\/attachment\](.*)/ism", $body, $match)) {
|
if (!preg_match("/(.*)\[attachment(.*?)\](.*?)\[\/attachment\](.*)/ism", $body, $match)) {
|
||||||
DI::profiler()->stopRecording();
|
DI::profiler()->stopRecording();
|
||||||
return self::getOldAttachmentData($body);
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$attributes = $match[2];
|
$attributes = $match[2];
|
||||||
|
@ -253,6 +182,33 @@ class BBCode
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove [attachment] BBCode and replaces it with a regular [url]
|
||||||
|
*
|
||||||
|
* @param string $body
|
||||||
|
* @param boolean $no_link_desc No link description
|
||||||
|
* @return string with replaced body
|
||||||
|
*/
|
||||||
|
public static function replaceAttachment(string $body, bool $no_link_desc = false): string
|
||||||
|
{
|
||||||
|
return preg_replace_callback(
|
||||||
|
"/\s*\[attachment (.*?)\](.*?)\[\/attachment\]\s*/ism",
|
||||||
|
function ($match) use ($body, $no_link_desc) {
|
||||||
|
$attach_data = self::getAttachmentData($match[0]);
|
||||||
|
if (empty($attach_data['url'])) {
|
||||||
|
return $match[0];
|
||||||
|
} elseif (strpos(str_replace($match[0], '', $body), $attach_data['url']) !== false) {
|
||||||
|
return '';
|
||||||
|
} elseif (empty($attach_data['title']) || $no_link_desc) {
|
||||||
|
return " \n[url]" . $attach_data['url'] . "[/url]\n";
|
||||||
|
} else {
|
||||||
|
return " \n[url=" . $attach_data['url'] . ']' . $attach_data['title'] . "[/url]\n";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
$body
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public static function getAttachedData(string $body, array $item = []): array
|
public static function getAttachedData(string $body, array $item = []): array
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -305,7 +261,7 @@ class BBCode
|
||||||
// if nothing is found, it maybe having an image.
|
// if nothing is found, it maybe having an image.
|
||||||
if (!isset($post['type'])) {
|
if (!isset($post['type'])) {
|
||||||
if (preg_match_all("#\[url=([^\]]+?)\]\s*\[img\]([^\[]+?)\[/img\]\s*\[/url\]#ism", $post['text'], $pictures, PREG_SET_ORDER)) {
|
if (preg_match_all("#\[url=([^\]]+?)\]\s*\[img\]([^\[]+?)\[/img\]\s*\[/url\]#ism", $post['text'], $pictures, PREG_SET_ORDER)) {
|
||||||
if ((count($pictures) == 1) && !$has_title && !Photo::isLocal($pictures[0][2])) {
|
if ((count($pictures) == 1) && !$has_title) {
|
||||||
if (!empty($item['object-type']) && ($item['object-type'] == Activity\ObjectType::IMAGE)) {
|
if (!empty($item['object-type']) && ($item['object-type'] == Activity\ObjectType::IMAGE)) {
|
||||||
// Replace the preview picture with the real picture
|
// Replace the preview picture with the real picture
|
||||||
$url = str_replace('-1.', '-0.', $pictures[0][2]);
|
$url = str_replace('-1.', '-0.', $pictures[0][2]);
|
||||||
|
@ -430,30 +386,6 @@ class BBCode
|
||||||
return $post;
|
return $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove [attachment] BBCode and replaces it with a regular [url]
|
|
||||||
*
|
|
||||||
* @param string $body
|
|
||||||
* @param boolean $no_link_desc No link description
|
|
||||||
* @return string with replaced body
|
|
||||||
*/
|
|
||||||
public static function replaceAttachment(string $body, bool $no_link_desc = false): string
|
|
||||||
{
|
|
||||||
return preg_replace_callback("/\s*\[attachment (.*?)\](.*?)\[\/attachment\]\s*/ism",
|
|
||||||
function ($match) use ($body, $no_link_desc) {
|
|
||||||
$attach_data = self::getAttachmentData($match[0]);
|
|
||||||
if (empty($attach_data['url'])) {
|
|
||||||
return $match[0];
|
|
||||||
} elseif (strpos(str_replace($match[0], '', $body), $attach_data['url']) !== false) {
|
|
||||||
return '';
|
|
||||||
} elseif (empty($attach_data['title']) || $no_link_desc) {
|
|
||||||
return " \n[url]" . $attach_data['url'] . "[/url]\n";
|
|
||||||
} else {
|
|
||||||
return " \n[url=" . $attach_data['url'] . ']' . $attach_data['title'] . "[/url]\n";
|
|
||||||
}
|
|
||||||
}, $body);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove [attachment] BBCode
|
* Remove [attachment] BBCode
|
||||||
*
|
*
|
||||||
|
@ -956,8 +888,11 @@ class BBCode
|
||||||
// We're depending on the property of 'foreach' (specified on the PHP website) that
|
// We're depending on the property of 'foreach' (specified on the PHP website) that
|
||||||
// it loops over the array starting from the first element and going sequentially
|
// it loops over the array starting from the first element and going sequentially
|
||||||
// to the last element
|
// to the last element
|
||||||
$newbody = str_replace('[$#saved_image' . $cnt . '#$]',
|
$newbody = str_replace(
|
||||||
'<img src="' . self::proxyUrl($image, self::INTERNAL, $uriid) . '" alt="' . DI::l10n()->t('Image/photo') . '" />', $newbody);
|
'[$#saved_image' . $cnt . '#$]',
|
||||||
|
'<img src="' . self::proxyUrl($image, self::INTERNAL, $uriid) . '" alt="' . DI::l10n()->t('Image/photo') . '" />',
|
||||||
|
$newbody
|
||||||
|
);
|
||||||
$cnt++;
|
$cnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1112,8 +1047,7 @@ class BBCode
|
||||||
$attributes[$field] = html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8');
|
$attributes[$field] = html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
$img_str = '<img src="' .
|
$img_str = '<img src="' . self::proxyUrl($match[2], $simplehtml, $uriid) . '"';
|
||||||
self::proxyUrl($match[2], $simplehtml, $uriid) . '"';
|
|
||||||
foreach ($attributes as $key => $value) {
|
foreach ($attributes as $key => $value) {
|
||||||
if (!empty($value)) {
|
if (!empty($value)) {
|
||||||
$img_str .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT) . '"';
|
$img_str .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT) . '"';
|
||||||
|
@ -1150,13 +1084,13 @@ class BBCode
|
||||||
switch ($simplehtml) {
|
switch ($simplehtml) {
|
||||||
case self::MASTODON_API:
|
case self::MASTODON_API:
|
||||||
case self::TWITTER_API:
|
case self::TWITTER_API:
|
||||||
$text = ($is_quote_share? '<br>' : '') .
|
$text = ($is_quote_share ? '<br>' : '') .
|
||||||
'<b><a href="' . $attributes['link'] . '">' . html_entity_decode('♲', ENT_QUOTES, 'UTF-8') . ' ' . $author_contact['addr'] . "</a>:</b><br>\n" .
|
'<b><a href="' . $attributes['link'] . '">' . html_entity_decode('♲', ENT_QUOTES, 'UTF-8') . ' ' . $author_contact['addr'] . "</a>:</b><br>\n" .
|
||||||
'<blockquote class="shared_content" dir="auto">' . $content . '</blockquote>';
|
'<blockquote class="shared_content" dir="auto">' . $content . '</blockquote>';
|
||||||
break;
|
break;
|
||||||
case self::DIASPORA:
|
case self::DIASPORA:
|
||||||
if (stripos(Strings::normaliseLink($attributes['link']), 'http://twitter.com/') === 0) {
|
if (stripos(Strings::normaliseLink($attributes['link']), 'http://twitter.com/') === 0) {
|
||||||
$text = ($is_quote_share? '<hr />' : '') . '<p><a href="' . $attributes['link'] . '">' . $attributes['link'] . '</a></p>' . "\n";
|
$text = ($is_quote_share ? '<hr />' : '') . '<p><a href="' . $attributes['link'] . '">' . $attributes['link'] . '</a></p>' . "\n";
|
||||||
} else {
|
} else {
|
||||||
$headline = '<p><b>♲ <a href="' . $attributes['profile'] . '">' . $attributes['author'] . '</a>:</b></p>' . "\n";
|
$headline = '<p><b>♲ <a href="' . $attributes['profile'] . '">' . $attributes['author'] . '</a>:</b></p>' . "\n";
|
||||||
|
|
||||||
|
@ -1164,7 +1098,7 @@ class BBCode
|
||||||
$headline = '<p><b>♲ <a href="' . $attributes['profile'] . '">' . $attributes['author'] . '</a></b> - <a href="' . $attributes['link'] . '">' . $attributes['posted'] . ' GMT</a></p>' . "\n";
|
$headline = '<p><b>♲ <a href="' . $attributes['profile'] . '">' . $attributes['author'] . '</a></b> - <a href="' . $attributes['link'] . '">' . $attributes['posted'] . ' GMT</a></p>' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$text = ($is_quote_share? '<hr />' : '') . $headline . '<blockquote>' . trim($content) . '</blockquote>' . "\n";
|
$text = ($is_quote_share ? '<hr />' : '') . $headline . '<blockquote>' . trim($content) . '</blockquote>' . "\n";
|
||||||
|
|
||||||
if (empty($attributes['posted']) && !empty($attributes['link'])) {
|
if (empty($attributes['posted']) && !empty($attributes['link'])) {
|
||||||
$text .= '<p><a href="' . $attributes['link'] . '">[Source]</a></p>' . "\n";
|
$text .= '<p><a href="' . $attributes['link'] . '">[Source]</a></p>' . "\n";
|
||||||
|
@ -1177,18 +1111,18 @@ class BBCode
|
||||||
$headline .= DI::l10n()->t('<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a> %3$s', $attributes['link'], $mention, $attributes['posted']);
|
$headline .= DI::l10n()->t('<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a> %3$s', $attributes['link'], $mention, $attributes['posted']);
|
||||||
$headline .= ':</b></p>' . "\n";
|
$headline .= ':</b></p>' . "\n";
|
||||||
|
|
||||||
$text = ($is_quote_share? '<hr />' : '') . $headline . '<blockquote class="shared_content" dir="auto">' . trim($content) . '</blockquote>' . "\n";
|
$text = ($is_quote_share ? '<hr />' : '') . $headline . '<blockquote class="shared_content" dir="auto">' . trim($content) . '</blockquote>' . "\n";
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case self::OSTATUS:
|
case self::OSTATUS:
|
||||||
$text = ($is_quote_share? '<br>' : '') . '<p>' . html_entity_decode('♲ ', ENT_QUOTES, 'UTF-8') . ' @' . $author_contact['addr'] . ': ' . $content . '</p>' . "\n";
|
$text = ($is_quote_share ? '<br>' : '') . '<p>' . html_entity_decode('♲ ', ENT_QUOTES, 'UTF-8') . ' @' . $author_contact['addr'] . ': ' . $content . '</p>' . "\n";
|
||||||
break;
|
break;
|
||||||
case self::ACTIVITYPUB:
|
case self::ACTIVITYPUB:
|
||||||
$author = '@<span class="vcard"><a href="' . $author_contact['url'] . '" class="url u-url mention" title="' . $author_contact['addr'] . '"><span class="fn nickname mention">' . $author_contact['addr'] . '</span></a>:</span>';
|
$author = '@<span class="vcard"><a href="' . $author_contact['url'] . '" class="url u-url mention" title="' . $author_contact['addr'] . '"><span class="fn nickname mention">' . $author_contact['addr'] . '</span></a>:</span>';
|
||||||
$text = '<div><a href="' . $attributes['link'] . '">' . html_entity_decode('♲', ENT_QUOTES, 'UTF-8') . '</a> ' . $author . '<blockquote>' . $content . '</blockquote></div>' . "\n";
|
$text = '<div><a href="' . $attributes['link'] . '">' . html_entity_decode('♲', ENT_QUOTES, 'UTF-8') . '</a> ' . $author . '<blockquote>' . $content . '</blockquote></div>' . "\n";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$text = ($is_quote_share? "\n" : '');
|
$text = ($is_quote_share ? "\n" : '');
|
||||||
|
|
||||||
$contact = Contact::getByURL($attributes['profile'], false, ['network']);
|
$contact = Contact::getByURL($attributes['profile'], false, ['network']);
|
||||||
$network = $contact['network'] ?? Protocol::PHANTOM;
|
$network = $contact['network'] ?? Protocol::PHANTOM;
|
||||||
|
@ -1500,8 +1434,7 @@ class BBCode
|
||||||
* $match[1] = $url
|
* $match[1] = $url
|
||||||
* $match[2] = $title or absent
|
* $match[2] = $title or absent
|
||||||
*/
|
*/
|
||||||
$try_oembed_callback = function (array $match)
|
$try_oembed_callback = function (array $match) {
|
||||||
{
|
|
||||||
$url = $match[1];
|
$url = $match[1];
|
||||||
$title = $match[2] ?? '';
|
$title = $match[2] ?? '';
|
||||||
|
|
||||||
|
@ -1554,18 +1487,22 @@ class BBCode
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove linefeeds inside of the table elements. See issue #6799
|
// Remove linefeeds inside of the table elements. See issue #6799
|
||||||
$search = ["\n[th]", "[th]\n", " [th]", "\n[/th]", "[/th]\n", "[/th] ",
|
$search = [
|
||||||
|
"\n[th]", "[th]\n", " [th]", "\n[/th]", "[/th]\n", "[/th] ",
|
||||||
"\n[td]", "[td]\n", " [td]", "\n[/td]", "[/td]\n", "[/td] ",
|
"\n[td]", "[td]\n", " [td]", "\n[/td]", "[/td]\n", "[/td] ",
|
||||||
"\n[tr]", "[tr]\n", " [tr]", "[tr] ", "\n[/tr]", "[/tr]\n", " [/tr]", "[/tr] ",
|
"\n[tr]", "[tr]\n", " [tr]", "[tr] ", "\n[/tr]", "[/tr]\n", " [/tr]", "[/tr] ",
|
||||||
"\n[hr]", "[hr]\n", " [hr]", "[hr] ",
|
"\n[hr]", "[hr]\n", " [hr]", "[hr] ",
|
||||||
"\n[attachment ", " [attachment ", "\n[/attachment]", "[/attachment]\n", " [/attachment]", "[/attachment] ",
|
"\n[attachment ", " [attachment ", "\n[/attachment]", "[/attachment]\n", " [/attachment]", "[/attachment] ",
|
||||||
"[table]\n", "[table] ", " [table]", "\n[/table]", " [/table]", "[/table] "];
|
"[table]\n", "[table] ", " [table]", "\n[/table]", " [/table]", "[/table] "
|
||||||
$replace = ["[th]", "[th]", "[th]", "[/th]", "[/th]", "[/th]",
|
];
|
||||||
|
$replace = [
|
||||||
|
"[th]", "[th]", "[th]", "[/th]", "[/th]", "[/th]",
|
||||||
"[td]", "[td]", "[td]", "[/td]", "[/td]", "[/td]",
|
"[td]", "[td]", "[td]", "[/td]", "[/td]", "[/td]",
|
||||||
"[tr]", "[tr]", "[tr]", "[tr]", "[/tr]", "[/tr]", "[/tr]", "[/tr]",
|
"[tr]", "[tr]", "[tr]", "[tr]", "[/tr]", "[/tr]", "[/tr]", "[/tr]",
|
||||||
"[hr]", "[hr]", "[hr]", "[hr]",
|
"[hr]", "[hr]", "[hr]", "[hr]",
|
||||||
"[attachment ", "[attachment ", "[/attachment]", "[/attachment]", "[/attachment]", "[/attachment]",
|
"[attachment ", "[attachment ", "[/attachment]", "[/attachment]", "[/attachment]", "[/attachment]",
|
||||||
"[table]", "[table]", "[table]", "[/table]", "[/table]", "[/table]"];
|
"[table]", "[table]", "[table]", "[/table]", "[/table]", "[/table]"
|
||||||
|
];
|
||||||
do {
|
do {
|
||||||
$oldtext = $text;
|
$oldtext = $text;
|
||||||
$text = str_replace($search, $replace, $text);
|
$text = str_replace($search, $replace, $text);
|
||||||
|
@ -1581,10 +1518,14 @@ class BBCode
|
||||||
|
|
||||||
// removing multiplicated newlines
|
// removing multiplicated newlines
|
||||||
if (DI::config()->get('system', 'remove_multiplicated_lines')) {
|
if (DI::config()->get('system', 'remove_multiplicated_lines')) {
|
||||||
$search = ["\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[*]", "\n[ul]", "[/ul]\n", "\n\n[share ", "[/attachment]\n",
|
$search = [
|
||||||
"\n[h1]", "[/h1]\n", "\n[h2]", "[/h2]\n", "\n[h3]", "[/h3]\n", "\n[h4]", "[/h4]\n", "\n[h5]", "[/h5]\n", "\n[h6]", "[/h6]\n"];
|
"\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[*]", "\n[ul]", "[/ul]\n", "\n\n[share ", "[/attachment]\n",
|
||||||
$replace = ["\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[*]", "[ul]", "[/ul]", "\n[share ", "[/attachment]",
|
"\n[h1]", "[/h1]\n", "\n[h2]", "[/h2]\n", "\n[h3]", "[/h3]\n", "\n[h4]", "[/h4]\n", "\n[h5]", "[/h5]\n", "\n[h6]", "[/h6]\n"
|
||||||
"[h1]", "[/h1]", "[h2]", "[/h2]", "[h3]", "[/h3]", "[h4]", "[/h4]", "[h5]", "[/h5]", "[h6]", "[/h6]"];
|
];
|
||||||
|
$replace = [
|
||||||
|
"\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[*]", "[ul]", "[/ul]", "\n[share ", "[/attachment]",
|
||||||
|
"[h1]", "[/h1]", "[h2]", "[/h2]", "[h3]", "[/h3]", "[h4]", "[/h4]", "[h5]", "[/h5]", "[h6]", "[/h6]"
|
||||||
|
];
|
||||||
do {
|
do {
|
||||||
$oldtext = $text;
|
$oldtext = $text;
|
||||||
$text = str_replace($search, $replace, $text);
|
$text = str_replace($search, $replace, $text);
|
||||||
|
@ -1702,9 +1643,9 @@ class BBCode
|
||||||
$endlessloop = 0;
|
$endlessloop = 0;
|
||||||
|
|
||||||
while ((((strpos($text, "[/list]") !== false) && (strpos($text, "[list") !== false)) ||
|
while ((((strpos($text, "[/list]") !== false) && (strpos($text, "[list") !== false)) ||
|
||||||
((strpos($text, "[/ol]") !== false) && (strpos($text, "[ol]") !== false)) ||
|
((strpos($text, "[/ol]") !== false) && (strpos($text, "[ol]") !== false)) ||
|
||||||
((strpos($text, "[/ul]") !== false) && (strpos($text, "[ul]") !== false)) ||
|
((strpos($text, "[/ul]") !== false) && (strpos($text, "[ul]") !== false)) ||
|
||||||
((strpos($text, "[/li]") !== false) && (strpos($text, "[li]") !== false))) && (++$endlessloop < 20)) {
|
((strpos($text, "[/li]") !== false) && (strpos($text, "[li]") !== false))) && (++$endlessloop < 20)) {
|
||||||
$text = preg_replace("/\[list\](.*?)\[\/list\]/ism", '<ul class="listbullet" style="list-style-type: circle;">$1</ul>', $text);
|
$text = preg_replace("/\[list\](.*?)\[\/list\]/ism", '<ul class="listbullet" style="list-style-type: circle;">$1</ul>', $text);
|
||||||
$text = preg_replace("/\[list=\](.*?)\[\/list\]/ism", '<ul class="listnone" style="list-style-type: none;">$1</ul>', $text);
|
$text = preg_replace("/\[list=\](.*?)\[\/list\]/ism", '<ul class="listnone" style="list-style-type: none;">$1</ul>', $text);
|
||||||
$text = preg_replace("/\[list=1\](.*?)\[\/list\]/ism", '<ul class="listdecimal" style="list-style-type: decimal;">$1</ul>', $text);
|
$text = preg_replace("/\[list=1\](.*?)\[\/list\]/ism", '<ul class="listdecimal" style="list-style-type: decimal;">$1</ul>', $text);
|
||||||
|
@ -1750,10 +1691,12 @@ class BBCode
|
||||||
|
|
||||||
// handle nested quotes
|
// handle nested quotes
|
||||||
$endlessloop = 0;
|
$endlessloop = 0;
|
||||||
while ((strpos($text, "[/spoiler]")!== false) && (strpos($text, "[spoiler=") !== false) && (++$endlessloop < 20)) {
|
while ((strpos($text, "[/spoiler]") !== false) && (strpos($text, "[spoiler=") !== false) && (++$endlessloop < 20)) {
|
||||||
$text = preg_replace("/\[spoiler=[\"\']*(.*?)[\"\']*\](.*?)\[\/spoiler\]/ism",
|
$text = preg_replace(
|
||||||
|
"/\[spoiler=[\"\']*(.*?)[\"\']*\](.*?)\[\/spoiler\]/ism",
|
||||||
'<details class="spoiler"><summary>$1</summary>$2</details>',
|
'<details class="spoiler"><summary>$1</summary>$2</details>',
|
||||||
$text);
|
$text
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Declare the format for [quote] layout
|
// Declare the format for [quote] layout
|
||||||
|
@ -1772,10 +1715,12 @@ class BBCode
|
||||||
|
|
||||||
// handle nested quotes
|
// handle nested quotes
|
||||||
$endlessloop = 0;
|
$endlessloop = 0;
|
||||||
while ((strpos($text, "[/quote]")!== false) && (strpos($text, "[quote=") !== false) && (++$endlessloop < 20)) {
|
while ((strpos($text, "[/quote]") !== false) && (strpos($text, "[quote=") !== false) && (++$endlessloop < 20)) {
|
||||||
$text = preg_replace("/\[quote=[\"\']*(.*?)[\"\']*\](.*?)\[\/quote\]/ism",
|
$text = preg_replace(
|
||||||
"<p><strong class=".'"author"'.">" . $t_wrote . "</strong></p><blockquote>$2</blockquote>",
|
"/\[quote=[\"\']*(.*?)[\"\']*\](.*?)\[\/quote\]/ism",
|
||||||
$text);
|
"<p><strong class=" . '"author"' . ">" . $t_wrote . "</strong></p><blockquote>$2</blockquote>",
|
||||||
|
$text
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1796,13 +1741,15 @@ class BBCode
|
||||||
$text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="width: $1px;" >', $text);
|
$text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="width: $1px;" >', $text);
|
||||||
$text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*)\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$3" style="width: $1px;" >', $text);
|
$text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*)\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$3" style="width: $1px;" >', $text);
|
||||||
|
|
||||||
$text = preg_replace_callback("/\[img\=(.*?)\](.*?)\[\/img\]/ism",
|
$text = preg_replace_callback(
|
||||||
|
"/\[img\=(.*?)\](.*?)\[\/img\]/ism",
|
||||||
function ($matches) use ($simple_html, $uriid) {
|
function ($matches) use ($simple_html, $uriid) {
|
||||||
$matches[1] = self::proxyUrl($matches[1], $simple_html, $uriid);
|
$matches[1] = self::proxyUrl($matches[1], $simple_html, $uriid);
|
||||||
$matches[2] = htmlspecialchars($matches[2], ENT_COMPAT);
|
$matches[2] = htmlspecialchars($matches[2], ENT_COMPAT);
|
||||||
return '<img src="' . $matches[1] . '" alt="' . $matches[2] . '" title="' . $matches[2] . '">';
|
return '<img src="' . $matches[1] . '" alt="' . $matches[2] . '" title="' . $matches[2] . '">';
|
||||||
},
|
},
|
||||||
$text);
|
$text
|
||||||
|
);
|
||||||
|
|
||||||
// Images
|
// Images
|
||||||
// [img]pathtoimage[/img]
|
// [img]pathtoimage[/img]
|
||||||
|
@ -1824,8 +1771,8 @@ class BBCode
|
||||||
|
|
||||||
$text = self::convertImages($text, $simple_html, $uriid);
|
$text = self::convertImages($text, $simple_html, $uriid);
|
||||||
|
|
||||||
$text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism", '<br><img src="' .DI::baseUrl() . '/images/lock_icon.gif" alt="' . DI::l10n()->t('Encrypted content') . '" title="' . DI::l10n()->t('Encrypted content') . '" /><br>', $text);
|
$text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism", '<br><img src="' . DI::baseUrl() . '/images/lock_icon.gif" alt="' . DI::l10n()->t('Encrypted content') . '" title="' . DI::l10n()->t('Encrypted content') . '" /><br>', $text);
|
||||||
$text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism", '<br><img src="' .DI::baseUrl() . '/images/lock_icon.gif" alt="' . DI::l10n()->t('Encrypted content') . '" title="' . '$1' . ' ' . DI::l10n()->t('Encrypted content') . '" /><br>', $text);
|
$text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism", '<br><img src="' . DI::baseUrl() . '/images/lock_icon.gif" alt="' . DI::l10n()->t('Encrypted content') . '" title="' . '$1' . ' ' . DI::l10n()->t('Encrypted content') . '" /><br>', $text);
|
||||||
//$text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism", '<br><img src="' .DI::baseUrl() . '/images/lock_icon.gif" alt="' . DI::l10n()->t('Encrypted content') . '" title="' . '$1' . ' ' . DI::l10n()->t('Encrypted content') . '" /><br>', $text);
|
//$text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism", '<br><img src="' .DI::baseUrl() . '/images/lock_icon.gif" alt="' . DI::l10n()->t('Encrypted content') . '" title="' . '$1' . ' ' . DI::l10n()->t('Encrypted content') . '" /><br>', $text);
|
||||||
|
|
||||||
// Simplify "video" element
|
// Simplify "video" element
|
||||||
|
@ -1833,20 +1780,32 @@ class BBCode
|
||||||
|
|
||||||
if ($try_oembed) {
|
if ($try_oembed) {
|
||||||
// html5 video and audio
|
// html5 video and audio
|
||||||
$text = preg_replace("/\[video\](.*?\.(ogg|ogv|oga|ogm|webm|mp4).*?)\[\/video\]/ism",
|
$text = preg_replace(
|
||||||
'<video src="$1" controls width="100%" height="auto"><a href="$1">$1</a></video>', $text);
|
"/\[video\](.*?\.(ogg|ogv|oga|ogm|webm|mp4).*?)\[\/video\]/ism",
|
||||||
|
'<video src="$1" controls width="100%" height="auto"><a href="$1">$1</a></video>',
|
||||||
|
$text
|
||||||
|
);
|
||||||
|
|
||||||
$text = preg_replace_callback("/\[video\](.*?)\[\/video\]/ism", $try_oembed_callback, $text);
|
$text = preg_replace_callback("/\[video\](.*?)\[\/video\]/ism", $try_oembed_callback, $text);
|
||||||
$text = preg_replace_callback("/\[audio\](.*?)\[\/audio\]/ism", $try_oembed_callback, $text);
|
$text = preg_replace_callback("/\[audio\](.*?)\[\/audio\]/ism", $try_oembed_callback, $text);
|
||||||
|
|
||||||
$text = preg_replace("/\[video\](.*?)\[\/video\]/ism",
|
$text = preg_replace(
|
||||||
'<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>', $text);
|
"/\[video\](.*?)\[\/video\]/ism",
|
||||||
|
'<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>',
|
||||||
|
$text
|
||||||
|
);
|
||||||
$text = preg_replace("/\[audio\](.*?)\[\/audio\]/ism", '<audio src="$1" controls><a href="$1">$1</a></audio>', $text);
|
$text = preg_replace("/\[audio\](.*?)\[\/audio\]/ism", '<audio src="$1" controls><a href="$1">$1</a></audio>', $text);
|
||||||
} else {
|
} else {
|
||||||
$text = preg_replace("/\[video\](.*?)\[\/video\]/ism",
|
$text = preg_replace(
|
||||||
'<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>', $text);
|
"/\[video\](.*?)\[\/video\]/ism",
|
||||||
$text = preg_replace("/\[audio\](.*?)\[\/audio\]/ism",
|
'<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>',
|
||||||
'<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>', $text);
|
$text
|
||||||
|
);
|
||||||
|
$text = preg_replace(
|
||||||
|
"/\[audio\](.*?)\[\/audio\]/ism",
|
||||||
|
'<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>',
|
||||||
|
$text
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backward compatibility, [iframe] support has been removed in version 2020.12
|
// Backward compatibility, [iframe] support has been removed in version 2020.12
|
||||||
|
@ -1868,8 +1827,11 @@ class BBCode
|
||||||
if ($try_oembed) {
|
if ($try_oembed) {
|
||||||
$text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="' . $a->getThemeInfoValue('videowidth') . '" height="' . $a->getThemeInfoValue('videoheight') . '" src="https://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $text);
|
$text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="' . $a->getThemeInfoValue('videowidth') . '" height="' . $a->getThemeInfoValue('videoheight') . '" src="https://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $text);
|
||||||
} else {
|
} else {
|
||||||
$text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism",
|
$text = preg_replace(
|
||||||
'<a href="https://www.youtube.com/watch?v=$1" target="_blank" rel="noopener noreferrer">https://www.youtube.com/watch?v=$1</a>', $text);
|
"/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism",
|
||||||
|
'<a href="https://www.youtube.com/watch?v=$1" target="_blank" rel="noopener noreferrer">https://www.youtube.com/watch?v=$1</a>',
|
||||||
|
$text
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($try_oembed) {
|
if ($try_oembed) {
|
||||||
|
@ -1883,8 +1845,11 @@ class BBCode
|
||||||
if ($try_oembed) {
|
if ($try_oembed) {
|
||||||
$text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '<iframe width="' . $a->getThemeInfoValue('videowidth') . '" height="' . $a->getThemeInfoValue('videoheight') . '" src="https://player.vimeo.com/video/$1" frameborder="0" ></iframe>', $text);
|
$text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '<iframe width="' . $a->getThemeInfoValue('videowidth') . '" height="' . $a->getThemeInfoValue('videoheight') . '" src="https://player.vimeo.com/video/$1" frameborder="0" ></iframe>', $text);
|
||||||
} else {
|
} else {
|
||||||
$text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism",
|
$text = preg_replace(
|
||||||
'<a href="https://vimeo.com/$1" target="_blank" rel="noopener noreferrer">https://vimeo.com/$1</a>', $text);
|
"/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism",
|
||||||
|
'<a href="https://vimeo.com/$1" target="_blank" rel="noopener noreferrer">https://vimeo.com/$1</a>',
|
||||||
|
$text
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// oembed tag
|
// oembed tag
|
||||||
|
@ -1920,27 +1885,39 @@ class BBCode
|
||||||
// Handle mentions and hashtag links
|
// Handle mentions and hashtag links
|
||||||
if ($simple_html == self::DIASPORA) {
|
if ($simple_html == self::DIASPORA) {
|
||||||
// The ! is converted to @ since Diaspora only understands the @
|
// The ! is converted to @ since Diaspora only understands the @
|
||||||
$text = preg_replace("/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
$text = preg_replace(
|
||||||
|
"/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
||||||
'@<a href="$2">$3</a>',
|
'@<a href="$2">$3</a>',
|
||||||
$text);
|
$text
|
||||||
|
);
|
||||||
} elseif (in_array($simple_html, [self::OSTATUS, self::ACTIVITYPUB])) {
|
} elseif (in_array($simple_html, [self::OSTATUS, self::ACTIVITYPUB])) {
|
||||||
$text = preg_replace("/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
$text = preg_replace(
|
||||||
|
"/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
||||||
'<span class="h-card"><a href="$2" class="u-url mention">$1<span>$3</span></a></span>',
|
'<span class="h-card"><a href="$2" class="u-url mention">$1<span>$3</span></a></span>',
|
||||||
$text);
|
$text
|
||||||
$text = preg_replace("/([#])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
);
|
||||||
|
$text = preg_replace(
|
||||||
|
"/([#])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
||||||
'<a href="$2" class="mention hashtag" rel="tag">$1<span>$3</span></a>',
|
'<a href="$2" class="mention hashtag" rel="tag">$1<span>$3</span></a>',
|
||||||
$text);
|
$text
|
||||||
|
);
|
||||||
} elseif (in_array($simple_html, [self::INTERNAL, self::EXTERNAL, self::TWITTER_API])) {
|
} elseif (in_array($simple_html, [self::INTERNAL, self::EXTERNAL, self::TWITTER_API])) {
|
||||||
$text = preg_replace("/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
$text = preg_replace(
|
||||||
|
"/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
||||||
'<bdi>$1<a href="$2" class="userinfo mention" title="$3">$3</a></bdi>',
|
'<bdi>$1<a href="$2" class="userinfo mention" title="$3">$3</a></bdi>',
|
||||||
$text);
|
$text
|
||||||
|
);
|
||||||
} elseif ($simple_html == self::MASTODON_API) {
|
} elseif ($simple_html == self::MASTODON_API) {
|
||||||
$text = preg_replace("/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
$text = preg_replace(
|
||||||
|
"/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
||||||
'<a class="u-url mention status-link" href="$2" rel="nofollow noopener noreferrer" target="_blank" title="$3">$1<span>$3</span></a>',
|
'<a class="u-url mention status-link" href="$2" rel="nofollow noopener noreferrer" target="_blank" title="$3">$1<span>$3</span></a>',
|
||||||
$text);
|
$text
|
||||||
$text = preg_replace("/([#])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
);
|
||||||
|
$text = preg_replace(
|
||||||
|
"/([#])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
||||||
'<a class="mention hashtag status-link" href="$2" rel="tag">$1<span>$3</span></a>',
|
'<a class="mention hashtag status-link" href="$2" rel="tag">$1<span>$3</span></a>',
|
||||||
$text);
|
$text
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$text = preg_replace("/([#@!])\[url\=(.*?)\](.*?)\[\/url\]/ism", '$1$3', $text);
|
$text = preg_replace("/([#@!])\[url\=(.*?)\](.*?)\[\/url\]/ism", '$1$3', $text);
|
||||||
}
|
}
|
||||||
|
@ -1958,8 +1935,11 @@ class BBCode
|
||||||
// Bookmarks in red - will be converted to bookmarks in friendica
|
// Bookmarks in red - will be converted to bookmarks in friendica
|
||||||
$text = preg_replace("/#\^\[url\](.*?)\[\/url\]/ism", '[bookmark=$1]$1[/bookmark]', $text);
|
$text = preg_replace("/#\^\[url\](.*?)\[\/url\]/ism", '[bookmark=$1]$1[/bookmark]', $text);
|
||||||
$text = preg_replace("/#\^\[url\=(.*?)\](.*?)\[\/url\]/ism", '[bookmark=$1]$2[/bookmark]', $text);
|
$text = preg_replace("/#\^\[url\=(.*?)\](.*?)\[\/url\]/ism", '[bookmark=$1]$2[/bookmark]', $text);
|
||||||
$text = preg_replace("/#\[url\=.*?\]\^\[\/url\]\[url\=(.*?)\](.*?)\[\/url\]/i",
|
$text = preg_replace(
|
||||||
"[bookmark=$1]$2[/bookmark]", $text);
|
"/#\[url\=.*?\]\^\[\/url\]\[url\=(.*?)\](.*?)\[\/url\]/i",
|
||||||
|
"[bookmark=$1]$2[/bookmark]",
|
||||||
|
$text
|
||||||
|
);
|
||||||
|
|
||||||
if (in_array($simple_html, [self::OSTATUS, self::TWITTER])) {
|
if (in_array($simple_html, [self::OSTATUS, self::TWITTER])) {
|
||||||
$text = preg_replace_callback("/([^#@!])\[url\=([^\]]*)\](.*?)\[\/url\]/ism", [self::class, 'expandLinksCallback'], $text);
|
$text = preg_replace_callback("/([^#@!])\[url\=([^\]]*)\](.*?)\[\/url\]/ism", [self::class, 'expandLinksCallback'], $text);
|
||||||
|
@ -1979,20 +1959,22 @@ class BBCode
|
||||||
"&\[url=/?posts/([^\[\]]*)\](.*)\[\/url\]&Usi",
|
"&\[url=/?posts/([^\[\]]*)\](.*)\[\/url\]&Usi",
|
||||||
function ($match) {
|
function ($match) {
|
||||||
return "[url=" . DI::baseUrl() . "/display/" . $match[1] . "]" . $match[2] . "[/url]";
|
return "[url=" . DI::baseUrl() . "/display/" . $match[1] . "]" . $match[2] . "[/url]";
|
||||||
}, $text
|
},
|
||||||
|
$text
|
||||||
);
|
);
|
||||||
|
|
||||||
$text = preg_replace_callback(
|
$text = preg_replace_callback(
|
||||||
"&\[url=/people\?q\=(.*)\](.*)\[\/url\]&Usi",
|
"&\[url=/people\?q\=(.*)\](.*)\[\/url\]&Usi",
|
||||||
function ($match) {
|
function ($match) {
|
||||||
return "[url=" . DI::baseUrl() . "/search?search=%40" . $match[1] . "]" . $match[2] . "[/url]";
|
return "[url=" . DI::baseUrl() . "/search?search=%40" . $match[1] . "]" . $match[2] . "[/url]";
|
||||||
}, $text
|
},
|
||||||
|
$text
|
||||||
);
|
);
|
||||||
|
|
||||||
// Server independent link to posts and comments
|
// Server independent link to posts and comments
|
||||||
// See issue: https://github.com/diaspora/diaspora_federation/issues/75
|
// See issue: https://github.com/diaspora/diaspora_federation/issues/75
|
||||||
$expression = "=diaspora://.*?/post/([0-9A-Za-z\-_@.:]{15,254}[0-9A-Za-z])=ism";
|
$expression = "=diaspora://.*?/post/([0-9A-Za-z\-_@.:]{15,254}[0-9A-Za-z])=ism";
|
||||||
$text = preg_replace($expression, DI::baseUrl()."/display/$1", $text);
|
$text = preg_replace($expression, DI::baseUrl() . "/display/$1", $text);
|
||||||
|
|
||||||
/* Tag conversion
|
/* Tag conversion
|
||||||
* Supports:
|
* Supports:
|
||||||
|
@ -2000,7 +1982,7 @@ class BBCode
|
||||||
* - [url=<anything>]#<term>[/url]
|
* - [url=<anything>]#<term>[/url]
|
||||||
*/
|
*/
|
||||||
self::performWithEscapedTags($text, ['url', 'share'], function ($text) use ($simple_html) {
|
self::performWithEscapedTags($text, ['url', 'share'], function ($text) use ($simple_html) {
|
||||||
$text = preg_replace_callback("/(?:#\[url\=[^\[\]]*\]|\[url\=[^\[\]]*\]#)(.*?)\[\/url\]/ism", function($matches) use ($simple_html) {
|
$text = preg_replace_callback("/(?:#\[url\=[^\[\]]*\]|\[url\=[^\[\]]*\]#)(.*?)\[\/url\]/ism", function ($matches) use ($simple_html) {
|
||||||
if ($simple_html == self::ACTIVITYPUB) {
|
if ($simple_html == self::ACTIVITYPUB) {
|
||||||
return '<a href="' . DI::baseUrl() . '/search?tag=' . rawurlencode($matches[1])
|
return '<a href="' . DI::baseUrl() . '/search?tag=' . rawurlencode($matches[1])
|
||||||
. '" data-tag="' . XML::escape($matches[1]) . '" rel="tag ugc">#'
|
. '" data-tag="' . XML::escape($matches[1]) . '" rel="tag ugc">#'
|
||||||
|
@ -2017,8 +1999,8 @@ class BBCode
|
||||||
// We need no target="_blank" rel="noopener noreferrer" for local links
|
// We need no target="_blank" rel="noopener noreferrer" for local links
|
||||||
// convert links start with DI::baseUrl() as local link without the target="_blank" rel="noopener noreferrer" attribute
|
// convert links start with DI::baseUrl() as local link without the target="_blank" rel="noopener noreferrer" attribute
|
||||||
$escapedBaseUrl = preg_quote(DI::baseUrl(), '/');
|
$escapedBaseUrl = preg_quote(DI::baseUrl(), '/');
|
||||||
$text = preg_replace("/\[url\](".$escapedBaseUrl.".*?)\[\/url\]/ism", '<a href="$1">$1</a>', $text);
|
$text = preg_replace("/\[url\](" . $escapedBaseUrl . ".*?)\[\/url\]/ism", '<a href="$1">$1</a>', $text);
|
||||||
$text = preg_replace("/\[url\=(".$escapedBaseUrl.".*?)\](.*?)\[\/url\]/ism", '<a href="$1">$2</a>', $text);
|
$text = preg_replace("/\[url\=(" . $escapedBaseUrl . ".*?)\](.*?)\[\/url\]/ism", '<a href="$1">$2</a>', $text);
|
||||||
|
|
||||||
$text = preg_replace("/\[url\](.*?)\[\/url\]/ism", '<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>', $text);
|
$text = preg_replace("/\[url\](.*?)\[\/url\]/ism", '<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>', $text);
|
||||||
$text = preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/ism", '<a href="$1" target="_blank" rel="noopener noreferrer">$2</a>', $text);
|
$text = preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/ism", '<a href="$1" target="_blank" rel="noopener noreferrer">$2</a>', $text);
|
||||||
|
@ -2049,10 +2031,15 @@ class BBCode
|
||||||
// sanitizes src attributes (http and redir URLs for displaying in a web page, cid used for inline images in emails)
|
// sanitizes src attributes (http and redir URLs for displaying in a web page, cid used for inline images in emails)
|
||||||
$allowed_src_protocols = ['//', 'http://', 'https://', 'contact/redir/', 'cid:'];
|
$allowed_src_protocols = ['//', 'http://', 'https://', 'contact/redir/', 'cid:'];
|
||||||
|
|
||||||
array_walk($allowed_src_protocols, function(&$value) { $value = preg_quote($value, '#');});
|
array_walk($allowed_src_protocols, function (&$value) {
|
||||||
|
$value = preg_quote($value, '#');
|
||||||
|
});
|
||||||
|
|
||||||
$text = preg_replace('#<([^>]*?)(src)="(?!' . implode('|', $allowed_src_protocols) . ')(.*?)"(.*?)>#ism',
|
$text = preg_replace(
|
||||||
'<$1$2=""$4 data-original-src="$3" class="invalid-src" title="' . DI::l10n()->t('Invalid source protocol') . '">', $text);
|
'#<([^>]*?)(src)="(?!' . implode('|', $allowed_src_protocols) . ')(.*?)"(.*?)>#ism',
|
||||||
|
'<$1$2=""$4 data-original-src="$3" class="invalid-src" title="' . DI::l10n()->t('Invalid source protocol') . '">',
|
||||||
|
$text
|
||||||
|
);
|
||||||
|
|
||||||
// sanitize href attributes (only allowlisted protocols URLs)
|
// sanitize href attributes (only allowlisted protocols URLs)
|
||||||
// default value for backward compatibility
|
// default value for backward compatibility
|
||||||
|
@ -2064,7 +2051,9 @@ class BBCode
|
||||||
$allowed_link_protocols[] = 'https://';
|
$allowed_link_protocols[] = 'https://';
|
||||||
$allowed_link_protocols[] = 'contact/redir/';
|
$allowed_link_protocols[] = 'contact/redir/';
|
||||||
|
|
||||||
array_walk($allowed_link_protocols, function(&$value) { $value = preg_quote($value, '#');});
|
array_walk($allowed_link_protocols, function (&$value) {
|
||||||
|
$value = preg_quote($value, '#');
|
||||||
|
});
|
||||||
|
|
||||||
$regex = '#<([^>]*?)(href)="(?!' . implode('|', $allowed_link_protocols) . ')(.*?)"(.*?)>#ism';
|
$regex = '#<([^>]*?)(href)="(?!' . implode('|', $allowed_link_protocols) . ')(.*?)"(.*?)>#ism';
|
||||||
$text = preg_replace($regex, '<$1$2="javascript:void(0)"$4 data-original-href="$3" class="invalid-href" title="' . DI::l10n()->t('Invalid link protocol') . '">', $text);
|
$text = preg_replace($regex, '<$1$2="javascript:void(0)"$4 data-original-href="$3" class="invalid-href" title="' . DI::l10n()->t('Invalid link protocol') . '">', $text);
|
||||||
|
@ -2074,7 +2063,8 @@ class BBCode
|
||||||
$text,
|
$text,
|
||||||
function (array $attributes, array $author_contact, $content, $is_quote_share) use ($simple_html) {
|
function (array $attributes, array $author_contact, $content, $is_quote_share) use ($simple_html) {
|
||||||
return self::convertShareCallback($attributes, $author_contact, $content, $is_quote_share, $simple_html);
|
return self::convertShareCallback($attributes, $author_contact, $content, $is_quote_share, $simple_html);
|
||||||
}, $uriid
|
},
|
||||||
|
$uriid
|
||||||
);
|
);
|
||||||
|
|
||||||
$text = self::interpolateSavedImagesIntoItemBody($uriid, $text, $saved_image);
|
$text = self::interpolateSavedImagesIntoItemBody($uriid, $text, $saved_image);
|
||||||
|
@ -2089,13 +2079,14 @@ class BBCode
|
||||||
|
|
||||||
// Additionally, [pre] tags preserve spaces
|
// Additionally, [pre] tags preserve spaces
|
||||||
$text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", function ($match) {
|
$text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", function ($match) {
|
||||||
return str_replace([' ', "\n"], [' ', "<br>"], htmlentities($match[1], ENT_NOQUOTES,'UTF-8'));
|
return str_replace([' ', "\n"], [' ', "<br>"], htmlentities($match[1], ENT_NOQUOTES, 'UTF-8'));
|
||||||
}, $text);
|
}, $text);
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}); // Escaped code
|
}); // Escaped code
|
||||||
|
|
||||||
$text = preg_replace_callback("#\[code(?:=([^\]]*))?\](.*?)\[\/code\]#ism",
|
$text = preg_replace_callback(
|
||||||
|
"#\[code(?:=([^\]]*))?\](.*?)\[\/code\]#ism",
|
||||||
function ($matches) {
|
function ($matches) {
|
||||||
if (strpos($matches[2], "\n") !== false) {
|
if (strpos($matches[2], "\n") !== false) {
|
||||||
$return = '<pre><code class="language-' . trim($matches[1]) . '">' . htmlentities(trim($matches[2], "\n\r"), ENT_NOQUOTES, 'UTF-8') . '</code></pre>';
|
$return = '<pre><code class="language-' . trim($matches[1]) . '">' . htmlentities(trim($matches[2], "\n\r"), ENT_NOQUOTES, 'UTF-8') . '</code></pre>';
|
||||||
|
@ -2111,8 +2102,8 @@ class BBCode
|
||||||
// Default iframe allowed domains/path
|
// Default iframe allowed domains/path
|
||||||
$allowedIframeDomains = [
|
$allowedIframeDomains = [
|
||||||
DI::baseUrl()->getHost()
|
DI::baseUrl()->getHost()
|
||||||
. (DI::baseUrl()->getPath() ? '/' . DI::baseUrl()->getPath() : '')
|
. (DI::baseUrl()->getPath() ? '/' . DI::baseUrl()->getPath() : '')
|
||||||
. '/oembed/', # The path part has to change with the source in Content\Oembed::iframe
|
. '/oembed/', # The path part has to change with the source in Content\Oembed::iframe
|
||||||
'www.youtube.com/embed/',
|
'www.youtube.com/embed/',
|
||||||
'player.vimeo.com/video/',
|
'player.vimeo.com/video/',
|
||||||
];
|
];
|
||||||
|
@ -2225,7 +2216,8 @@ class BBCode
|
||||||
* Transform #tags, strip off the [url] and replace spaces with underscore
|
* Transform #tags, strip off the [url] and replace spaces with underscore
|
||||||
*/
|
*/
|
||||||
$url_search_string = "^\[\]";
|
$url_search_string = "^\[\]";
|
||||||
$text = preg_replace_callback("/#\[url\=([$url_search_string]*)\](.*?)\[\/url\]/i",
|
$text = preg_replace_callback(
|
||||||
|
"/#\[url\=([$url_search_string]*)\](.*?)\[\/url\]/i",
|
||||||
function ($matches) {
|
function ($matches) {
|
||||||
return '#' . str_replace(' ', '_', $matches[2]);
|
return '#' . str_replace(' ', '_', $matches[2]);
|
||||||
},
|
},
|
||||||
|
@ -2360,7 +2352,8 @@ class BBCode
|
||||||
*/
|
*/
|
||||||
public static function expandTags(string $body): string
|
public static function expandTags(string $body): string
|
||||||
{
|
{
|
||||||
return preg_replace_callback("/(?<=\W|^)([!#@])([^\^ \x0D\x0A,;:?'\"]*[^\^ \x0D\x0A,;:?!'\".])/",
|
return preg_replace_callback(
|
||||||
|
"/(?<=\W|^)([!#@])([^\^ \x0D\x0A,;:?'\"]*[^\^ \x0D\x0A,;:?!'\".])/",
|
||||||
function (array $match) {
|
function (array $match) {
|
||||||
switch ($match[1]) {
|
switch ($match[1]) {
|
||||||
case '!':
|
case '!':
|
||||||
|
@ -2377,7 +2370,9 @@ class BBCode
|
||||||
default:
|
default:
|
||||||
return $match[1] . '[url=' . DI::baseUrl() . '/search?tag=' . $match[2] . ']' . $match[2] . '[/url]';
|
return $match[1] . '[url=' . DI::baseUrl() . '/search?tag=' . $match[2] . ']' . $match[2] . '[/url]';
|
||||||
}
|
}
|
||||||
}, $body);
|
},
|
||||||
|
$body
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -122,8 +122,11 @@ class Plaintext
|
||||||
$body = preg_replace("/([#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $item['body']);
|
$body = preg_replace("/([#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $item['body']);
|
||||||
|
|
||||||
// Add an URL element if the text contains a raw link
|
// Add an URL element if the text contains a raw link
|
||||||
$body = preg_replace('/([^\]\=\'"]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism',
|
$body = preg_replace(
|
||||||
'$1[url]$2[/url]', $body);
|
'/([^\]\=\'"]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism',
|
||||||
|
'$1[url]$2[/url]',
|
||||||
|
$body
|
||||||
|
);
|
||||||
|
|
||||||
// Remove the abstract
|
// Remove the abstract
|
||||||
$body = BBCode::stripAbstract($body);
|
$body = BBCode::stripAbstract($body);
|
||||||
|
@ -149,7 +152,7 @@ class Plaintext
|
||||||
if (($limit == 0) && ($abstract == $default_abstract)) {
|
if (($limit == 0) && ($abstract == $default_abstract)) {
|
||||||
$abstract = '';
|
$abstract = '';
|
||||||
}
|
}
|
||||||
} else {// Try to guess the correct target network
|
} else { // Try to guess the correct target network
|
||||||
switch ($htmlmode) {
|
switch ($htmlmode) {
|
||||||
case BBCode::TWITTER:
|
case BBCode::TWITTER:
|
||||||
$abstract = BBCode::getAbstract($item['body'], Protocol::TWITTER);
|
$abstract = BBCode::getAbstract($item['body'], Protocol::TWITTER);
|
||||||
|
|
|
@ -39,45 +39,40 @@ class Card extends BaseFactory
|
||||||
*/
|
*/
|
||||||
public function createFromUriId(int $uriId, array $history = []): \Friendica\Object\Api\Mastodon\Card
|
public function createFromUriId(int $uriId, array $history = []): \Friendica\Object\Api\Mastodon\Card
|
||||||
{
|
{
|
||||||
$item = Post::selectFirst(['body'], ['uri-id' => $uriId]);
|
$media = Post\Media::getByURIId($uriId, [Post\Media::HTML]);
|
||||||
if (!empty($item['body'])) {
|
if (empty($media) || (empty($media[0]['description']) && empty($media[0]['image']) && empty($media[0]['preview']))) {
|
||||||
$data = BBCode::getAttachmentData($item['body']);
|
return new \Friendica\Object\Api\Mastodon\Card([], $history);
|
||||||
} else {
|
|
||||||
$data = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Post\Media::getByURIId($uriId, [Post\Media::HTML]) as $attached) {
|
$parts = parse_url($media[0]['url']);
|
||||||
if ((empty($data['url']) || Strings::compareLink($data['url'], $attached['url'])) &&
|
if (!empty($parts['scheme']) && !empty($parts['host'])) {
|
||||||
(!empty($attached['description']) || !empty($attached['image']) || !empty($attached['preview']))) {
|
if (empty($media[0]['publisher-name'])) {
|
||||||
$parts = parse_url($attached['url']);
|
$media[0]['publisher-name'] = $parts['host'];
|
||||||
if (!empty($parts['scheme']) && !empty($parts['host'])) {
|
}
|
||||||
if (empty($attached['publisher-name'])) {
|
if (empty($media[0]['publisher-url']) || empty(parse_url($media[0]['publisher-url'], PHP_URL_SCHEME))) {
|
||||||
$attached['publisher-name'] = $parts['host'];
|
$media[0]['publisher-url'] = $parts['scheme'] . '://' . $parts['host'];
|
||||||
}
|
|
||||||
if (empty($attached['publisher-url']) || empty(parse_url($attached['publisher-url'], PHP_URL_SCHEME))) {
|
|
||||||
$attached['publisher-url'] = $parts['scheme'] . '://' . $parts['host'];
|
|
||||||
|
|
||||||
if (!empty($parts['port'])) {
|
if (!empty($parts['port'])) {
|
||||||
$attached['publisher-url'] .= ':' . $parts['port'];
|
$media[0]['publisher-url'] .= ':' . $parts['port'];
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['url'] = $attached['url'];
|
|
||||||
$data['title'] = $attached['name'];
|
|
||||||
$data['description'] = $attached['description'];
|
|
||||||
$data['type'] = 'link';
|
|
||||||
$data['author_name'] = $attached['author-name'];
|
|
||||||
$data['author_url'] = $attached['author-url'];
|
|
||||||
$data['provider_name'] = $attached['publisher-name'];
|
|
||||||
$data['provider_url'] = $attached['publisher-url'];
|
|
||||||
$data['image'] = $attached['preview'];
|
|
||||||
$data['width'] = $attached['preview-width'];
|
|
||||||
$data['height'] = $attached['preview-height'];
|
|
||||||
$data['blurhash'] = $attached['blurhash'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
$data['url'] = $media[0]['url'];
|
||||||
|
$data['title'] = $media[0]['name'];
|
||||||
|
$data['description'] = $media[0]['description'];
|
||||||
|
$data['type'] = 'link';
|
||||||
|
$data['author_name'] = $media[0]['author-name'];
|
||||||
|
$data['author_url'] = $media[0]['author-url'];
|
||||||
|
$data['provider_name'] = $media[0]['publisher-name'];
|
||||||
|
$data['provider_url'] = $media[0]['publisher-url'];
|
||||||
|
$data['image'] = $media[0]['preview'];
|
||||||
|
$data['width'] = $media[0]['preview-width'];
|
||||||
|
$data['height'] = $media[0]['preview-height'];
|
||||||
|
$data['blurhash'] = $media[0]['blurhash'];
|
||||||
|
|
||||||
return new \Friendica\Object\Api\Mastodon\Card($data, $history);
|
return new \Friendica\Object\Api\Mastodon\Card($data, $history);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,10 +259,12 @@ class Status extends BaseFactory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['body'] = $this->contentItem->addSharedPost($item);
|
|
||||||
|
|
||||||
if (!is_null($item['raw-body'])) {
|
if (!is_null($item['raw-body'])) {
|
||||||
$item['raw-body'] = $this->contentItem->addSharedPost($item, $item['raw-body']);
|
$item['raw-body'] = $this->contentItem->addSharedPost($item, $item['raw-body']);
|
||||||
|
$item['raw-body'] = Post\Media::addHTMLLinkToBody($uriId, $item['raw-body']);
|
||||||
|
} else {
|
||||||
|
$item['body'] = $this->contentItem->addSharedPost($item);
|
||||||
|
$item['body'] = Post\Media::addHTMLLinkToBody($uriId, $item['body']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +291,7 @@ class Status extends BaseFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
$delivery_data = new FriendicaDeliveryData($item['delivery_queue_count'], $item['delivery_queue_done'], $item['delivery_queue_failed']);
|
$delivery_data = new FriendicaDeliveryData($item['delivery_queue_count'], $item['delivery_queue_done'], $item['delivery_queue_failed']);
|
||||||
$friendica = new FriendicaExtension($item['title'], $item['changed'], $item['commented'], $item['edited'], $item['received'], $counts->dislikes, $delivery_data);
|
$friendica = new FriendicaExtension($item['title'], $item['changed'], $item['commented'], $item['received'], $counts->dislikes, $delivery_data);
|
||||||
|
|
||||||
return new \Friendica\Object\Api\Mastodon\Status($item, $account, $counts, $userAttributes, $sensitive, $application, $mentions, $tags, $card, $attachments, $in_reply, $reshare, $friendica, $quote, $poll);
|
return new \Friendica\Object\Api\Mastodon\Status($item, $account, $counts, $userAttributes, $sensitive, $application, $mentions, $tags, $card, $attachments, $in_reply, $reshare, $friendica, $quote, $poll);
|
||||||
}
|
}
|
||||||
|
@ -355,7 +357,7 @@ class Status extends BaseFactory
|
||||||
$attachments = [];
|
$attachments = [];
|
||||||
$in_reply = [];
|
$in_reply = [];
|
||||||
$reshare = [];
|
$reshare = [];
|
||||||
$friendica = new FriendicaExtension('', null, null, null, null, 0, new FriendicaDeliveryData(0, 0, 0));
|
$friendica = new FriendicaExtension('', null, null, null, 0, new FriendicaDeliveryData(0, 0, 0));
|
||||||
|
|
||||||
return new \Friendica\Object\Api\Mastodon\Status($item, $account, $counts, $userAttributes, $sensitive, $application, $mentions, $tags, $card, $attachments, $in_reply, $reshare, $friendica);
|
return new \Friendica\Object\Api\Mastodon\Status($item, $account, $counts, $userAttributes, $sensitive, $application, $mentions, $tags, $card, $attachments, $in_reply, $reshare, $friendica);
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,7 @@ class Status extends BaseFactory
|
||||||
*/
|
*/
|
||||||
private function createFromArray(array $item, int $uid, bool $include_entities): \Friendica\Object\Api\Twitter\Status
|
private function createFromArray(array $item, int $uid, bool $include_entities): \Friendica\Object\Api\Twitter\Status
|
||||||
{
|
{
|
||||||
|
$item = Post\Media::addHTMLAttachmentToItem($item);
|
||||||
$author = $this->twitterUser->createFromContactId($item['author-id'], $uid, true);
|
$author = $this->twitterUser->createFromContactId($item['author-id'], $uid, true);
|
||||||
|
|
||||||
if (!empty($item['causer-id']) && ($item['post-reason'] == Item::PR_ANNOUNCEMENT)) {
|
if (!empty($item['causer-id']) && ($item['post-reason'] == Item::PR_ANNOUNCEMENT)) {
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
namespace Friendica\Model\Post;
|
namespace Friendica\Model\Post;
|
||||||
|
|
||||||
|
use Friendica\Content\PageInfo;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
|
@ -161,8 +162,10 @@ class Media
|
||||||
*/
|
*/
|
||||||
public static function getAttachElement(string $href, int $length, string $type, string $title = ''): string
|
public static function getAttachElement(string $href, int $length, string $type, string $title = ''): string
|
||||||
{
|
{
|
||||||
$media = self::fetchAdditionalData(['type' => self::DOCUMENT, 'url' => $href,
|
$media = self::fetchAdditionalData([
|
||||||
'size' => $length, 'mimetype' => $type, 'description' => $title]);
|
'type' => self::DOCUMENT, 'url' => $href,
|
||||||
|
'size' => $length, 'mimetype' => $type, 'description' => $title
|
||||||
|
]);
|
||||||
|
|
||||||
return '[attach]href="' . $media['url'] . '" length="' . $media['size'] .
|
return '[attach]href="' . $media['url'] . '" length="' . $media['size'] .
|
||||||
'" type="' . $media['mimetype'] . '" title="' . $media['description'] . '"[/attach]';
|
'" type="' . $media['mimetype'] . '" title="' . $media['description'] . '"[/attach]';
|
||||||
|
@ -262,8 +265,10 @@ class Media
|
||||||
return $media;
|
return $media;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($item['plink']) && Strings::compareLink($item['plink'], $media['url']) &&
|
if (
|
||||||
parse_url($item['plink'], PHP_URL_HOST) != parse_url($item['uri'], PHP_URL_HOST)) {
|
!empty($item['plink']) && Strings::compareLink($item['plink'], $media['url']) &&
|
||||||
|
parse_url($item['plink'], PHP_URL_HOST) != parse_url($item['uri'], PHP_URL_HOST)
|
||||||
|
) {
|
||||||
Logger::debug('Not a link to an activity', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'plink' => $item['plink'], 'uri' => $item['uri']]);
|
Logger::debug('Not a link to an activity', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'plink' => $item['plink'], 'uri' => $item['uri']]);
|
||||||
return $media;
|
return $media;
|
||||||
}
|
}
|
||||||
|
@ -482,8 +487,10 @@ class Media
|
||||||
}
|
}
|
||||||
$body = str_replace($picture[0], '', $body);
|
$body = str_replace($picture[0], '', $body);
|
||||||
$image = str_replace('-1.', '-0.', $picture[2]);
|
$image = str_replace('-1.', '-0.', $picture[2]);
|
||||||
$attachments[$image] = ['uri-id' => $uriid, 'type' => self::IMAGE, 'url' => $image,
|
$attachments[$image] = [
|
||||||
'preview' => $picture[2], 'description' => $picture[3]];
|
'uri-id' => $uriid, 'type' => self::IMAGE, 'url' => $image,
|
||||||
|
'preview' => $picture[2], 'description' => $picture[3]
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,8 +508,10 @@ class Media
|
||||||
}
|
}
|
||||||
$body = str_replace($picture[0], '', $body);
|
$body = str_replace($picture[0], '', $body);
|
||||||
$image = str_replace('-1.', '-0.', $picture[2]);
|
$image = str_replace('-1.', '-0.', $picture[2]);
|
||||||
$attachments[$image] = ['uri-id' => $uriid, 'type' => self::IMAGE, 'url' => $image,
|
$attachments[$image] = [
|
||||||
'preview' => $picture[2], 'description' => null];
|
'uri-id' => $uriid, 'type' => self::IMAGE, 'url' => $image,
|
||||||
|
'preview' => $picture[2], 'description' => null
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,7 +639,7 @@ class Media
|
||||||
public static function insertFromAttachmentData(int $uriid, string $body)
|
public static function insertFromAttachmentData(int $uriid, string $body)
|
||||||
{
|
{
|
||||||
$data = BBCode::getAttachmentData($body);
|
$data = BBCode::getAttachmentData($body);
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -802,8 +811,10 @@ class Media
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($medium['type'], [self::AUDIO, self::IMAGE]) ||
|
if (
|
||||||
in_array($filetype, ['audio', 'image'])) {
|
in_array($medium['type'], [self::AUDIO, self::IMAGE]) ||
|
||||||
|
in_array($filetype, ['audio', 'image'])
|
||||||
|
) {
|
||||||
$attachments['visual'][] = $medium;
|
$attachments['visual'][] = $medium;
|
||||||
} elseif (($medium['type'] == self::VIDEO) || ($filetype == 'video')) {
|
} elseif (($medium['type'] == self::VIDEO) || ($filetype == 'video')) {
|
||||||
if (!empty($medium['height'])) {
|
if (!empty($medium['height'])) {
|
||||||
|
@ -870,15 +881,15 @@ class Media
|
||||||
if ($media['type'] == self::IMAGE) {
|
if ($media['type'] == self::IMAGE) {
|
||||||
if (!empty($media['preview'])) {
|
if (!empty($media['preview'])) {
|
||||||
if (!empty($media['description'])) {
|
if (!empty($media['description'])) {
|
||||||
$body .= "\n[url=" . $media['url'] . "][img=" . $media['preview'] . ']' . $media['description'] .'[/img][/url]';
|
$body .= "\n[url=" . $media['url'] . "][img=" . $media['preview'] . ']' . $media['description'] . '[/img][/url]';
|
||||||
} else {
|
} else {
|
||||||
$body .= "\n[url=" . $media['url'] . "][img]" . $media['preview'] .'[/img][/url]';
|
$body .= "\n[url=" . $media['url'] . "][img]" . $media['preview'] . '[/img][/url]';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!empty($media['description'])) {
|
if (!empty($media['description'])) {
|
||||||
$body .= "\n[img=" . $media['url'] . ']' . $media['description'] .'[/img]';
|
$body .= "\n[img=" . $media['url'] . ']' . $media['description'] . '[/img]';
|
||||||
} else {
|
} else {
|
||||||
$body .= "\n[img]" . $media['url'] .'[/img]';
|
$body .= "\n[img]" . $media['url'] . '[/img]';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($media['type'] == self::AUDIO) {
|
} elseif ($media['type'] == self::AUDIO) {
|
||||||
|
@ -895,6 +906,92 @@ class Media
|
||||||
return $body;
|
return $body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an [attachment] element to the body for a given uri-id with a HTML media element
|
||||||
|
*
|
||||||
|
* @param integer $uriid
|
||||||
|
* @param string $body
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function addHTMLAttachmentToBody(int $uriid, string $body): string
|
||||||
|
{
|
||||||
|
if (preg_match("/.*(\[attachment.*?\].*?\[\/attachment\]).*/ism", $body, $match)) {
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
|
||||||
|
$links = self::getByURIId($uriid, [self::HTML]);
|
||||||
|
if (empty($links)) {
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'type' => 'link',
|
||||||
|
'url' => $links[0]['url'],
|
||||||
|
'title' => $links[0]['name'],
|
||||||
|
'text' => $links[0]['description'],
|
||||||
|
'publisher_name' => $links[0]['publisher-name'],
|
||||||
|
'publisher_url' => $links[0]['publisher-url'],
|
||||||
|
'publisher_img' => $links[0]['publisher-image'],
|
||||||
|
'author_name' => $links[0]['author-name'],
|
||||||
|
'author_url' => $links[0]['author-url'],
|
||||||
|
'author_img' => $links[0]['author-image'],
|
||||||
|
'images' => [[
|
||||||
|
'src' => $links[0]['preview'],
|
||||||
|
'height' => $links[0]['preview-height'],
|
||||||
|
'width' => $links[0]['preview-width'],
|
||||||
|
]]
|
||||||
|
];
|
||||||
|
$body .= "\n" . PageInfo::getFooterFromData($data);
|
||||||
|
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a link to the body for a given uri-id with a HTML media element
|
||||||
|
*
|
||||||
|
* @param integer $uriid
|
||||||
|
* @param string $body
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function addHTMLLinkToBody(int $uriid, string $body): string
|
||||||
|
{
|
||||||
|
$links = self::getByURIId($uriid, [self::HTML]);
|
||||||
|
if (empty($links)) {
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($body, $links[0]['url'])) {
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($links[0]['name']) && ($links[0]['name'] != $links[0]['url'])) {
|
||||||
|
return $body . "\n[url=" . $links[0]['url'] . ']' . $links[0]['name'] . "[/url]";
|
||||||
|
} else {
|
||||||
|
return $body . "\n[url]" . $links[0]['url'] . "[/url]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an [attachment] element to the body and a link to raw-body for a given uri-id with a HTML media element
|
||||||
|
*
|
||||||
|
* @param array $item
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function addHTMLAttachmentToItem(array $item): array
|
||||||
|
{
|
||||||
|
if (($item['gravity'] == Item::GRAVITY_ACTIVITY) || empty($item['uri-id'])) {
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
$item['body'] = self::addHTMLAttachmentToBody($item['uri-id'], $item['body']);
|
||||||
|
|
||||||
|
if (!empty($item['raw-body'])) {
|
||||||
|
$item['raw-body'] = self::addHTMLLinkToBody($item['uri-id'], $item['raw-body']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get preview link for given media id
|
* Get preview link for given media id
|
||||||
*
|
*
|
||||||
|
|
|
@ -221,8 +221,8 @@ class BaseApi extends BaseModule
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TimelineOrderByTypes::EDITED:
|
case TimelineOrderByTypes::EDITED:
|
||||||
if (!empty($status->friendicaExtension()->editedAt())) {
|
if (!empty($status->editedAt())) {
|
||||||
self::setBoundaries(new DateTime(DateTimeFormat::utc($status->friendicaExtension()->editedAt(), DateTimeFormat::JSON)));
|
self::setBoundaries(new DateTime(DateTimeFormat::utc($status->editedAt(), DateTimeFormat::JSON)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TimelineOrderByTypes::RECEIVED:
|
case TimelineOrderByTypes::RECEIVED:
|
||||||
|
|
|
@ -116,6 +116,7 @@ class Edit extends BaseModule
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['body'] = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']);
|
$item['body'] = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']);
|
||||||
|
$item = Post\Media::addHTMLAttachmentToItem($item);
|
||||||
|
|
||||||
$jotplugins = '';
|
$jotplugins = '';
|
||||||
|
|
||||||
|
|
|
@ -116,8 +116,8 @@ class Account extends BaseDataTransferObject
|
||||||
$this->following_count = $account['ap-following_count'] ?? $account['diaspora-interacting_count'] ?? 0;
|
$this->following_count = $account['ap-following_count'] ?? $account['diaspora-interacting_count'] ?? 0;
|
||||||
$this->statuses_count = $account['ap-statuses_count'] ?? $account['diaspora-post_count'] ?? 0;
|
$this->statuses_count = $account['ap-statuses_count'] ?? $account['diaspora-post_count'] ?? 0;
|
||||||
|
|
||||||
$lastItem = $account['last-item'] ?: DBA::NULL_DATETIME;
|
$lastItem = $account['last-item'] ? DateTimeFormat::utc($account['last-item'], 'Y-m-d') : DBA::NULL_DATETIME;
|
||||||
$this->last_status_at = $lastItem != DBA::NULL_DATETIME ? DateTimeFormat::utc($lastItem, 'Y-m-d') : null;
|
$this->last_status_at = $lastItem != DBA::NULL_DATETIME ? DateTimeFormat::utc($lastItem, DateTimeFormat::JSON) : null;
|
||||||
|
|
||||||
// No custom emojis per account in Friendica
|
// No custom emojis per account in Friendica
|
||||||
$this->emojis = [];
|
$this->emojis = [];
|
||||||
|
|
|
@ -40,6 +40,8 @@ class Status extends BaseDataTransferObject
|
||||||
protected $id;
|
protected $id;
|
||||||
/** @var string|null (Datetime) */
|
/** @var string|null (Datetime) */
|
||||||
protected $created_at;
|
protected $created_at;
|
||||||
|
/** @var string|null (Datetime) */
|
||||||
|
protected $edited_at;
|
||||||
/** @var string|null */
|
/** @var string|null */
|
||||||
protected $in_reply_to_id = null;
|
protected $in_reply_to_id = null;
|
||||||
/** @var Status|null - Fedilab extension, see issue https://github.com/friendica/friendica/issues/12672 */
|
/** @var Status|null - Fedilab extension, see issue https://github.com/friendica/friendica/issues/12672 */
|
||||||
|
@ -108,7 +110,8 @@ class Status extends BaseDataTransferObject
|
||||||
public function __construct(array $item, Account $account, Counts $counts, UserAttributes $userAttributes, bool $sensitive, Application $application, array $mentions, array $tags, Card $card, array $attachments, array $in_reply, array $reblog, FriendicaExtension $friendica, array $quote = null, array $poll = null)
|
public function __construct(array $item, Account $account, Counts $counts, UserAttributes $userAttributes, bool $sensitive, Application $application, array $mentions, array $tags, Card $card, array $attachments, array $in_reply, array $reblog, FriendicaExtension $friendica, array $quote = null, array $poll = null)
|
||||||
{
|
{
|
||||||
$this->id = (string)$item['uri-id'];
|
$this->id = (string)$item['uri-id'];
|
||||||
$this->created_at = $item['created'];
|
$this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::JSON);
|
||||||
|
$this->edited_at = DateTimeFormat::utc($item['edited'], DateTimeFormat::JSON);
|
||||||
|
|
||||||
if ($item['gravity'] == Item::GRAVITY_COMMENT) {
|
if ($item['gravity'] == Item::GRAVITY_COMMENT) {
|
||||||
$this->in_reply_to_id = (string)$item['thr-parent-id'];
|
$this->in_reply_to_id = (string)$item['thr-parent-id'];
|
||||||
|
@ -163,6 +166,15 @@ class Status extends BaseDataTransferObject
|
||||||
return $this->created_at;
|
return $this->created_at;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current edited_at string or null if not set
|
||||||
|
* @return ?string
|
||||||
|
*/
|
||||||
|
public function editedAt(): ?string
|
||||||
|
{
|
||||||
|
return $this->edited_at;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Friendica Extension properties
|
* Returns the Friendica Extension properties
|
||||||
* @return FriendicaExtension
|
* @return FriendicaExtension
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
namespace Friendica\Object\Api\Mastodon\Status;
|
namespace Friendica\Object\Api\Mastodon\Status;
|
||||||
|
|
||||||
use Friendica\BaseDataTransferObject;
|
use Friendica\BaseDataTransferObject;
|
||||||
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class FriendicaExtension
|
* Class FriendicaExtension
|
||||||
|
@ -41,9 +42,6 @@ class FriendicaExtension extends BaseDataTransferObject
|
||||||
/** @var string|null (Datetime) */
|
/** @var string|null (Datetime) */
|
||||||
protected $commented_at;
|
protected $commented_at;
|
||||||
|
|
||||||
/** @var string|null (Datetime) */
|
|
||||||
protected $edited_at;
|
|
||||||
|
|
||||||
/** @var string|null (Datetime) */
|
/** @var string|null (Datetime) */
|
||||||
protected $received_at;
|
protected $received_at;
|
||||||
|
|
||||||
|
@ -68,16 +66,14 @@ class FriendicaExtension extends BaseDataTransferObject
|
||||||
string $title,
|
string $title,
|
||||||
?string $changed_at,
|
?string $changed_at,
|
||||||
?string $commented_at,
|
?string $commented_at,
|
||||||
?string $edited_at,
|
|
||||||
?string $received_at,
|
?string $received_at,
|
||||||
int $dislikes_count,
|
int $dislikes_count,
|
||||||
FriendicaDeliveryData $delivery_data
|
FriendicaDeliveryData $delivery_data
|
||||||
) {
|
) {
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
$this->changed_at = $changed_at;
|
$this->changed_at = $changed_at ? DateTimeFormat::utc($changed_at, DateTimeFormat::JSON) : null;
|
||||||
$this->commented_at = $commented_at;
|
$this->commented_at = $commented_at ? DateTimeFormat::utc($commented_at, DateTimeFormat::JSON) : null;
|
||||||
$this->edited_at = $edited_at;
|
$this->received_at = $received_at ? DateTimeFormat::utc($received_at, DateTimeFormat::JSON) : null;
|
||||||
$this->received_at = $received_at;
|
|
||||||
$this->delivery_data = $delivery_data;
|
$this->delivery_data = $delivery_data;
|
||||||
$this->dislikes_count = $dislikes_count;
|
$this->dislikes_count = $dislikes_count;
|
||||||
}
|
}
|
||||||
|
@ -100,15 +96,6 @@ class FriendicaExtension extends BaseDataTransferObject
|
||||||
return $this->commented_at;
|
return $this->commented_at;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the current edited_at string or null if not set
|
|
||||||
* @return ?string
|
|
||||||
*/
|
|
||||||
public function editedAt(): ?string
|
|
||||||
{
|
|
||||||
return $this->edited_at;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current received_at string or null if not set
|
* Returns the current received_at string or null if not set
|
||||||
* @return ?string
|
* @return ?string
|
||||||
|
|
|
@ -1639,6 +1639,8 @@ class Transmitter
|
||||||
|
|
||||||
$real_quote = false;
|
$real_quote = false;
|
||||||
|
|
||||||
|
$item = Post\Media::addHTMLAttachmentToItem($item);
|
||||||
|
|
||||||
$body = $item['body'];
|
$body = $item['body'];
|
||||||
|
|
||||||
if ($type == 'Note') {
|
if ($type == 'Note') {
|
||||||
|
|
|
@ -774,6 +774,7 @@ class DFRN
|
||||||
}
|
}
|
||||||
|
|
||||||
$body = Post\Media::addAttachmentsToBody($item['uri-id'], DI::contentItem()->addSharedPost($item));
|
$body = Post\Media::addAttachmentsToBody($item['uri-id'], DI::contentItem()->addSharedPost($item));
|
||||||
|
$body = Post\Media::addHTMLAttachmentToBody($item['uri-id'], $body);
|
||||||
|
|
||||||
if ($item['private'] == Item::PRIVATE) {
|
if ($item['private'] == Item::PRIVATE) {
|
||||||
$body = Item::fixPrivatePhotos($body, $owner['uid'], $item, $cid);
|
$body = Item::fixPrivatePhotos($body, $owner['uid'], $item, $cid);
|
||||||
|
|
|
@ -83,14 +83,21 @@ class Diaspora
|
||||||
return $contacts;
|
return $contacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
$items = Post::select(['author-id', 'author-link', 'parent-author-link', 'parent-guid', 'guid'],
|
$items = Post::select(
|
||||||
['parent' => $item['parent'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY]]);
|
['author-id', 'author-link', 'parent-author-link', 'parent-guid', 'guid'],
|
||||||
|
['parent' => $item['parent'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY]]
|
||||||
|
);
|
||||||
while ($item = Post::fetch($items)) {
|
while ($item = Post::fetch($items)) {
|
||||||
$contact = DBA::selectFirst('contact', ['id', 'url', 'name', 'protocol', 'batch', 'network'],
|
$contact = DBA::selectFirst(
|
||||||
['id' => $item['author-id']]);
|
'contact',
|
||||||
if (!DBA::isResult($contact) || empty($contact['batch']) ||
|
['id', 'url', 'name', 'protocol', 'batch', 'network'],
|
||||||
|
['id' => $item['author-id']]
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
!DBA::isResult($contact) || empty($contact['batch']) ||
|
||||||
($contact['network'] != Protocol::DIASPORA) ||
|
($contact['network'] != Protocol::DIASPORA) ||
|
||||||
Strings::compareLink($item['parent-author-link'], $item['author-link'])) {
|
Strings::compareLink($item['parent-author-link'], $item['author-link'])
|
||||||
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +277,7 @@ class Diaspora
|
||||||
$basedom = XML::parseString($xml, true);
|
$basedom = XML::parseString($xml, true);
|
||||||
|
|
||||||
if (!is_object($basedom)) {
|
if (!is_object($basedom)) {
|
||||||
Logger::notice('Received data does not seem to be an XML. Discarding. '.$xml);
|
Logger::notice('Received data does not seem to be an XML. Discarding. ' . $xml);
|
||||||
if ($no_exit) {
|
if ($no_exit) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -438,7 +445,7 @@ class Diaspora
|
||||||
$alg = $base->alg;
|
$alg = $base->alg;
|
||||||
|
|
||||||
|
|
||||||
$signed_data = $data.'.'.Strings::base64UrlEncode($type).'.'.Strings::base64UrlEncode($encoding).'.'.Strings::base64UrlEncode($alg);
|
$signed_data = $data . '.' . Strings::base64UrlEncode($type) . '.' . Strings::base64UrlEncode($encoding) . '.' . Strings::base64UrlEncode($alg);
|
||||||
|
|
||||||
|
|
||||||
// decode the data
|
// decode the data
|
||||||
|
@ -719,7 +726,8 @@ class Diaspora
|
||||||
|
|
||||||
$signed_data .= $entry;
|
$signed_data .= $entry;
|
||||||
}
|
}
|
||||||
if (!in_array($fieldname, ['parent_author_signature', 'target_author_signature'])
|
if (
|
||||||
|
!in_array($fieldname, ['parent_author_signature', 'target_author_signature'])
|
||||||
|| ($orig_type == 'relayable_retraction')
|
|| ($orig_type == 'relayable_retraction')
|
||||||
) {
|
) {
|
||||||
XML::copy($entry, $fields, $fieldname);
|
XML::copy($entry, $fields, $fieldname);
|
||||||
|
@ -795,7 +803,7 @@ class Diaspora
|
||||||
Logger::info('Fetching diaspora key', ['handle' => $uri->getAddr(), 'callstack' => System::callstack(20)]);
|
Logger::info('Fetching diaspora key', ['handle' => $uri->getAddr(), 'callstack' => System::callstack(20)]);
|
||||||
try {
|
try {
|
||||||
return DI::dsprContact()->getByAddr($uri)->pubKey;
|
return DI::dsprContact()->getByAddr($uri)->pubKey;
|
||||||
} catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
|
} catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1185,9 +1193,11 @@ class Diaspora
|
||||||
*/
|
*/
|
||||||
private static function parentItem(int $uid, string $guid, WebFingerUri $author, array $contact)
|
private static function parentItem(int $uid, string $guid, WebFingerUri $author, array $contact)
|
||||||
{
|
{
|
||||||
$fields = ['id', 'parent', 'body', 'wall', 'uri', 'guid', 'private', 'origin',
|
$fields = [
|
||||||
|
'id', 'parent', 'body', 'wall', 'uri', 'guid', 'private', 'origin',
|
||||||
'author-name', 'author-link', 'author-avatar', 'gravity',
|
'author-name', 'author-link', 'author-avatar', 'gravity',
|
||||||
'owner-name', 'owner-link', 'owner-avatar'];
|
'owner-name', 'owner-link', 'owner-avatar'
|
||||||
|
];
|
||||||
|
|
||||||
$condition = ['uid' => $uid, 'guid' => $guid];
|
$condition = ['uid' => $uid, 'guid' => $guid];
|
||||||
$item = Post::selectFirst($fields, $condition);
|
$item = Post::selectFirst($fields, $condition);
|
||||||
|
@ -1435,7 +1445,7 @@ class Diaspora
|
||||||
} elseif ($person_uri) {
|
} elseif ($person_uri) {
|
||||||
try {
|
try {
|
||||||
return DI::dsprContact()->selectOneByAddr($person_uri)->baseurl . '/objects/' . $guid;
|
return DI::dsprContact()->selectOneByAddr($person_uri)->baseurl . '/objects/' . $guid;
|
||||||
} catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
|
} catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1472,7 +1482,6 @@ class Diaspora
|
||||||
$contact = DI::dsprContact()->getByUrl(new Uri($match[3]));
|
$contact = DI::dsprContact()->getByUrl(new Uri($match[3]));
|
||||||
Tag::storeByHash($uriid, $match[1], $contact->name ?: $contact->nick, $contact->url);
|
Tag::storeByHash($uriid, $match[1], $contact->name ?: $contact->nick, $contact->url);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1531,7 +1540,7 @@ class Diaspora
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$author_url = (string)DI::dsprContact()->getByAddr($author)->url;
|
$author_url = (string)DI::dsprContact()->getByAddr($author)->url;
|
||||||
} catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
|
} catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
|
||||||
Logger::notice('Unable to find author details', ['author' => $author->getAddr()]);
|
Logger::notice('Unable to find author details', ['author' => $author->getAddr()]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1783,7 +1792,7 @@ class Diaspora
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$author_url = (string)DI::dsprContact()->getByAddr($author)->url;
|
$author_url = (string)DI::dsprContact()->getByAddr($author)->url;
|
||||||
} catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
|
} catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
|
||||||
Logger::notice('Unable to find author details', ['author' => $author->getAddr()]);
|
Logger::notice('Unable to find author details', ['author' => $author->getAddr()]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1896,7 +1905,7 @@ class Diaspora
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$author = DI::dsprContact()->getByAddr($author_uri);
|
$author = DI::dsprContact()->getByAddr($author_uri);
|
||||||
} catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
|
} catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
|
||||||
Logger::notice('Unable to find author details', ['author' => $author_uri->getAddr()]);
|
Logger::notice('Unable to find author details', ['author' => $author_uri->getAddr()]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1968,7 +1977,7 @@ class Diaspora
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$author_url = (string)DI::dsprContact()->getByAddr($author)->url;
|
$author_url = (string)DI::dsprContact()->getByAddr($author)->url;
|
||||||
} catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
|
} catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
|
||||||
Logger::notice('unable to find author details', ['author' => $author->getAddr()]);
|
Logger::notice('unable to find author details', ['author' => $author->getAddr()]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2013,8 +2022,10 @@ class Diaspora
|
||||||
Logger::info('Participation stored', ['id' => $message_id, 'guid' => $guid, 'parent_guid' => $parent_guid, 'author' => $author]);
|
Logger::info('Participation stored', ['id' => $message_id, 'guid' => $guid, 'parent_guid' => $parent_guid, 'author' => $author]);
|
||||||
|
|
||||||
// Send all existing comments and likes to the requesting server
|
// Send all existing comments and likes to the requesting server
|
||||||
$comments = Post::select(['id', 'uri-id', 'parent-author-network', 'author-network', 'verb', 'gravity'],
|
$comments = Post::select(
|
||||||
['parent' => $toplevel_parent_item['id'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY]]);
|
['id', 'uri-id', 'parent-author-network', 'author-network', 'verb', 'gravity'],
|
||||||
|
['parent' => $toplevel_parent_item['id'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY]]
|
||||||
|
);
|
||||||
while ($comment = Post::fetch($comments)) {
|
while ($comment = Post::fetch($comments)) {
|
||||||
if (($comment['gravity'] == Item::GRAVITY_ACTIVITY) && !in_array($comment['verb'], [Activity::LIKE, Activity::DISLIKE])) {
|
if (($comment['gravity'] == Item::GRAVITY_ACTIVITY) && !in_array($comment['verb'], [Activity::LIKE, Activity::DISLIKE])) {
|
||||||
Logger::info('Unsupported activities are not relayed', ['item' => $comment['id'], 'verb' => $comment['verb']]);
|
Logger::info('Unsupported activities are not relayed', ['item' => $comment['id'], 'verb' => $comment['verb']]);
|
||||||
|
@ -2089,7 +2100,7 @@ class Diaspora
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = XML::unescape($data->first_name).((strlen($data->last_name)) ? ' ' . XML::unescape($data->last_name) : '');
|
$name = XML::unescape($data->first_name) . ((strlen($data->last_name)) ? ' ' . XML::unescape($data->last_name) : '');
|
||||||
$image_url = XML::unescape($data->image_url);
|
$image_url = XML::unescape($data->image_url);
|
||||||
$birthday = XML::unescape($data->birthday);
|
$birthday = XML::unescape($data->birthday);
|
||||||
$about = Markdown::toBBCode(XML::unescape($data->bio));
|
$about = Markdown::toBBCode(XML::unescape($data->bio));
|
||||||
|
@ -2136,10 +2147,12 @@ class Diaspora
|
||||||
$birthday = $contact['bd'];
|
$birthday = $contact['bd'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = ['name' => $name, 'location' => $location,
|
$fields = [
|
||||||
|
'name' => $name, 'location' => $location,
|
||||||
'name-date' => DateTimeFormat::utcNow(), 'about' => $about,
|
'name-date' => DateTimeFormat::utcNow(), 'about' => $about,
|
||||||
'addr' => $author->getAddr(), 'nick' => $author->getUser(), 'keywords' => $keywords,
|
'addr' => $author->getAddr(), 'nick' => $author->getUser(), 'keywords' => $keywords,
|
||||||
'unsearchable' => !$searchable, 'sensitive' => $nsfw];
|
'unsearchable' => !$searchable, 'sensitive' => $nsfw
|
||||||
|
];
|
||||||
|
|
||||||
if (!empty($birthday)) {
|
if (!empty($birthday)) {
|
||||||
$fields['bd'] = $birthday;
|
$fields['bd'] = $birthday;
|
||||||
|
@ -2249,7 +2262,7 @@ class Diaspora
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$author_url = (string)DI::dsprContact()->getByAddr($author)->url;
|
$author_url = (string)DI::dsprContact()->getByAddr($author)->url;
|
||||||
} catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
|
} catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
|
||||||
Logger::notice('Cannot resolve diaspora handle for recipient', ['author' => $author->getAddr(), 'recipient' => $recipient]);
|
Logger::notice('Cannot resolve diaspora handle for recipient', ['author' => $author->getAddr(), 'recipient' => $recipient]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2426,7 +2439,7 @@ class Diaspora
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$author = DI::dsprContact()->getByAddr($author_uri);
|
$author = DI::dsprContact()->getByAddr($author_uri);
|
||||||
} catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
|
} catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
|
||||||
Logger::notice('Unable to find details for author', ['author' => $author_uri->getAddr()]);
|
Logger::notice('Unable to find details for author', ['author' => $author_uri->getAddr()]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2561,7 +2574,7 @@ class Diaspora
|
||||||
private static function storePhotoAsMedia(int $uriid, $photo)
|
private static function storePhotoAsMedia(int $uriid, $photo)
|
||||||
{
|
{
|
||||||
// @TODO Need to find object type, roland@f.haeder.net
|
// @TODO Need to find object type, roland@f.haeder.net
|
||||||
Logger::debug('photo='.get_class($photo));
|
Logger::debug('photo=' . get_class($photo));
|
||||||
$data = [];
|
$data = [];
|
||||||
$data['uri-id'] = $uriid;
|
$data['uri-id'] = $uriid;
|
||||||
$data['type'] = Post\Media::IMAGE;
|
$data['type'] = Post\Media::IMAGE;
|
||||||
|
@ -2930,8 +2943,7 @@ class Diaspora
|
||||||
try {
|
try {
|
||||||
$target = DI::dsprContact()->getByAddr(WebFingerUri::fromString($contact['addr']));
|
$target = DI::dsprContact()->getByAddr(WebFingerUri::fromString($contact['addr']));
|
||||||
$dest_url = $public_batch ? $target->batch : $target->notify;
|
$dest_url = $public_batch ? $target->batch : $target->notify;
|
||||||
} catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
|
} catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($dest_url)) {
|
if (empty($dest_url)) {
|
||||||
|
@ -3011,8 +3023,7 @@ class Diaspora
|
||||||
if (!empty($contact['addr'])) {
|
if (!empty($contact['addr'])) {
|
||||||
try {
|
try {
|
||||||
$pubkey = DI::dsprContact()->getByAddr(WebFingerUri::fromString($contact['addr']))->pubKey;
|
$pubkey = DI::dsprContact()->getByAddr(WebFingerUri::fromString($contact['addr']))->pubKey;
|
||||||
} catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
|
} catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// The "addr" field should always be filled.
|
// The "addr" field should always be filled.
|
||||||
|
@ -3058,8 +3069,10 @@ class Diaspora
|
||||||
// If the item belongs to a user, we take this user id.
|
// If the item belongs to a user, we take this user id.
|
||||||
if ($item['uid'] == 0) {
|
if ($item['uid'] == 0) {
|
||||||
// @todo Possibly use an administrator account?
|
// @todo Possibly use an administrator account?
|
||||||
$condition = ['verified' => true, 'blocked' => false,
|
$condition = [
|
||||||
'account_removed' => false, 'account_expired' => false, 'account-type' => User::ACCOUNT_TYPE_PERSON];
|
'verified' => true, 'blocked' => false,
|
||||||
|
'account_removed' => false, 'account_expired' => false, 'account-type' => User::ACCOUNT_TYPE_PERSON
|
||||||
|
];
|
||||||
$first_user = DBA::selectFirst('user', ['uid'], $condition, ['order' => ['uid']]);
|
$first_user = DBA::selectFirst('user', ['uid'], $condition, ['order' => ['uid']]);
|
||||||
$owner = User::getOwnerDataById($first_user['uid']);
|
$owner = User::getOwnerDataById($first_user['uid']);
|
||||||
} else {
|
} else {
|
||||||
|
@ -3099,7 +3112,7 @@ class Diaspora
|
||||||
$old_handle = DI::pConfig()->get($uid, 'system', 'previous_addr');
|
$old_handle = DI::pConfig()->get($uid, 'system', 'previous_addr');
|
||||||
$profile = self::createProfileData($uid);
|
$profile = self::createProfileData($uid);
|
||||||
|
|
||||||
$signed_text = 'AccountMigration:'.$old_handle.':'.$profile['author'];
|
$signed_text = 'AccountMigration:' . $old_handle . ':' . $profile['author'];
|
||||||
$signature = base64_encode(Crypto::rsaSign($signed_text, $owner['uprvkey'], 'sha256'));
|
$signature = base64_encode(Crypto::rsaSign($signed_text, $owner['uprvkey'], 'sha256'));
|
||||||
|
|
||||||
$message = [
|
$message = [
|
||||||
|
@ -3326,12 +3339,13 @@ class Diaspora
|
||||||
|
|
||||||
$title = $item['title'];
|
$title = $item['title'];
|
||||||
$body = Post\Media::addAttachmentsToBody($item['uri-id'], DI::contentItem()->addSharedPost($item), $attach_media);
|
$body = Post\Media::addAttachmentsToBody($item['uri-id'], DI::contentItem()->addSharedPost($item), $attach_media);
|
||||||
|
$body = Post\Media::addHTMLLinkToBody($item['uri-id'], $body);
|
||||||
|
|
||||||
// Fetch the title from an attached link - if there is one
|
// Fetch the title from an attached link - if there is one
|
||||||
if (empty($item['title']) && DI::pConfig()->get($owner['uid'], 'system', 'attach_link_title')) {
|
if (empty($item['title']) && DI::pConfig()->get($owner['uid'], 'system', 'attach_link_title')) {
|
||||||
$page_data = BBCode::getAttachmentData($item['body']);
|
$media = Post\Media::getByURIId($item['uri-id'], [Post\Media::HTML]);
|
||||||
if (!empty($page_data['type']) && !empty($page_data['title']) && ($page_data['type'] == 'link')) {
|
if (!empty($media) && !empty($media[0]['name']) && ($media[0]['name'] != $media[0]['url'])) {
|
||||||
$title = $page_data['title'];
|
$title = $media[0]['name'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3387,9 +3401,11 @@ class Diaspora
|
||||||
if (count($event)) {
|
if (count($event)) {
|
||||||
$message['event'] = $event;
|
$message['event'] = $event;
|
||||||
|
|
||||||
if (!empty($event['location']['address']) &&
|
if (
|
||||||
|
!empty($event['location']['address']) &&
|
||||||
!empty($event['location']['lat']) &&
|
!empty($event['location']['lat']) &&
|
||||||
!empty($event['location']['lng'])) {
|
!empty($event['location']['lng'])
|
||||||
|
) {
|
||||||
$message['location'] = $event['location'];
|
$message['location'] = $event['location'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3452,7 +3468,8 @@ class Diaspora
|
||||||
private static function prependParentAuthorMention(string $body, string $profile_url): string
|
private static function prependParentAuthorMention(string $body, string $profile_url): string
|
||||||
{
|
{
|
||||||
$profile = Contact::getByURL($profile_url, false, ['addr', 'name']);
|
$profile = Contact::getByURL($profile_url, false, ['addr', 'name']);
|
||||||
if (!empty($profile['addr'])
|
if (
|
||||||
|
!empty($profile['addr'])
|
||||||
&& !strstr($body, $profile['addr'])
|
&& !strstr($body, $profile['addr'])
|
||||||
&& !strstr($body, $profile_url)
|
&& !strstr($body, $profile_url)
|
||||||
) {
|
) {
|
||||||
|
@ -3585,6 +3602,7 @@ class Diaspora
|
||||||
}
|
}
|
||||||
|
|
||||||
$body = Post\Media::addAttachmentsToBody($item['uri-id'], DI::contentItem()->addSharedPost($item));
|
$body = Post\Media::addAttachmentsToBody($item['uri-id'], DI::contentItem()->addSharedPost($item));
|
||||||
|
$body = Post\Media::addHTMLLinkToBody($item['uri-id'], $body);
|
||||||
|
|
||||||
// The replied to autor mention is prepended for clarity if:
|
// The replied to autor mention is prepended for clarity if:
|
||||||
// - Item replied isn't yours
|
// - Item replied isn't yours
|
||||||
|
@ -3906,9 +3924,9 @@ class Diaspora
|
||||||
$kw = str_replace(' ', ' ', $kw);
|
$kw = str_replace(' ', ' ', $kw);
|
||||||
$arr = explode(' ', $kw);
|
$arr = explode(' ', $kw);
|
||||||
if (count($arr)) {
|
if (count($arr)) {
|
||||||
for ($x = 0; $x < 5; $x ++) {
|
for ($x = 0; $x < 5; $x++) {
|
||||||
if (!empty($arr[$x])) {
|
if (!empty($arr[$x])) {
|
||||||
$data['tag_string'] .= '#'. trim($arr[$x]) .' ';
|
$data['tag_string'] .= '#' . trim($arr[$x]) . ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4093,7 +4111,7 @@ class Diaspora
|
||||||
'body' => '',
|
'body' => '',
|
||||||
'quote-uri-id' => $UriId,
|
'quote-uri-id' => $UriId,
|
||||||
'allow_cid' => $owner['allow_cid'] ?? '',
|
'allow_cid' => $owner['allow_cid'] ?? '',
|
||||||
'allow_gid' => $owner['allow_gid']?? '',
|
'allow_gid' => $owner['allow_gid'] ?? '',
|
||||||
'deny_cid' => $owner['deny_cid'] ?? '',
|
'deny_cid' => $owner['deny_cid'] ?? '',
|
||||||
'deny_gid' => $owner['deny_gid'] ?? '',
|
'deny_gid' => $owner['deny_gid'] ?? '',
|
||||||
];
|
];
|
||||||
|
|
|
@ -384,8 +384,10 @@ class Feed
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$dryRun) {
|
if (!$dryRun) {
|
||||||
$condition = ["`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
|
$condition = [
|
||||||
$importer['uid'], $item['uri'], Protocol::FEED, Protocol::DFRN];
|
"`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
|
||||||
|
$importer['uid'], $item['uri'], Protocol::FEED, Protocol::DFRN
|
||||||
|
];
|
||||||
$previous = Post::selectFirst(['id', 'created'], $condition);
|
$previous = Post::selectFirst(['id', 'created'], $condition);
|
||||||
if (DBA::isResult($previous)) {
|
if (DBA::isResult($previous)) {
|
||||||
// Use the creation date when the post had been stored. It can happen this date changes in the feed.
|
// Use the creation date when the post had been stored. It can happen this date changes in the feed.
|
||||||
|
@ -644,8 +646,10 @@ class Feed
|
||||||
if (!$notify) {
|
if (!$notify) {
|
||||||
Post\Delayed::publish($item, $notify, $taglist, $attachments);
|
Post\Delayed::publish($item, $notify, $taglist, $attachments);
|
||||||
} else {
|
} else {
|
||||||
$postings[] = ['item' => $item, 'notify' => $notify,
|
$postings[] = [
|
||||||
'taglist' => $taglist, 'attachments' => $attachments];
|
'item' => $item, 'notify' => $notify,
|
||||||
|
'taglist' => $taglist, 'attachments' => $attachments
|
||||||
|
];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Logger::info('Post already created or exists in the delayed posts queue', ['uid' => $item['uid'], 'uri' => $item['uri']]);
|
Logger::info('Post already created or exists in the delayed posts queue', ['uid' => $item['uid'], 'uri' => $item['uri']]);
|
||||||
|
@ -852,7 +856,7 @@ class Feed
|
||||||
|
|
||||||
$min_poll_interval = max(1, DI::config()->get('system', 'min_poll_interval'));
|
$min_poll_interval = max(1, DI::config()->get('system', 'min_poll_interval'));
|
||||||
|
|
||||||
$poll_intervals = [$min_poll_interval, 15, 30, 60, 120, 180, 360, 720 ,1440, 10080, 43200];
|
$poll_intervals = [$min_poll_interval, 15, 30, 60, 120, 180, 360, 720, 1440, 10080, 43200];
|
||||||
|
|
||||||
//$poll_intervals = [$min_poll_interval . ' minute', '15 minute', '30 minute',
|
//$poll_intervals = [$min_poll_interval . ' minute', '15 minute', '30 minute',
|
||||||
// '1 hour', '2 hour', '3 hour', '6 hour', '12 hour' ,'1 day', '1 week', '1 month'];
|
// '1 hour', '2 hour', '3 hour', '6 hour', '12 hour' ,'1 day', '1 week', '1 month'];
|
||||||
|
@ -942,7 +946,7 @@ class Feed
|
||||||
$previous_created = $last_update;
|
$previous_created = $last_update;
|
||||||
|
|
||||||
// Don't cache when the last item was posted less then 15 minutes ago (Cache duration)
|
// Don't cache when the last item was posted less then 15 minutes ago (Cache duration)
|
||||||
if ((time() - strtotime($owner['last-item'])) < 15*60) {
|
if ((time() - strtotime($owner['last-item'])) < 15 * 60) {
|
||||||
$result = DI::cache()->get($cachekey);
|
$result = DI::cache()->get($cachekey);
|
||||||
if (!$nocache && !is_null($result)) {
|
if (!$nocache && !is_null($result)) {
|
||||||
Logger::info('Cached feed duration', ['seconds' => number_format(microtime(true) - $stamp, 3), 'nick' => $owner['nickname'], 'filter' => $filter, 'created' => $previous_created]);
|
Logger::info('Cached feed duration', ['seconds' => number_format(microtime(true) - $stamp, 3), 'nick' => $owner['nickname'], 'filter' => $filter, 'created' => $previous_created]);
|
||||||
|
@ -953,11 +957,13 @@ class Feed
|
||||||
$check_date = empty($last_update) ? '' : DateTimeFormat::utc($last_update);
|
$check_date = empty($last_update) ? '' : DateTimeFormat::utc($last_update);
|
||||||
$authorid = Contact::getIdForURL($owner['url']);
|
$authorid = Contact::getIdForURL($owner['url']);
|
||||||
|
|
||||||
$condition = ["`uid` = ? AND `received` > ? AND NOT `deleted` AND `gravity` IN (?, ?)
|
$condition = [
|
||||||
|
"`uid` = ? AND `received` > ? AND NOT `deleted` AND `gravity` IN (?, ?)
|
||||||
AND `private` != ? AND `visible` AND `wall` AND `parent-network` IN (?, ?, ?, ?)",
|
AND `private` != ? AND `visible` AND `wall` AND `parent-network` IN (?, ?, ?, ?)",
|
||||||
$owner['uid'], $check_date, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT,
|
$owner['uid'], $check_date, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT,
|
||||||
Item::PRIVATE, Protocol::ACTIVITYPUB,
|
Item::PRIVATE, Protocol::ACTIVITYPUB,
|
||||||
Protocol::OSTATUS, Protocol::DFRN, Protocol::DIASPORA];
|
Protocol::OSTATUS, Protocol::DFRN, Protocol::DIASPORA
|
||||||
|
];
|
||||||
|
|
||||||
if ($filter === 'comments') {
|
if ($filter === 'comments') {
|
||||||
$condition[0] .= " AND `gravity` = ? ";
|
$condition[0] .= " AND `gravity` = ? ";
|
||||||
|
@ -1124,13 +1130,21 @@ class Feed
|
||||||
XML::addElement($doc, $entry, 'title', html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
|
XML::addElement($doc, $entry, 'title', html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
|
||||||
|
|
||||||
$body = Post\Media::addAttachmentsToBody($item['uri-id'], DI::contentItem()->addSharedPost($item));
|
$body = Post\Media::addAttachmentsToBody($item['uri-id'], DI::contentItem()->addSharedPost($item));
|
||||||
|
$body = Post\Media::addHTMLLinkToBody($item['uri-id'], $body);
|
||||||
|
|
||||||
$body = BBCode::convertForUriId($item['uri-id'], $body, BBCode::ACTIVITYPUB);
|
$body = BBCode::convertForUriId($item['uri-id'], $body, BBCode::ACTIVITYPUB);
|
||||||
|
|
||||||
XML::addElement($doc, $entry, 'content', $body, ['type' => 'html']);
|
XML::addElement($doc, $entry, 'content', $body, ['type' => 'html']);
|
||||||
|
|
||||||
XML::addElement($doc, $entry, 'link', '', ['rel' => 'alternate', 'type' => 'text/html',
|
XML::addElement(
|
||||||
'href' => DI::baseUrl() . '/display/' . $item['guid']]
|
$doc,
|
||||||
|
$entry,
|
||||||
|
'link',
|
||||||
|
'',
|
||||||
|
[
|
||||||
|
'rel' => 'alternate', 'type' => 'text/html',
|
||||||
|
'href' => DI::baseUrl() . '/display/' . $item['guid']
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
XML::addElement($doc, $entry, 'published', DateTimeFormat::utc($item['created'] . '+00:00', DateTimeFormat::ATOM));
|
XML::addElement($doc, $entry, 'published', DateTimeFormat::utc($item['created'] . '+00:00', DateTimeFormat::ATOM));
|
||||||
|
@ -1172,12 +1186,14 @@ class Feed
|
||||||
if (isset($parent_plink)) {
|
if (isset($parent_plink)) {
|
||||||
$attributes = [
|
$attributes = [
|
||||||
'ref' => $item['thr-parent'],
|
'ref' => $item['thr-parent'],
|
||||||
'href' => $parent_plink];
|
'href' => $parent_plink
|
||||||
|
];
|
||||||
XML::addElement($doc, $entry, 'thr:in-reply-to', '', $attributes);
|
XML::addElement($doc, $entry, 'thr:in-reply-to', '', $attributes);
|
||||||
|
|
||||||
$attributes = [
|
$attributes = [
|
||||||
'rel' => 'related',
|
'rel' => 'related',
|
||||||
'href' => $parent_plink];
|
'href' => $parent_plink
|
||||||
|
];
|
||||||
XML::addElement($doc, $entry, 'link', '', $attributes);
|
XML::addElement($doc, $entry, 'link', '', $attributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1210,16 +1226,16 @@ class Feed
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch information about the post
|
// Fetch information about the post
|
||||||
$siteinfo = BBCode::getAttachedData($item['body']);
|
$media = Post\Media::getByURIId($item['uri-id'], [Post\Media::HTML]);
|
||||||
if (isset($siteinfo['title'])) {
|
if (!empty($media) && !empty($media[0]['name']) && ($media[0]['name'] != $media[0]['url'])) {
|
||||||
return $siteinfo['title'];
|
return $media[0]['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no bookmark is found then take the first line
|
// If no bookmark is found then take the first line
|
||||||
// Remove the share element before fetching the first line
|
// Remove the share element before fetching the first line
|
||||||
$title = trim(preg_replace("/\[share.*?\](.*?)\[\/share\]/ism", "\n$1\n", $item['body']));
|
$title = trim(preg_replace("/\[share.*?\](.*?)\[\/share\]/ism", "\n$1\n", $item['body']));
|
||||||
|
|
||||||
$title = BBCode::toPlaintext($title)."\n";
|
$title = BBCode::toPlaintext($title) . "\n";
|
||||||
$pos = strpos($title, "\n");
|
$pos = strpos($title, "\n");
|
||||||
$trailer = '';
|
$trailer = '';
|
||||||
if (($pos == 0) || ($pos > 100)) {
|
if (($pos == 0) || ($pos > 100)) {
|
||||||
|
|
|
@ -1515,6 +1515,7 @@ class OStatus
|
||||||
XML::addElement($doc, $entry, 'title', html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
|
XML::addElement($doc, $entry, 'title', html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
|
||||||
|
|
||||||
$body = Post\Media::addAttachmentsToBody($item['uri-id'], DI::contentItem()->addSharedPost($item));
|
$body = Post\Media::addAttachmentsToBody($item['uri-id'], DI::contentItem()->addSharedPost($item));
|
||||||
|
$body = Post\Media::addHTMLLinkToBody($item['uri-id'], $body);
|
||||||
|
|
||||||
if (!empty($item['title'])) {
|
if (!empty($item['title'])) {
|
||||||
$body = '[b]' . $item['title'] . "[/b]\n\n" . $body;
|
$body = '[b]' . $item['title'] . "[/b]\n\n" . $body;
|
||||||
|
|
|
@ -154,32 +154,9 @@ class OAuthUtil
|
||||||
|
|
||||||
public static function build_http_query($params)
|
public static function build_http_query($params)
|
||||||
{
|
{
|
||||||
if (!$params) return '';
|
|
||||||
|
|
||||||
// Urlencode both keys and values
|
|
||||||
$keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
|
|
||||||
$values = OAuthUtil::urlencode_rfc3986(array_values($params));
|
|
||||||
$params = array_combine($keys, $values);
|
|
||||||
|
|
||||||
// Parameters are sorted by name, using lexicographical byte value ordering.
|
// Parameters are sorted by name, using lexicographical byte value ordering.
|
||||||
// Ref: Spec: 9.1.1 (1)
|
// Ref: Spec: 9.1.1 (1)
|
||||||
uksort($params, 'strcmp');
|
uksort($params, 'strcmp');
|
||||||
|
return http_build_query($params, '', null, PHP_QUERY_RFC3986);
|
||||||
$pairs = [];
|
|
||||||
foreach ($params as $parameter => $value) {
|
|
||||||
if (is_array($value)) {
|
|
||||||
// If two or more parameters share the same name, they are sorted by their value
|
|
||||||
// Ref: Spec: 9.1.1 (1)
|
|
||||||
natsort($value);
|
|
||||||
foreach ($value as $duplicate_value) {
|
|
||||||
$pairs[] = $parameter . '=' . $duplicate_value;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$pairs[] = $parameter . '=' . $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
|
|
||||||
// Each name-value pair is separated by an '&' character (ASCII code 38)
|
|
||||||
return implode('&', $pairs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,7 @@ class Notifier
|
||||||
// find ancestors
|
// find ancestors
|
||||||
$condition = ['id' => $target_id, 'visible' => true];
|
$condition = ['id' => $target_id, 'visible' => true];
|
||||||
$target_item = Post::selectFirst(Item::DELIVER_FIELDLIST, $condition);
|
$target_item = Post::selectFirst(Item::DELIVER_FIELDLIST, $condition);
|
||||||
|
$target_item = Post\Media::addHTMLAttachmentToItem($target_item);
|
||||||
|
|
||||||
if (!DBA::isResult($target_item) || !intval($target_item['parent'])) {
|
if (!DBA::isResult($target_item) || !intval($target_item['parent'])) {
|
||||||
Logger::info('No target item', ['cmd' => $cmd, 'target' => $target_id]);
|
Logger::info('No target item', ['cmd' => $cmd, 'target' => $target_id]);
|
||||||
|
|
|
@ -1994,6 +1994,18 @@ code > .hl-main {
|
||||||
.wall-item-actions-right {
|
.wall-item-actions-right {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
.wall-item-actions-items {
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
.wall-item-actions-row {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.wall-item-actions-row .btn {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.wall-item-actions-row > * {
|
||||||
|
flex: 1 1 0;
|
||||||
|
}
|
||||||
.wall-item-actions .checkbox {
|
.wall-item-actions .checkbox {
|
||||||
margin: 0 0 0 15px;
|
margin: 0 0 0 15px;
|
||||||
}
|
}
|
||||||
|
@ -2001,14 +2013,17 @@ code > .hl-main {
|
||||||
.wall-item-actions .btn,
|
.wall-item-actions .btn,
|
||||||
.wall-item-actions a,
|
.wall-item-actions a,
|
||||||
.wall-item-actions button {
|
.wall-item-actions button {
|
||||||
padding-right: 12px;
|
padding-right: 0;
|
||||||
padding-left: 12px;
|
padding-left: 0;
|
||||||
}
|
}
|
||||||
.wall-item-actions .checkbox {
|
.wall-item-actions .checkbox {
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
|
flex: 0 1 auto;
|
||||||
}
|
}
|
||||||
.wall-item-actions .like-rotator {
|
.wall-item-actions .like-rotator {
|
||||||
padding-top: 8px;
|
position: absolute;
|
||||||
|
top: 8px;
|
||||||
|
right: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.wall-item-actions button:hover {
|
.wall-item-actions button:hover {
|
||||||
|
@ -2023,7 +2038,10 @@ code > .hl-main {
|
||||||
.wall-item-responses > div > p {
|
.wall-item-responses > div > p {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
.btn-group-event {
|
||||||
|
display: flex;
|
||||||
|
flex-basis: auto;
|
||||||
|
}
|
||||||
/* wall item hover effects */
|
/* wall item hover effects */
|
||||||
|
|
||||||
@media (min-width: 768px) {
|
@media (min-width: 768px) {
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
|
|
||||||
<p class="comment-edit-submit-wrapper">
|
<p class="comment-edit-submit-wrapper">
|
||||||
{{if $preview}}
|
{{if $preview}}
|
||||||
<button type="button" class="btn btn-defaul comment-edit-preview" onclick="preview_comment({{$id}});" id="comment-edit-preview-link-{{$id}}"><i class="fa fa-eye"></i> {{$preview}}</button>
|
<button type="button" class="btn btn-default comment-edit-preview" onclick="preview_comment({{$id}});" id="comment-edit-preview-link-{{$id}}"><i class="fa fa-eye"></i> {{$preview}}</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<button type="submit" class="btn btn-primary comment-edit-submit" id="comment-edit-submit-{{$id}}" name="submit" data-loading-text="{{$loading}}"><i class="fa fa-envelope"></i> {{$submit}}</button>
|
<button type="submit" class="btn btn-primary comment-edit-submit" id="comment-edit-submit-{{$id}}" name="submit" data-loading-text="{{$loading}}"><i class="fa fa-envelope"></i> {{$submit}}</button>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -436,146 +436,149 @@ as the value of $top_child_total (this is done at the end of this file)
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div class="btn-toolbar btn-group visible-xs" role="group">
|
<div class="wall-item-actions-items btn-toolbar btn-group visible-xs" role="group">
|
||||||
{{* Buttons for like and dislike *}}
|
<div class="wall-item-actions-row">
|
||||||
{{if $item.vote}}
|
{{* Buttons for like and dislike *}}
|
||||||
{{if $item.vote.like}}
|
{{if $item.vote}}
|
||||||
<button type="button" class="btn button-likes{{if $item.responses.like.self}} active" aria-pressed="true{{/if}}" id="like-{{$item.id}}" title="{{$item.vote.like.0}}" onclick="doActivityItemAction({{$item.id}}, 'like'{{if $item.responses.like.self}}, true{{/if}});" data-toggle="button"><i class="fa fa-thumbs-up" aria-hidden="true"></i></button>
|
{{if $item.vote.like}}
|
||||||
{{/if}}
|
<button type="button" class="btn button-likes{{if $item.responses.like.self}} active" aria-pressed="true{{/if}}" id="like-{{$item.id}}" title="{{$item.vote.like.0}}" onclick="doActivityItemAction({{$item.id}}, 'like'{{if $item.responses.like.self}}, true{{/if}});" data-toggle="button"><i class="fa fa-thumbs-up" aria-hidden="true"></i></button>
|
||||||
{{if $item.vote.dislike}}
|
|
||||||
<button type="button" class="btn button-likes{{if $item.responses.dislike.self}} active" aria-pressed="true{{/if}}" id="dislike-{{$item.id}}" title="{{$item.vote.dislike.0}}" onclick="doActivityItemAction({{$item.id}}, 'dislike'{{if $item.responses.dislike.self}}, true{{/if}});" data-toggle="button"><i class="fa fa-thumbs-down" aria-hidden="true"></i></button>
|
|
||||||
{{/if}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{* Button to open the comment text field *}}
|
|
||||||
{{if $item.comment_html}}
|
|
||||||
<button type="button" class="btn button-comments" id="comment-{{$item.id}}" title="{{$item.switchcomment}}" {{if $item.thread_level != 1}}onclick="openClose('item-comments-{{$item.id}}'); commentExpand({{$item.id}});" {{else}} onclick="openClose('item-comments-{{$item.id}}'); commentExpand({{$item.id}});"{{/if}}><i class="fa fa-commenting" aria-hidden="true"></i></button>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{if $item.vote.announce OR $item.vote.share}}
|
|
||||||
<div class="share-links btn-group{{if $item.thread_level > 1}} dropup{{/if}}" role="group">
|
|
||||||
<button type="button" class="btn dropdown-toggle{{if $item.responses.announce.self}} active{{/if}}" data-toggle="dropdown" id="shareMenuOptions-{{$item.id}}" aria-haspopup="true" aria-expanded="false" title="{{$item.menu}}">
|
|
||||||
<i class="fa fa-share" aria-hidden="true"></i>
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu dropdown-menu-left" role="menu" aria-labelledby="shareMenuOptions-{{$item.id}}">
|
|
||||||
{{if $item.vote.announce}} {{* edit the posting *}}
|
|
||||||
<li role="menuitem">
|
|
||||||
{{if $item.responses.announce.self}}
|
|
||||||
<a class="btn-link" id="announce-{{$item.id}}" href="javascript:doActivityItemAction({{$item.id}}, 'announce', true);" title="{{$item.vote.unannounce.0}}">
|
|
||||||
<i class="fa fa-ban" aria-hidden="true"></i> {{$item.vote.unannounce.1}}
|
|
||||||
</a>
|
|
||||||
{{else}}
|
|
||||||
<a class="btn-link" id="announce-{{$item.id}}" href="javascript:doActivityItemAction({{$item.id}}, 'announce');" title="{{$item.vote.announce.0}}">
|
|
||||||
<i class="fa fa-retweet" aria-hidden="true"></i> {{$item.vote.announce.1}}
|
|
||||||
</a>
|
|
||||||
{{/if}}
|
|
||||||
</li>
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{if $item.vote.share}}
|
{{if $item.vote.dislike}}
|
||||||
<li role="menuitem">
|
<button type="button" class="btn button-likes{{if $item.responses.dislike.self}} active" aria-pressed="true{{/if}}" id="dislike-{{$item.id}}" title="{{$item.vote.dislike.0}}" onclick="doActivityItemAction({{$item.id}}, 'dislike'{{if $item.responses.dislike.self}}, true{{/if}});" data-toggle="button"><i class="fa fa-thumbs-down" aria-hidden="true"></i></button>
|
||||||
<a class="btn-link" id="share-{{$item.id}}" href="javascript:jotShare({{$item.id}});" title="{{$item.vote.share.0}}">
|
|
||||||
<i class="fa fa-share" aria-hidden="true"></i> {{$item.vote.share.1}}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</ul>
|
{{/if}}
|
||||||
</div>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{if $item.browsershare}}
|
{{* Button to open the comment text field *}}
|
||||||
<button type="button" class="btn button-browser-share" onclick="navigator.share({url: '{{$item.plink.orig}}'})" title="{{$item.browsershare.1}}"><i class="fa fa-share-alt"></i></button>
|
{{if $item.comment_html}}
|
||||||
{{/if}}
|
<button type="button" class="btn button-comments" id="comment-{{$item.id}}" title="{{$item.switchcomment}}" {{if $item.thread_level != 1}}onclick="openClose('item-comments-{{$item.id}}'); commentExpand({{$item.id}});" {{else}} onclick="openClose('item-comments-{{$item.id}}'); commentExpand({{$item.id}});"{{/if}}><i class="fa fa-commenting" aria-hidden="true"></i></button>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{* Put additional actions in a dropdown menu *}}
|
{{if $item.vote.announce OR $item.vote.share}}
|
||||||
<img id="like-rotator-{{$item.id}}" class="like-rotator" src="images/rotator.gif" alt="{{$item.wait}}" title="{{$item.wait}}" style="display: none;" />
|
<div class="share-links btn-group{{if $item.thread_level > 1}} dropup{{/if}}" role="group">
|
||||||
</div>
|
<button type="button" class="btn dropdown-toggle{{if $item.responses.announce.self}} active{{/if}}" data-toggle="dropdown" id="shareMenuOptions-{{$item.id}}" aria-haspopup="true" aria-expanded="false" title="{{$item.menu}}">
|
||||||
|
<i class="fa fa-share" aria-hidden="true"></i>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu dropdown-menu-left" role="menu" aria-labelledby="shareMenuOptions-{{$item.id}}">
|
||||||
|
{{if $item.vote.announce}} {{* edit the posting *}}
|
||||||
|
<li role="menuitem">
|
||||||
|
{{if $item.responses.announce.self}}
|
||||||
|
<a class="btn-link" id="announce-{{$item.id}}" href="javascript:doActivityItemAction({{$item.id}}, 'announce', true);" title="{{$item.vote.unannounce.0}}">
|
||||||
|
<i class="fa fa-ban" aria-hidden="true"></i> {{$item.vote.unannounce.1}}
|
||||||
|
</a>
|
||||||
|
{{else}}
|
||||||
|
<a class="btn-link" id="announce-{{$item.id}}" href="javascript:doActivityItemAction({{$item.id}}, 'announce');" title="{{$item.vote.announce.0}}">
|
||||||
|
<i class="fa fa-retweet" aria-hidden="true"></i> {{$item.vote.announce.1}}
|
||||||
|
</a>
|
||||||
|
{{/if}}
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
{{if $item.vote.share}}
|
||||||
|
<li role="menuitem">
|
||||||
|
<a class="btn-link" id="share-{{$item.id}}" href="javascript:jotShare({{$item.id}});" title="{{$item.vote.share.0}}">
|
||||||
|
<i class="fa fa-share" aria-hidden="true"></i> {{$item.vote.share.1}}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
{{if $item.browsershare}}
|
||||||
|
<li role="menuitem">
|
||||||
|
<button type="button" class="btn-link button-browser-share" onclick="navigator.share({url: '{{$item.plink.orig}}'})" title="{{$item.browsershare.1}}">
|
||||||
|
<i class="fa fa-share-alt" aria-hidden="true"></i> {{$item.browsershare.0}}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{* Put additional actions in a dropdown menu *}}
|
||||||
|
<img id="like-rotator-{{$item.id}}" class="like-rotator" src="images/rotator.gif" alt="{{$item.wait}}" title="{{$item.wait}}" style="display: none;" />
|
||||||
|
|
||||||
<div class="wall-item-actions-right visible-xs">
|
|
||||||
{{* Event attendance buttons *}}
|
{{* Event attendance buttons *}}
|
||||||
{{if $item.isevent}}
|
{{if $item.isevent}}
|
||||||
<div class="btn-group" role="group">
|
<div class="btn-group btn-group-event" role="group">
|
||||||
<button type="button" class="btn btn-default button-event{{if $item.responses.attendyes.self}} active" aria-pressed="true{{/if}}" id="attendyes-{{$item.id}}" title="{{$item.attend.0}}" onclick="doActivityItemAction({{$item.id}}, 'attendyes'{{if $item.responses.attendyes.self}}, true{{/if}});"><i class="fa fa-check" aria-hidden="true"><span class="sr-only">{{$item.attend.0}}</span></i></button>
|
<button type="button" class="btn btn-default button-event{{if $item.responses.attendyes.self}} active" aria-pressed="true{{/if}}" id="attendyes-{{$item.id}}" title="{{$item.attend.0}}" onclick="doActivityItemAction({{$item.id}}, 'attendyes'{{if $item.responses.attendyes.self}}, true{{/if}});"><i class="fa fa-check" aria-hidden="true"><span class="sr-only">{{$item.attend.0}}</span></i></button>
|
||||||
<button type="button" class="btn btn-default button-event{{if $item.responses.attendno.self}} active" aria-pressed="true{{/if}}" id="attendno-{{$item.id}}" title="{{$item.attend.1}}" onclick="doActivityItemAction({{$item.id}}, 'attendno'{{if $item.responses.attendno.self}}, true{{/if}});"><i class="fa fa-times" aria-hidden="true"><span class="sr-only">{{$item.attend.1}}</span></i></button>
|
<button type="button" class="btn btn-default button-event{{if $item.responses.attendno.self}} active" aria-pressed="true{{/if}}" id="attendno-{{$item.id}}" title="{{$item.attend.1}}" onclick="doActivityItemAction({{$item.id}}, 'attendno'{{if $item.responses.attendno.self}}, true{{/if}});"><i class="fa fa-times" aria-hidden="true"><span class="sr-only">{{$item.attend.1}}</span></i></button>
|
||||||
<button type="button" class="btn btn-default button-event{{if $item.responses.attendmaybe.self}} active" aria-pressed="true{{/if}}" id="attendmaybe-{{$item.id}}" title="{{$item.attend.2}}" onclick="doActivityItemAction({{$item.id}}, 'attendmaybe'{{if $item.responses.attendmaybe.self}}, true{{/if}});"><i class="fa fa-question" aria-hidden="true"><span class="sr-only">{{$item.attend.2}}</span></i></button>
|
<button type="button" class="btn btn-default button-event{{if $item.responses.attendmaybe.self}} active" aria-pressed="true{{/if}}" id="attendmaybe-{{$item.id}}" title="{{$item.attend.2}}" onclick="doActivityItemAction({{$item.id}}, 'attendmaybe'{{if $item.responses.attendmaybe.self}}, true{{/if}});"><i class="fa fa-question" aria-hidden="true"><span class="sr-only">{{$item.attend.2}}</span></i></button>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{if $item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.follow_thread || $item.ignore || ($item.drop && $item.drop.dropping)}}
|
{{if $item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.follow_thread || $item.ignore || ($item.drop && $item.drop.dropping)}}
|
||||||
<div class="more-links btn-group{{if $item.thread_level > 1}} dropup{{/if}}">
|
<div class="more-links btn-group{{if $item.thread_level > 1}} dropup{{/if}}">
|
||||||
<button type="button" class="btn dropdown-toggle" data-toggle="dropdown" id="dropdownMenuOptions-{{$item.id}}" aria-haspopup="true" aria-expanded="false" title="{{$item.menu}}"><i class="fa fa-ellipsis-h" aria-hidden="true"></i></button>
|
<button type="button" class="btn dropdown-toggle" data-toggle="dropdown" id="dropdownMenuOptions-{{$item.id}}" aria-haspopup="true" aria-expanded="false" title="{{$item.menu}}"><i class="fa fa-ellipsis-h" aria-hidden="true"></i></button>
|
||||||
<ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="dropdownMenuOptions-{{$item.id}}">
|
<ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="dropdownMenuOptions-{{$item.id}}">
|
||||||
{{if $item.edpost}} {{* edit the posting *}}
|
{{if $item.edpost}} {{* edit the posting *}}
|
||||||
<li role="menuitem">
|
|
||||||
<a href="javascript:editpost('{{$item.edpost.0}}?mode=none');" title="{{$item.edpost.1}}" class="btn-link navicon pencil"><i class="fa fa-pencil" aria-hidden="true"></i> {{$item.edpost.1}}</a>
|
|
||||||
</li>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{if $item.tagger}} {{* tag the post *}}
|
|
||||||
<li role="menuitem">
|
<li role="menuitem">
|
||||||
<a id="tagger-{{$item.id}}" href="javascript:itemTag({{$item.id}});" class="btn-link {{$item.tagger.class}}" title="{{$item.tagger.add}}"><i class="fa fa-tag" aria-hidden="true"></i> {{$item.tagger.add}}</a>
|
<a href="javascript:editpost('{{$item.edpost.0}}?mode=none');" title="{{$item.edpost.1}}" class="btn-link navicon pencil"><i class="fa fa-pencil" aria-hidden="true"></i> {{$item.edpost.1}}</a>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{if $item.filer}}
|
{{if $item.tagger}} {{* tag the post *}}
|
||||||
|
<li role="menuitem">
|
||||||
|
<a id="tagger-{{$item.id}}" href="javascript:itemTag({{$item.id}});" class="btn-link {{$item.tagger.class}}" title="{{$item.tagger.add}}"><i class="fa fa-tag" aria-hidden="true"></i> {{$item.tagger.add}}</a>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $item.filer}}
|
||||||
|
<li role="menuitem">
|
||||||
|
<a id="filer-{{$item.id}}" href="javascript:itemFiler({{$item.id}});" class="btn-link filer-item filer-icon" title="{{$item.filer}}"><i class="fa fa-folder" aria-hidden="true"></i> {{$item.filer}}</a>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $item.pin}}
|
||||||
|
<li role="menuitem">
|
||||||
|
<a id="pin-{{$item.id}}" href="javascript:doPin({{$item.id}});" class="btn-link {{$item.pin.classdo}}" title="{{$item.pin.do}}"><i class="fa fa-circle-o" aria-hidden="true"></i> {{$item.pin.do}}</a>
|
||||||
|
<a id="unpin-{{$item.id}}" href="javascript:doPin({{$item.id}});" class="btn-link {{$item.pin.classundo}}" title="{{$item.pin.undo}}"><i class="fa fa-dot-circle-o" aria-hidden="true"></i> {{$item.pin.undo}}</a>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $item.star}}
|
||||||
|
<li role="menuitem">
|
||||||
|
<a id="star-{{$item.id}}" href="javascript:doStar({{$item.id}});" class="btn-link {{$item.star.classdo}}" title="{{$item.star.do}}"><i class="fa fa-star-o" aria-hidden="true"></i> {{$item.star.do}}</a>
|
||||||
|
<a id="unstar-{{$item.id}}" href="javascript:doStar({{$item.id}});" class="btn-link {{$item.star.classundo}}" title="{{$item.star.undo}}"><i class="fa fa-star" aria-hidden="true"></i> {{$item.star.undo}}</a>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $item.follow_thread}}
|
||||||
|
<li role="menuitem">
|
||||||
|
<a id="follow_thread-{{$item.id}}" href="javascript:{{$item.follow_thread.action}}" class="btn-link" title="{{$item.follow_thread.title}}"><i class="fa fa-plus" aria-hidden="true"></i> {{$item.follow_thread.title}}</a>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $item.language}}
|
||||||
<li role="menuitem">
|
<li role="menuitem">
|
||||||
<a id="filer-{{$item.id}}" href="javascript:itemFiler({{$item.id}});" class="btn-link filer-item filer-icon" title="{{$item.filer}}"><i class="fa fa-folder" aria-hidden="true"></i> {{$item.filer}}</a>
|
<a id="language-{{$item.id}}" href="javascript:alert('{{$item.language.1}}');" class="btn-link filer-item language-icon" title="{{$item.language.0}}"><i class="fa fa-language" aria-hidden="true"></i> {{$item.language.0}}</a>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{if $item.pin}}
|
{{if $item.ignore || ($item.drop && $item.drop.dropping)}}
|
||||||
<li role="menuitem">
|
<li role="separator" class="divider"></li>
|
||||||
<a id="pin-{{$item.id}}" href="javascript:doPin({{$item.id}});" class="btn-link {{$item.pin.classdo}}" title="{{$item.pin.do}}"><i class="fa fa-circle-o" aria-hidden="true"></i> {{$item.pin.do}}</a>
|
{{/if}}
|
||||||
<a id="unpin-{{$item.id}}" href="javascript:doPin({{$item.id}});" class="btn-link {{$item.pin.classundo}}" title="{{$item.pin.undo}}"><i class="fa fa-dot-circle-o" aria-hidden="true"></i> {{$item.pin.undo}}</a>
|
|
||||||
</li>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{if $item.star}}
|
{{if $item.ignore}}
|
||||||
<li role="menuitem">
|
<li role="menuitem">
|
||||||
<a id="star-{{$item.id}}" href="javascript:doStar({{$item.id}});" class="btn-link {{$item.star.classdo}}" title="{{$item.star.do}}"><i class="fa fa-star-o" aria-hidden="true"></i> {{$item.star.do}}</a>
|
<a id="ignore-{{$item.id}}" href="javascript:doIgnoreThread({{$item.id}});" class="btn-link {{$item.ignore.classdo}}" title="{{$item.ignore.do}}"><i class="fa fa-eye-slash" aria-hidden="true"></i> {{$item.ignore.do}}</a>
|
||||||
<a id="unstar-{{$item.id}}" href="javascript:doStar({{$item.id}});" class="btn-link {{$item.star.classundo}}" title="{{$item.star.undo}}"><i class="fa fa-star" aria-hidden="true"></i> {{$item.star.undo}}</a>
|
</li>
|
||||||
</li>
|
<li role="menuitem">
|
||||||
{{/if}}
|
<a id="unignore-{{$item.id}}" href="javascript:doIgnoreThread({{$item.id}});" class="btn-link {{$item.ignore.classundo}}" title="{{$item.ignore.undo}}"><i class="fa fa-eye" aria-hidden="true"></i> {{$item.ignore.undo}}</a>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{if $item.follow_thread}}
|
{{if $item.drop && $item.drop.dropping}}
|
||||||
<li role="menuitem">
|
<li role="menuitem">
|
||||||
<a id="follow_thread-{{$item.id}}" href="javascript:{{$item.follow_thread.action}}" class="btn-link" title="{{$item.follow_thread.title}}"><i class="fa fa-plus" aria-hidden="true"></i> {{$item.follow_thread.title}}</a>
|
<a class="btn-link navicon delete" href="javascript:dropItem('item/drop/{{$item.id}}/{{$item.return}}', 'item-{{$item.guid}}');" title="{{$item.drop.delete}}"><i class="fa fa-trash" aria-hidden="true"></i> {{$item.drop.delete}}</a>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
</ul>
|
||||||
{{if $item.language}}
|
<img id="like-rotator-{{$item.id}}" class="like-rotator" src="images/rotator.gif" alt="{{$item.wait}}" title="{{$item.wait}}" style="display: none;" />
|
||||||
<li role="menuitem">
|
</div>
|
||||||
<a id="language-{{$item.id}}" href="javascript:alert('{{$item.language.1}}');" class="btn-link filer-item language-icon" title="{{$item.language.0}}"><i class="fa fa-language" aria-hidden="true"></i> {{$item.language.0}}</a>
|
{{/if}}
|
||||||
</li>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{if $item.ignore || ($item.drop && $item.drop.dropping)}}
|
|
||||||
<li role="separator" class="divider"></li>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{if $item.ignore}}
|
|
||||||
<li role="menuitem">
|
|
||||||
<a id="ignore-{{$item.id}}" href="javascript:doIgnoreThread({{$item.id}});" class="btn-link {{$item.ignore.classdo}}" title="{{$item.ignore.do}}"><i class="fa fa-eye-slash" aria-hidden="true"></i> {{$item.ignore.do}}</a>
|
|
||||||
</li>
|
|
||||||
<li role="menuitem">
|
|
||||||
<a id="unignore-{{$item.id}}" href="javascript:doIgnoreThread({{$item.id}});" class="btn-link {{$item.ignore.classundo}}" title="{{$item.ignore.undo}}"><i class="fa fa-eye" aria-hidden="true"></i> {{$item.ignore.undo}}</a>
|
|
||||||
</li>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{if $item.drop && $item.drop.dropping}}
|
|
||||||
<li role="menuitem">
|
|
||||||
<a class="btn-link navicon delete" href="javascript:dropItem('item/drop/{{$item.id}}/{{$item.return}}', 'item-{{$item.guid}}');" title="{{$item.drop.delete}}"><i class="fa fa-trash" aria-hidden="true"></i> {{$item.drop.delete}}</a>
|
|
||||||
</li>
|
|
||||||
{{/if}}
|
|
||||||
</ul>
|
|
||||||
<img id="like-rotator-{{$item.id}}" class="like-rotator" src="images/rotator.gif" alt="{{$item.wait}}" title="{{$item.wait}}" style="display: none;" />
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
|
||||||
<span class="pull-right checkbox">
|
<span class="pull-right checkbox">
|
||||||
{{if $item.drop && $item.drop.pagedrop}}
|
{{if $item.drop && $item.drop.pagedrop}}
|
||||||
<input type="checkbox" title="{{$item.drop.select}}" name="itemselected[]" id="checkbox-{{$item.id}}" class="item-select" value="{{$item.id}}" />
|
<input type="checkbox" title="{{$item.drop.select}}" name="itemselected[]" id="checkbox-{{$item.id}}" class="item-select" value="{{$item.id}}" />
|
||||||
<label for="checkbox-{{$item.id}}"></label>
|
<label for="checkbox-{{$item.id}}"></label>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</span>
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div><!--./wall-item-actions-->
|
</div><!--./wall-item-actions-->
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue