From b6b28b15417fd5dd047c2c851ef885038b47423c Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 4 Oct 2020 18:52:28 +0000 Subject: [PATCH] Display the languages in the post --- include/conversation.php | 4 ++++ mod/settings.php | 2 +- src/Model/Item.php | 10 ++++++++++ src/Object/Post.php | 6 ++++++ view/theme/frio/templates/search_item.tpl | 6 ++++++ view/theme/frio/templates/wall_thread.tpl | 6 ++++++ 6 files changed, 33 insertions(+), 1 deletion(-) diff --git a/include/conversation.php b/include/conversation.php index f3df8db01..1e8437f71 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -917,6 +917,10 @@ function item_photo_menu($item) { DI::l10n()->t('Ignore') => $ignore_link ]; + if (!empty($item['language'])) { + $menu[DI::l10n()->t('Languages')] = 'javascript:alert(\'' . Item::getLanguageMessage($item) . '\');'; + } + if ($network == Protocol::DFRN) { $menu[DI::l10n()->t("Poke")] = $poke_link; } diff --git a/mod/settings.php b/mod/settings.php index 92a7bb461..d1eefefc0 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -225,7 +225,7 @@ function settings_post(App $a) if (isset($_FILES['importcontact-filename'])) { // was there an error if ($_FILES['importcontact-filename']['error'] > 0) { - Logger::notice('Contact CSV file upload error'); + Logger::notice('Contact CSV file upload error', ['error' => $_FILES['importcontact-filename']['error']]); notice(DI::l10n()->t('Contact CSV file upload error')); } else { $csvArray = array_map('str_getcsv', file($_FILES['importcontact-filename']['tmp_name'])); diff --git a/src/Model/Item.php b/src/Model/Item.php index 8af14e824..dfea29681 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -2487,6 +2487,16 @@ class Item return ''; } + public static function getLanguageMessage(array $item) + { + $used_languages = ''; + foreach (json_decode($item['language'], true) as $language => $reliability) { + $used_languages .= $language . ": " . number_format($reliability, 5) . '\n'; + } + $used_languages = DI::l10n()->t('Used languages in this post:\n%s', $used_languages); + return $used_languages; + } + /** * Creates an unique guid out of a given uri * diff --git a/src/Object/Post.php b/src/Object/Post.php index 51b952d61..894b75f93 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -411,6 +411,11 @@ class Post } } + $languages = []; + if (!empty($item['language'])) { + $languages = [DI::l10n()->t('Languages'), Item::getLanguageMessage($item)]; + } + $tmp_item = [ 'template' => $this->getTemplate(), 'type' => implode("", array_slice(explode("/", $item['verb']), -1)), @@ -466,6 +471,7 @@ class Post 'ignore' => $ignore, 'tagger' => $tagger, 'filer' => $filer, + 'language' => $languages, 'drop' => $drop, 'vote' => $buttons, 'like_html' => $responses['like']['output'], diff --git a/view/theme/frio/templates/search_item.tpl b/view/theme/frio/templates/search_item.tpl index b516d486f..717340b8b 100644 --- a/view/theme/frio/templates/search_item.tpl +++ b/view/theme/frio/templates/search_item.tpl @@ -217,6 +217,12 @@ {{/if}} + {{if $item.language}} +
  • +  {{$item.language.0}} +
  • + {{/if}} + {{if ($item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.subthread) && ($item.ignore || $item.drop.dropping)}} {{/if}} diff --git a/view/theme/frio/templates/wall_thread.tpl b/view/theme/frio/templates/wall_thread.tpl index 048fbc226..0375dc472 100644 --- a/view/theme/frio/templates/wall_thread.tpl +++ b/view/theme/frio/templates/wall_thread.tpl @@ -363,6 +363,12 @@ as the value of $top_child_total (this is done at the end of this file) {{/if}} + {{if $item.language}} +
  • +  {{$item.language.0}} +
  • + {{/if}} + {{if ($item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.subthread) && ($item.ignore || $item.drop.dropping)}} {{/if}}