namespace Friendica\Model;
-use DOMDocument;
-use DOMXPath;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Hook;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\System;
-use Friendica\Model\Tag;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
if (($uid != 0) && (($item['gravity'] == self::GRAVITY_PARENT) || $is_reshare) &&
DI::pConfig()->get($uid, 'system', 'accept_only_sharer') == self::COMPLETION_NONE &&
- !in_array($item['post-reason'], [self::PR_FOLLOWER, self::PR_TAG, self::PR_TO, self::PR_CC])) {
+ !in_array($item['post-reason'], [self::PR_FOLLOWER, self::PR_TAG, self::PR_TO, self::PR_CC, self::PR_ACTIVITY])) {
Logger::info('Contact is not a follower, thread will not be stored', ['author' => $item['author-link'], 'uid' => $uid, 'uri-id' => $uri_id, 'post-reason' => $item['post-reason']]);
return 0;
}
return;
}
- if (!DBA::exists('contact', ['id' => $item['contact-id'], 'remote_self' => Contact::MIRROR_NATIVE_RESHARE])) {
+ $cdata = Contact::getPublicAndUserContactID($item['author-id'], $item['uid']);
+ if (empty($cdata['user']) || ($cdata['user'] != $item['contact-id'])) {
+ return;
+ }
+
+ if (!DBA::exists('contact', ['id' => $cdata['user'], 'remote_self' => Contact::MIRROR_NATIVE_RESHARE])) {
return;
}
$item['hashtags'] = $tags['hashtags'];
$item['mentions'] = $tags['mentions'];
- $body = $item['body'] = Post\Media::removeFromEndOfBody($item['body'] ?? '');
+ if (!$is_preview) {
+ $item['body'] = Post\Media::removeFromEndOfBody($item['body'] ?? '');
+ }
+
+ $body = $item['body'];
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network', 'has-media', 'quote-uri-id', 'post-type'];
$shared = DI::contentItem()->getSharedPost($item, $fields);
if (!empty($shared['post'])) {
$shared_item = $shared['post'];
+ $shared_item['body'] = Post\Media::removeFromEndOfBody($shared_item['body']);
$quote_uri_id = $shared['post']['uri-id'];
$shared_links[] = strtolower($shared['post']['uri']);
$item['body'] = BBCode::removeSharedData($item['body']);
'filter_reasons' => $filter_reasons
];
Hook::callAll('prepare_body', $hook_data);
+ $s = $hook_data['html'];
+
unset($hook_data);
if (!$attach) {
* @return string
* @throws \Friendica\Network\HTTPException\ServiceUnavailableException
*/
- public static function makeImageGrid(array $images): string
+ private static function makeImageGrid(array $images): string
{
- $img_tags_landscape = array();
- $img_tags_portrait = array();
- foreach ($images as $image) {
- ($image['attachment']['width'] > $image['attachment']['height']) ? ($img_tags_landscape[] = $image) : ($img_tags_portrait[] = $image);
- }
+ // Image for first column (fc) and second column (sc)
+ $images_fc = [];
+ $images_sc = [];
- // @todo add some fany ai to divide images equally on both columns
- $img_tags_fc = array();
- $img_tags_sc = array();
- if (count($img_tags_landscape) == 0) {
- // only portrait
- for ($i = 0; $i < count($img_tags_portrait); $i++) {
- ($i % 2 == 0) ? ($img_tags_fc[] = $img_tags_portrait[$i]) : ($img_tags_sc[] = $img_tags_portrait[$i]);
- }
- }
- if (count($img_tags_portrait) == 0) {
- // ony landscapes
- for ($i = 0; $i < count($img_tags_landscape); $i++) {
- ($i % 2 == 0) ? ($img_tags_fc[] = $img_tags_landscape[$i]) : ($img_tags_sc[] = $img_tags_landscape[$i]);
- }
+ for ($i = 0; $i < count($images); $i++) {
+ ($i % 2 == 0) ? ($images_fc[] = $images[$i]) : ($images_sc[] = $images[$i]);
}
- $media = Renderer::replaceMacros(Renderer::getMarkupTemplate('content/image_grid.tpl'), [
+ return Renderer::replaceMacros(Renderer::getMarkupTemplate('content/image_grid.tpl'), [
'columns' => [
- 'fc' => $img_tags_fc,
- 'sc' => $img_tags_sc,
+ 'fc' => $images_fc,
+ 'sc' => $images_sc,
],
]);
- return $media;
}
+
/**
* Check if the body contains a link
$media = '';
if (count($images) > 1) {
$media = self::makeImageGrid($images);
- }
- elseif (count($images) == 1) {
- $media = $media = Renderer::replaceMacros(Renderer::getMarkupTemplate('content/image.tpl'), [
+ } elseif (count($images) == 1) {
+ $media = Renderer::replaceMacros(Renderer::getMarkupTemplate('content/image.tpl'), [
'$image' => $images[0],
]);
}
}
if ($shared) {
- $content = str_replace(BBCode::TOP_ANCHOR, '<div class="body-attach">' . $leading . '<div class="clear"></div></div>' . BBCode::TOP_ANCHOR, $content);
- $content = str_replace(BBCode::BOTTOM_ANCHOR, '<div class="body-attach">' . $trailing . '<div class="clear"></div></div>' . BBCode::BOTTOM_ANCHOR, $content);
+ $content = str_replace(BBCode::TOP_ANCHOR, '<div class="body-attach">' . $leading . '</div>' . BBCode::TOP_ANCHOR, $content);
+ $content = str_replace(BBCode::BOTTOM_ANCHOR, '<div class="body-attach">' . $trailing . '</div>' . BBCode::BOTTOM_ANCHOR, $content);
} else {
if ($leading != '') {
- $content = '<div class="body-attach">' . $leading . '<div class="clear"></div></div>' . $content;
+ $content = '<div class="body-attach">' . $leading . '</div>' . $content;
}
if ($trailing != '') {
- $content .= '<div class="body-attach">' . $trailing . '<div class="clear"></div></div>';
+ $content .= '<div class="body-attach">' . $trailing . '</div>';
}
}
}
if ($trailing != '') {
- $content .= '<div class="body-attach">' . $trailing . '<div class="clear"></div></div>';
+ $content .= '<div class="body-attach">' . $trailing . '</div>';
}
DI::profiler()->stopRecording();