X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FObject%2FPost.php;h=0561f5506c7a2680b245a34ede7bdd0e65e7a15e;hb=f2af985350b775a120f01cd620dfc6a17b2354b2;hp=a7071ad794d298eaf7a3d0a0ef36f2176a3df8fe;hpb=8f460644306bcad39a2bd901eb2b9df388716df9;p=friendica.git diff --git a/src/Object/Post.php b/src/Object/Post.php index a7071ad794..0561f5506c 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -1,6 +1,6 @@ visibleActivity($item)) { continue; } @@ -125,6 +125,7 @@ class Post * Get data in a form usable by a conversation template * * @param array $conv_responses conversation responses + * @param string $formSecurityToken A security Token to avoid CSF attacks * @param integer $thread_level default = 1 * * @return mixed The data requested on success @@ -132,10 +133,8 @@ class Post * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \ImagickException */ - public function getTemplateData(array $conv_responses, $thread_level = 1) + public function getTemplateData(array $conv_responses, string $formSecurityToken, $thread_level = 1) { - $a = DI::app(); - $item = $this->getData(); $edited = false; // If the time between "created" and "edited" differs we add @@ -176,6 +175,8 @@ class Post ? DI::l10n()->t('Private Message') : false); + $connector = !$item['global'] ? DI::l10n()->t('Connector Message') : false; + $shareable = in_array($conv->getProfileOwner(), [0, local_user()]) && $item['private'] != Item::PRIVATE; $announceable = $shareable && in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::TWITTER]); @@ -236,7 +237,7 @@ class Post ]; } - $filer = (($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) ? DI::l10n()->t('Save to folder') : false); + $filer = local_user() ? DI::l10n()->t('Save to folder') : false; $profile_name = $item['author-name']; if (!empty($item['author-link']) && empty($item['author-name'])) { @@ -278,7 +279,7 @@ class Post foreach ($response_verbs as $value => $verb) { $responses[$verb] = [ 'self' => $conv_responses[$verb][$item['uri-id']]['self'] ?? 0, - 'output' => !empty($conv_responses[$verb][$item['uri-id']]) ? format_activity($conv_responses[$verb][$item['uri-id']]['links'], $verb, $item['uri-id']) : '', + 'output' => !empty($conv_responses[$verb][$item['uri-id']]) ? DI::conversation()->formatActivity($conv_responses[$verb][$item['uri-id']]['links'], $verb, $item['uri-id']) : '', ]; } @@ -296,7 +297,7 @@ class Post $tagger = ''; if ($this->isToplevel()) { - if(local_user()) { + if (local_user()) { $ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], local_user()); if ($item['mention'] || $ignored) { $ignore = [ @@ -309,6 +310,17 @@ class Post ]; } + $isstarred = (($item['starred']) ? "starred" : "unstarred"); + + $star = [ + 'do' => DI::l10n()->t('Add star'), + 'undo' => DI::l10n()->t('Remove star'), + 'toggle' => DI::l10n()->t('Toggle star status'), + 'classdo' => $item['starred'] ? "hidden" : "", + 'classundo' => $item['starred'] ? "" : "hidden", + 'starred' => DI::l10n()->t('Starred'), + ]; + if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) { if ($origin) { $ispinned = ($item['pinned'] ? 'pinned' : 'unpinned'); @@ -323,17 +335,6 @@ class Post ]; } - $isstarred = (($item['starred']) ? "starred" : "unstarred"); - - $star = [ - 'do' => DI::l10n()->t('Add star'), - 'undo' => DI::l10n()->t('Remove star'), - 'toggle' => DI::l10n()->t('Toggle star status'), - 'classdo' => $item['starred'] ? "hidden" : "", - 'classundo' => $item['starred'] ? "" : "hidden", - 'starred' => DI::l10n()->t('Starred'), - ]; - $tagger = [ 'add' => DI::l10n()->t('Add tag'), 'class' => "", @@ -362,11 +363,11 @@ class Post $shiny = 'shiny'; } - localize_item($item); + DI::contentItem()->localize($item); $body_html = Item::prepareBody($item, true); - list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item); + list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item, local_user()); if (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) { $title = ucfirst($item['content-warning']); @@ -458,7 +459,7 @@ class Post 'vwall' => DI::l10n()->t('via Wall-To-Wall:'), 'profile_url' => $profile_link, 'name' => $profile_name, - 'item_photo_menu_html' => item_photo_menu($item), + 'item_photo_menu_html' => DI::contentItem()->photoMenu($item, $formSecurityToken), 'thumb' => DI::baseUrl()->remove(Contact::getAvatarUrlForUrl($item['author-link'], $item['uid'], Proxy::SIZE_THUMB)), 'osparkle' => $osparkle, 'sparkle' => $sparkle, @@ -468,6 +469,7 @@ class Post 'app' => $item['app'], 'created' => $ago, 'lock' => $lock, + 'connector' => $connector, 'location_html' => $location_html, 'indent' => $indent, 'shiny' => $shiny, @@ -476,6 +478,7 @@ class Post 'owner_photo' => DI::baseUrl()->remove(Contact::getAvatarUrlForUrl($item['owner-link'], $item['uid'], Proxy::SIZE_THUMB)), 'owner_name' => $this->getOwnerName(), 'plink' => Item::getPlink($item), + 'browsershare' => DI::l10n()->t('Share'), 'edpost' => $edpost, 'ispinned' => $ispinned, 'pin' => $pin, @@ -532,7 +535,7 @@ class Post $nb_children = count($children); if ($nb_children > 0) { foreach ($children as $child) { - $result['children'][] = $child->getTemplateData($conv_responses, $thread_level + 1); + $result['children'][] = $child->getTemplateData($conv_responses, $formSecurityToken, $thread_level + 1); } // Collapse @@ -593,10 +596,10 @@ class Post { $item_id = $item->getId(); if (!$item_id) { - Logger::log('[ERROR] Post::addChild : Item has no ID!!', Logger::DEBUG); + Logger::info('[ERROR] Post::addChild : Item has no ID!!'); return false; } elseif ($this->getChild($item->getId())) { - Logger::log('[WARN] Post::addChild : Item already exists (' . $item->getId() . ').', Logger::DEBUG); + Logger::info('[WARN] Post::addChild : Item already exists (' . $item->getId() . ').'); return false; } @@ -695,7 +698,7 @@ class Post return true; } } - Logger::log('[WARN] Item::removeChild : Item is not a child (' . $id . ').', Logger::DEBUG); + Logger::info('[WARN] Item::removeChild : Item is not a child (' . $id . ').'); return false; } @@ -759,7 +762,7 @@ class Post public function getDataValue($name) { if (!isset($this->data[$name])) { - // Logger::log('[ERROR] Item::getDataValue : Item has no value name "'. $name .'".', Logger::DEBUG); + // Logger::info('[ERROR] Item::getDataValue : Item has no value name "'. $name .'".'); return false; } @@ -776,7 +779,7 @@ class Post private function setTemplate($name) { if (empty($this->available_templates[$name])) { - Logger::log('[ERROR] Item::setTemplate : Template not available ("' . $name . '").', Logger::DEBUG); + Logger::info('[ERROR] Item::setTemplate : Template not available ("' . $name . '").'); return false; } @@ -870,7 +873,7 @@ class Post return ''; } - $owner = User::getOwnerDataById($a->user['uid']); + $owner = User::getOwnerDataById($a->getLoggedInUserId()); if (!Feature::isEnabled(local_user(), 'explicit_mentions')) { return '';